Skip to content

Commit

Permalink
chore(apigateway): remove default* properties from SpecRestApi (aws#9099
Browse files Browse the repository at this point in the history
)

SpecRestApiProps contained `defaultMethodOptions`,
`defaultCorsPreflightOptions` and `defaultIntegration` as properties.
However, these defaults are only applied to Methods and Resources
defined via addMethod() and addResource() APIs. These do *not* apply to
Resources and Methods defined in the OpenAPI spec.

Users have complained that this is unclear [1] [2]. This PR removes
these options from the constructor properties of `SpecRestApi`. Users
can still specify these when adding new Resources and new Methods.

These options don't make much sense to be specified on a `SpecRestApi`
since they cannot be applied to the Resources and Methods in the OpenAPI
spec. This will match up with the functionality available.

closes aws#8347

[1]: aws#8347 (comment)
[2]: aws#8347 (comment)

BREAKING CHANGE: `defaultMethodOptions`, `defaultCorsPreflightOptions`
and `defaultIntegration` have been removed from `SpecRestApiProps`.
These can be specifed directly in the OpenAPI spec or via `addMethod()`
 and `addResource()` APIs.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Niranjan Jayakar authored Jul 16, 2020
1 parent 34ea143 commit 06842d6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface IRestApi extends IResourceBase {
/**
* Represents the props that all Rest APIs share
*/
export interface RestApiOptions extends ResourceOptions {
export interface RestApiBaseProps {
/**
* Indicates if a Deployment should be automatically created for this API,
* and recreated when the API model (resources, methods) changes.
Expand Down Expand Up @@ -161,6 +161,13 @@ export interface RestApiOptions extends ResourceOptions {
readonly endpointExportName?: string;
}

/**
* Represents the props that all Rest APIs share.
* @deprecated - superceded by `RestApiBaseProps`
*/
export interface RestApiOptions extends RestApiBaseProps, ResourceOptions {
}

/**
* Props to create a new instance of RestApi
*/
Expand Down Expand Up @@ -229,7 +236,7 @@ export interface RestApiProps extends RestApiOptions {
* Props to instantiate a new SpecRestApi
* @experimental
*/
export interface SpecRestApiProps extends RestApiOptions {
export interface SpecRestApiProps extends RestApiBaseProps {
/**
* An OpenAPI definition compatible with API Gateway.
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-import-api.html
Expand Down Expand Up @@ -296,7 +303,7 @@ export abstract class RestApiBase extends Resource implements IRestApi {
private _latestDeployment?: Deployment;
private _domainName?: DomainName;

constructor(scope: Construct, id: string, props: RestApiOptions = { }) {
constructor(scope: Construct, id: string, props: RestApiBaseProps = { }) {
super(scope, id, {
physicalName: props.restApiName || id,
});
Expand Down Expand Up @@ -461,7 +468,7 @@ export class SpecRestApi extends RestApiBase {
this.node.defaultChild = resource;
this.restApiId = resource.ref;
this.restApiRootResourceId = resource.attrRootResourceId;
this.root = new RootResource(this, props, this.restApiRootResourceId);
this.root = new RootResource(this, {}, this.restApiRootResourceId);

this.configureDeployment(props);
if (props.domainName) {
Expand Down

0 comments on commit 06842d6

Please sign in to comment.