override host
In the old version of UI, i can override the host using window.swaggerUi.api.setHost(url), as explained in https://github.com/swagger-api/swagger-js/issues/532.
How couldI achieve the same with thet latest version (3.0.8)?
It's not implemented yet. If you'd like to see it, please file a ticket in swagger-js.
You can implement a requestInterceptor. Make sure to set the contextUrl and the url.
That works for me.
window.ui.getConfigs().requestInterceptor = (e) => {
e.contextUrl = window.location.origin + "/api/v1/";
e.url = e.url.replace(/http:\/\/[^/]*\//i, e.contextUrl);
return e;
}
Might be cool to have this plumbed through as a query param in the UI that overrides the host.
Addressing this issue should now be possible purely from swagger-ui by UrlMutatorPlugin.