From 436e18421bc43214b605d404aab54528209efccc Mon Sep 17 00:00:00 2001 From: Edwin van den Houdt Date: Thu, 27 Aug 2026 14:21:34 +0200 Subject: [PATCH] fix(tooling): keep gen:api working under RB-09's Development-only stub RB-09 registers StubIdentityProvider only under IsDevelopment() and throws for Production. `dotnet swagger tofile` (npm run gen:api) loads the same Program.cs through .NET's design-time HostFactoryResolver, which executes the app's startup code (including the unconditional app.Services.GetRequiredService() the identity middleware already relied on) without ever setting ASPNETCORE_ENVIRONMENT - so it now defaults to Production and crashes (dotnet swagger tofile exited 134), breaking `npm run gen:api` entirely, including the "api-client drift" job in .github/workflows/ci.yml (a separate `- run:` step there, so this would fail real CI even though ci-local.sh's `cmd1 && cmd2` step shape happens to swallow a cmd1 failure under `set -e` and reports "passed" - a separate, pre-existing script fragility, not touched here). Real usage is unaffected: dotnet run already sets ASPNETCORE_ENVIRONMENT=Development via launchSettings.json, and docker-compose.yml/docker-compose.prod.yml already set Development/Production explicitly - gen:api's bare CLI invocation was the one place with no environment variable at all. Set it to Development inline, the same value launchSettings.json already uses for the real app. Co-Authored-By: Claude Opus 5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 41c60b2..3265575 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "format": "prettier --write .", "start": "ng serve ssp", "start:behandelportal": "ng serve behandelportal", - "gen:api": "cd backend && dotnet tool restore && dotnet build src/BigRegister.Api -v q && dotnet swagger tofile --output swagger.json src/BigRegister.Api/bin/Debug/net10.0/BigRegister.Api.dll v1 && cd .. && nswag run nswag.json", + "gen:api": "cd backend && dotnet tool restore && dotnet build src/BigRegister.Api -v q && ASPNETCORE_ENVIRONMENT=Development dotnet swagger tofile --output swagger.json src/BigRegister.Api/bin/Debug/net10.0/BigRegister.Api.dll v1 && cd .. && nswag run nswag.json", "build": "ng build ssp && ng build behandelportal", "watch": "ng build ssp --watch --configuration development", "test": "ng test ssp && ng test behandelportal && ng test shared && ng test beheer",