-
Notifications
You must be signed in to change notification settings - Fork 129
Support base64-encoded data #326
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 base64-encoded data #326
Conversation
Motivation OpenAPI supports base64-encoded data but to this point Swift OpenAPI Generator has not (apple#11). Modifications A data type specified as `type: string, format: byte` will now result in a generated type which is `Codable` and backed by a `OpenAPIRuntime.Base64EncodedData` type which knows how to encode and decode base64 data. Result Users will be able to specify request/response payloads as base64-encoded data which will be encoded and decoded transparently Test Plan Unit tested locally.
ada956b
to
6b59d6a
Compare
@swift-server-bot add to allowlist |
`base64DataEncodingDecoding` enables interpretation of `type: string, format: byte` as base64-encoded data.
@rnro As a last thing, can you add a base64 property to an object of your choice in the file-based reference tests? I'm a little paranoid that this PR is passing even though we haven't released the update runtime yet, which means we're not testing that it all builds and works together. Add a property, and make sure PetstoreConsumerTests are updated to also populate and verify the value both on client and server side. Otherwise lgtm. |
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.
One last ask about testing, see my other comment.
Thanks for the review, I've added an endpoint to upload audio of your pet in base64-encoded binary format. I'm not sure if that's the best API design for an actual pet app but I think it's plausible to get the new code in there. |
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.
Please also add tests to Test_Client and Test_Server that set and verify the value in Pet.genome
, just to make sure it works end-to-end.
Also, you can now update to 0.3.2 of the runtime library in Package.swift of swift-openapi-generator, all that should hopefully make the CI green on this PR. |
6e36455
to
84ef6c6
Compare
84ef6c6
to
ab6dd25
Compare
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 @rnro!
This change accompanies apple/swift-openapi-runtime#55 and relies on it for the
OpenAPIRuntime.Base64EncodedData
type.Motivation
OpenAPI supports base64-encoded data but to this point Swift OpenAPI Generator has not (#11).
Modifications
A data type specified as
type: string, format: byte
will now result in a generated type which isCodable
and backed by aOpenAPIRuntime.Base64EncodedData
type which knows how to encode and decode base64 data.Result
Users will be able to specify request/response payloads as base64-encoded data which will be encoded and decoded transparently
Test Plan
Unit tested locally.