TheAkhemist TheAkhemist - 3 years ago 109
ASP.NET (C#) Question

Swagger showing error section on API UI Screen

I have an error on the Swagger API documentation/List page. All the calls work properly its just that the image detailing error is not a comfortable look. When I drill into the error I receive the following json response:

{"schemaValidationMessages":[{"level":"error","domain":"validation","keyword":"minItems","message":"array is too short: must have at least 1 elements but instance has 0 elements","schema":{"loadingURI":"","pointer":"/properties/enum"},"instance":{"pointer":"/definitions/Permissions/properties/permissionType/enum"}}]}

Has anyone come across this issue?
Error on API pager.

Answer Source

Swagger will always validate your schema against their online validator. In your case it has failed validation because of the permissionType enum having no elements, as per the JSON returned. If you really want to and fixing the issue is not viable then you can turn the validation off using Swagger's validatorUrl parameter - see this link. If you wish to do this via Swashbuckle you could use:

.EnableSwaggerUi(c =>
        // Your other config...

as per the Swashbuckle documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download