swagger-api / swagger-api/swagger-ui
Relative links in description markup broken
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A
- OS: n/a (linux)
- Browser: n/a (chrome)
- Version: n/a (87.0.4280.66)
- Method of installation: n/a (maven WebJars artifact: org.webjars:swagger-ui🫙3.35.0)
- Swagger-UI version: 3.35.0
- Swagger/OpenAPI version: OpenAPI 3.0.1
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.1
info:
title: Test API
version: 0.0.1
description: General info can be found in [readme-api.html](readme-api.html).
servers:
- url: https://prod.example.com/test/v1
description: Default Server
paths:
/status:
get:
summary: Service status
responses:
"200":
description: Service is ready
"404":
description: Service is not ready
Swagger-UI configuration options:
SwaggerUI({
/*--------------------------------------------*\
* Core
\*--------------------------------------------*/
configUrl: null,
dom_id: "#swagger-ui",
dom_node: null,
spec: {},
url: "",
urls: [{
name: "Test API",
url: "http://doc.example.com/apis/testApi/service-api.yaml"
}],
/*--------------------------------------------*\
* Plugin system
\*--------------------------------------------*/
layout: "StandaloneLayout",
plugins: [
SwaggerUIBundle.plugins.DownloadUrl,
],
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
/*--------------------------------------------*\
* Display
\*--------------------------------------------*/
deepLinking: true,
displayOperationId: false,
defaultModelsExpandDepth: 1,
defaultModelExpandDepth: 1,
defaultModelRendering: "example",
displayRequestDuration: false,
docExpansion: "none",
filter: false,
maxDisplayedTags: null,
operationsSorter: "alpha",
showExtensions: false,
showCommonExtensions: false,
tagSorter: "alpha",
/*--------------------------------------------*\
* Network
\*--------------------------------------------*/
oauth2RedirectUrl: null,
validatorUrl: null,
/*--------------------------------------------*\
* Macros
\*--------------------------------------------*/
modelPropertyMacro: null,
parameterMacro: null
})
Describe the bug you're encountering
Relative links in description fields throughout the spec are treated as relative to the URL form which the Swagger UI was loaded rather than the URL from which the spec was loaded.
Steps to reproduce the behavior
- Configure Swagger UI as described above, update the spec URL as needed.
- Load the Swagger UI and inspect the target of the
readme-api.htmllink in the API description.
Expected behavior
The link is assumed to be relative to the URL the spec (in which it is defined) was loaded from. I.e. in the case presented in the screenshots, the link target should be: http://doc.example.com/apis/testApi/readme-api.html.
Screenshots
-
The URL from which spec was loaded (and which should be used as the base URL for any relative links in the various
descriptionfields throughout the spec):

-
The URL from which the Swagger UI was loaded (and which is currently used as the base URL for the relative links in the
descriptions):

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided OpenAPI definition, Swagger UI configuration, and external spec URL, then trace how description links are rendered and how their base URL is selected. Confirm that relative links resolve against the loaded spec URL rather than the Swagger UI page URL, and verify the expected target with the reproduction case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100