Aws-cdk: API Gateway ModelOptions interface should require contentType

Created on 7 Feb 2020  路  3Comments  路  Source: aws/aws-cdk

Cloudformation requires contentType to be defined in ModelOptions, but in API it is marked as optional.

Reproduction Steps

    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,
          }
        }
      }
    });

Error Log

Environment

  • CLI Version : 1.22.0 (build 309ac1b)
  • Framework Version: 1.22.0
  • OS : MacOS
  • Language : Typescript

Other

Adding contentType property everything works fine.


This is :bug: Bug Report

@aws-cdaws-apigateway bug good first issue p2

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eladb picture eladb  路  3Comments

sudoforge picture sudoforge  路  3Comments

kawamoto picture kawamoto  路  3Comments

eladb picture eladb  路  3Comments

peterdeme picture peterdeme  路  3Comments