Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overriding host #1045

Closed
vivilian-git opened this issue May 5, 2017 · 17 comments
Closed

overriding host #1045

vivilian-git opened this issue May 5, 2017 · 17 comments

Comments

@vivilian-git
Copy link

In the old version of UI, i can override the host using window.swaggerUi.api.setHost(url), as explained in #532.

How could achieve the same with the latest version?

@hareeqi
Copy link

hareeqi commented May 9, 2017

this worked for me but it's not official nor elegant

https://gist.github.com/hareeqi/c9496288cfccf52342930874ac9670d3

@zhimoda
Copy link

zhimoda commented May 11, 2017

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.

@webron
Copy link
Contributor

webron commented May 12, 2017

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.

@alkrauss48
Copy link

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/ ]';

@rautars
Copy link

rautars commented Jun 13, 2017

Please consider include ability to override basePath as well.

@melanke
Copy link

melanke commented Sep 18, 2017

+1

1 similar comment
@joeherwig
Copy link

+1

@shockey
Copy link
Contributor

shockey commented Nov 15, 2017

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 😄

@AdrieanKhisbe
Copy link

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)

@shockey
Copy link
Contributor

shockey commented Apr 20, 2018

@AdrieanKhisbe, we don't have a gitter (swagger-api/swagger-ui#3544!), send me an email if you need guidance!

@cancan101
Copy link

Any updates on the ability to override the Host?

@dark-reiser
Copy link

I need this feature too

@zhoumeina
Copy link

I need this feature too.

@AdrieanKhisbe
Copy link

@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

@Rmannn
Copy link

Rmannn commented May 28, 2019

2 years and still no way to override host at init ?

@niondir
Copy link

niondir commented Jul 24, 2019

I'm also looking for this. Sounds like easily solvable inside the app.

@char0n
Copy link
Member

char0n commented Apr 30, 2020

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 swagger-api/swagger-ui#5981

@char0n char0n closed this as completed Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests