-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
@aws-cdk/aws-apigatewayRelated to Amazon API GatewayRelated to Amazon API GatewaybugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2
Description
When defining an api gateway model schema such as:
const createBlockModel = this.addModel('Model', {
contentType: 'application/json',
schema: {
schema: JsonSchemaVersion.DRAFT4,
id: 'http://example.com/my_schema.json',
properties: {
userId: {
type: JsonSchemaType.STRING,
},
},
required: ['userId'],
},
});This will generate the following template
{
"PrivateApiModelB06227A2": {
"Type": "AWS::ApiGateway::Model",
"Properties": {
"RestApiId": {
"Ref": "PrivateApi1FA926D9"
},
"ContentType": "application/json",
"Schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "http://example.com/my_schema.json",
"properties": {
"userId": {
"type": "string"
}
},
"required": [
"userId"
]
}
}
}
}This will now fail in cloudformation with the following error:
Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified. Unsupported keyword(s): ["$id"]]
This is due to draft-04 using id rather than $id which was introduced in draft-06
Cause of the problem stems from here which uses the following to map id => $id.
private static readonly SchemaPropsWithPrefix: { [key: string]: string } = {
schema: '$schema',
ref: '$ref',
id: '$id',
};This is 🐛 Bug Report
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-apigatewayRelated to Amazon API GatewayRelated to Amazon API GatewaybugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2