I'm using a swagger/OpenAPI file to describe a mock API that I've implemented in AWS API Gateway. The API returns a HTTP 200 when the swagger is written like this:
"x-amazon-apigateway-request-validator": "params-only",
"x-amazon-apigateway-integration": {
"requestTemplates": {
"application/json" : "{\"statusCode\": 200 }"
},
"responses" : {
"2\\d{2}" : {
"statusCode" : "200"
},
"4\\d{2}" : {
"statusCode" : "400"
}
},
"passthroughBehavior": "when_no_match",
"timeoutInMillis": "20000",
"httpMethod": "POST",
"type": "mock"
}
However, when I alter the swagger to return a value found in the request header, I get a HTTP 500 error. Here's the modified swagger:
"x-amazon-apigateway-request-validator": "params-only",
"x-amazon-apigateway-integration": {
"requestTemplates": {
"application/json" : "{\"statusCode\": 200 }"
},
"responses" : {
"2\\d{2}" : {
"statusCode" : "$input.params('Mock-Return-Code')"
},
"4\\d{2}" : {
"statusCode" : "$input.params('Mock-Return-Code')"
}
},
"passthroughBehavior": "when_no_match",
"timeoutInMillis": "20000",
"httpMethod": "POST",
"type": "mock"
}
Here's the exact error I receive when I run the API with the $input.params reference:
Execution failed due to configuration error: Output mapping refers to an invalid method response: $input.params('Mock-Return-Code')
Any ideas?