BlazorApiGenerator 0.0.3

dotnet tool install --global BlazorApiGenerator --version 0.0.3
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local BlazorApiGenerator --version 0.0.3
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=BlazorApiGenerator&version=0.0.3
                    
nuke :add-package BlazorApiGenerator --version 0.0.3
                    

BlazorApiGenerator

A .NET global tool that generates C# source code from OpenAPI and custom SignalR schemas. Given a schema file it produces:

  • Models — plain C# classes / enums from components/schemas
  • Endpoints — typed Endpoint<TReq, TRes> or SignalR<TReq, TRes> classes, one per operation
  • Components — Blazor component hooks (UseEndpoint<> / UseSignalR<>) wired to each endpoint

Installation

# Install globally from NuGet
dotnet tool install --global BlazorApiGenerator

# Or install into a local tool manifest
dotnet tool install BlazorApiGenerator

To update an existing installation:

dotnet tool update --global BlazorApiGenerator

Usage

blazor-api-gen <schema-file> <output-dir> <namespace> <type>
Argument Description
<schema-file> Path to the OpenAPI (JSON/YAML) or SignalR schema file
<output-dir> Directory where generated files will be written
<namespace> Root C# namespace for the generated code (e.g. MyApp)
<type> http for REST endpoints, signalr for SignalR hubs

Examples

Generate REST client code from an OpenAPI file:

blazor-api-gen ./api/openapi.json ./src/Generated MyApp.Client http

Generate SignalR hub bindings:

blazor-api-gen ./api/signalr.json ./src/Generated MyApp.Client signalr

Output structure

Given namespace MyApp.Client the tool writes:

<output-dir>/
  Models/
    Product.cs
    OrderStatusEnum.cs
    GetProductParams.cs   # auto-generated params class when path/query params exist
    ...
  Endpoints/
    Products/
      GetProductEndpoint.cs
      CreateProductEndpoint.cs
      ...
  Components/
    Products/
      UseEndpointGetProduct.cs
      ...

Generated code depends on

The generated code compiles against the SpecKit runtime types that must be present in the consuming project:

  • Endpoint<TReq, TRes> — base class for HTTP endpoint wrappers
  • SignalR<TReq, TRes> — base class for SignalR hub bindings
  • UseEndpoint<TReq, TRes> / UseSignalR<TReq, TRes> — Blazor component base classes
  • EndpointHelpers — static HTTP helpers (ProcessResponse, PrepareRequest)
  • [EndpointRegistration] — attribute used for DI registration scanning

Schema format

REST (OpenAPI)

Any valid OpenAPI 3.x JSON or YAML file. The tool reads:

  • components/schemas → Models + Enums
  • paths → one Endpoint class per operation, grouped by the first tag

SignalR

Same OpenAPI envelope format. Set <type> to signalr and the tool emits SignalR<> classes instead of Endpoint<> classes. The URL is translated to a hub method name by stripping the leading / and replacing / with . (e.g. /chat/send → chat.send).


Integration in a build pipeline

You can invoke the tool as a pre-build step. Example csproj snippet:

<Target Name="GenerateBlazorApi" BeforeTargets="Build">
  <Exec Command="blazor-api-gen $(MSBuildThisFileDirectory)../api/openapi.json $(MSBuildThisFileDirectory)Generated MyApp.Client http" />
</Target>

CI / CD

See NUGET-PUBLISH.md for instructions on publishing new versions via GitHub Actions.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.0.3 163 5/28/2026
0.0.2 153 3/25/2026
0.0.1 145 3/7/2026