LinuxCommandLibrary

openapi-generator

TLDR

Generate client library

$ openapi-generator generate -i [spec.yaml] -g [python] -o [./client]
copy
Generate server stub
$ openapi-generator generate -i [spec.yaml] -g [spring] -o [./server]
copy
List available generators
$ openapi-generator list
copy
Generate with config file
$ openapi-generator generate -i [spec.yaml] -g [typescript-axios] -c [config.yaml] -o [./client]
copy
Validate spec
$ openapi-generator validate -i [spec.yaml]
copy
Generate documentation
$ openapi-generator generate -i [spec.yaml] -g [html2] -o [./docs]
copy

SYNOPSIS

openapi-generator command [options]

DESCRIPTION

OpenAPI Generator generates API clients, server stubs, and documentation from OpenAPI (Swagger) specifications. It supports 50+ languages and frameworks.
The tool is a fork of Swagger Codegen with active community development.

PARAMETERS

generate

Generate code.
validate
Validate spec.
list
List generators.
-i file
Input spec file.
-g generator
Generator name.
-o dir
Output directory.
-c file
Config file.
-p params
Additional properties.

POPULAR GENERATORS

$ Clients: python, typescript-axios, go, java
Servers: spring, python-flask, go-server
Docs: html2, markdown
copy

CAVEATS

Generated code may need customization. Large specs produce many files. Some generators more mature than others.

HISTORY

OpenAPI Generator was forked from Swagger Codegen in 2018 by William Cheng and others to create a more community-driven project.

SEE ALSO

Copied to clipboard