Three tools generate a working C# SDK from an OpenAPI spec in 2026: NSwag, Microsoft's Kiota, and OpenAPI Generator's csharp target. Kiota is the default worth trying first for new .NET projects — it's Microsoft-maintained, its C# target is stable-maturity, and it ships modern HttpClient + System.Text.Json output by default. NSwag remains the more feature-rich, longer-standing choice if you also need to generate an OpenAPI spec from ASP.NET controllers. Sourced generates neither — pair your spec with one of the tools above, and bring Sourced in for hosted docs, llms.txt, and validation on the same spec.
NSwag — the long-standing, feature-rich toolchain
NSwag is a two-way toolchain: it can generate an OpenAPI/Swagger spec from ASP.NET Core controllers and generate a C# (or TypeScript) client from a spec. As of September 2026 it's actively maintained — 7.4k GitHub stars, over 4,300 commits on master, and ongoing CI activity.
Install the CLI via npm or as a .NET tool:
npm install nswag -g
# or
dotnet tool install --global NSwag.ConsoleCore
Generate a C# client with the openapi2csclient command:
nswag openapi2csclient /input:openapi.json \
/classname:ApiClient \
/namespace:MyApp.Client \
/output:Generated/ApiClient.cs
For repeatable builds, most teams check in an nswag.json config (generated via nswag openapi2csclient with the /output flag pointed at a .nswag file) and run nswag run nswag.json in CI instead of passing flags every time.
Kiota — Microsoft's modern default
Kiota is Microsoft's own OpenAPI-to-client generator, built on the Microsoft.OpenApi.NET library. Its supported-languages table marks C# as stable across generation, abstractions, serialization, authentication, and HTTP — the highest maturity tier Kiota offers, as of September 2026. It follows semver with minor releases on the first Tuesday of each month.
Install as a .NET global tool:
dotnet tool install --global Microsoft.OpenApi.Kiota
Or run it in Docker without installing anything:
docker run -v "${PWD}:/app/output" -v "${PWD}/openapi.yaml:/app/openapi.yaml" \
mcr.microsoft.com/openapi/kiota generate --language csharp -n MyApp.Client
Generate directly:
kiota generate --openapi ./openapi.yaml --language csharp \
--class-name ApiClient --namespace-name MyApp.Client --output ./generated
Kiota's default output uses HttpClient with .NET's Generic Host integration and System.Text.Json — no Newtonsoft dependency, which matters if your project has already moved off it.
OpenAPI Generator — the multi-language option
OpenAPI Generator's csharp generator (version 7.25.0 as of September 2026, per its docs) supports a library option with four values, per its generator reference: generichost (default — HttpClient, Generic Host, System.Text.Json), httpclient (experimental — HttpClient + Newtonsoft), unityWebRequest (experimental — Unity projects), and restsharp (RestSharp-based).
openapi-generator generate -i openapi.yaml -g csharp -o ./generated --library generichost
# npm, if you don't want a local install
npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g csharp -o ./generated --library generichost
Its default generichost library overlaps conceptually with what Kiota ships by default (HttpClient + System.Text.Json), so the practical choice between them comes down to maintainer and ecosystem, not output shape.
Comparison
| Tool | Default HTTP/JSON stack | Also generates spec-from-code | Status (Sep 2026) | Install | Best for |
|---|---|---|---|---|---|
| NSwag | HttpClient (configurable) |
Yes (ASP.NET → OpenAPI) | Active, 7.4k stars, 4,300+ commits | npm / dotnet tool | Teams needing spec generation and client generation |
| Kiota | HttpClient + System.Text.Json |
No | Active, C# marked stable | dotnet tool / Docker / binary | New .NET projects, Microsoft-maintained default |
OpenAPI Generator (csharp, generichost) |
HttpClient + System.Text.Json |
No | Active, v7.25.0 | npm / brew / Docker / jar | Org standardized on OpenAPI Generator across languages |
A minimal working sequence
Kiota, end to end:
dotnet tool install --global Microsoft.OpenApi.Kiota
kiota generate --openapi ./openapi.yaml --language csharp \
--class-name ApiClient --namespace-name MyApp.Client --output ./src/ApiClient
dotnet add package Microsoft.Kiota.Bundle
dotnet build
kiota info -l csharp prints the exact package versions the generated code expects, so you're not guessing which Microsoft.Kiota.* packages to add.
Honest scope: what Sourced does and doesn't do here
Sourced's generated SDKs focus on TypeScript and Python today — the two ecosystems where teams publish first. If C# is your target, generate it with NSwag, Kiota, or OpenAPI Generator as shown above, and bring Sourced in for the part of the workflow it does own: docs, llms.txt, and validation on the same spec.
What carries over regardless of generator choice: the same OpenAPI spec that drives your C# client also drives Sourced's hosted docs, llms.txt output, and validation — all free, all language-independent. Run the OpenAPI validator before you generate; missing operationIds or unreferenced inline schemas produce awkward method and class names in C# exactly the same way they do in every other language.
FAQ
Should I use NSwag or Kiota for a C# SDK in 2026?
Kiota if you're starting fresh and want a Microsoft-maintained tool with a stable C# target and modern HttpClient/System.Text.Json defaults. NSwag if you also need to generate an OpenAPI spec from existing ASP.NET Core controllers, or you want its broader customization surface (NSwag has been generating C# and TypeScript clients for longer and has more configuration knobs).
Does OpenAPI Generator's csharp output duplicate what Kiota does?
Functionally, the generichost library (its default) targets the same stack as Kiota's default: HttpClient and System.Text.Json. The difference is mostly maintainer and tooling ecosystem — pick OpenAPI Generator if your org already standardizes on it for Go, Java, or Ruby and wants one config format.
Is NSwag still maintained?
Yes, as of September 2026: 7.4k GitHub stars, over 4,300 commits on master, and active CI. It's maintained primarily by one lead maintainer with community contributions — worth knowing if your risk tolerance leans toward tools with a larger core team, in which case Kiota (backed by Microsoft) or OpenAPI Generator (backed by a broader open-source org) may fit better.
What does --library generichost actually change in OpenAPI Generator's C# output?
It picks the HTTP client and serializer: generichost uses HttpClient with .NET Generic Host integration and System.Text.Json; httpclient (marked experimental) uses HttpClient with Newtonsoft.Json instead. Use httpclient only if your project is still on Newtonsoft and can't move yet.
Does Sourced generate C# SDKs?
No — see "Honest scope" above for what Sourced covers instead. Pair the spec with NSwag, Kiota, or OpenAPI Generator for the C# client.
My spec has no securitySchemes defined — will the generated C# client have an auth helper?
No, for any of these three generators. Without securitySchemes in the spec, there's nothing for the generator to build an auth constructor param or header injector from, so you'll end up hand-wiring authentication after generation. Define your security scheme in the spec first — see OpenAPI best practices for SDK-friendly specs.
Get hosted docs and llms.txt from the same spec
Whichever C# tool you pick, create hosted docs from your repo or start free with a direct OpenAPI upload — unlimited previews, up to 2 hosted noindex docs review sites and one hosted MCP server, no credit card. Validate the spec first with the OpenAPI validator, and if TypeScript or Python are also on your list, see the TypeScript and Java generation guides.