DotnetClientGenerator 0.1.0

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

DotnetClientGenerator

A .NET tool for generating C# API clients from OpenAPI specifications.

Quick Start

Install the tool globally:

dotnet tool install --global DotnetClientGenerator

Generate a client:

dotnet-client-generator --input openapi.json --output ApiClient.cs

Features

  • ✅ OpenAPI 3.0 specification support
  • ✅ Modern C# with HttpClient and async/await
  • ✅ JSON serialization with System.Text.Json
  • ✅ Customizable class names and namespaces
  • ✅ Watch mode for automatic regeneration
  • ✅ Support for URLs and local files
  • ✅ Query parameters and path parameters
  • ✅ Request body handling

Usage Examples

Basic Generation

dotnet-client-generator -i openapi.json -o MyClient.cs

Custom Class and Namespace

dotnet-client-generator \
  --input https://petstore.swagger.io/v2/swagger.json \
  --output PetStoreClient.cs \
  --class-name PetStoreClient \
  --namespace PetStore.Api

Watch Mode

dotnet-client-generator -i openapi.json -o ApiClient.cs --watch

Generated Client Usage

// Dependency injection setup
services.AddHttpClient<ApiClient>();

// Manual setup
var httpClient = new HttpClient();
var client = new ApiClient(httpClient, "https://api.example.com");

// Use the client
var result = await client.GetUsersAsync();
await client.CreateUserAsync(userData);

Command Line Options

  • --input, -i: OpenAPI spec file path or URL (required)
  • --output, -o: Output C# file path (required)
  • --class-name, -c: Generated class name (default: "ApiClient")
  • --namespace, -n: Generated namespace (default: "GeneratedClient")
  • --watch, -w: Watch for changes and regenerate

Requirements

  • .NET 9.0 or later
  • OpenAPI 3.0 specification

More Information

For detailed documentation, examples, and contribution guidelines, visit the main repository.

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.1.0 85 6/28/2025