Commit 1bace68
fix(library): avoid false circular refs for external schema re-exports
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>1 parent b215087 commit 1bace68Copy full SHA for 1bace68
2 files changed
+75-1Lines changed: 75 additions & 1 deletion
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- src/Microsoft.OpenApi/Services
- test/Microsoft.OpenApi.Readers.Tests/V31Tests
Expand file treeCollapse file tree
Open diff view settings
Collapse file
src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs
Copy file name to clipboardExpand all lines: src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs+6-1Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
94 | 94 | |
95 | 95 | |
96 | 96 | |
97 | | - |
| 97 | + |
98 | 98 | |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
99 | 104 | |
100 | 105 | |
101 | 106 | |
|
Collapse file
test/Microsoft.OpenApi.Readers.Tests/V31Tests/RelativeReferenceTests.cs
Copy file name to clipboardExpand all lines: test/Microsoft.OpenApi.Readers.Tests/V31Tests/RelativeReferenceTests.cs+69Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
203 | 203 | |
204 | 204 | |
205 | 205 | |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | + |
| 218 | + |
| 219 | + |
| 220 | + |
| 221 | + |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | + |
| 232 | + |
| 233 | + |
| 234 | + |
| 235 | + |
| 236 | + |
| 237 | + |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + |
| 243 | + |
| 244 | + |
| 245 | + |
| 246 | + |
| 247 | + |
| 248 | + |
| 249 | + |
| 250 | + |
| 251 | + |
| 252 | + |
| 253 | + |
| 254 | + |
| 255 | + |
| 256 | + |
| 257 | + |
| 258 | + |
| 259 | + |
| 260 | + |
| 261 | + |
| 262 | + |
| 263 | + |
| 264 | + |
| 265 | + |
| 266 | + |
| 267 | + |
| 268 | + |
| 269 | + |
| 270 | + |
| 271 | + |
| 272 | + |
| 273 | + |
| 274 | + |
206 | 275 | |
207 | 276 | |
208 | 277 | |
|
0 commit comments