Merge pull request #3220 from crobibero/api-swagger-auth
Add Authentication to openapi generation.
This commit is contained in:
commit
d975ad155e
|
@ -120,6 +120,25 @@ namespace Jellyfin.Server.Extensions
|
|||
return serviceCollection.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("api-docs", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" });
|
||||
c.AddSecurityDefinition(AuthenticationSchemes.CustomAuthentication, new OpenApiSecurityScheme
|
||||
{
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
In = ParameterLocation.Header,
|
||||
Name = "X-Emby-Token",
|
||||
Description = "API key header parameter"
|
||||
});
|
||||
|
||||
var securitySchemeRef = new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = AuthenticationSchemes.CustomAuthentication },
|
||||
};
|
||||
|
||||
// TODO: Apply this with an operation filter instead of globally
|
||||
// https://github.com/domaindrivendev/Swashbuckle.AspNetCore#add-security-definitions-and-requirements
|
||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{ securitySchemeRef, Array.Empty<string>() }
|
||||
});
|
||||
|
||||
// Add all xml doc files to swagger generator.
|
||||
var xmlFiles = Directory.GetFiles(
|
||||
|
|
Loading…
Reference in New Issue
Block a user