swagger-ui: Try it out requires host property & NoHostWarning not shown
I see that the “Try it out” button is supposed to only be shown if the Spec has host property: https://github.com/swagger-api/swagger-ui/blob/master/src/core/plugins/allow-try-it-out-if-host.js
Why is this? Previously Swagger-UI just presumed that is host is not set, the host serving documentation is used, like described in the Specification:
https://github.com/OAI/OpenAPI-Specification/blob/master//versions/2.0.md#fixed-fields
If the host is not included, the host serving the documentation is to be used (including the port).
Also, if host property is not set, NoHostWarning should be shown? I don’t see this anywhere.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 16 (8 by maintainers)
Commits related to this issue
- Fixing swagger context path change requested by Carlos. Added new validations like no git repo found. Fixed https://github.com/swagger-api/swagger-ui/issues/2760 by adding host property to swagger.yam... — committed to lahiruk/dead-code-analyzer by lahiruk 7 years ago
- New test optimizations (#3) * Add deadcode test case to subproject * Adding integration tests. * Remove unwanted unit test class * Fixing swagger context path change requested by Carlos. Add... — committed to lahiruk/dead-code-analyzer by lahiruk 7 years ago
All related issues should be fixed with the current master (and latest release). Please report otherwise.
It is fixed: now “Try it out” works when the spec doesn’t contain a host, when the spec is served from the host serving Swagger UI.
There is a remaining issue however: The curl command shows a wrong URL: without host.
Oke. I hope it is fixed soon. Don’t yet know how to fix it myself yet. Really need swagger-ui to work without a host in the spec and use the current host and scheme.
Op wo 29 mrt. 2017 19:00 schreef Ron notifications@github.com:
@GJRTimmer thanks, I think we’ve got this covered.
I have the same problem with the latest version checkout from git.
Exactly the same as above screenshot. Do you need me to post my screenshot?
also the actual call,
did a bit of debugging yesterday, looks like in https://github.com/swagger-api/swagger-js/blob/master/src/execute.js#L178 the contextUrl is “/sap/ztodo/rest/swagger.json” in this example, my guess is that swagger-ui should send the current host as part of the contextUrl?