How would you go about changing the default port of swagger-ui dist version?
By default it listens to requests on port 8080
. I want it to listen to some other port. The use case is that we want to have a couple of dists running on our host but listening on different ports.
Is this possible or do you actually need to do some more complicated setup?
We run it via node js default package:
{
"name": "dist",
"version": "1.0.0",
"description": "",
"main": "swagger-ui-bundle.js",
"scripts": {
"start": "http-server"
},
"keywords": [],
"author": "",
"license": "ISC"
}
By default it listens to requests on port 8080 .
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.
Look for the following code: url: "http://petstore.swagger.io/v2/swagger.json", Change the url value to an online web URL to your Swagger file.
The simples solution that I know Is just to use docker and map port by -p 80:8080
:
https://hub.docker.com/r/swaggerapi/swagger-ui/
docker run -p 80:8080 -e API_URL=http://generator.swagger.io/api/swagger.json swaggerapi/swagger-ui
In case if you not use API_URL here is docker file for above docker - you cna use this information SWAGGER_JSON "/app/swagger.json"
to map path to swagger.json in your local machine (using docker --volume
parameter)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With