Skip to content

Commit 8a5cbcd

Browse files
authored
Merge pull request #180 from marcominerva/develop
Update JWT version, OpenAPI docs, and code style settings
2 parents ba3a390 + 883396f commit 8a5cbcd

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="[8.0.22,9.0.0)" />
1110
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.0.1" />
1211
</ItemGroup>
1312

src/SimpleAuthentication.Abstractions/SimpleAuthentication.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</ItemGroup>
3737

3838
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
39-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0" />
39+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.1" />
4040
</ItemGroup>
4141

4242
<ItemGroup>

src/SimpleAuthentication/OpenApi/AuthenticationDocumentTransformer.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void CheckAddJwtBearer(OpenApiDocument document, IConfigurationSection se
157157
return;
158158
}
159159

160-
AddSecurityScheme(document, settings.SchemeName, SecuritySchemeType.Http, JwtBearerDefaults.AuthenticationScheme, ParameterLocation.Header, HeaderNames.Authorization, "Insert the Bearer Token");
160+
AddSecurityScheme(document, settings.SchemeName, SecuritySchemeType.Http, JwtBearerDefaults.AuthenticationScheme, ParameterLocation.Header, HeaderNames.Authorization, "Insert the Bearer Token", "JWT");
161161
AddSecurityRequirement(document, settings.SchemeName);
162162
}
163163

@@ -199,7 +199,7 @@ static void CheckAddBasicAuthentication(OpenApiDocument document, IConfiguration
199199
}
200200
}
201201

202-
private static void AddSecurityScheme(OpenApiDocument document, string name, SecuritySchemeType securitySchemeType, string? scheme, ParameterLocation location, string parameterName, string description)
202+
private static void AddSecurityScheme(OpenApiDocument document, string name, SecuritySchemeType securitySchemeType, string? scheme, ParameterLocation location, string parameterName, string description, string? bearerFormat = null)
203203
{
204204
document.Components ??= new();
205205
document.Components.SecuritySchemes ??= new Dictionary<string, IOpenApiSecurityScheme>();
@@ -210,7 +210,8 @@ private static void AddSecurityScheme(OpenApiDocument document, string name, Sec
210210
Name = parameterName,
211211
Description = description,
212212
Type = securitySchemeType,
213-
Scheme = scheme
213+
Scheme = scheme,
214+
BearerFormat = bearerFormat
214215
});
215216
}
216217

src/SimpleAuthentication/OpenApi/DefaultResponseDocumentTransformer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public Task TransformAsync(OpenApiDocument document, OpenApiDocumentTransformerC
6262

6363
#elif NET10_0_OR_GREATER
6464

65-
using System.Net.Mime;
6665
using Microsoft.AspNetCore.Mvc;
6766
using Microsoft.AspNetCore.OpenApi;
6867
using Microsoft.OpenApi;
@@ -74,8 +73,8 @@ internal class DefaultResponseDocumentTransformer : IOpenApiDocumentTransformer
7473
public async Task TransformAsync(OpenApiDocument document, OpenApiDocumentTransformerContext context, CancellationToken cancellationToken)
7574
{
7675
// Generate schema for error responses.
77-
var errorSchema = await context.GetOrCreateSchemaAsync(typeof(ProblemDetails), cancellationToken: cancellationToken);
78-
document.AddComponent(nameof(ProblemDetails), errorSchema);
76+
var problemDetailsSchema = await context.GetOrCreateSchemaAsync(typeof(ProblemDetails), cancellationToken: cancellationToken);
77+
document.AddComponent(nameof(ProblemDetails), problemDetailsSchema);
7978
}
8079
}
8180

0 commit comments

Comments
 (0)