Draft
Conversation
…emaWarningsForwardedToGeneratorDiagnostics`
3ed2442 to
b61dbf0
Compare
…ted natively by OpenAPIKit.
…g OAS documents prior to 3.2.0 in the same manner for now
… that no Components Objects entries are references
b61dbf0 to
4e5ff88
Compare
This could be squashed into 'fix code that inspects UnresolvedSchemas for references' except for the fact that two commits tells the story better. The first commit fixes by looking into JSONSchema.references when they are found in UnresolvedSchemas in places where that is needed. This second commit cleans up by flattening the UnresolvedSchema so that we only need the inner of the two switch statements.
4e5ff88 to
7b35cbd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR builds upon #839 to update from OpenAPIKit 4.x to OpenAPIKit 5.0. Given that, here's a more useful diff of this PR's changes:
iT0ny/swift-openapi-generator@update-openapi-kit-to-v4...mattpolzin:swift-openapi-generator:update-openapi-kit-to-v5
The work here is best reviewed one commit at a time starting with ff6cf0bd8644cdf2727f4ca22f83e7a9c133f315.
Motivation
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.
Modifications
assumeLookupOnce()to temporarily maintain the existing invariant that no entries in the Components Object are themselves references; replace alllookup()calls withassumeLookupOnce(). See the Note on this below.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 usedlookup()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 andlookupOnce()acts more likelookup()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 ofassumeLookupOnce()over time and replace them with eitherlookupOnce()orlookup()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 testpassing, "Compatibility test" suite passing.