domaindrivendev / Swashbuckle.AspNetCore

Swagger tools for documenting API's built on ASP.NET Core
MIT License
5.26k stars 1.31k forks source link

CLI is running all registered IHostedService #2712

Closed desjoerd closed 6 months ago

desjoerd commented 1 year ago

Currently the CLI is running all registered Hosted Services (IHostedService). I see that it's needed to start the application because otherwise the app.Use*/app.Map* configuration is not run. Because it's starting the application (with a NoopServer) it is running all registered HostedServices.

Because the CLI is almost always run in the context of a build it would be nice to not run those registered hosted services. This would also solve instances of for example HangFire or other things which start an IHostedService.

I've got a fix which I would like to discuss. It's a bit dirty but it works in my tests.

0xced commented 1 year ago

Related: dotnet-getdocument issues in .NET7 on the ASP.NET Core repository.

The workaround I describe there requires modifying the application code so your pull request is probably a much better approach!

I'm just a bit worried that this project looks currently inactive. Last commit and last comment from @domaindrivendev dates back to January, 11. In the meantime, issues and pull requests are piling on. 😕 I hope this is only temporary. 🤞

github-actions[bot] commented 7 months ago

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.

martincostello commented 7 months ago

https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/2713#issuecomment-2053583005

martincostello commented 6 months ago

Thanks for your help with this - the fix is available in Swashbuckle.AspNetCore 6.6.2.