How to change default swagger.json file path? How to change default swagger.json file path? nginx nginx

How to change default swagger.json file path?


Had similar problem myself. The solution for me was to disable path rewrite in the NGINX level, so that the microservice would receive the full url:

Before:

Request: http://example.com/service_name/get_dataService sees:/get_data

After:

Request: http://example.com/service_name/get_dataService sees:/service_name/get_data

Only then you can specify basePath as "service_name" in the swagger.yaml file:

swagger: "2.0"    info:      description: "Add service"      version: "1.0.0"      title: "Add Service"    host: "abc.efg.com"    basePath: "service_name"


If file swagger.json is static in NGINX config you can make alias rule like this:

location ^~ /swagger.json {    alias /path_to/swagger.json;}