Visitar URL original
fix(v3): retain full JSON pointer path on OpenAPI 3.0 schema references by hardikkaurani · Pull Request #3155 · microsoft/OpenAPI.NET · GitHub
Skip to content

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

Merged
Vincent Biret (baywet) merged 3 commits into
microsoft:mainfrom
hardikkaurani:fix/v3-subschema-reference-pointer-path
Nov 13, 2026
Merged

Vincent Biret (baywet) merged 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.

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.

🟢 Approval recommended

The review reports no active issues with the OpenAPI 3.0 reference-path fix.

No open issues 🎉

Review effort: Balanced

@baywet
Vincent Biret (baywet) enabled auto-merge (squash) November 13, 2026 15:44
@baywet
Vincent Biret (baywet) merged commit d8f20e8 into microsoft:main Nov 13, 2026
8 of 9 checks passed
Vincent Biret (baywet) added a commit that referenced this pull request Nov 13, 2026
…es (#3155) (#3170)

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

* fix(v3): retain full JSON pointer path on OpenAPI 3.0 schema references

* test(v3): add unit test for component property schema reference in OpenAPI 3.0

* test(v3): add regression test for nested component subschema references in OpenAPI 3.0

* fix(reader): balance example locations and defer reference paths

Restore parsing locations after named examples, including exception paths, and construct locations only when relative reference resolution requires them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dc47aa82-c449-43a1-8a70-c4f3c464ae51

* chore(benchmark): refresh performance reports

Regenerate description and empty-model benchmark reports after repairing example locations and deferring reference path construction.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dc47aa82-c449-43a1-8a70-c4f3c464ae51

---------

Co-authored-by: Hardik K <hardikkaurani1@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: dc47aa82-c449-43a1-8a70-c4f3c464ae51
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

3 participants