Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(apigateway): duplicate methodResponses if the same array is reuse…
…d between addMethod calls (#26636) Adding a new method to an API with `addMethod` and passing `methodOptions.methodResponses` was generating duplicate entries using `StepFunctionsIntegration.startExecution` as integration: For example: ``` const integ = apigw.StepFunctionsIntegration.startExecution(stateMachine, integrationOptions); api.root.addMethod('GET', integ, methodOptions); api.root.addMethod('POST', integ, methodOptions); ``` Would generate (fails on deployment): ``` "MethodResponses": [ { "ResponseParameters": { "method.response.header.Access-Control-Allow-Origin": true }, "StatusCode": "200" }, { "ResponseModels": { "application/json": "Empty" }, "StatusCode": "200" }, { "ResponseModels": { "application/json": "Error" }, "StatusCode": "400" }, { "ResponseModels": { "application/json": "Error" }, "StatusCode": "500" }, { "ResponseModels": { "application/json": "Empty" }, "StatusCode": "200" }, { "ResponseModels": { "application/json": "Error" }, "StatusCode": "400" }, { "ResponseModels": { "application/json": "Error" }, "StatusCode": "500" } ], ``` With this fix, it will keep only the specified `methodResponses`. Also, the `integrationResponses` option in `StepFunctionsIntegration.startExecution` was not used by the corresponding `Integration`. This fix will allow to use the specified option value. Closes #26586. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information