swagger-api / swagger-api/swagger-ui

Passed url=../swagger.json, but the href of the link in UI become ./swagger.json, the first dot gets lost

Open
#10,439 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: macOS
  • Browser: chrome
  • Version: 135.0.7049.115
  • Method of installation: dist assets
  • Swagger-UI version: 5.21.0
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Example Swagger/OpenAPI definition:

#Does not matter

Swagger-UI configuration options:

//Does not matter
Describe the bug you're encountering

Passing url=../swagger.json, but the link in UI become "ref=./swagger.json", the first dot gets lost!

To reproduce...

Steps to reproduce the behavior:

  • Just make the web server serve the ../swagger.json
  • In the Swagger UI, input ../swagger.json to the top text input field, then click the "Explore".
Expected behavior
  • The link "../swagger.json" is shown, and its href should be "../swagger.json", notes the 2 dots.
Screenshots

Image

Additional context or thoughts

Should be a bug of the sanitizeUrl function.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/core/utils/url.js at the sanitizeUrl function referenced by the issue. Reproduce the problem by entering ../swagger.json in Swagger UI's top input and selecting Explore, then verify that the displayed link and its href preserve both dots. Done means the relative URL is no longer changed to ./swagger.json.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.