Skip to content

APIGW: fix binaryMediaTypes when importing/updating REST APIs #12586

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

Merged
merged 4 commits into from
May 7, 2025

Conversation

bentsku
Copy link
Contributor

@bentsku bentsku commented May 6, 2025

Motivation

We've recently received a report that binary support for APIGW wasn't working when deploying a REST API through CloudFormation and using the Body attribute to use an OpenAPI spec file to define the API.

The OpenAPI spec file didn't define binary media types via the x-amazon-apigateway-binary-media-types, but it did with the CloudFormation parameter BinaryMediaTypes.

After testing against AWS, it seems the behavior is defined by the merge mode when calling PutRestApi for an existing API, and it will be merged by default with the custom extension when using CloudFormation.

Changes

  • update support for binary media types when used with the CFN parameter and the Body parameter
  • update test cases to recreate the scenario (both CFN parameter + body)
  • add test case around PutRestApi depending on the merge mode
  • refresh tests using the same OpenAPI spec file
  • update export logic to return the binary media types extension

@bentsku bentsku added this to the 4.5 milestone May 6, 2025
@bentsku bentsku self-assigned this May 6, 2025
@bentsku bentsku added aws:apigateway Amazon API Gateway semver: patch Non-breaking changes which can be included in patch releases labels May 6, 2025
Copy link

github-actions bot commented May 6, 2025

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 43m 11s ⏱️ + 2m 2s
4 401 tests +2  4 039 ✅ +2  362 💤 ±0  0 ❌ ±0 
4 403 runs  +2  4 039 ✅ +2  364 💤 ±0  0 ❌ ±0 

Results for commit 2094d53. ± Comparison against base commit 5df40f1.

♻️ This comment has been updated with latest results.

@bentsku bentsku marked this pull request as ready for review May 6, 2025 21:33
@bentsku bentsku added the review: merge when ready Signals to the reviewer that a PR can be merged if accepted label May 6, 2025
Copy link
Contributor

@cloutierMat cloutierMat left a comment

Choose a reason for hiding this comment

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

Thanks for the addition and the super thorough testing and investigation of behaviours for the put modes!
🚀

@bentsku bentsku modified the milestones: 4.5, 4.4 May 7, 2025
@bentsku bentsku merged commit 92aa776 into master May 7, 2025
32 checks passed
@bentsku bentsku deleted the apigw-binary-media-cfn branch May 7, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:apigateway Amazon API Gateway review: merge when ready Signals to the reviewer that a PR can be merged if accepted semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants