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

Add validation for payloadFormatVersion with HTTP APIs #688

Merged
merged 3 commits into from
Jan 12, 2021

Conversation

srchase
Copy link
Contributor

@srchase srchase commented Jan 11, 2021

HTTP APIs on API Gateway require that the payloadFormatVersion is set, either to 1.0 or 2.0. This CR adds validation to ensure that when converting to OpenAPI for use with API Gateway, the aws.apigateway#integration trait must have this property set when used with an HTTP API. Use with an HTTP API is indicated by setting the apiGatewayType to HTTP when configuring the openapi plugin.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@srchase srchase requested a review from kstich January 11, 2021 22:52
@srchase srchase requested a review from kstich January 11, 2021 23:25
ApiGatewayConfig.ApiType apiType = context.getConfig().getExtensions(ApiGatewayConfig.class)
.getApiGatewayType();
if (!trait.getPayloadFormatVersion().isPresent() && apiType.equals(ApiGatewayConfig.ApiType.HTTP)) {
throw new OpenApiException("When using the HTTP apiGatewayType, a payloadFormatVersion must be set on the"
Copy link
Contributor

@kstich kstich Jan 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be clarified a little. It's important here to show the source of the conflict and guide to where this should be fixed.

String.format("When the 'apiGatewayType' OpenAPI conversion setting is 'HTTP', a 'payloadFormatVersion' must "
        + "be set on the aws.apigateway#integration trait applied at %s", trait.getSourceLocation());

Thought I submitted this in the first review, apologies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the error message in 9c1f284, but did not include the sourceLocation of the trait. That sourceLocation points back to where the aws.api#integration trait itself was defined, not where it was applied on the service or operation, so it wouldn't be helpful in this case.

@srchase srchase requested a review from kstich January 12, 2021 19:34
@srchase srchase merged commit a9ee9b4 into main Jan 12, 2021
@srchase srchase deleted the payload-format-version-validation branch January 12, 2021 19:44
@kstich kstich mentioned this pull request Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants