Forum Discussion

suhasOracle's avatar
suhasOracle
New Contributor
6 years ago

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?

  • suhasOracle's avatar
    suhasOracle
    New Contributor

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

     

    • kyleshockey's avatar
      kyleshockey
      SmartBear Alumni (Retired)

      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