To use this with any API, just clone the Gist and run the following:
NGINX_API_URL=https://api.example.com API_PATH=/v0/openAPI docker-compose up
Finally browse to : http://docs.localhost:16640.
To use this with any API, just clone the Gist and run the following:
NGINX_API_URL=https://api.example.com API_PATH=/v0/openAPI docker-compose up
Finally browse to : http://docs.localhost:16640.
server { | |
listen ${NGINX_PORT} default_server; | |
server_name ${NGINX_HOST}; | |
server_name_in_redirect off; | |
location / { | |
proxy_pass ${NGINX_API_URL}; | |
proxy_hide_header Access-Control-Allow-Origin; | |
add_header 'Access-Control-Allow-Origin' 'http://docs.localhost:16640' always; | |
} | |
} |
version: "3.5" | |
networks: | |
api_docs: | |
name: 'api_docs' | |
driver: bridge | |
# Avoid colliding with the AWS VPC subnet | |
ipam: | |
driver: default | |
config: | |
- subnet: 10.6.0.0/16 | |
ip_range: 10.6.0.0/24 | |
gateway: 10.6.0.1 | |
aux_addresses: | |
swagger: 10.6.0.2 | |
api: 10.6.0.3 | |
services: | |
swagger: | |
image: swaggerapi/swagger-ui | |
networks: | |
- 'api_docs' | |
ports: | |
- "16640:8080" | |
environment: | |
- SWAGGER_JSON_URL=http://api.localhost:16641${API_PATH-/openapi.json} | |
api: | |
image: nginx | |
networks: | |
- 'api_docs' | |
volumes: | |
- ./default.conf.template:/etc/nginx/templates/default.conf.template | |
ports: | |
- "16641:80" | |
environment: | |
- NGINX_HOST=_ | |
- NGINX_PORT=80 | |
- NGINX_API_URL |
More infos: https://insertafter.com/en/blog/swagger_ui_docker_compose.html