Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change swagger-ui.html default path

I wanna change my swagger-ui path from localhost:8080/swagger-ui.html to localhost:8080/myapi/swagger-ui.html in springboot redirect is helpless to me

like image 513
Chen Zhang Avatar asked Jul 25 '19 02:07

Chen Zhang


People also ask

How do I change the path to swagger?

You can change default swagger-ui path programmatically using ApplicationListener<ApplicationPreparedEvent> . The idea is simple - override springdoc. swagger-ui. path=/custom/path before your Spring Boot application starts.

Where is swagger UI HTML located?

Generating HTML documentation using Swagger-ui. This will be located at localhost:8080/swagger-ui. html. Swagger will display the API endpoints which you have configured it to generate documentation for.

What is the swagger UI URL?

http://localhost:8080/your-app-root/swagger-ui/ In our case, by the way, the exact URL will be: http://localhost:8080/spring-security-rest/api/swagger-ui/


2 Answers

In the application.properties of Spring Boot

springdoc.swagger-ui.path=/swagger-ui-custom.html

in your case it will be

springdoc.swagger-ui.path=/myapi/swagger-ui.html
like image 59
Anil Dabas Avatar answered Sep 19 '22 14:09

Anil Dabas


You can modify springfox properties in application.properties

For example, to edit the base-url

springfox.documentation.swagger-ui.base-url=documentation

For e.g. setting it to /documentation will put swagger-ui at /documentation/swagger-ui/index.html

like image 26
Rishav Avatar answered Sep 20 '22 14:09

Rishav