Open
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:jar: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.html
link 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
.