Closed
Description
Describe the bug
- Swagger UI cannot load the API description after start. It only works after explicitly requesting
${apiDocs.path}/swagger-config
To Reproduce
Steps to reproduce the behavior:
- Configure springdoc as follows
apiDocs:
path: /api-docs/v3
groups:
enabled: true
group-configs:
- group: basic
paths-to-match: /v2/**,
...
-
Start the Spring Boot application
-
Open
swagger-ui/index.html?configUrl=/api-docs/v3/swagger-config
Swagger UI cannot find the API definition. The source of index.html contains:
...
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
// End Swagger UI call region
window.ui = ui;
};
</script>
-
Open
/api-docs/v3/swagger-config
-
Open
swagger-ui/index.html?configUrl=/api-docs/v3/swagger-config
again
Swagger UI can now find the API definition. The source of index.html contains:
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout" ,
"oauth2RedirectUrl" : "http://localhost:8080/swagger-ui/oauth2-redirect.html",
"urls" : [ {
"url" : "<redacted>",
"name" : "<redacted>"
} ]
});
// End Swagger UI call region
window.ui = ui;
};
</script>
- What version of spring-boot you are using? --> 2.6.1
- What modules and versions of springdoc-openapi are you using? --> 1.6.0
- What is the actual and the expected result using OpenAPI Description (yml or json)? --> Swagger UI should always work
- Provide with a sample code (HelloController) or Test that reproduces the problem --> not related to a particular controller
Expected behavior
Swagger UI should always work