Skip to content

fix: Inlining of references with dot (#2109) - #2384

Merged
ewaostrowska merged 1 commit into
masterfrom
issue-2109
Aug 25, 2026
Merged

fix: Inlining of references with dot (#2109)#2384
ewaostrowska merged 1 commit into
masterfrom
issue-2109

Conversation

@ewaostrowska

@ewaostrowska ewaostrowska commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Description

InlineModelResolver.flatten() generated bare schema names (e.g. admin.user) instead of fully-qualified local references (#/components/schemas/admin.user) in every $ref it produced. For simple names this was harmless, but when a model title contained a dot the bare name admin.user was parsed as a relative file reference rather than a local component reference, breaking resolution.

The array-item case for request/response bodies was previously fixed in #2330. This PR applies the same prefix to all remaining paths.

Fix

Every call-site in InlineModelResolver that sets a $ref to an extracted schema now prepends Components.COMPONENTS_SCHEMAS_REF (#/components/schemas/) instead of a bare name.

Swagger Core's $ref setter skips the auto-prefix when the name contains a ., treating it as a potential relative file path. That's correct for resolve, where admin.user could legitimately refer to ./admin.user. In flatten, every schema being referenced has just been extracted into #/components/schemas/ by the resolver, so the target is always local.

Out of scope (known issues, not introduced by this PR)

  1. Reporter of Getting invalid reference when used with flatten = true option #2109 uses example with a space admin.user schema . The spec requires component keys to match ^[a-zA-Z0-9\.\-_]+$. A space is not in that character class, so admin.user schema is not a valid component key.

  2. InlineModelResolver.java:179-180 registers am (the array) instead of inner (the item schema). - such behavior is a non-reported bug

Fixes: #2109

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

@ewaostrowska
ewaostrowska merged commit d3398c8 into master Aug 25, 2026
7 checks passed
@ewaostrowska
ewaostrowska deleted the issue-2109 branch August 25, 2026 08:15
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.

Getting invalid reference when used with flatten = true option

2 participants