Skip to content

Conversation

czechboy0
Copy link
Contributor

Motivation

In service of an upcoming generator PR - to better handle parameters in MIME types.

This is needed for APIs such as Kubernetes, that has both application/json and application/json; watch=true in a single operation.

Modifications

Use the more modern OpenAPIMIMEType type for parsing and comparing content types, rather than the old naive logic that ignored parameter (mis)matches.

Result

More accurate handling of content types.

Test Plan

Adapted unit tests.

Copy link
Collaborator

@simonjbeaumont simonjbeaumont left a comment

Choose a reason for hiding this comment

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

Nice one, thanks!

@simonjbeaumont simonjbeaumont merged commit b820948 into apple:main Nov 19, 2024
25 checks passed
@czechboy0 czechboy0 deleted the hd-mime-type-params branch November 19, 2024 21:23
@czechboy0 czechboy0 added the 🔨 semver/patch No public API change. label Nov 25, 2024
czechboy0 added a commit to apple/swift-openapi-generator that referenced this pull request Nov 28, 2024
…#646) ### Motivation The generator piece of apple/swift-openapi-runtime#113. This is needed for APIs such as Kubernetes, that has both `application/json` and `application/json; watch=true` in a single operation. Currently the parameters weren't taken into account, which could lead to incorrect matching of content types. ### Modifications Use the full MIME type, including the parameters, for matching. ### Result More correct behavior, now we correctly handle multiple MIME types with the same type/subtype in an operation. ### Test Plan Added a unit test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

2 participants