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,13 +51,26 @@ namespace NDB.Extensions.Swagger
|
|||
return;
|
||||
|
||||
case AuthorizationType.Basic:
|
||||
options.AddSecurityDefinition("Basic",
|
||||
new OpenApiSecurityScheme
|
||||
options.SetAuthorization(authorizationType.ToString(), "Basic");
|
||||
break;
|
||||
|
||||
case AuthorizationType.InhouseIdentity:
|
||||
options.SetAuthorization(authorizationType.ToString(), "Identity");
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException($"Swagger extensions: Authorization type '{authorizationType}' is not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
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 Basic scheme. Enter 'Basic' [space] and then your token in the text input below. Example: 'Basic 12345abcdef'",
|
||||
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 = "Basic",
|
||||
Scheme = schemeName,
|
||||
Type = SecuritySchemeType.ApiKey
|
||||
});
|
||||
|
||||
|
@ -69,20 +82,15 @@ namespace NDB.Extensions.Swagger
|
|||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Basic"
|
||||
Id = schemeName
|
||||
},
|
||||
Scheme = "Basic",
|
||||
Scheme = schemeName,
|
||||
Name = "Authorization",
|
||||
In = ParameterLocation.Header
|
||||
},
|
||||
new List<string>()
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException($"Swagger extensions: Authorization type '{authorizationType}' is not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
public static IApplicationBuilder ConfigureSwagger(this IApplicationBuilder applicationBuilder, string endpointName)
|
||||
|
|
|
@ -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