LinuxCommandLibrary

swagger-codegen

Generate API client code from OpenAPI specs

TLDR

Generate client

$ swagger-codegen generate -i [api.yaml] -l [java] -o [output/]
copy
List languages
$ swagger-codegen langs
copy
Generate with config
$ swagger-codegen generate -i [api.yaml] -l [python] -c [config.json] -o [output/]
copy
Validate spec
$ swagger-codegen validate -i [api.yaml]
copy
Show help for language
$ swagger-codegen config-help -l [typescript-angular]
copy

SYNOPSIS

swagger-codegen command [-i input] [-l language] [-o output] [options]

DESCRIPTION

swagger-codegen generates API client libraries, server stubs, and documentation from OpenAPI (Swagger) specification files. It reads a YAML or JSON API definition and produces code in dozens of target languages and frameworks including Java, Python, TypeScript, Go, Ruby, and many more.
Client generation creates ready-to-use SDK code with models, API classes, and serialization logic matching the API specification. Server stub generation scaffolds backend code with route definitions and request/response models. Documentation generation produces HTML or other formats.
The tool uses Mustache templates that can be customized to control the exact output format. A configuration file can specify additional options such as package names, model naming conventions, and library preferences for the target language.

PARAMETERS

generate

Generate code.
langs
List languages.
validate
Validate spec.
-i FILE
Input spec file.
-l LANG
Target language.
-o DIR
Output directory.
-c FILE
Config file.

CAVEATS

Java required. Large dependency. Consider openapi-generator.

HISTORY

swagger-codegen was created for generating API client libraries from OpenAPI/Swagger specifications.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community