Matchup

Swagger Codegen vs OpenAPI Generator

Same roots, two projects. OpenAPI Generator was forked from Swagger Codegen 2.x by its community contributors; Swagger Codegen carries on under SmartBear in two separately maintained lines, 2.x for Swagger 2.0 and 3.x for OpenAPI 3.0. Both are free and open source, so the choice comes down to languages, spec support and which project's generators fit your code.

vs
Criteria

Tick what matters. ×2 counts a criterion double.

Verdict

OpenAPI Generator wins, 11 to 9, narrowly, over Swagger Codegen.

Swagger Codegen 9/18 OpenAPI Generator 11/18

OpenAPI Generator takes language support and maintenance. Even on typing, auth handling, retries and error handling.

CriterionSwagger CodegenOpenAPI Generator
Language supportEdge: OpenAPI GeneratorSolid

The 3.x line, the one that reads OpenAPI 3.0, lists clients for C#, Dart, Go, Java, JavaScript, Kotlin, PHP, Python, R, Ruby, Scala, Swift and TypeScript. The 2.x line lists more languages but reads Swagger 2.0 only.

Check: Swagger Codegen 3.x 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
TypingEvenSolid

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: Swagger Codegen 3.x 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 handlingEvenSolid

Security schemes in the description (API key, basic, bearer, OAuth) become configuration on the client. Token refresh is usually yours to build.

Check: Swagger Codegen 3.x README
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
RetriesEvenPartial

Retry behaviour mostly comes from the HTTP library the generated client uses; you configure it, and it differs by language.

Check: Swagger Codegen 3.x README
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 handlingEvenPartial

Generated clients typically raise one generic API exception with the status code and body; check the generator for your language.

Check: Swagger Codegen 3.x README
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
MaintenanceEdge: OpenAPI GeneratorPartial

Regenerate from the description when the API changes, but its compatibility table lists specs up to OpenAPI 3.0, and the 2.x and 3.x lines are separate artifacts with different generator lists, so an upgrade can mean switching lines.

Check: Swagger Codegen compatibility
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 Swagger Codegen. OpenAPI Generator takes language support and maintenance. Even on typing, auth handling, retries and error handling.

Pick Swagger Codegen when

Your build already runs Swagger Codegen with templates you've tuned, your description is Swagger 2.0 or OpenAPI 3.0, and its generator for your language does what you need. Check the release notes for your line before upgrading.

Swagger Codegen on GitHub

Pick OpenAPI Generator when

You need a language or framework outside Swagger Codegen 3.x's list, you're moving from 2.x anyway (its migration guide starts from Swagger Codegen 2.4), or you want the larger generator list to choose from.

openapi-generator.tech