Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aws-apigateway): expand RestApi support to models, parameters and validators #2960

Merged
merged 17 commits into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move back to modelId
Use PhysicalName constructs
  • Loading branch information
julienlepine committed Jun 25, 2019
commit c5603b89dde1c48bed8901d2ebe5aaeb0463ea72
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class Method extends Resource {
responseModels = {};
for (const contentType in mr.responseModels) {
if (mr.responseModels.hasOwnProperty(contentType)) {
responseModels[contentType] = mr.responseModels[contentType].modelName;
responseModels[contentType] = mr.responseModels[contentType].modelId;
}
}
}
Expand All @@ -265,7 +265,7 @@ export class Method extends Resource {
const models: {[param: string]: string} = {};
for (const contentType in requestModels) {
if (requestModels.hasOwnProperty(contentType)) {
models[contentType] = requestModels[contentType].modelName;
models[contentType] = requestModels[contentType].modelId;
}
}

Expand Down
12 changes: 7 additions & 5 deletions packages/@aws-cdk/aws-apigateway/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface IModel extends IResource {
*
* @attribute
*/
readonly modelName: string;
readonly modelId: string;
}

export interface ModelOptions {
Expand Down Expand Up @@ -107,7 +107,7 @@ export class Model extends Resource implements IModel {

public static fromModelName(scope: Construct, id: string, modelName: string): IModel {
class Import extends Resource implements IModel {
public readonly modelName = modelName;
public readonly modelId = modelName;
}

return new Import(scope, id);
Expand All @@ -125,10 +125,12 @@ export class Model extends Resource implements IModel {
*
* @attribute
*/
public readonly modelName: string;
public readonly modelId: string;

constructor(scope: Construct, id: string, props: ModelProps) {
super(scope, id);
super(scope, id, {
physicalName: props.modelName,
});

const modelProps: CfnModelProps = {
name: props.modelName,
Expand All @@ -140,7 +142,7 @@ export class Model extends Resource implements IModel {

const resource = new CfnModel(this, 'Resource', modelProps);

this.modelName = resource.ref;
this.modelId = resource.ref;

const deployment = (props.restApi instanceof RestApi) ? props.restApi.latestDeployment : undefined;
if (deployment) {
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-apigateway/lib/requestvalidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export class RequestValidator extends Resource implements IRequestValidator {
public readonly requestValidatorId: string;

constructor(scope: Construct, id: string, props: RequestValidatorProps) {
super(scope, id);
super(scope, id, {
physicalName: props.requestValidatorName,
});

const validatorProps: CfnRequestValidatorProps = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be “this.physicalName”

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for Model.ts, for RequestValidator the name is actually kind of useless per se, name is not a property of the CfnRequestValidator, and it's really an Id.

name: props.requestValidatorName,
Expand Down