-
Notifications
You must be signed in to change notification settings - Fork 761
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
allow override of host
and basePath
#532
Comments
Bump - could someone explain how to use this feature to change the URL/basePath on the fly? I've tried creating a SwaggerClient and called setHost and setBasePath and the UI still uses the url/path defined in the swagger.json. |
OK @jifka it sounds like you're trying to override those in the context of the UI. If that's true, you'll need to get the window.swaggerUi.api.setBasePath('/v3'); The calls will now reflect that |
I'm actually more interested in setting the URL to execute calls against a different server, instead of the URL defined in the yaml/json definition of the API. This is supposed to be thru the 'host' but doesn't seem to work. |
Hi, I'm confused. by setting the basePath like I suggested, you can load the swagger file from one location and execute methods against a different one, just as if you had set the |
Like the OP stated, I'm also looking for a way to dynamically set the host URL without reloading the API definition yaml/jason. I now see that there's a function on swaggerUi.api.setHost() that will change the endpoint on the fly so I'll need to update the UI to allow users to select their own host. |
So my suggestion from #532 (comment) should do just that. You can let the user choose which host and trigger logic like what I mentioned. Then you can dynamically target different hosts as needed |
Hi. function addBaseUrl() {
$('#input_baseUrl').change(addBaseUrl); But it is simply not working, when I inspect the swaggerUi object, they are all with my new host, but when I try to do the call, it always calls the original host. I've trying calling swaggerUi.api.build() and the returned object also seems fine. I'm thinking this is a bug, so i'm reporting it here. I'm attaching the full index.html file, maybe it helps. |
@pcontezini can you share the link to your branch of Swagger UI? |
@dnascimento Just imported, here it is: https://github.com/asaasdev/swagger-ui |
how could i achieve this setBasePath/setHost functionality here.. |
It's not supported in the new client. Please file a new ticket. |
Addressing this issue should now be possible purely from |
Hi @fehguy , which console do you mean? Browser console? Which will show up when F12 key is pressed? I think I'm executing this in wrong console. which console do you mean? |
Once swagger-client is loaded, you cannot easily override the
host
orbasePath
values as they are copied to each operation. While you can currently iterate over each api + host, it's a pain.The text was updated successfully, but these errors were encountered: