Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with when_no_match passthroughBehavior for @cors preflight integration in openapi definition #2289

Closed
jfkisafk opened this issue May 17, 2024 · 0 comments · Fixed by #2290

Comments

@jfkisafk
Copy link
Contributor

Issue

Smithy's @cors trait does not give you access to change the passThroughBehavior and sets the $options.x-amazon-apigateway-integration.passThroughBehavior as when_no_match for all resource paths in the openapi definition. That means if the site uses CORS and submits an OPTION request with application/x-www-form-urlencoded Content-Type, then API Gateway might reject the response with a 500 if the request payload does not happen to be:

{"statusCode":200}

We won't want to reject with a 415 Unsupported by overriding the passthroughBehavior to never through jsonSchema injection. That skips calling the actual GET/PUT/.. operation and is a better choice if we need to reject specific Content-Type(s) or provide extra gateway template configurations.

Source code: https://github.com/smithy-lang/smithy/blob/main/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsPreflightIntegration.java#L225-L230

Potential Fixes

We can add the {"statusCode":200} request template for all unique mime-type(s) supported by each operations within a path. That way we won't get inadvertent API Gateway errors with OPTIONS operation and the request can move to GET/PUT/... integration.

jfkisafk added a commit to jfkisafk/foxbat.model that referenced this issue May 21, 2024
kstich pushed a commit that referenced this issue May 22, 2024
…a new flag

The new Open API setting is `syncCorsPreflightIntegration`.

Added the docs as well.

closes #2289
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant