Skip to content

Commit

Permalink
Disable UI validator badge by default
Browse files Browse the repository at this point in the history
  • Loading branch information
domaindrivendev committed Feb 24, 2018
1 parent d2be724 commit efaf85d
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ app.UseSwaggerUI(c =>
c.EnableFilter();
c.MaxDisplayedTags(5);
c.ShowExtensions();
c.ValidatorUrl(null);
c.EnableValidator();
c.SupportedSubmitMethods(SubmitMethod.Get, SubmitMethod.Head);
});
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Swashbuckle (Swagger) Command Line Tools</Description>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<VersionPrefix>2.0.0-beta1</VersionPrefix>
<VersionPrefix>2.1.0-beta1</VersionPrefix>
<OutputType>Exe</OutputType>
<AssemblyName>dotnet-swagger</AssemblyName>
<PackageId>Swashbuckle.AspNetCore.Cli</PackageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Swashbuckle.AspNetCore.ReDoc</AssemblyName>
<PackageId>Swashbuckle.AspNetCore.ReDoc</PackageId>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionPrefix>2.1.0</VersionPrefix>
<PackageTags>swagger;documentation;discovery;help;webapi;aspnet;aspnetcore;redoc</PackageTags>
<PackageProjectUrl>https://github.com/domaindrivendev/Swashbuckle.AspNetCore</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/domaindrivendev/Swashbuckle.AspNetCore/master/LICENSE</PackageLicenseUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Swashbuckle.AspNetCore.Swagger</PackageId>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionPrefix>2.1.0</VersionPrefix>
<PackageTags>swagger;documentation;discovery;help;webapi;aspnet;aspnetcore</PackageTags>
<PackageProjectUrl>https://github.com/domaindrivendev/Swashbuckle.AspNetCore</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/domaindrivendev/Swashbuckle.AspNetCore/master/LICENSE</PackageLicenseUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Swashbuckle.AspNetCore.SwaggerGen</PackageId>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionPrefix>2.1.0</VersionPrefix>
<PackageTags>swagger;documentation;discovery;help;webapi;aspnet;aspnetcore</PackageTags>
<PackageProjectUrl>https://github.com/domaindrivendev/Swashbuckle.AspNetCore</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/domaindrivendev/Swashbuckle.AspNetCore/master/LICENSE</PackageLicenseUrl>
Expand Down
3 changes: 2 additions & 1 deletion src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class SwaggerUIOptions
/// </summary>
public JObject ConfigObject { get; } = JObject.FromObject(new
{
urls = new object[] { }
urls = new object[] { },
validatorUrl = JValue.CreateNull()
});

/// <summary>
Expand Down
14 changes: 10 additions & 4 deletions src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System;
using System.Text;
using System.Linq;
using Newtonsoft.Json.Linq;
using Swashbuckle.AspNetCore.SwaggerUI;
Expand Down Expand Up @@ -158,14 +159,19 @@ public static void OAuth2RedirectUrl(this SwaggerUIOptions options, string url)
options.ConfigObject["oauth2RedirectUrl"] = url;
}

[Obsolete("The validator is disabled by default. Use EnableValidator to enable it")]
public static void ValidatorUrl(this SwaggerUIOptions options, string url)
{
options.ConfigObject["validatorUrl"] = url;
}

/// <summary>
/// By default, Swagger-UI attempts to validate specs against swagger.io's online validator.
/// You can use this parameter to set a different validator URL, for example for locally deployed validators (Validator Badge).
/// You can use this parameter to enable the swagger-ui's built-in validator (badge) functionality
/// Setting it to null will disable validation
/// </summary>
/// <param name="options"></param>
/// <param name="url"></param>
public static void ValidatorUrl(this SwaggerUIOptions options, string url)
public static void EnableValidator(this SwaggerUIOptions options, string url = "https://online.swagger.io/validator")
{
options.ConfigObject["validatorUrl"] = url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Swashbuckle.AspNetCore.SwaggerUI</PackageId>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionPrefix>2.1.0</VersionPrefix>
<PackageTags>swagger;documentation;discovery;help;webapi;aspnet;aspnetcore</PackageTags>
<PackageProjectUrl>https://github.com/domaindrivendev/Swashbuckle.AspNetCore</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/domaindrivendev/Swashbuckle.AspNetCore/master/LICENSE</PackageLicenseUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/Swashbuckle.AspNetCore/Swashbuckle.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<AssemblyName>Swashbuckle.AspNetCore</AssemblyName>
<PackageId>Swashbuckle.AspNetCore</PackageId>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionPrefix>2.1.0</VersionPrefix>
<PackageTags>swagger;documentation;discovery;help;webapi;aspnet;aspnetcore</PackageTags>
<PackageProjectUrl>https://github.com/domaindrivendev/Swashbuckle.AspNetCore</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/domaindrivendev/Swashbuckle.AspNetCore/master/LICENSE</PackageLicenseUrl>
Expand Down
2 changes: 1 addition & 1 deletion test/WebSites/CustomUIConfig/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Configure(IApplicationBuilder app)
c.ShowExtensions();
// Network
c.ValidatorUrl(null);
c.EnableValidator();
c.SupportedSubmitMethods(SubmitMethod.Get);
// Other
Expand Down

0 comments on commit efaf85d

Please sign in to comment.