alma-cdk / openapix

Combine the power of AWS CDK & OpenAPI YAML Schema Definitions
https://constructs.dev/packages/@alma-cdk/openapix/
93 stars 5 forks source link

OPTIONS method with CorsIntegration returns HTTP 500 "Internal server error" #37

Closed bkovacki closed 1 year ago

bkovacki commented 1 year ago

Calling an OPTIONS method defined with CorsIntegration returns error with status code 500.

Response body:

{
  "message": "Internal server error"
}

API Gateway Logs:

Execution log for request 8eae9904-378d-4377-bff1-97a2cd11f8f7
Mon Nov 28 19:52:17 UTC 2022 : Starting execution for request: 8eae9904-378d-4377-bff1-97a2cd11f8f7
Mon Nov 28 19:52:17 UTC 2022 : HTTP Method: OPTIONS, Resource Path: /test
Mon Nov 28 19:52:17 UTC 2022 : Method request path: {}
Mon Nov 28 19:52:17 UTC 2022 : Method request query string: {}
Mon Nov 28 19:52:17 UTC 2022 : Method request headers: {content-type= application/json}
Mon Nov 28 19:52:17 UTC 2022 : Method request body before transformations: 
Mon Nov 28 19:52:17 UTC 2022 : Execution failed due to configuration error: Unable to parse statusCode. It should be an integer that is defined in the request template.
Mon Nov 28 19:52:17 UTC 2022 : Method completed with status: 500

Example code:

new openapix.Api(this, "TestAPI", {
  source: testApiSource,
  paths: {
    "/test": 
      post: new openapix.LambdaIntegration(this, testFunction),
      options: new CorsIntegration(this, {
        headers: "'Content-Type,X-Amz-Date,Authorization'",
        origins: "*",
        methods: "'POST, OPTIONS'",
      }),
    },
  },
});
mpiltz commented 1 year ago

Hi,

Thank you for opening this issue. We look into your PR asap.