UDIT SONI
UDIT SONI

Reputation: 81

Getting Error button on swagger UI that is schemaValidationMessages

When I am using localhost in SwaggerUIBundle URL it works fine and does not show error button

SwaggerUIBundle({ url: "http://localhost:9001/api/docs/data" });

but when I use IP address instead of localhost, error button appear on the page and clicking on error button getting this message.

{"schemaValidationMessages":[ { "level":"error", "message":"Can't read from file http://10.100.160.420:9001/api/docs/swagger.json" } ]}

I don't want to use validatorUrl: null, Please don't answer to use this validatorUrl: null. I just want to know why it is not working with IP address but working with localhost ?

Upvotes: 2

Views: 1834

Answers (1)

Helen
Helen

Reputation: 97609

I don't want to use validatorUrl: null, Please don't answer to use this validatorUrl: null. I just want to know why it is not working with IP address but working with localhost ?

Swagger UI does not display the validator badge in the following cases:

  • validatorUrl: null configuration option is specified
  • URL of the API definition (YAML/JSON file) contains localhost or 127.0.0.1

Source: https://github.com/swagger-api/swagger-ui/blob/master/src/core/components/online-validator-badge.jsx#L40

That's why the validator badge does not appear if you use http://localhost/... but appears if you use http://10.100.160.420:9001/....

Upvotes: 4

Related Questions