Dan
Dan

Reputation: 862

Defaulting to mock endpoints in AWS API Gateway?

After importing a Swagger model, I am greeted with the following message for each API:

Method not set up. Set up now.

For my use case, I would greatly appreciate being able to default to mock behavior. Equally useful would be a way to apply mock behavior to every API after the Swagger import.

Is this possible?

Upvotes: 1

Views: 516

Answers (1)

Dan
Dan

Reputation: 862

It is possible to specify the mock behavior in the Swagger model itself.

API Gateway supports API Gateway-specific Swagger extensions, documented here.

After creating the mock endpoints manually and exporting the Swagger model (importantly, using the "Export as Swagger + API Gateway Extensions" link) you will see something like the following:

  responses:
    200:
      description: "200 response"
  x-amazon-apigateway-integration:
    responses:
      default:
        statusCode: "200"
    requestTemplates:
      application/json: "{\"statusCode\": 200}"
    passthroughBehavior: "when_no_match"
    type: "mock"

Upvotes: 2

Related Questions