aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
diff options
context:
space:
mode:
authorDavid <daullmer@gmail.com>2020-06-14 12:48:17 +0200
committerDavid <daullmer@gmail.com>2020-06-14 12:48:17 +0200
commit9bedd9ac3ca5b5854acd6891e746bf2e7225ff21 (patch)
tree5c30410be03df839661582cfe615538656149363 /Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
parent043d76bd6e9e4a2e1093ae0e5ba025de1438b528 (diff)
parent0011e8df47380936742302ef40639a4626a780ed (diff)
Merge remote-tracking branch 'upstream/api-migration' into api-204
Diffstat (limited to 'Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs')
-rw-r--r--Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs21
1 files changed, 20 insertions, 1 deletions
diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
index 387977ec4..9cdaa0eb1 100644
--- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
+++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
@@ -93,7 +93,7 @@ namespace Jellyfin.Server.Extensions
.AddJsonOptions(options =>
{
// Update all properties that are set in JsonDefaults
- var jsonOptions = JsonDefaults.PascalCase;
+ var jsonOptions = JsonDefaults.GetPascalCaseOptions();
// From JsonDefaults
options.JsonSerializerOptions.ReadCommentHandling = jsonOptions.ReadCommentHandling;
@@ -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(