Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't read from file issue in Swagger UI

I have incorporated swagger-ui in my application.

When I try and see the swagger-ui I get the documentation of the API nicely but after some time it shows some error icon at the button.

The Error message is like below:

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

I am not sure what is causing it. If I refresh it works and shows error after few seconds.

like image 472
Abi P Avatar asked Aug 24 '15 17:08

Abi P


1 Answers

I am guessing "http://MYIP/swagger/docs/v1" is not publicly accessible.

By default swagger ui uses an online validator: online.swagger.io. If it cannot access your swagger url then you will see that error message.

Possible solutions:

  1. Disable validation:

    config.EnableSwagger().EnableSwaggerUi(c => c.DisableValidator());

  2. Make your site publicly accessible

  3. Host the validator locally:

You can get the validator from: https://github.com/swagger-api/validator-badge#running-locally

You will also need to tell swaggerui the location of the validator

config.EnableSwagger().EnableSwaggerUi(c => c.SetValidatorUrl(<validator_url>));

like image 161
Jon R Avatar answered Oct 18 '22 22:10

Jon R