MagnusOpera.OpenApiGen 0.43.0

Prefix Reserved
dotnet tool install --global MagnusOpera.OpenApiGen --version 0.43.0
                    
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 MagnusOpera.OpenApiGen --version 0.43.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=MagnusOpera.OpenApiGen&version=0.43.0
                    
nuke :add-package MagnusOpera.OpenApiGen --version 0.43.0
                    

OpenApiGen

OpenApiGen is a .NET tool that generates simple, type-safe TypeScript clients from OpenAPI definitions. The generated clients are designed for easy integration with Axios and React Query.

Usage

Run the tool with:

openapigen <configuration-file> <openapi-file> <output-dir>
  • <configuration-file>: Path to the configuration JSON file
  • <openapi-file>: Path to the OpenAPI definition JSON file
  • <output-dir>: Output directory for the generated TypeScript client (will be purged)

For help:

openapigen --help

Note on Any Types

This tool implements a workaround for a bug in Microsoft.Extensions.ApiDescription.Server 9.0.8, where nullable types are incorrectly emitted as type "any" in the OpenAPI definition. The generator heuristically locates an equivalent non-nullable schema and applies the intended nullability. This assumes the base, non-nullable schema is emitted correctly.

Example Output

Sample TypeScript code generated for a PATCH operation on /User/{id}:

// === patch /User/{id} ===
export type UserIdPatchRequest = {
    firstName: null | string
    lastName: null | string
}
export type UserIdPatch200Response = {
    firstName: string
    lastName: string
}
export type UserIdPatch400Response = ProblemDetails
export type UserIdPatch404Response = ProblemDetails
export async function patchUserIdAsync(axios: AxiosInstance, bearer: string, id: string, request: UserIdPatchRequest): Promise<[200, UserIdPatch200Response] | [400, UserIdPatch400Response] | [404, UserIdPatch404Response]> {
    const resp = await axios.patch(`/User/${id}`, request, { validateStatus: () => true, headers: { Authorization: `Bearer ${bearer}` } })
    switch (resp.status) {
        case 200: return [200, resp.data as UserIdPatch200Response]
        case 400: return [400, resp.data as UserIdPatch400Response]
        case 404: return [404, resp.data as UserIdPatch404Response]
        default: throw `Unexpected status ${resp.status}`
    }
}

Features

  • Generates TypeScript clients from OpenAPI definitions
  • Designed for easy integration with Axios and React Query
  • Inlines types for clarity and simplicity
  • Support for Bearer token (authorization header) and ApiKey (cookie)
  • Minimal dependencies, no runtime bloat

Note on Nullable Types

This tool implements a workaround for a bug in Microsoft.Extensions.ApiDescription.Server 9.0.8, where nullable types are incorrectly emitted as type "any" in the OpenAPI definition. The generator heuristically locates an equivalent non-nullable schema (with the same required members) and applies the intended nullability. This assumes the base, non-nullable schema is emitted correctly.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.43.0 967 11/22/2025
0.42.0 349 11/12/2025
0.41.0 275 11/12/2025
0.40.0 278 11/12/2025
0.39.0 277 11/12/2025
0.38.0 342 11/11/2025
0.37.0 271 11/11/2025
0.36.0 443 11/10/2025
0.35.0 190 11/3/2025
0.34.0 306 10/27/2025
0.33.2 116 10/18/2025
0.33.1 126 10/18/2025 0.33.1 is deprecated because it has critical bugs.
0.33.0 556 9/23/2025
0.32.0 231 9/13/2025
0.31.0 112 9/13/2025
0.30.0 189 9/7/2025
0.29.0 276 9/7/2025
0.28.0 172 9/5/2025
0.27.0 314 8/26/2025
0.26.0 214 8/26/2025
0.25.0 204 8/25/2025
0.24.0 184 8/25/2025
0.23.0 155 8/25/2025
0.22.0 237 8/21/2025
0.21.0 164 8/21/2025
0.20.0 159 8/21/2025
0.18.0 163 8/21/2025
0.17.0 163 8/21/2025
0.16.0 100 8/15/2025
0.15.0 111 8/15/2025
0.14.0 176 8/15/2025
0.13.0 150 8/15/2025
0.12.0 168 8/14/2025
0.11.0 170 8/14/2025
0.10.0 177 8/14/2025
0.9.0 216 8/13/2025
0.8.0 199 8/11/2025
0.7.1 163 8/11/2025
0.7.0 177 8/10/2025
0.6.0 167 8/10/2025
0.5.0 158 8/9/2025
0.4.0 160 8/9/2025
0.3.0 166 8/9/2025
0.2.0 144 8/9/2025
0.1.0 143 8/9/2025
0.0.6 275 8/7/2025
0.0.5 243 8/7/2025
0.0.4 246 8/7/2025
0.0.3 245 8/7/2025
0.0.2 243 8/7/2025
0.0.1 250 8/7/2025