OpenApiWeaver 1.3.2

dotnet add package OpenApiWeaver --version 1.3.2
                    
NuGet\Install-Package OpenApiWeaver -Version 1.3.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenApiWeaver" Version="1.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenApiWeaver" Version="1.3.2" />
                    
Directory.Packages.props
<PackageReference Include="OpenApiWeaver" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenApiWeaver --version 1.3.2
                    
#r "nuget: OpenApiWeaver, 1.3.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenApiWeaver@1.3.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenApiWeaver&version=1.3.2
                    
Install as a Cake Addin
#tool nuget:?package=OpenApiWeaver&version=1.3.2
                    
Install as a Cake Tool

OpenApiWeaver logo

CI Downloads NuGet License

OpenApiWeaver is an incremental Roslyn source generator that generates strongly typed C# HTTP clients from OpenAPI 3.x documents, including OpenAPI 3.2, at build time. It does not rely on runtime code generation or reflection, and emits plain C# during compilation.

Quick Start

1. Install the package

<ItemGroup>
  <PackageReference Include="OpenApiWeaver" Version="x.y.z" PrivateAssets="all" />
</ItemGroup>

2. Add your OpenAPI document

<ItemGroup>
  <OpenApiWeaverDocument Include="openapi\petstore.yaml"
                         ClientName="PetstoreClient"
                         Namespace="Contoso.Generated" />
</ItemGroup>

Declare the document as an OpenApiWeaverDocument item rather than AdditionalFiles. The package's MSBuild targets project these items into compiler inputs automatically.

3. Use the generated client

var client = new PetstoreClient(accessToken: "your-token");

// Operations are grouped by OpenAPI tag
var pet = await client.Pets.GetAsync(petId: 1);

You can also pass an existing HttpClient to the generated root client. When you do, the generated client reuses that instance, preserves an existing BaseAddress, and applies security headers per request instead of mutating DefaultRequestHeaders.

The package includes the source generator and all required analyzer assemblies, so no additional dependencies are required.

Features

  • Incremental source generation — uses the Roslyn incremental generator pipeline to keep rebuilds efficient
  • OpenAPI 3.0-3.2 support — reads .json, .yaml, and .yml documents, including OpenAPI 3.2 features such as response summaries and nullable type arrays
  • Tag-based sub-clients — groups operations by OpenAPI tags and exposes them as properties on the root client
  • Typed request / response models — generates classes, enums, nested inline types, dictionaries, and composition-aware schema mappings from components/schemas, including discriminator-based polymorphic models
  • Multiple request body formats — supports application/json, application/x-www-form-urlencoded, and multipart/form-data
  • Security scheme support — supports OAuth2 and bearer tokens, together with API keys in headers, query strings, and cookies
  • Runtime error handling — throws OpenApiException, with typed OpenApiException<TError> when error schemas are available
  • OpenAPI-driven XML docs — generates IntelliSense comments from document, tag, operation, response, and schema metadata, with HTML removed automatically
  • Build-time diagnostics — reports errors and warnings as standard compiler diagnostics

Requirements

  • .NET SDK 10.0 or later

Documentation

For detailed guides, configuration options, and schema type mapping, see the documentation site.

License

This project is licensed under the MIT License.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.2 93 5/3/2026
1.3.1 103 4/20/2026
1.3.0 100 4/18/2026
1.2.0 99 4/15/2026
1.1.1 92 4/12/2026
1.0.0 108 4/1/2026