-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix security scheme issues in Delivery API OpenAPI spec (#17401)
- Loading branch information
Showing
3 changed files
with
55 additions
and
20 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/Umbraco.Cms.Api.Common/OpenApi/RemoveSecuritySchemesDocumentFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.OpenApi.Models; | ||
using Swashbuckle.AspNetCore.SwaggerGen; | ||
|
||
namespace Umbraco.Cms.Api.Common.OpenApi; | ||
|
||
/// <summary> | ||
/// This filter explicitly removes all security schemes from a named OpenAPI document. | ||
/// </summary> | ||
public class RemoveSecuritySchemesDocumentFilter : IDocumentFilter | ||
{ | ||
private readonly string _documentName; | ||
|
||
public RemoveSecuritySchemesDocumentFilter(string documentName) | ||
=> _documentName = documentName; | ||
|
||
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) | ||
{ | ||
if (context.DocumentName != _documentName) | ||
{ | ||
return; | ||
} | ||
|
||
swaggerDoc.Components.SecuritySchemes.Clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters