scripts/openapi/README.md
Use NSwag (local dotnet tool) to generate typed C# clients + DTOs from the Playground API spec.
.config/dotnet-tools.json (created) with nswag.consolecore./scripts/openapi/generate-api-clients.ps1 -SpecUrl "https://localhost:7030/openapi/v1.json"
This restores the local tool, ensures the output directory exists, and runs NSwag with the spec URL you provide.
src/Playground/Playground.Blazor/ApiClient/Generated.cs (single file; multiple client types grouped by first path segment after the base path, e.g., /api/v1/identity/* -> IdentityClient).FSH.Playground.Blazor.ApiClientMultipleClientsFromPathSegments; ensure Minimal API routes keep module-specific first segments.HttpClient (via DI) with the bearer token; generated clients use injected HttpClient. Base URLs are not baked into the generated code (useBaseUrl: false), so HttpClient.BaseAddress must be set by the app (see Program.cs).Use ./scripts/openapi/check-openapi-drift.ps1 -SpecUrl "<spec-url>" to regenerate the clients and fail if ApiClient/Generated.cs changes. This is useful in PRs to ensure the spec and generated clients stay in sync even before CI enforcement.
Note: The spec endpoint must be reachable when running the generation scripts. If the API is not running locally, point
-SpecUrlto an accessible environment or start the Playground API first.