From 091464a39037251d94e3767b2cd0ca004c7c526c Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Fri, 15 Apr 2022 14:45:04 +0500 Subject: [PATCH] Set PersistAuthorization to swagger-ui --- AsbCloudWebApi/DependencyInjection.cs | 29 +++++++++++++-------------- AsbCloudWebApi/Startup.cs | 1 + 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/AsbCloudWebApi/DependencyInjection.cs b/AsbCloudWebApi/DependencyInjection.cs index bc818660..c6442461 100644 --- a/AsbCloudWebApi/DependencyInjection.cs +++ b/AsbCloudWebApi/DependencyInjection.cs @@ -29,27 +29,26 @@ namespace AsbCloudWebApi Name = "Authorization", In = ParameterLocation.Header, Type = SecuritySchemeType.ApiKey, - Scheme = "Bearer" + Scheme = "Bearer", }); c.AddSecurityRequirement(new OpenApiSecurityRequirement() - { + { { - new OpenApiSecurityScheme - { - Reference = new OpenApiReference - { - Type = ReferenceType.SecurityScheme, - Id = "Bearer" - }, - Scheme = "oauth2", - Name = "Bearer", - In = ParameterLocation.Header, - + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "Bearer" + }, + Scheme = "oauth2", + Name = "Bearer", + In = ParameterLocation.Header, }, new List() - } - }); + } + }); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); diff --git a/AsbCloudWebApi/Startup.cs b/AsbCloudWebApi/Startup.cs index a2fe8159..8fea2b10 100644 --- a/AsbCloudWebApi/Startup.cs +++ b/AsbCloudWebApi/Startup.cs @@ -71,6 +71,7 @@ namespace AsbCloudWebApi app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1"); + c.EnablePersistAuthorization(); }); if (env.IsDevelopment())