Repository navigation
Fix array handling for JSON pointers when resolving OpenAPI schemas - #67573
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes JSON Pointer ($ref) resolution in OpenApiSchemaService to follow RFC 6901 more closely, addressing failures when navigating into arrays (e.g., anyOf/0/...) and when reference tokens require unescaping. It also adds regression coverage for polymorphic schemas with dictionary-valued properties to ensure derived schemas are fully populated.
Changes:
- Update
$refresolution to parse JSON Pointer tokens, including~0/~1unescaping and URI unescaping, and to support navigatingJsonArrayby index. - Add regression test coverage for polymorphic derived schemas that previously ended up with empty
additionalPropertiesdue to unresolved pointers. - Adjust the test helper to return the generated
OpenApiDocumentso tests can serialize/compare full documents.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/OpenApi/src/Services/Schemas/OpenApiSchemaService.cs | Implements JSON Pointer parsing/token evaluation for $ref resolution (including arrays and unescaping). |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Shared/SharedTypes.Polymorphism.cs | Adds polymorphic dictionary-container types used by the new regression test. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.PolymorphicSchemas.cs | Adds regression test asserting dictionary schemas are complete for every derived type; compares serialized document JSON. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiDocumentServiceTestsBase.cs | Changes helper to return OpenApiDocument to support follow-up serialization/assertions. |
Youssef1313
marked this pull request as draft
July 3, 2026 08:34
Youssef1313
marked this pull request as ready for review
July 3, 2026 09:03
DeagleGross
reviewed
Jul 3, 2026
DeagleGross
approved these changes
Jul 3, 2026
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.
Fix array handling for JSON pointers when resolving OpenAPI schemas
Fixes #66800
Fixes #65759
The algorithm for resolving a reference (a JSON pointer) was naive and didn't implement the spec correctly.
~1and~0.This PR attempts to implement it per the specification, referencing the relevant spec parts when needed.