overriding host
In the old version of UI, i can override the host using window.swaggerUi.api.setHost(url), as explained in swagger-api/swagger-js#532.
How could achieve the same with the latest version?
this worked for me but it's not official nor elegant
https://gist.github.com/hareeqi/c9496288cfccf52342930874ac9670d3
This is actually very important for many scenarios, simplest being one spec and executing against test systems. How to achieve the same without the ability to switch? I can only think of multiple specs, one for each target system. In case only the host differs this does not make much sense. Hence, this feature should be considered important.
It is considered important, but we still have to prioritize based on our resources. As with anything else, PRs are welcome.
@zhimoda in general, if you don't specify a host at all, and load it from the environment that you want to run against, that would work as well.
Wanted to comment here with a semi-workaround. For me, I wanted to showcase a production URL in the docs, but have the "Try it out" button fire requests to a staging URL instead. I'm sure I'm not alone in this desire.
What I did was just set the host in my Swagger conf file to my staging URL so that the "Try it out" button would use that, but I just changed the .base-url DOM element to my production URL using the very-browser-supported document#querySelector method on page load. That element is the main place where the user sees the base URL:
document.querySelector('.base-url').textContent = '[ Base url: api.prod.com/ ]';
Please consider include ability to override basePath as well.
+1
+1
Folks, please note that OpenAPI 3.0 allows you to specify multiple URLs for your API, and use variables in server hostnames and paths. Support for this is in Swagger-UI :smile:
My team and I are very interested on this feature, and I consider to volonteer to implement it. Would it be possible to have some guidance? @shockey @webron :) (gitter session for instance)
@AdrieanKhisbe, we don't have a gitter (https://github.com/swagger-api/swagger-ui/issues/3544!), send me an email if you need guidance!
Any updates on the ability to override the Host?
I need this feature too
I need this feature too.
@cancan101, Sorry we went an other way at my company, so I shifted subject and did not took care of it. :/ So no updates on my side
2 years and still no way to override host at init ?
I'm also looking for this. Sounds like easily solvable inside the app.
I've explained here why there is no need for swagger-js to support these mutators.
Addressing this issue should now be possible purely from swagger-ui by UrlMutatorPlugin.
Closing in favor of https://github.com/swagger-api/swagger-ui/issues/5981