diff --git a/Endpoint/Configuration/AppConfig/SwaggerConfiguration.cs b/Endpoint/Configuration/AppConfig/SwaggerConfiguration.cs index c43c730..4c2ff9f 100644 --- a/Endpoint/Configuration/AppConfig/SwaggerConfiguration.cs +++ b/Endpoint/Configuration/AppConfig/SwaggerConfiguration.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; using Mirea.Api.Endpoint.Configuration.Swagger; using Swashbuckle.AspNetCore.SwaggerGen; using System; @@ -19,6 +20,29 @@ public static class SwaggerConfiguration options.OperationFilter(); var basePath = AppDomain.CurrentDomain.BaseDirectory; + options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme + { + In = ParameterLocation.Header, + Description = "Keep the JWT token in the field (Bearer token)", + Name = "Authorization", + Type = SecuritySchemeType.ApiKey + }); + + options.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "Bearer" + } + }, + [] + } + }); + options.IncludeXmlComments(Path.Combine(basePath, "docs.xml")); options.IncludeXmlComments(Path.Combine(basePath, "ApiDtoDocs.xml")); });