Skip to content

defaultMethodOptions in SpecRestApi is confusing #8347

@john-tipper

Description

@john-tipper

The documentation states about defaultIntegration:

An integration to use as a default for all methods created within this API unless an integration is specified.

Yet when I define an API with no integration defined within the OpenAPI spec, the default integration is ignored and an error occurs when deploying.

Reproduction Steps

SpecRestApi openapiRestApi = SpecRestApi.Builder.create(this, "MyApi")
						.restApiName("MyApi")
						.apiDefinition(ApiDefinition.fromAsset("openapi.yaml"))
						.defaultIntegration(LambdaIntegration.Builder.create(myLambda)
									.proxy(false)
									.build())
						.deploy(true)
						.build();

where myLambda is a lambda defined earlier in the CDK.

The OpenApi spec has a single method defined (the header and model are not shown):

paths:
  /items:
    get:
      summary: List all items.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ItemList'

Error Log

The following error appears in the CloudFormation events when deploying:

No integration defined for method (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 56113150-1460-4ed2-93b9-a12618864582)

Environment

  • CLI Version : 1.42.0
  • Framework Version: 1.42.1
  • Node.js Version: v12.16.0
  • OS : Windows
  • Language (Version): Java

Other


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions