question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allow override of `host` and `basePath`

See original GitHub issue

Once swagger-client is loaded, you cannot easily override the host or basePath values as they are copied to each operation. While you can currently iterate over each api + host, it’s a pain.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
k11k2commented, Apr 21, 2017
const ui = SwaggerUIBundle({
                    url: `url1` ,
                    dom_id: '#swagger-ui-1',
                    presets: [
                  SwaggerUIBundle.presets.apis,
                  // yay ES6 modules ↘
                  Array.isArray(SwaggerUIStandalonePreset) ? SwaggerUIStandalonePreset : SwaggerUIStandalonePreset.default
                    ],
                    plugins: [
                      SwaggerUIBundle.plugins.DownloadUrl
                    ],

                    layout: "StandaloneLayout"

                })

how could i achieve this setBasePath/setHost functionality here…

3reactions
Padmahascommented, May 22, 2020

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 swagger-js instance that the UI is using, and call it from there. For example, I open http://petstore.swagger.io and enter this in the console:

window.swaggerUi.api.setBasePath('/v3');

The calls will now reflect that basePath.

Hi @fehguy , which console do you mean? Browser console? Which will show up when F12 key is pressed? I opened the URL you gave and executed the command you showed, to change the basePath, but I’m getting the below error “Uncaught TypeError: Cannot read property ‘api’ of undefined at <anonymous>:1:18 (anonymous) @ VM51:1”

I think I’m executing this in wrong console. which console do you mean?

Read more comments on GitHub >

github_iconTop Results From Across the Web

swagger - Override "host" and "basePath" at the "/{path}" level
Overriding the target server at the path or operation level is now supported in OpenAPI 3.0: openapi: 3.0.0 servers: - url: ...
Read more >
API Host and Base Path - Swagger
REST APIs have a base URL to which the endpoint paths are appended. The base URL is defined by schemes , host and...
Read more >
Running Behind a Reverse Proxy - Sonatype Help
Reverse Proxy Virtual Host at Base Path ... Scenario: You need to expose the repository manager using a custom host name of repo.example.com...
Read more >
Set the OpenAPIbasePath property - Amazon API Gateway
In OpenAPI 2.0 , you can use the basePath property to provide one or more path ... and all of the declared API...
Read more >
ASP.NET Core Web Host | Microsoft Learn
Set up a host; Host configuration values; Override configuration ... The content root is also used as the base path for the web...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found