Gregory Pace
Gregory Pace

Reputation: 51

How disable the swagger validator when using Swashbuckle for a net core web api project. Swashbuckle 6.0.0

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()

Upvotes: 5

Views: 7402

Answers (5)

JWilson
JWilson

Reputation: 87

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);
    });

Upvotes: 2

Maximilian Ast
Maximilian Ast

Reputation: 3499

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();
    /* ... */
});

Upvotes: 1

arielorvits
arielorvits

Reputation: 5535

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

Upvotes: 1

Alex Pashkin
Alex Pashkin

Reputation: 301

var config = new HttpConfiguration();
config.EnableSwagger(c =>{ })
      .EnableSwaggerUi(c => { c.DisableValidator(); });   

Upvotes: 0

Benjamin Soulier
Benjamin Soulier

Reputation: 2263

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.

Upvotes: 1

Related Questions