Skip to content

fix: preserve root component keys in back-references - #2400

Open
goutamadwant wants to merge 1 commit into
swagger-api:masterfrom
goutamadwant:bug/2399-preserve-root-component-name
Open

fix: preserve root component keys in back-references#2400
goutamadwant wants to merge 1 commit into
swagger-api:masterfrom
goutamadwant:bug/2399-preserve-root-component-name

Conversation

@goutamadwant

Copy link
Copy Markdown

Pull Request

Description

ResolverCache can resolve an external back-reference from an external component to a component in the original root document. ExternalRefProcessor previously continued into component-name allocation after that lookup. When the root component was itself an external $ref and its declared key differed from the target filename, the allocator treated the root component as a conflict, created a suffixed duplicate, and could mutate the root snapshot. With resolveFully and validateExternalRefs, this later produced an invalid basename-derived lookup.

This PR:

  • retains the declared JSON Pointer key when a reference resolves from the root document snapshot
  • reuses that key before component allocation and recursive processing for every supported component type
  • keeps root-resolved schema targets referenced through component cleanup
  • adds the [Bug]: Regression: resolveFully fails when components key does not match external file basename #2399 regression fixture and focused cache, schema-alias, and response tests, including negative fallbacks for absent, nested, and wrong-type pointers

Fixes #2399

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

Validated with:

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.

[Bug]: Regression: resolveFully fails when components key does not match external file basename

1 participant