Uh oh!
There was an error while loading. Please reload this page.
feat: support relative URI resolution in $dynamicRef (#2928) - #2945
Conversation
Set ExternalResource on non-fragment $dynamicRef references so the workspace loader can discover and fetch external documents. Resolve relative URIs against hostDocument.BaseUri in Target before calling FindDocumentByBaseUri. Tests: - Fragment-only: ExternalResource is null - Absolute URI: ExternalResource is set, resolves across documents - Relative URI: ExternalResource is set, resolves against BaseUri across documents - V31 and V32 coverage
Adds 17 missing V32 test mirrors for full parity with V31 coverage. Replaces dead '?? new OpenApiWorkspace()' fallback with null-forgiving '!' in both V31 and V32 cross-document tests.
Abdullah Alaqeel (aqeelat)
commented
Jul 14, 2026
Vincent Biret (@baywet) the actual change is in the first commit. the second commit is just mirroring the tests between V31 and V32 |
There was a problem hiding this comment.
Pull request overview
Adds support for resolving cross-document $dynamicRef values that use relative URIs by (1) capturing the external resource on deserialization so the workspace loader can fetch it, and (2) resolving relative document URIs against the host document BaseUri during $dynamicRef resolution.
Changes:
- Populate
Reference.ExternalResourcefor non-fragment$dynamicRefduring V3.1/V3.2 schema deserialization. - Update
OpenApiWorkspace.ResolveDynamicRefto resolve relative$dynamicRefdocument URIs againsthostDocument.BaseUribefore lookup. - Expand V3.2 dynamic-ref test coverage to mirror V3.1 and add cross-document relative URI resolution tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.OpenApi.Readers.Tests/V32Tests/OpenApiDynamicRefTests.cs | Adds/extends V3.2 tests, including cross-document relative $dynamicRef resolution and parity coverage. |
| test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDynamicRefTests.cs | Adds assertions/coverage for ExternalResource and a V3.1 cross-document relative $dynamicRef test. |
| src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs | Resolves relative $dynamicRef document URIs against BaseUri before document lookup (and updates docs). |
| src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs | Sets externalResource for $dynamicRef schema references (V3.2). |
| src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs | Sets externalResource for $dynamicRef schema references (V3.1). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Vincent Biret (baywet)
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
LGTM, besides copilot's comments.
…resolution Addresses Copilot review feedback on microsoft#2945.
Vincent Biret (baywet)
left a comment
There was a problem hiding this comment.
Thank you for making the changes!
Uh oh!
There was an error while loading. Please reload this page.
…microsoft#2945) * feat: support relative URI resolution in $dynamicRef (microsoft#2928) Set ExternalResource on non-fragment $dynamicRef references so the workspace loader can discover and fetch external documents. Resolve relative URIs against hostDocument.BaseUri in Target before calling FindDocumentByBaseUri. Tests: - Fragment-only: ExternalResource is null - Absolute URI: ExternalResource is set, resolves across documents - Relative URI: ExternalResource is set, resolves against BaseUri across documents - V31 and V32 coverage * test: mirror V31 dynamic ref tests to V32 and fix workspace fallback Adds 17 missing V32 test mirrors for full parity with V31 coverage. Replaces dead '?? new OpenApiWorkspace()' fallback with null-forgiving '!' in both V31 and V32 cross-document tests. * fix: remove duplicate XML doc and use Uri.TryCreate for relative URI resolution Addresses Copilot review feedback on microsoft#2945.
Summary
Resolves#2928.
Extends cross-document
$dynamicRefresolution to support relative URIs (e.g.external.yaml#node). Previously only absolute URIs worked.Changes
ExternalResourceon non-fragment$dynamicRefreferences so the workspace loader can discover and fetch external documents automatically.OpenApiWorkspace.ResolveDynamicRef: Resolve relative URIs against the host documentBaseUribefore callingFindDocumentByBaseUri.Depends on
#2913 (merged in
eacc2fc0)