Skip to content

fix(v3): retain full JSON pointer path on OpenAPI 3.0 schema references - #3155

Open
Hardik K (hardikkaurani) wants to merge 3 commits into
microsoft:mainfrom
hardikkaurani:fix/v3-subschema-reference-pointer-path
Open

Hardik K (hardikkaurani) wants to merge 3 commits into
microsoft:mainfrom
hardikkaurani:fix/v3-subschema-reference-pointer-path

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Pull Request

Description

When parsing an OpenAPI 3.0 document containing a $ref to a component's subschema/property (e.g., #/components/schemas/User/properties/name), OpenApiSchemaDeserializer.LoadSchema only extracted the terminal segment (name) without preserving the full JSON pointer path. As a result, ReferenceV3 defaulted to #/components/schemas/name, discarding intermediate segments (User/properties) and causing resolution failure or binding to an incorrect component schema.

This change invokes result.Reference.SetJsonPointerPath(pointer, context.GetLocation()) in OpenAPI 3.0 OpenApiSchemaDeserializer, aligning it with OpenAPI 3.1 and 3.2 deserializers.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Related Issue(s)

Fixes #3154

Changes Made

  • In src/Microsoft.OpenApi/Reader/V3/OpenApiSchemaDeserializer.cs, called SetJsonPointerPath(pointer, context.GetLocation()) on result.Reference when pointer != null.
  • Added unit and regression tests in test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSubschemaReferenceTests.cs verifying single-level and nested component property $ref resolution in OpenAPI 3.0.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Local verification:

  • dotnet test test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj --filter "FullyQualifiedName~OpenApiSubschemaReferenceTests" passed (2 succeeded, 0 failed).
  • Full Microsoft.OpenApi.Readers.Tests suite passed (638 passed, 0 failed).
  • Full Microsoft.OpenApi.Tests suite passed (1310 passed, 0 failed).

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Versions applicability

  • My change applies to the version 1.X of the library, if so PR link:
  • My change applies to the version 2.X of the library, if so PR link:
  • My change applies to the version 3.X of the library, if so PR link:
  • I have evaluated the applicability of my change against the other versions above.

@hardikkaurani
Hardik K (hardikkaurani) requested a review from a team as a code owner November 1, 2026 18:57
Copilot AI balanced review requested due to automatic review settings November 1, 2026 18:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAPI 3.0: schema $ref to a component's property (#/components/schemas/User/properties/name) is truncated to #/components/schemas/name

2 participants