Open hahn-kev opened 7 months ago
The reason I'm doing this is to validate that we can generate a swagger doc
If it were me, I'd use an integration test to validate this.
I wonder if the endpoints are lazily initialized on first use (or after Run()
), so we can't "see" them yet.
Same problem happens to me when using <OpenApiGenerateDocumentsOnBuild>true</OpenApiGenerateDocumentsOnBuild>
in my csproj.
Turns out, I could fix the issue by upgrading Microsoft.Extensions.ApiDescription.Server
to the newest version.
Right now it seems like version 6.0.5
is referenced. Once I upgraded it to a 8.0.x
version, it worked again in my .NET 8 project.
Microsoft.Extensions.ApiDescription.Server
seems to be backwards compatible, so maybe it would be a good idea to bump the version of this reference in Swashbuckle.AspNetCore.
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.
bump
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.
Swashbuckle version 6.4 and 6.5 (didn't test others).
await app.Services.GetRequiredService<IAsyncSwaggerProvider>().GetSwaggerAsync("v1");
just beforeapp.Run()
in program.csnow the default weather api doesn't show up in swagger. Here's a full copy of the source:
it seems like there's a race condition with calling
GetSwaggerAsync
too early where the minimal apis don't show up. MVC Controllers will show up correctly. The reason I'm doing this is to validate that we can generate a swagger doc on startup when devs are working. In my case I put it in a service and called generate after a 5 second delay to work around the issue.