diff --git a/samples/MinimalApis/JwtBearerSample/Program.cs b/samples/MinimalApis/JwtBearerSample/Program.cs index e66b998..1aade6a 100644 --- a/samples/MinimalApis/JwtBearerSample/Program.cs +++ b/samples/MinimalApis/JwtBearerSample/Program.cs @@ -103,8 +103,7 @@ { var newToken = await jwtBearerService.RefreshTokenAsync(token, validateLifetime, expiration); return TypedResults.Ok(new LoginResponse(newToken)); -}) -.WithOpenApi(); +}); app.MapGet("api/me", (ClaimsPrincipal user) => { diff --git a/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj b/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj index 54fc3da..9e6cfe8 100644 --- a/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj +++ b/samples/MinimalApis/Net8JwtBearerSample/Net8JwtBearerSample.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/SimpleAuthentication.Swashbuckle/SimpleAuthentication.Swashbuckle.csproj b/src/SimpleAuthentication.Swashbuckle/SimpleAuthentication.Swashbuckle.csproj index ac43c14..11d5be7 100644 --- a/src/SimpleAuthentication.Swashbuckle/SimpleAuthentication.Swashbuckle.csproj +++ b/src/SimpleAuthentication.Swashbuckle/SimpleAuthentication.Swashbuckle.csproj @@ -31,6 +31,11 @@ + + + + + True @@ -39,12 +44,4 @@ - - - - - - - - diff --git a/src/SimpleAuthentication.Swashbuckle/Swagger/AuthenticationOperationFilter.cs b/src/SimpleAuthentication.Swashbuckle/Swagger/AuthenticationOperationFilter.cs index d23df59..27739a0 100644 --- a/src/SimpleAuthentication.Swashbuckle/Swagger/AuthenticationOperationFilter.cs +++ b/src/SimpleAuthentication.Swashbuckle/Swagger/AuthenticationOperationFilter.cs @@ -22,6 +22,7 @@ public async Task ApplyAsync(OpenApiOperation operation, OperationFilterContext if ((requireAuthenticatedUser || requireAuthorization) && !allowAnonymous) { + operation.Responses ??= []; operation.Responses.TryAdd(StatusCodes.Status401Unauthorized.ToString(), OpenApiHelpers.CreateResponse(HttpStatusCode.Unauthorized.ToString())); operation.Responses.TryAdd(StatusCodes.Status403Forbidden.ToString(), OpenApiHelpers.CreateResponse(HttpStatusCode.Forbidden.ToString())); } diff --git a/src/SimpleAuthentication/SimpleAuthentication.csproj b/src/SimpleAuthentication/SimpleAuthentication.csproj index d7457d8..6e60cc4 100644 --- a/src/SimpleAuthentication/SimpleAuthentication.csproj +++ b/src/SimpleAuthentication/SimpleAuthentication.csproj @@ -38,6 +38,10 @@ + + + + True @@ -46,8 +50,4 @@ - - - -