Problem
$dynamicRef values with relative URIs (e.g., ./external.yaml#node) are not resolved. FindDocumentByBaseUri compares the raw string against document base URIs, so a relative reference never matches an absolute document URI.
Example:
# Document A (baseUri: https://example.com/main.yaml)Tree:
properties:
next:
$dynamicRef: './external.yaml#node'# Document B (baseUri: https://example.com/external.yaml)ExternalNode:
$dynamicAnchor: nodetype: object
$dynamicRef: './external.yaml#node' should resolve to https://example.com/external.yaml (Document B), but FindDocumentByBaseUri('./external.yaml') cannot match https://example.com/external.yaml.
Proposed fix
Pass the host document's BaseUri to FindDocumentByBaseUri and resolve the relative reference via new Uri(baseUri, documentUri):
internalOpenApiDocument?FindDocumentByBaseUri(stringdocumentUri,Uri?baseUri){varresolved=baseUriis not null?newUri(baseUri,documentUri).ToString():documentUri;return_dynamicAnchorRegistryByDocument.Keys.Concat(_anchorRegistryByDocument.Keys).Distinct().FirstOrDefault(doc =>doc.BaseUri?.ToString().Equals(resolved,StringComparison.OrdinalIgnoreCase)==true);}Scope
OpenApiWorkspace.FindDocumentByBaseUri — accept optional base URI parameterOpenApiSchemaReference.Target — pass Reference.HostDocument.BaseUri- Tests — cross-document resolution with relative URIs
Related
Problem
$dynamicRefvalues with relative URIs (e.g.,./external.yaml#node) are not resolved.FindDocumentByBaseUricompares the raw string against document base URIs, so a relative reference never matches an absolute document URI.Example:
$dynamicRef: './external.yaml#node'should resolve tohttps://example.com/external.yaml(Document B), butFindDocumentByBaseUri('./external.yaml')cannot matchhttps://example.com/external.yaml.Proposed fix
Pass the host document's
BaseUritoFindDocumentByBaseUriand resolve the relative reference vianew Uri(baseUri, documentUri):Scope
OpenApiWorkspace.FindDocumentByBaseUri— accept optional base URI parameterOpenApiSchemaReference.Target— passReference.HostDocument.BaseUriRelated
$dynamicRef/$dynamicAnchorresolution