diff --git a/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj b/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj index 78b0e0f..6d59ca3 100644 --- a/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj +++ b/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj @@ -7,7 +7,6 @@ - diff --git a/src/SimpleAuthentication.Abstractions/SimpleAuthentication.Abstractions.csproj b/src/SimpleAuthentication.Abstractions/SimpleAuthentication.Abstractions.csproj index d05f562..ba7a93f 100644 --- a/src/SimpleAuthentication.Abstractions/SimpleAuthentication.Abstractions.csproj +++ b/src/SimpleAuthentication.Abstractions/SimpleAuthentication.Abstractions.csproj @@ -36,7 +36,7 @@ - + diff --git a/src/SimpleAuthentication/OpenApi/AuthenticationDocumentTransformer.cs b/src/SimpleAuthentication/OpenApi/AuthenticationDocumentTransformer.cs index 96b8e87..c78d266 100644 --- a/src/SimpleAuthentication/OpenApi/AuthenticationDocumentTransformer.cs +++ b/src/SimpleAuthentication/OpenApi/AuthenticationDocumentTransformer.cs @@ -157,7 +157,7 @@ static void CheckAddJwtBearer(OpenApiDocument document, IConfigurationSection se return; } - AddSecurityScheme(document, settings.SchemeName, SecuritySchemeType.Http, JwtBearerDefaults.AuthenticationScheme, ParameterLocation.Header, HeaderNames.Authorization, "Insert the Bearer Token"); + AddSecurityScheme(document, settings.SchemeName, SecuritySchemeType.Http, JwtBearerDefaults.AuthenticationScheme, ParameterLocation.Header, HeaderNames.Authorization, "Insert the Bearer Token", "JWT"); AddSecurityRequirement(document, settings.SchemeName); } @@ -199,7 +199,7 @@ static void CheckAddBasicAuthentication(OpenApiDocument document, IConfiguration } } - private static void AddSecurityScheme(OpenApiDocument document, string name, SecuritySchemeType securitySchemeType, string? scheme, ParameterLocation location, string parameterName, string description) + private static void AddSecurityScheme(OpenApiDocument document, string name, SecuritySchemeType securitySchemeType, string? scheme, ParameterLocation location, string parameterName, string description, string? bearerFormat = null) { document.Components ??= new(); document.Components.SecuritySchemes ??= new Dictionary(); @@ -210,7 +210,8 @@ private static void AddSecurityScheme(OpenApiDocument document, string name, Sec Name = parameterName, Description = description, Type = securitySchemeType, - Scheme = scheme + Scheme = scheme, + BearerFormat = bearerFormat }); } diff --git a/src/SimpleAuthentication/OpenApi/DefaultResponseDocumentTransformer.cs b/src/SimpleAuthentication/OpenApi/DefaultResponseDocumentTransformer.cs index 78cb6d4..a262b45 100644 --- a/src/SimpleAuthentication/OpenApi/DefaultResponseDocumentTransformer.cs +++ b/src/SimpleAuthentication/OpenApi/DefaultResponseDocumentTransformer.cs @@ -62,7 +62,6 @@ public Task TransformAsync(OpenApiDocument document, OpenApiDocumentTransformerC #elif NET10_0_OR_GREATER -using System.Net.Mime; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.OpenApi; using Microsoft.OpenApi; @@ -74,8 +73,8 @@ internal class DefaultResponseDocumentTransformer : IOpenApiDocumentTransformer public async Task TransformAsync(OpenApiDocument document, OpenApiDocumentTransformerContext context, CancellationToken cancellationToken) { // Generate schema for error responses. - var errorSchema = await context.GetOrCreateSchemaAsync(typeof(ProblemDetails), cancellationToken: cancellationToken); - document.AddComponent(nameof(ProblemDetails), errorSchema); + var problemDetailsSchema = await context.GetOrCreateSchemaAsync(typeof(ProblemDetails), cancellationToken: cancellationToken); + document.AddComponent(nameof(ProblemDetails), problemDetailsSchema); } }