RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.61k stars 1.22k forks source link

Why is NSwag starting my app? #4851

Closed aeslinger0 closed 2 months ago

aeslinger0 commented 2 months ago

I use Azure App Configuration in my application. On app startup, I print all my config variables to the output pane. When generating the client upon building the project, I see them getting printed out during the NSwag generation via the post build event.

Why does NSwag appear to start the app in order to generate the client? I set "noBuild" to "true" in nswag.json, but this had no effect. I'm using version 14.0.7

vvdb-architecture commented 2 months ago

NSwag is starting your app because it needs the openapi spec, which is dynamically generated from your controllers by NSwag from within your app. The "nobuild" option only relates to building your app, not running your app.

aeslinger0 commented 2 months ago

Got it. My biggest problem was that my deployment pipeline was failing due to a trying to connect to azure app configuration. I was able to get past my problems with my deployment pipeline by changing NSwag to only generate upon a rebuild of the project. That way, a dev can manually generate whenever they need to, and the pipeline will just ignore that step.