NDB.Extensions.Swagger updates
parent
e842f56caf
commit
685be06f80
|
@ -3,6 +3,7 @@
|
|||
public enum AuthorizationType
|
||||
{
|
||||
None,
|
||||
Basic
|
||||
Basic,
|
||||
InhouseIdentity
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<RepositoryUrl>https://dev.azure.com/tstanciu94/NDB</RepositoryUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
<PackageTags>NDB swagger</PackageTags>
|
||||
<Version>1.0.1</Version>
|
||||
<Version>1.0.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -51,33 +51,11 @@ namespace NDB.Extensions.Swagger
|
|||
return;
|
||||
|
||||
case AuthorizationType.Basic:
|
||||
options.AddSecurityDefinition("Basic",
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
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.SetAuthorization(authorizationType.ToString(), "Basic");
|
||||
break;
|
||||
|
||||
options.AddSecurityRequirement(new OpenApiSecurityRequirement()
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Basic"
|
||||
},
|
||||
Scheme = "Basic",
|
||||
Name = "Authorization",
|
||||
In = ParameterLocation.Header
|
||||
},
|
||||
new List<string>()
|
||||
}
|
||||
});
|
||||
case AuthorizationType.InhouseIdentity:
|
||||
options.SetAuthorization(authorizationType.ToString(), "Identity");
|
||||
break;
|
||||
|
||||
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)
|
||||
{
|
||||
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.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
|
||||
|
||||
|
|
Loading…
Reference in New Issue