cancel
Showing results for 
Search instead for 
Did you mean: 

Download updated Swagger JSON after setting host

New Contributor

Download updated Swagger JSON after setting host

I embedded Swagger UI in my web application. I dynamically set the "host" on Swagger JSON inside swaggerui/index.html -

swaggerUi.api.setHost(<hosturl>);


My question is how to download  Swagger JSON updated with "host" ? Is there a way I can print the swaggerUI object which contains swagger Json?

3 REPLIES 3
Community Manager

Re: Download updated Swagger JSON after setting host

Community, is there anything we can suggest?

---------
Tanya Gorbunova
SmartBear Community Manager

Join the annual community event and share your stories to win gifts
Wintertainment2019
New Contributor

Re: Download updated Swagger JSON after setting host

I want to  set "host" attribute in Swagger JSON dynamically and update Swagger JSON file.

 

Re: Download updated Swagger JSON after setting host

Hi @suhasOracle!

 

There's no way to have Swagger UI produce a JSON document based on the host information you're setting with setHost(), but you can have it dynamically change based on the URL of your swagger.json by leaving host out completely:

 

If the host is not included, the host serving the documentation is to be used (including the port)

OpenAPI 2.0 Specification