Forum Discussion

MusicMonkey5555's avatar
MusicMonkey5555
Regular Visitor
4 years ago

Amazon API gateway lambda sync: Gateway Responses

I'm using the Amazon API gateway lambda sync and I've customized the Gateway responses (default responses) in amazon. For instance Missing Authentication Token I have the default 403 status code, but for the template I have: 

 

 

 

{"message":$context.error.messageString, "code":403, "errors": []}

 

 

 

But every time I make an update in swaggerhub it resets it to the amazon default.

I even looked into the documentation and added at the very bottom of my OpenAPI 3.0 yaml in swaggerhub:

 

 

 

x-amazon-apigateway-gateway-responses:
  MISSING_AUTHENTICATION_TOKEN:
    statusCode: 403
    responseTemplates:
      application/json: "{\"message\":$context.error.messageString, \"code\":403,\
        \ \"errors\": []}"

 

 

 

But it still gets over-written.

Amazon specific tags on some of my paths like:

 

 

 

      x-amazon-apigateway-integration:
        type: aws
        httpMethod: POST
        responses:
          default:
            statusCode: "200"
          ".*\"code\":403.*":
            statusCode: "403"
            responseTemplates:
              application/json: $input.path('$.errorMessage')

 

 

 

  work fine and I see changes made to the api, just not the gateway level responses.

No RepliesBe the first to reply