swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

override host

Open vivilian-git opened this issue 9 years ago • 4 comments

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)?

vivilian-git avatar May 05 '17 20:05 vivilian-git

It's not implemented yet. If you'd like to see it, please file a ticket in swagger-js.

webron avatar May 05 '17 21:05 webron

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;
}

dgrahn avatar May 15 '18 19:05 dgrahn

Might be cool to have this plumbed through as a query param in the UI that overrides the host.

cancan101 avatar Jul 25 '18 15:07 cancan101

Addressing this issue should now be possible purely from swagger-ui by UrlMutatorPlugin.

char0n avatar Apr 30 '20 13:04 char0n