apple / swift-openapi-generator

Generate Swift client and server code from an OpenAPI document.
https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
Apache License 2.0
1.45k stars 121 forks source link

[Refactor] Introduce TranslatorContext (2/2) #640

Closed czechboy0 closed 1 month ago

czechboy0 commented 1 month ago

Motivation

Depends on https://github.com/apple/swift-openapi-generator/pull/638, so don't review until that lands.

Continuation of #638, broke up into multiple PRs for easier review.

Also a non-functional change, purely a refactoring.

Modifications

Changed a bunch of TypeMatcher methods from static to being instance methods, which gives them access to the translator context.

Moved a few other methods that depended on the static methods to be extensions on the closest type that already has access to the context.

Result

Now TypeAssigner/TypeMatcher can take runtime configuration, e.g. through feature flags.

Test Plan

All tests still pass.

simonjbeaumont commented 1 month ago

I'll wait until the other PR lands, but will approve it when it's all rebased.

czechboy0 commented 1 month ago

I'll wait until the other PR lands, but will approve it when it's all rebased.

Okay, ready to go.