Skip to content

fix: resolve external refs nested in array items of external schemas (#2409) - #2410

Open
vinirib wants to merge 1 commit into
swagger-api:masterfrom
vinirib:issue-2409
Open

vinirib wants to merge 1 commit into
swagger-api:masterfrom
vinirib:issue-2409

Conversation

@vinirib

@vinirib vinirib commented Oct 29, 2026

Copy link
Copy Markdown

Description

When an externalized schema has an array property whose items is a $ref to another external file, and that is the only $ref in the file, the items ref is left as a raw relative path (./schemas/Item.yaml) instead of #/components/schemas/Item. It also stays unresolved with resolveFully.

The second pass in ComponentsProcessor.processSchemas only reprocessed a model when one of its direct properties had a $ref, so a pending ref one level down (inside array items) was skipped. It worked only when the same file also had a bare property $ref, which triggered a reprocess of the whole model.

The second pass now reprocesses a model once when it has a pending external ref at any depth: properties, items, additionalProperties, allOf/anyOf/oneOf, not and discriminator mapping. A visited set keeps the check safe on recursive schemas. This also stops the model from being reprocessed once per property with a $ref.

Fixes: #2409

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

Issue2409Test uses the reproduction from the issue plus two variants:

  • the array property renamed (entries), to show the property name is not a factor
  • resolveFully, where the items schema is now inlined

The full swagger-parser-v3 test suite passes on JDK 17 (700 tests).

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]: Array items $ref to an external file is not resolved to #/components/schemas/... when it's the only $ref in the referencing file

1 participant