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 basePath #1095

Closed
Cheprer opened this issue Jun 26, 2017 · 2 comments
Closed

Overriding basePath #1095

Cheprer opened this issue Jun 26, 2017 · 2 comments

Comments

@Cheprer
Copy link

Cheprer commented Jun 26, 2017

Could add support for overriding of basePath in specification when loading from SwaggerUIBundle please?

This could fix the issue with multiple basePaths requested in here OAI/OpenAPI-Specification#562

At least for our case since we are using hapi views and then we can modify html context to render. So then you can use this context to modify basePath property when instantiating SwaggerUIBundle.

@Cheprer
Copy link
Author

Cheprer commented Jun 26, 2017

follow up on #1045

@char0n
Copy link
Member

char0n commented Apr 30, 2020

Hi Honza (@Cheprer) ;]

swagger-js (swagger-client) no longer needs to have mutators for host, basePath or schemes for OpenAPI 2.0.

Mutations can be achieved by current version 3.x in following way:

(async () => {
  const { spec } = await new SwaggerClient({ url: 'https://petstore.swagger.io/v2/swagger.json' });
  spec.host = 'www.google.com';

  const swaggerClient = await new SwaggerClient({ spec });
  const response = await swaggerClient.apis.pet.findPetsByStatus({ status: 'available'}); // hits the www.google.com

  console.dir(response);
})();

Newer versions of swagger-ui use swagger-js 3.x in a new way (because in API changes of swagger-js 3.x). By implementing the explicit mutators on swagger-js (setHost, setBasePath, setScheme) directly wouldn't help solving the problem in swagger-ui.

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

Closing in favor of swagger-api/swagger-ui#5981

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

3 participants