Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default port for swagger-ui dist bundle

Tags:

swagger-ui

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"
}
like image 276
Souciance Eqdam Rashti Avatar asked Jan 09 '18 10:01

Souciance Eqdam Rashti


People also ask

What is the default port for Swagger?

By default it listens to requests on port 8080 .

How do I change my Swagger UI?

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.

How do I access Swagger UI URL?

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.


1 Answers

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)

like image 67
Kamil Kiełczewski Avatar answered Sep 21 '22 22:09

Kamil Kiełczewski