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

Most upvoted comments

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 https://github.com/GJRTimmer thanks, I think we’ve got this covered.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/swagger-api/swagger-ui/issues/2760#issuecomment-290154752, or mute the thread https://github.com/notifications/unsubscribe-auth/AFynv9diUqvLQbxyj2vMbpqxYINFY_nLks5rqo5GgaJpZM4MkBoS .

@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, image

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?