Swashbuckle.AspNetCore.Filters icon indicating copy to clipboard operation
Swashbuckle.AspNetCore.Filters copied to clipboard

Duplicit security content for methods in minimal api

Open scholtz opened this issue 1 year ago • 2 comments

Problem

on each access of swagger.json file new security item is inserted

on 4th access it looks like this:

"security": [
          {
            "oauth2": [ ]
          },
          {
            "oauth2": [ ]
          },
          {
            "oauth2": [ ]
          },
          {
            "oauth2": [ ]
          }
        ]

Version

Framework: net8.0 Microsoft.AspNetCore.OpenApi: 8.0.3 Swashbuckle.AspNetCore: 6.5.0 Swashbuckle.AspNetCore.Filters: 8.0.1

Example

https://github.com/scholtz/TestMinimalAPI

image

image

Why is it problem

We want to use the swagger for generated clients and in cicd pipeline on each build of the web api we want to insert into the code repo the generated swagger file which will rebuild the affected shared client. Because on each hit we get different file and will force rebuild of the project.

scholtz avatar Apr 09 '24 14:04 scholtz

I can't reproduce this, and the URL https://github.com/scholtz/TestMinimalAPI gives me a 404 - is it a private repo?

Which of my filters are you using? And how are they configured in Program.cs?

mattfrear avatar Apr 14 '24 23:04 mattfrear

@mattfrear sorry, my mistake, https://github.com/scholtz/TestMinimalAPI is public now.

thanks

scholtz avatar Apr 24 '24 07:04 scholtz

I'm not sure why yet, but this is caused by your usage of .WithOpenApi(); If you remove that it doesn't happen.

mattfrear avatar May 01 '24 01:05 mattfrear

Released https://www.nuget.org/packages/Swashbuckle.AspNetCore.Filters/8.0.2

mattfrear avatar May 01 '24 03:05 mattfrear