NDB.Extensions.Swagger updates
parent
e842f56caf
commit
685be06f80
|
@ -3,6 +3,7 @@
|
||||||
public enum AuthorizationType
|
public enum AuthorizationType
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Basic
|
Basic,
|
||||||
|
InhouseIdentity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<RepositoryUrl>https://dev.azure.com/tstanciu94/NDB</RepositoryUrl>
|
<RepositoryUrl>https://dev.azure.com/tstanciu94/NDB</RepositoryUrl>
|
||||||
<RepositoryType>Git</RepositoryType>
|
<RepositoryType>Git</RepositoryType>
|
||||||
<PackageTags>NDB swagger</PackageTags>
|
<PackageTags>NDB swagger</PackageTags>
|
||||||
<Version>1.0.1</Version>
|
<Version>1.0.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -51,33 +51,11 @@ namespace NDB.Extensions.Swagger
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case AuthorizationType.Basic:
|
case AuthorizationType.Basic:
|
||||||
options.AddSecurityDefinition("Basic",
|
options.SetAuthorization(authorizationType.ToString(), "Basic");
|
||||||
new OpenApiSecurityScheme
|
break;
|
||||||
{
|
|
||||||
In = ParameterLocation.Header,
|
|
||||||
Description = @"JWT Authorization header using the Basic scheme. Enter 'Basic' [space] and then your token in the text input below. Example: 'Basic 12345abcdef'",
|
|
||||||
Name = "Authorization",
|
|
||||||
Scheme = "Basic",
|
|
||||||
Type = SecuritySchemeType.ApiKey
|
|
||||||
});
|
|
||||||
|
|
||||||
options.AddSecurityRequirement(new OpenApiSecurityRequirement()
|
case AuthorizationType.InhouseIdentity:
|
||||||
{
|
options.SetAuthorization(authorizationType.ToString(), "Identity");
|
||||||
{
|
|
||||||
new OpenApiSecurityScheme
|
|
||||||
{
|
|
||||||
Reference = new OpenApiReference
|
|
||||||
{
|
|
||||||
Type = ReferenceType.SecurityScheme,
|
|
||||||
Id = "Basic"
|
|
||||||
},
|
|
||||||
Scheme = "Basic",
|
|
||||||
Name = "Authorization",
|
|
||||||
In = ParameterLocation.Header
|
|
||||||
},
|
|
||||||
new List<string>()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -85,6 +63,36 @@ namespace NDB.Extensions.Swagger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void SetAuthorization(this SwaggerGenOptions options, string schemeName, string schemeKey)
|
||||||
|
{
|
||||||
|
options.AddSecurityDefinition(schemeName, new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
In = ParameterLocation.Header,
|
||||||
|
Description = $@"JWT Authorization header using the {schemeName} scheme. Enter '{schemeKey}' [space] and then your token in the text input below. Example: '{schemeKey} 12345abcdef'",
|
||||||
|
Name = "Authorization",
|
||||||
|
Scheme = schemeName,
|
||||||
|
Type = SecuritySchemeType.ApiKey
|
||||||
|
});
|
||||||
|
|
||||||
|
options.AddSecurityRequirement(new OpenApiSecurityRequirement()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Reference = new OpenApiReference
|
||||||
|
{
|
||||||
|
Type = ReferenceType.SecurityScheme,
|
||||||
|
Id = schemeName
|
||||||
|
},
|
||||||
|
Scheme = schemeName,
|
||||||
|
Name = "Authorization",
|
||||||
|
In = ParameterLocation.Header
|
||||||
|
},
|
||||||
|
new List<string>()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static IApplicationBuilder ConfigureSwagger(this IApplicationBuilder applicationBuilder, string endpointName)
|
public static IApplicationBuilder ConfigureSwagger(this IApplicationBuilder applicationBuilder, string endpointName)
|
||||||
{
|
{
|
||||||
applicationBuilder.UseSwagger(c =>
|
applicationBuilder.UseSwagger(c =>
|
||||||
|
|
|
@ -18,7 +18,7 @@ Push packages:
|
||||||
|
|
||||||
dotnet nuget push NDB.Application.DataContracts.1.0.0.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
dotnet nuget push NDB.Application.DataContracts.1.0.0.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
||||||
|
|
||||||
dotnet nuget push NDB.Extensions.Swagger.1.0.1.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
dotnet nuget push NDB.Extensions.Swagger.1.0.2.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
||||||
|
|
||||||
dotnet nuget push NDB.Extensions.Http.1.0.0.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
dotnet nuget push NDB.Extensions.Http.1.0.0.nupkg -k ***REMOVED*** -s http://stawebsrv:8081/NuGetServer/nuget
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue