-
Notifications
You must be signed in to change notification settings - Fork 49
Support base64-encoded data #55
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 #55
Conversation
83125e6
to
b1cd56e
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.
Users will be able to describe base64-encoded data as
OpenAPIRuntime.Base64EncodedData
e.g.public typealias MyData = OpenAPIRuntime.Base64EncodedData
By users, do we mean the generator will emit this type alias when it encounters format: base64
in the OpenAPI document?
Sorry, yes, the generator. I think we will use |
@swift-server-bot add to allowlist |
4a10d8c
to
bc27f86
Compare
@swift-server-bot test this please |
Motivation OpenAPI supports base64-encoded data but to this point OpenAPI Generator has not (apple/swift-openapi-generator#11). Modifications Introduce the `Base64EncodedData` codable type to allow users in the generator to describe byte types which must be en/de-coded. Result Users will be able to describe base64-encoded data as `OpenAPIRuntime.Base64EncodedData` e.g. ``` public typealias MyData = OpenAPIRuntime.Base64EncodedData ``` Test Plan Added a round-trip encode/decode test `testEncodingDecodingRoundTrip_base64_success`
6a86b64
to
dffa64c
Compare
a8c8212
to
1427a01
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.
A few minor requests, otherwise looks good! Could you also open a PR of the generator changes, so that we can review both before we start landing them? That's our usual workflow. That means that locally you need to develop the two branches together.
The accompanying generator change is apple/swift-openapi-generator#326 |
@swift-server-bot add to allowlist |
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.
Lgtm, just rerunning the integration test which should pass now that 0.3.0 has been released.
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.
Nice—thanks @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 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.
Motivation
OpenAPI supports base64-encoded data but to this point OpenAPI Generator has not (apple/swift-openapi-generator#11).
Modifications
Introduce the
Base64EncodedData
codable type to allow users in the generator to describe byte types which must be en/de-coded.Result
Users will be able to describe base64-encoded data as
OpenAPIRuntime.Base64EncodedData
e.g.Test Plan
Added a round-trip encode/decode test
testEncodingDecodingRoundTrip_base64_success