Support local dereferencing of schema anchors#492
Open
ayushshrivastv wants to merge 4 commits intomattpolzin:mainfrom
Open
Support local dereferencing of schema anchors#492ayushshrivastv wants to merge 4 commits intomattpolzin:mainfrom
ayushshrivastv wants to merge 4 commits intomattpolzin:mainfrom
Conversation
Contributor
Author
|
CI note: the This branch was missing the earlier Linux-stability follow-ups that we had already applied on other OpenAPIKit branches, so I pulled those fixes into this PR as well. Concretely, the fix removes the async fan-out in Local verification after the fix:
|
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.
Closes #363
Summary
#anchorreferences as a first-classJSONReference.InternalReferencecaseDocument.locallyDereferenced()build an anchor-aware temporary lookup so schema anchors can resolve during local dereferencingImplementation Details
OpenAPI 3.1 schema anchors live outside the Components Object, but local dereferencing in OpenAPIKit currently resolves only through
document.components. To keep the fix narrow and avoid changing unrelated reference behavior, this patch keeps the anchor support scoped to local dereferencing:JSONReference<...>.InternalReferencenow preserves#anchorvalues as.anchor(name:)instead of collapsing them into a generic path reference.JSONReference<JSONSchema>.anchor(named:)was added as a convenience constructor for local schema anchor references.Document.locallyDereferenced()now uses a temporary, anchor-aware copy ofcomponentsthat is populated by walking the document's inline and component-hosted schemas and registering anchored schemas for lookup during dereferencing.Components+JSONReferencenow recognizes.anchor(name:)forJSONSchemalookups so the existing dereference machinery can resolve anchored schemas and continue following nested references/cycles consistently.This keeps the public fix focused on the issue at hand: local document dereferencing now works for
$ref: '#someAnchor'without widening non-schema or non-local lookup behavior.Testing
swift test --filter JSONReferenceTestsswift test --filter DereferencedDocumentTestsswift test --filter ComponentsTestsswift test