You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR builds upon
#839 to update from
OpenAPIKit 4.x to OpenAPIKit ~5.0~ 6.0.
### Motivation
Updating to OpenAPIKit v4.x enables efforts to add external loading
support to the generator (as a separate future project). This means
being able to read in OpenAPI Documents spread across multiple files.
Updating to OpenAPIKit v5.x allows the generator project to support OAS
3.2.0 features and take advantage of various other improvements to
OpenAPIKit that required breaking changes to be made.
Updating to OpenAPIKit v6.0 allows this project to turn the
`ExternalLoading` trait off (on by default). Turning this trait off
saves 50% of the compile time of OpenAPKit for as long as
`swift-openapi-generator` is not using the external loading features of
OpenAPKit anyway.
### Modifications
- Update OpenAPIKit dependency to v6.x
- Remove code that parsed OAS 3.2.0 documents as 3.1.x documents;
OpenAPIKit v5 supports OAS 3.2.0 documents natively.
- Make changes required by move to new OpenAPIKit version (following
migration guide).
- Introduce `assumeLookupOnce()` to temporarily maintain the existing
invariant that no entries in the Components Object are themselves
references; replace all `lookup()` calls with `assumeLookupOnce()`. See
the **Note** on this below.
- Fix code that looked for references on JSON Schemas under the
assumption that they were wrapped in `OpenAPI.Reference`. This
assumption does not hold in OpenAPIKit v5.
**NOTE on `assumeLookupOnce()`**
The new `assumeLookupOnce()` function is intended to allow for gradual
migration. The generator had previously used `lookup()` which used to
look at the Components Object and either return an entry or throw. Going
forward, `lookup()` does recursive lookup until a non-reference is found
and `lookupOnce()` acts more like `lookup()` used to act -- however,
`lookupOnce()` has a different method signature owing to the fact that
it may return a reference instead of the ultimately desired object. The
need for these changes arise from the fact that OpenAPIKit v5 now allows
entries in the Components Object to themselves be references. This has
been supported by the OpenAPI Standard for some time but OpenAPIKit only
introduced support for it with v5.
Therefore, `assumeLookupOnce()` was added as a way to throw an error if
a reference is found as an entry in the Components Object (behavior
already exhibited by the generator project) but the goal should be to
remove uses of `assumeLookupOnce()` over time and replace them with
either `lookupOnce()` or `lookup()` depending on the needs of each call
site. In this way, the generator project will move closer to supporting
Component Object reference entries without the overhead of changing
every call site all at once.
### Result
Theoretically, nothing functionally changes.
### Test Plan
Tests updated, `swift test` passing, "Compatibility test" suite passing.
---------
Co-authored-by: Anton Titkov <atitkov@me.com>
Co-authored-by: Anton Titkov <iT0ny@users.noreply.github.com>
Co-authored-by: Si Beaumont <beaumont@apple.com>
0 commit comments