Cloudformation requires contentType to be defined in ModelOptions, but in API it is marked as optional.
const model = new gateway.Model(this, 'Model', {
restApi: props.resource.restApi,
schema: {
schema: gateway.JsonSchemaVersion.DRAFT4,
type: gateway.JsonSchemaType.OBJECT,
properties: {
name: {
type: gateway.JsonSchemaType.STRING,
}
}
}
});
Adding contentType property everything works fine.
This is :bug: Bug Report
I was just independently exposed to this same bug.
Thanks for filing this issue.
It seems that CF has also marked this property as optional. Internal reference: i/CFN-30792.
@richardhboyd & @Townsheriff - I think we should keep this property as optional in the CDK and set the default to application/json as per what I see in their API documentation.
What do you both think?
I agree with that plan. I am about 84% certain that the Content Type on Models is never enforced/checked anywhere else.