-
Notifications
You must be signed in to change notification settings - Fork 147
[Generator] Accept header #185
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
Conversation
...eratorReferenceTests/Resources/ReferenceSources/Petstore_FF_MultipleContentTypes/Types.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a pretty sensible shape. Not sure about the ordering of quality
and contentType
though.
...eratorReferenceTests/Resources/ReferenceSources/Petstore_FF_MultipleContentTypes/Types.swift
Outdated
Show resolved
Hide resolved
Tests/PetstoreConsumerTestsFFMultipleContentTypes/Test_Client.swift
Outdated
Show resolved
Hide resolved
@gjcairo @glbrntt if you have more time, would love your thoughts on the associated changes in the runtime library: apple/swift-openapi-runtime#37 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Honza!
Sources/_OpenAPIGeneratorCore/Translator/CommonTranslations/translateRawRepresentableEnum.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
[Runtime] Accept header ### Motivation SOAR-0003 was accepted, this is the runtime side of the implementation. ### Modifications - Introduced a new protocol `AcceptableProtocol`, which all the generated, operation-specific Accept enums conform to. - Introduced a new struct `QualityValue`, which wraps the quality parameter of the content type. Since the precision is capped at 3 decimal places, the internal storage is in 1000's, allowing for more reliable comparisons, as floating point numbers are only used when serialized into headers. - Introduced a new struct `AcceptHeaderContentType`, generic over `AcceptableProtocol`, which adds `QualityValue` to each generated Accept enum. - Introduced new extensions on `Converter` that allow setting and getting the Accept header. ### Result These are the requirements for apple/swift-openapi-generator#185. ### Test Plan Added unit tests for both `QualityValue` and `AcceptHeaderContentType`, and for the new `Converter` methods. Reviewed by: gjcairo Builds: ✔︎ pull request validation (5.8) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (api breakage) - Build finished. ✔︎ pull request validation (docc test) - Build finished. ✔︎ pull request validation (integration test) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. #37
Motivation
Fixes #160.
SOAR-0003 was accepted, this is the generator side of the implementation. The runtime side, which must land first, is at: apple/swift-openapi-runtime#37.
Modifications
AcceptableContentType
enum looks like.translateRawRepresentableEnum
, which allows sharing logic between generating this new enum and other string-based enums.Result
SOAR-0003 as proposed, working behind the
multipleContentTypes
feature flag.Test Plan
Adapted PetstoreConsumerTests to test the new behavior, adapter reference tests.