Swagger installation on localhost

sudo apt update
sudo apt install -y docker.io docker-compose
docker pull docker.swagger.io/swaggerapi/swagger-ui
#Load API definition local .json file. using -v point to the location of this .json file
sudo docker run -p 85:8080 -e  SWAGGER_JSON=/spec/openapi.json -v /h
/home/kali/swagger-docs:/spec docker.swagger.io/swaggerapi/swagger-ui  
#start the swagger UI
http://127.0.0.1:85/

If you have multiple json files that you want to load inside the same Swagger instance:

  sudo docker run --rm -p 85:8080 \
  -e URLS='[
    {"url":"/spec/JSON1.json","name":"Service A"},
    {"url":"/spec/JSON2.json","name":"Service B"}
     ]' \
  -e URLS_PRIMARY_NAME="Service A" \
  -v /home/kali/FolderWhereJsonFilesAreLocated:/usr/share/nginx/html/spec:ro \
  swaggerapi/swagger-ui

# make sure to have necessary rights as ngincs runs as non root user
chmod 755 /home/kali /home/kali/FolderWhereJsonFileAreLocated
chmod 644 /home/kali/FolderWhereJsonFileAreLocated/*.json

Create a .json API definition from .yaml file with npx

Last updated