MagnusOpera.OpenApiGen 0.46.0

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

Usage

Run the tool with:

openapigen --transport <axios|fetch> <openapi-file> <output-dir>
  • --transport <axios|fetch>: Mandatory transport to generate
  • <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} using the Axios transport:

// === 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 patchUserId(axios: AxiosInstance, bearer: string, id: string, request: UserIdPatchRequest): Promise<[200, UserIdPatch200Response] | [400, UserIdPatch400Response] | [404, UserIdPatch404Response]> {
    const __queryString__ = "";
    const __headers__: Record<string, string> = {};
    __headers__.Authorization = `Bearer ${bearer}`;
    __headers__["Content-Type"] = "application/json";
    const __response__ = await axios.request({
        method: "PATCH",
        url: `/User/${id}${__queryString__}`,
        data: JSON.stringify(request),
        headers: __headers__,
        validateStatus: () => true,
    });
    switch (__response__.status) {
        case 200: return [200, __response__.data as UserIdPatch200Response]
        case 400: return [400, __response__.data as UserIdPatch400Response]
        case 404: return [404, __response__.data as UserIdPatch404Response]
        default: throw Error(`Unexpected status ${__response__.status}`)
    }
}

Features

  • Generates TypeScript clients from OpenAPI definitions
  • Supports Axios and fetch transports
  • 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.46.0 475 4/8/2026
0.45.0 126 4/1/2026
0.44.0 109 4/1/2026
0.43.0 1,659 11/22/2025
0.42.0 363 11/12/2025
0.41.0 289 11/12/2025
0.40.0 293 11/12/2025
0.39.0 292 11/12/2025
0.38.0 441 11/11/2025
0.37.0 288 11/11/2025
0.36.0 459 11/10/2025
0.35.0 206 11/3/2025
0.34.0 323 10/27/2025
0.33.2 133 10/18/2025
0.33.1 144 10/18/2025 0.33.1 is deprecated because it has critical bugs.
0.33.0 570 9/23/2025
0.32.0 244 9/13/2025
0.31.0 124 9/13/2025
0.30.0 202 9/7/2025
0.29.0 290 9/7/2025
Loading failed