swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.54k stars 8.96k forks source link

Setting VALIDATOR_URL=null with Docker results in broken link #5519

Open RobinsonWM opened 5 years ago

RobinsonWM commented 5 years ago

Q&A (please complete the following information)

Describe the bug you're encountering

When running the Docker container with -e VALIDATOR_URL=null, the validator badge is not disabled and instead shows up as a broken link. The documentation at https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#network says to use null to disable the validator badge. It appears that an empty string does disable the validator (i.e. -e VALIDATOR_URL=). I'm not sure which behavior was intended, but if an empty string was the intended way to disable the validator, the documentation should probably be more explicit.

To reproduce...

Steps to reproduce the behavior:

  1. Run Docker container with docker run -d -p 80:8080 -e URL=http://mySwaggerSpec -e VALIDATOR_URL=null swaggerapi/swagger-ui
  2. Browse to the local Swagger UI using something other than localhost (e.g. http://myComputerDnsName)
  3. The validator badge displays as a broken image with a broken link

Expected behavior

The validator badge should not show up at all.

webron commented 5 years ago

@RobinsonWM - Thanks for the report. You indeed discovered a bug in the docker work, as it's likely that NULL is parsed as "NULL", so we'll have to get that fixed. In the meantime, it's good to know you found a workaround.

fabieu commented 5 years ago

@RobinsonWM - Thanks for the report. You indeed discovered a bug in the docker work, as it's likely that NULL is parsed as "NULL", so we'll have to get that fixed. In the meantime, it's good to know you found a workaround.

This also affects the parameter URL=null. When you try to change the default petstore specification with URL=null instead of an actual URL or a relative file path, you get an error that "null" doesn't exist. The bug most likely effects all Docker parameters where you can put in null. I tested this in a setup without Docker and the parameter URL=null works as intended. Same versions as above.