Skip to content

Conversation

czechboy0
Copy link
Contributor

Motivation

An idea of how to address apple/swift-openapi-generator#605 in a more holistic way, following the approach we took with the date transcoder and XML custom coder.

Modifications

  • Reuses and extends (with backwards shims) the CustomCoder protocol.
  • Adds a jsonCoder parameter to the Configuration struct.
  • Ensures the date transcoder still gets applied on the JSON coder (even when a custom one is provided).
  • Added convenience initializers for the case when the JSON encoder's output formatting is the only thing the user wants to customize (expected to be the vast majority of cases).

Result

Fixes #605 while also providing a customization hook allowing a completely custom JSON encoder and decoder. This allows handling new JSON standard improvements that are not yet present in Foundation's JSON encoder/decoder, or even processing the JSON transparently (e.g. inline encryption).

Test Plan

Added unit tests.

@czechboy0 czechboy0 requested a review from simonjbeaumont July 29, 2024 09:25
@czechboy0
Copy link
Contributor Author

Discussed more with @simonjbeaumont, this might be opening too much of an API surface for the ask. Will open a new PR with a solution that just allows providing the JSON encoding options, without having to provide a whole coder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant