Skip to content

fix: resolve 3.1 refs with path template braces in the fragment (#2159) - #2412

Open
vinirib wants to merge 3 commits into
swagger-api:masterfrom
vinirib:issue-2159
Open

vinirib wants to merge 3 commits into
swagger-api:masterfrom
vinirib:issue-2159

Conversation

@vinirib

@vinirib vinirib commented Oct 29, 2026

Copy link
Copy Markdown

Description

With OpenAPI 3.1, a $ref whose JSON Pointer goes through a templated path, such as #/paths/~1v1~1test~1{tid}, failed with URISyntaxException: Illegal character in fragment. ReferenceUtils passed the whole ref to java.net.URI, and {/} are not legal in a URI fragment. The 3.0 resolver had the same problem, fixed in #1523.

ReferenceUtils now splits the ref on #: only the document part goes through URI, and the fragment is kept as raw text. JSON Pointer tokens were already URL-decoded one by one in unescapePointer.

Fixes: #2159

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

Covered cases (Issue2159Test):

  • local path item ref: #/paths/~1v1~1test~1{tid}
  • external path item ref: ./paths.yaml#/paths/~1items~1{id}
  • schema ref pointing inside a templated path

The full swagger-parser-v3 test suite passes on JDK 17 (697 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.

openapi 3.1: Illegal character in fragment when path reference contains paramneters

1 participant