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

[Runtime] Improved content type matching #65

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

czechboy0
Copy link
Contributor

Motivation

The runtime changes for apple/swift-openapi-generator#315.

Modifications

  • Introduces a new SPI method Converter.bestContentType that takes a received content type value and from a provided list of other content types, picks the most appropriate one. This actually follows the specification now, by going from most specific (including parameter matching) to least specific (most wildcard-y).
  • Deprecates the previously used methods Converter.makeUnexpectedContentTypeError and Converter.isMatchingContentType.

Result

SPI methods that the generated code can use to correctly match content types.

Test Plan

Added unit tests.

Copy link

@gjcairo gjcairo left a comment

Choose a reason for hiding this comment

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

Looks great overall, just left a few comments with some pretty small nits.

Sources/OpenAPIRuntime/Base/OpenAPIMIMEType.swift Outdated Show resolved Hide resolved
Sources/OpenAPIRuntime/Conversion/Converter+Common.swift Outdated Show resolved Hide resolved
@czechboy0 czechboy0 merged commit 333d73a into apple:main Oct 30, 2023
@czechboy0 czechboy0 deleted the hd-improved-content-type-matching branch October 30, 2023 15:15
@czechboy0 czechboy0 added the 🔨 semver/patch No public API change. label Oct 30, 2023
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants