Disable the validation badge for those who do not want it #5994
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running swaggerui on Docker with a hostname, which is not
localhost, one gets a badge that says that the validation URI cannot be
accessed. Which is correct, because the URI is most likely to be on the
localhost. The check is done when the instance itself runs on 127.0.0.1
or localhost, but it ignores the VALIDATION_URI settings. The
documentation tells us when the VALIDATION_URI is set to
null
thevalidation isn't done. This isn't true, the code in
src/core/components/online-validator-badge.jsx
sets a defaultvalidatorUrl
when this is undefined.This changeset changes this, to not display the validation badge if the
validation URI is 127.0.0.1, localhost, none or empty.
There could also be another option, which would be to introduce a new
configuration parameter:
validationEnabled
, which would tell is thatwe need validation. This would eliminate the need to check if the host
is on localhost and would allow even more fine-grained control over when
and where the validation can be done. I've chosen not to go that route
because I'm unfamiliar with the code base and this seemed to be the
smallest change to accomplish my needs for a developing OpenAPI specs
with Docker without seeing a validation error badge.
Signed-off-by: Wesley Schwengle [email protected]
How Has This Been Tested?
I've tested this with Docker-compose and setting the environment var
VALIDATOR_URL=none
.Before my changes it looked like this (I have a crappy internet connection atm, so the badge isn't shown correctly, but you get the gist:

After my changes:

Checklist
My PR contains...
src/
is unmodified: changes to documentation, CI, metadata, etc.)package.json
)My changes...
Documentation
Automated tests