问题
How can I disable the Swagger Schema validator in options for Swashbuckle 6.0.0. I know it's turned off by default when I run locally but don't see validatorURL option for SwaggerUI()
回答1:
Seems that there is an option on Swagger 6.0.0 to manage Validator.
Didn't try myself, but seems to be pretty explicit on what it does.
回答2:
from the github repository:
This level of configuration will be available in the upcoming, stable 6.0.0 release as can be seen in the example website for custom UI config:
https://github.com/domaindrivendev/Ahoy/blob/master/test/WebSites/CustomUiConfig/Startup.cs#L30
If you can't wait until then, it's also available with the preview packages now available on MyGet
回答3:
Swashbuckle 6.0.0
got renamed to Swashbuckle.AspNetCore 1.0.0
. See here...
They also switched from DisableValidator
(.NET Framework) to EnableValidator
(.NET Core) as you can see in the docu. So it seems like the Validator is disabled by default in Swashbuckle.AspNetCore 1.0.0
.
app.UseSwaggerUI(c =>
{
c.EnabledValidator();
/* ... */
});
回答4:
var config = new HttpConfiguration();
config.EnableSwagger(c =>{ })
.EnableSwaggerUi(c => { c.DisableValidator(); });
回答5:
In Swashbuckle.AspNetCore 2.0.0, you disable validation in the Startup.Configure() method by setting the ValidatorUrl to null:
app.UseSwaggerUI(c =>
{
c.ValidatorUrl(null);
});
来源:https://stackoverflow.com/questions/39923109/how-disable-the-swagger-validator-when-using-swashbuckle-for-a-net-core-web-api