Thursday, April 19, 2018

Error on Swagger page

After publishing our API, we noticed a big red Error at the bottom of our Swagger UI page:


After clicking on it, we see the following error message:

{"schemaValidationMessages":[{"level":"error","message":"Can't read from file http://myapp/swagger/docs/v1"}]}

What’s happening here?

By default swagger uses an online validator to check your swagger file against the OpenAPI 2.0 Schema  If it cannot access your swagger url then you’ll end up with the error message above. As the API we are using is an internal one, it makes sense that we got this error.

But how can we get rid of it?

A first solution would be to just disable the validation in your SwashBuckle configuration:

If you want to keep the validation, a second solution would be to host the validator locally.

The steps to do this are explained here: In that case you need to specify the location of the validator:

No comments: