Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Springdoc Swagger UI not using swagger-config

need some help with springdoc-openapi-ui!

I am using springdoc-openapi-ui to render my API schema. This is the version details of it.

enter image description here

Now, i have done some configuration in my spring boot application like below enter image description here

Now, i was expecting that when i hit localhost:15041/swagger-ui.html, it should take me to http://localhost:15041/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config by default this and render my API document but unfortunately it only renders the Petstore. Even if i directly go to http://localhost:15041/swagger-ui.html?configUrl=/v3/api-docs/swagger-config, it doesn't render using the swagger-config. enter image description here

Although if i go to localhost:15041/v3/api-docs i get my json API documentation and localhost:15041/v3/api-docs/swagger-config, i get the swagger-config. Also, if i enter /v3/api-docs in the Explore search area of the petstore page, it shows my API documentation.

I have spent more than 1.5 days to fix it but it just doesn't work. Really appreciate if someone can help.

like image 453
Arpit Agrawal Avatar asked May 22 '26 07:05

Arpit Agrawal


1 Answers

Found the issue. The problem is with how the springdoc library uses the swagger-ui. They have written some custom code to patch the index.html file returned by swagger-ui jar on the fly to inject the configUrl query param in the response.

Now when swagger-ui moved from 4.8.1 to 4.9.0, they changed the index.html file format which broke the custom code written in springdoc.

To fix the issue, currently we need to downgrade the org.webjars:swagger-ui to 4.8.1 where index.html file is as per expectation of springdoc which will then honour the configUrl sent in the query params.

like image 111
Arpit Agrawal Avatar answered May 27 '26 08:05

Arpit Agrawal