Generic Client Generation (Any Language)#

The OpenAPI Generator project supports 50+ languages and frameworks. Use it when no language-specific tool is a better fit.

openapi-generator#

# Install via npm, Homebrew, or Docker
npm install -g @openapitools/openapi-generator-cli

# List available generators
openapi-generator-cli list

# Generate a client
openapi-generator-cli generate \
  -i http://localhost:3000/openapi.json \
  -g <generator-name> \
  -o ./generated-client

Common generators:

GeneratorLanguage/Framework
typescript-fetchTypeScript with Fetch API
typescript-axiosTypeScript with Axios
goGo
pythonPython
csharpC#
javaJava
kotlinKotlin
rustRust
swift5Swift
dartDart/Flutter
rubyRuby
phpPHP

Docker (no local install)#

docker run --rm --network host \
  -v "${PWD}:/out" \
  openapitools/openapi-generator-cli generate \
  -i http://host.docker.internal:3000/openapi.json \
  -g typescript-fetch \
  -o /out/generated

Configuration#

Customize generation with a config file:

# openapi-generator-config.yaml
generatorName: typescript-fetch
inputSpec: http://localhost:3000/openapi.json
outputDir: ./generated
additionalProperties:
  supportsES6: true
  withInterfaces: true
openapi-generator-cli batch openapi-generator-config.yaml