简体   繁体   中英

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":"http://json-schema.org/draft-04/schema#","pointer":"/properties/enum"},"instance":{"pointer":"/definitions/Permissions/properties/permissionType/enum"}}]}

Has anyone come across this issue? API寻呼机出错。

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...
        c.DisableValidator();
});

as per the Swashbuckle documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM