-
Notifications
You must be signed in to change notification settings - Fork 126
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
Support for XML request body and response body #664
base: main
Are you sure you want to change the base?
Conversation
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, thank you @ugocottin!
Added a few suggestions, and I wonder if you could also add an XML client and server example to the Examples directory? To show how to connect all the pieces to actually have it all working. You can add a dependency on an existing XML coder in those example packages.
Sources/_OpenAPIGeneratorCore/Translator/Content/ContentType.swift
Outdated
Show resolved
Hide resolved
Sources/swift-openapi-generator/Documentation.docc/Articles/Supported-OpenAPI-features.md
Outdated
Show resolved
Hide resolved
...-openapi-generator/Documentation.docc/Development/Converting-between-data-and-Swift-types.md
Outdated
Show resolved
Hide resolved
Tests/OpenAPIGeneratorCoreTests/Translator/Content/Test_ContentType.swift
Show resolved
Hide resolved
@ugocottin could you also review this section of OpenAPI to see if we should be taking that info into account? https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#xml-object |
@czechboy0 Regarding XML object metadata, I think it is out of the scope of this PR, but should definitely be implemented later for better XML support. |
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 for the updates @ugocottin, I added a few more minor comments.
Also two more questions for us to discuss:
- How does https://github.com/oai/openapi-specification/blob/main/versions/3.1.1.md#xml-object factor into the serialization? Or should we ignore that and the adopter-provided XML encoder/decoder is what should know about how to translate between the raw XML and a full Codable type?
- Could you add a new package to Examples that shows how to use this end to end, one for client and one for server, similar to the ones we already have? It'd be great for folks (including myself) to just clone the repo and run the example to see it work.
Thanks!
/// 2. text | ||
/// 3. binary |
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.
/// 2. text | |
/// 3. binary | |
/// 3. text | |
/// 4. binary |
static var applicationJSON: Self { try! .init(string: "application/json") } | ||
/// The content type `application/xml`. |
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.
static var applicationJSON: Self { try! .init(string: "application/json") } | |
/// The content type `application/xml`. | |
static var applicationJSON: Self { try! .init(string: "application/json") } | |
/// The content type `application/xml`. |
- [ ] XML | ||
- [X] XML | ||
- when content type is `application/xml` or ends with `+xml` | ||
- xmlCoder must be provided to `OpenAPIRuntime.Configuration` |
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, please also add a note to the section XML Object
to clarify the current state of support for XML.
Hello guys Do you have an estimated date for merging this feature? Thanks |
No date estimate. When it's ready, it'll get merged. We appreciate all contributions, on any timeline, as many folks invest their free time into these pull requests. |
Is there anything I can do to help? |
I'll let @ugocottin speak to that as the author of this PR. |
Motivation
See this issue for more.
Modifications
Based on modifications in the swift-openapi-runtime, I've added support for XML coding strategy and content-type category.
Result
Bodies with XML content-type can be encoded and decoded through
xmlCoder
inOpenAPIRuntime.Configuration
.Test Plan
I've updated test for ContentType parsing with
application/xml
content-type.Encoding and decoding to XML are out of scope of the tests, because encoding and decoding logic must be provided by user through custom coder implementation.