gitmyhub

swagger-codegen

Mustache ★ 18k updated 1mo ago

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.

A tool that reads an OpenAPI description file and automatically generates client libraries in dozens of languages and server skeleton code, eliminating the tedious boilerplate of writing HTTP calls by hand.

JavaMustacheOpenAPIYAMLJSONsetup: moderatecomplexity 3/5

Swagger Codegen is a tool that automatically generates code from an API description file. An API (application programming interface) is a defined way for software systems to talk to each other, and OpenAPI (also known as Swagger) is a popular standard for describing what an API does — what endpoints exist, what data they accept, what they return — in a machine-readable format (usually a JSON or YAML file).

The problem it solves is tedious boilerplate: once you have an OpenAPI description of your API, writing client libraries (code that calls the API in different programming languages) and server stubs (skeleton code that defines the server-side structure) by hand is repetitive and error-prone. Swagger Codegen reads your OpenAPI file and generates this code automatically, so your API consumers get a ready-to-use library in their language rather than having to hand-craft HTTP calls.

The tool supports generating API client libraries in a range of languages including Java, Python, Go, JavaScript, TypeScript, PHP, Ruby, C#, Kotlin, Swift, Dart, R, and Scala. For server stubs, it supports frameworks across several languages. It can also generate HTML documentation from the same API description.

You run it as a command-line tool (distributed as a Java JAR file) pointing at your OpenAPI spec, selecting the target language, and specifying an output directory. An online generator API is also available if you do not want to run it locally. The project is open source and used in workflows where teams want to keep their client code in sync with a changing API definition. The full README is longer than what was provided.

Where it fits