Matchup
NSwag vs OpenAPI Generator
The usual choice for .NET teams generating clients from an OpenAPI description. NSwag is built for .NET: it writes C# and TypeScript clients and can produce the description from your ASP.NET Core controllers in the same build. OpenAPI Generator covers far more languages, with a separate generator for each. Both are free and open source.
Verdict
OpenAPI Generator wins, 11 to 9, narrowly, over NSwag.
NSwag 9/18 OpenAPI Generator 11/18
NSwag takes error handling. OpenAPI Generator takes language support and auth handling. Even on typing, retries and maintenance.
| Criterion | NSwag | OpenAPI Generator |
|---|---|---|
| Language supportEdge: OpenAPI Generator | Partial Two client languages: C#, and TypeScript with templates for Fetch, Axios (preview), Angular, AngularJS, Aurelia and jQuery. Callers in any other language need another generator. Check: NSwag README | Strong It ships client generators for dozens of languages and frameworks. Quality and completeness vary by generator, so check the one you need. Check: OpenAPI Generator: generators list |
| TypingEven | Solid Typed C# DTOs and TypeScript classes or interfaces come from the schemas through NJsonSchema, which documents its handling of enums and inheritance. Check how oneOf comes through for your description. Check: NSwag README | Solid Typed models come from the schemas in your description. How well unions (oneOf), enums and nullables come through depends on the language's generator. Check: OpenAPI Generator: generators list |
| Auth handlingEdge: OpenAPI Generator | Partial Security schemes don't become client configuration. You add the Authorization header yourself: an injected HttpClient or the PrepareRequest hook in C#, a base class with transformOptions in TypeScript. Check: NSwag: TypeScript client generator | Solid Security schemes in the description (API key, basic, bearer, OAuth) become configuration on the client. Token refresh is usually yours to build. Check: OpenAPI Generator: generators list |
| RetriesEven | Partial No retry logic is generated. The C# client takes an injected HttpClient, so retries come from whatever handlers you configure on it; in TypeScript you wrap the calls yourself. Check: NSwag: C# client generator settings | Partial Retry behaviour mostly comes from the HTTP library the generated client uses; you configure it, and it differs by generator. Check: OpenAPI Generator: generators list |
| Error handlingEdge: NSwag | Solid Exception classes are generated by default and carry the status code, response body and headers; documented error responses with a schema come back as a typed result on the exception. Check: NSwag: C# client generator settings | Partial Most generators raise one generic API exception with the status code and body; typed error models vary by generator. Check: OpenAPI Generator: generators list |
| MaintenanceEven | Solid One .nswag configuration file regenerates the clients from the CLI, an npm package or an MSBuild target, and the same toolchain can produce the description from your ASP.NET Core controllers. Check its releases page for recent activity. Check: NSwag: C# client generator | Solid Regenerate from the description when the API changes. Custom templates and patches have to be carried forward across generator upgrades. |
The verdict, and when to ignore it
OpenAPI Generator wins, 11 to 9, narrowly, over NSwag. NSwag takes error handling. OpenAPI Generator takes language support and auth handling. Even on typing, retries and maintenance.
Pick NSwag when
Your API is ASP.NET Core, your callers are C# services and a TypeScript front end, and you want the description and both clients from one .nswag file in your build.
NSwag on GitHubPick OpenAPI Generator when
Callers need languages beyond C# and TypeScript (Java, Go, Python, Kotlin, Swift), or you want one generator for every client. Check that its csharp and typescript generators fit your framework.
openapi-generator.techMore matchups
Hand-written SDK vs OpenAPI Generator
OpenAPI Generator wins, 10 to 8, narrowly, over Hand-written SDK.
OpenAPI Generator vs Microsoft Kiota
Microsoft Kiota wins, 17 to 13, narrowly, over OpenAPI Generator.
No SDK (raw HTTP) vs hand-written SDK
Hand-written SDK wins, 9 to 2, over No SDK (raw HTTP).
Hand-written SDK vs MCP server
Too close to call: Hand-written SDK 10, MCP server over your API 9.
Speakeasy vs OpenAPI Generator
Speakeasy wins, 15 to 10, over OpenAPI Generator.
Swagger Codegen vs OpenAPI Generator
OpenAPI Generator wins, 11 to 9, narrowly, over Swagger Codegen.
Microsoft Kiota vs NSwag
Microsoft Kiota wins, 14 to 9, over NSwag.