https://github.com/shibayan/openapi-weaver
OpenAPI documents into strongly typed C# HTTP clients at build time with an incremental Roslyn source generator.
https://github.com/shibayan/openapi-weaver
Last synced: 3 months ago
JSON representation
OpenAPI documents into strongly typed C# HTTP clients at build time with an incremental Roslyn source generator.
- Host: GitHub
- URL: https://github.com/shibayan/openapi-weaver
- Owner: shibayan
- License: mit
- Created: 2026-03-28T09:37:42.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2026-04-12T04:52:28.000Z (3 months ago)
- Last Synced: 2026-04-12T06:23:50.804Z (3 months ago)
- Language: C#
- Homepage: https://shibayan.github.io/openapi-weaver/
- Size: 385 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README

[](https://github.com/shibayan/openapi-weaver/actions/workflows/ci.yml)
[](https://www.nuget.org/packages/OpenApiWeaver/)
[](https://www.nuget.org/packages/OpenApiWeaver)
[](https://github.com/shibayan/openapi-weaver/blob/master/LICENSE)
**OpenApiWeaver** is an incremental Roslyn source generator that turns OpenAPI 3.x documents, including OpenAPI 3.2, into strongly typed C# HTTP clients at build time. No runtime code generation, no reflection - just plain C# emitted during compilation.
## Quick Start
**1. Install the package**
```xml
```
**2. Add your OpenAPI document**
```xml
```
Use `OpenApiWeaverDocument` rather than `AdditionalFiles`; the package's MSBuild targets project these items into compiler inputs automatically.
**3. Use the generated client**
```csharp
var client = new PetstoreClient(accessToken: "your-token");
// Operations are grouped by OpenAPI tag
var pet = await client.Pets.GetAsync(petId: 1);
```
No extra dependencies are required — the package bundles the source generator and all analyzer assemblies.
## Features
- **Incremental source generation** — fast, cached rebuilds via the Roslyn incremental generator pipeline
- **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** — operations grouped by OpenAPI tags, exposed as properties on the root client
- **Typed request / response models** — sealed classes, enums, nested inline types, dictionaries, and composition-aware schema mappings from `components/schemas`
- **Multiple request body formats** — `application/json`, `application/x-www-form-urlencoded`, and `multipart/form-data`
- **Security scheme support** — OAuth2 / Bearer tokens, API keys (header, query, cookie)
- **Runtime error handling** — non-success responses throw `OpenApiException`, with typed `OpenApiException` when error schemas are available
- **OpenAPI-driven XML docs** — IntelliSense comments generated from document, tag, operation, response, and schema metadata with HTML stripped automatically
- **Build-time diagnostics** — errors and warnings reported as standard compiler diagnostics
## Requirements
- .NET SDK 8.0 or later
## Documentation
For detailed guides, configuration options, and schema type mapping, visit the **[documentation site](https://shibayan.github.io/openapi-weaver/)**.
## License
This project is licensed under the [MIT License](https://github.com/shibayan/openapi-weaver/blob/master/LICENSE).