fix(library): avoid false circular refs for external schema re-exports#2873
Open
baywet wants to merge 1 commit into
Open
fix(library): avoid false circular refs for external schema re-exports#2873baywet wants to merge 1 commit into
baywet wants to merge 1 commit into
Conversation
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall coverage remains at 88%, unchanged from the branch. Updated |
Fixes #2872. The false positive came from workspace schema registration preferring item.Value.Id for component aliases. For OpenApiSchemaReference values, reading Id eagerly dereferenced the external target during registration, which triggered "Circular reference detected while resolving schema" for a root schema re-export plus a direct external reference. This faulty behavior traces back to PR #1826, which introduced the item.Value.Id ?? fallback to support JSON Schema identifier-based resolution. Under JSON Schema 2020-12, JSON Pointer still identifies a lexical location in the containing document, but $id establishes the canonical schema resource URI. This change preserves explicit $id alias registration for concrete schemas while always registering component keys for schema references so workspace registration does not resolve refs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a9a6128 to
7a443c2
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.



Summary
OpenApiWorkspace.RegisterComponentsfrom dereferencing schema refs while registering component aliases$id-based registration for concrete schemas so canonical identifier lookups still workWhy
Fixes #2872.
The faulty behavior was introduced by #1826, which added the
item.Value.Id ?? ...fallback in schema registration to support identifier-based resolution. That was correct for concrete schemas, but it is unsafe forOpenApiSchemaReferencebecause accessingIdresolves the external target eagerly during workspace registration.JSON Schema reference-resolution implications
Under JSON Schema 2020-12, a JSON Pointer can still address a lexical location within the containing document, but
$iddefines the canonical URI of a schema resource. For this code path, component registration should therefore:$idaliases for concrete schemas that already own that canonical identifier