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

HTTPS is ignored when basePath is relative (1.3.0) #337

Closed
filip26 opened this issue Oct 31, 2013 · 6 comments
Closed

HTTPS is ignored when basePath is relative (1.3.0) #337

filip26 opened this issue Oct 31, 2013 · 6 comments

Comments

@filip26
Copy link

filip26 commented Oct 31, 2013

If basePath (swagger.api.basepath) is relative (e.g. /api) and swagger-ui is served on HTTPS as well as api-docs and real api then swagger-ui always use HTTP instead of HTTPS.

Swagger-UI should handle relative basePath properly.

@fehguy
Copy link
Contributor

fehguy commented Oct 31, 2013

Hi, swagger-ui should be using the base path as provided in the api declaration. Are you seeing otherwise?

Verify your base path, similar to this:

http://petstore.swagger.wordnik.com/api/api-docs/pet

note the base path--that's what is used to make the requests.

@filip26
Copy link
Author

filip26 commented Oct 31, 2013

basePath is relative so swagger-ui should handle it as relative and use protocol and host from which is served, HTTPS in our case, but for some unknown reason swagger-ui use HTTP, always.

e.g. basePath='/api' url='/docs/api-docs' url in browser = 'https://localhost/apidocs.jsp' and swagger-ui performs call on 'http://localhost/api/...' instead of 'https://localhost/api/...'

@fehguy
Copy link
Contributor

fehguy commented Oct 31, 2013

Please post your resource listing & api declaration (take out anything sensitive) so I can see

@filip26
Copy link
Author

filip26 commented Oct 31, 2013

swagger ui declaration (published on https://localhost/api/apidocs.jsp)

      window.swaggerUi = new SwaggerUi({
            url:"/api/api-docs",
            dom_id:"swagger-ui-container",
            basePath : "/api",

resource listing (https://localhost/api/api-docs)

{"apiVersion":"1.0.0","swaggerVersion":"1.2","apis":[{"path":"/metamodel","description":"the metamodel api"}]}

metamodel listing (https://localhost/api/api-docs/metamodel)

{"apiVersion":"1.0.0","swaggerVersion":"1.2","basePath":"/api","resourcePath":"/metamodel","apis":[{"path":"/metamodel/{metamodelId}","operations":[{"method":"GET","summary":"Returns metabodel by ID","notes":"","type":"MetamodelDto","nickname":"getMetamodel","produces":["application/json"],"parameters":[
...

important is that swagger ui is published on HTTPS as well as api-docs (it works) and the api (it doesn't work because of protocol)

e.g. when I perform GET /api/metamodel/123 in swagger-ui it calls http://localhost/api/metamodel/123 instead of https://localhost/api/metamodel/123

@valdemon
Copy link
Contributor

valdemon commented Nov 4, 2013

Hi,
swagger-api/swagger-js#59 - this swagger-js pull request resolves described above issue as well.

@filip26
Copy link
Author

filip26 commented Nov 5, 2013

I can confirm that swagger-api/swagger-js#59 fixes this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants