All Projects → OpenAPITools → Openapi Generator Cli

OpenAPITools / Openapi Generator Cli

Licence: apache-2.0
A node package wrapper for https://github.com/OpenAPITools/openapi-generator

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Openapi Generator Cli

shipengine-openapi
The official OpenAPI 3.0 definitions for ShipEngine™
Stars: ✭ 13 (-95.74%)
Mutual labels:  openapi, openapi3
fastify-openapi-glue
A plugin for Fastify to autogenerate a configuration based on a OpenApi(v2/v3) specification.
Stars: ✭ 94 (-69.18%)
Mutual labels:  openapi, openapi3
openapi-schema-validator
OpenAPI schema validator for Python
Stars: ✭ 35 (-88.52%)
Mutual labels:  openapi, openapi3
openapi
OpenAPI (fka Swagger) spec renderer for Sphinx.
Stars: ✭ 78 (-74.43%)
Mutual labels:  openapi, openapi3
Safrs
SqlAlchemy Flask-Restful Swagger Json:API OpenAPI
Stars: ✭ 255 (-16.39%)
Mutual labels:  openapi, openapi3
apiflask
A lightweight Python web API framework.
Stars: ✭ 442 (+44.92%)
Mutual labels:  openapi, openapi3
sbt-openapi-schema
Generate schema sources for Scala, Java and Elm from an openapi 3.0 spec.
Stars: ✭ 12 (-96.07%)
Mutual labels:  openapi, openapi3
swagger-petstore
petstore.swagger.io
Stars: ✭ 84 (-72.46%)
Mutual labels:  openapi, openapi3
sticker
Sticker is a powerful yet boilerplate-free alternative to writing your web API.
Stars: ✭ 26 (-91.48%)
Mutual labels:  openapi, openapi3
go-openapi
OpenAPI Specification (OAS) 3.0 implementation for Go
Stars: ✭ 38 (-87.54%)
Mutual labels:  openapi, openapi3
light-rest-4j
A RESTful framework built on top of light-4j with both Swagger 2.0 and OpenAPI 3.0 supports
Stars: ✭ 113 (-62.95%)
Mutual labels:  openapi, openapi3
Php Openapi
Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
Stars: ✭ 268 (-12.13%)
Mutual labels:  openapi, openapi3
php-json-schema-model-generator
Creates (immutable) PHP model classes from JSON-Schema files including all validation rules as PHP code
Stars: ✭ 36 (-88.2%)
Mutual labels:  openapi, openapi3
openapi-lint-vscode
OpenAPI 2.0/3.0.x intellisense, validator, linter, converter and resolver extension for Visual Studio Code
Stars: ✭ 47 (-84.59%)
Mutual labels:  openapi, openapi3
nexmo-oas-renderer
Render your API references, Nexmo-style!
Stars: ✭ 40 (-86.89%)
Mutual labels:  openapi, openapi3
thema
A CUE-based framework for portable, evolvable schema
Stars: ✭ 41 (-86.56%)
Mutual labels:  openapi, openapi3
firecracker
Stop half-done API specifications! Cherrybomb is a CLI tool that helps you avoid undefined user behaviour by validating your API specifications.
Stars: ✭ 438 (+43.61%)
Mutual labels:  openapi, openapi3
KaiZen-OpenApi-Parser
High-performance Parser, Validator, and Java Object Model for OpenAPI 3.x
Stars: ✭ 119 (-60.98%)
Mutual labels:  openapi, openapi3
openapi-schemas
JSON Schemas for every version of the OpenAPI Specification
Stars: ✭ 22 (-92.79%)
Mutual labels:  openapi, openapi3
Openapi.tools
A collection of Editors, Linters, Parsers, Code Generators, Documentation, Testing
Stars: ✭ 257 (-15.74%)
Mutual labels:  openapi, openapi3

@openapitools/openapi-generator-cli

Join the Slack chat room

Build Renovate enabled HitCount semantic-release

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (both 2.0 and 3.0 are supported). Please see OpenAPITools/openapi-generator


Version 2.x.x

[update] The command has been renamed

You need to execute openapi-generator-cli instead of openapi-generator from now on.

[added] semver support! 🎉

To make that happen, a version management was added to the package. The first time you run the command openapi-generator-cli the last stable version of OpenAPITools/openapi-generator is downloaded by default.

That version is saved in the file openapitools.json. Therefore you should include this file in your version control, to ensure that the correct version is being used next time you call the command.

If you would like to use a different version of the OpenAPITools/openapi-generator, you could change it by using one of the following commands:

  • openapi-generator-cli version-manager list
  • openapi-generator-cli version-manager set <versionTags...>

[added] generator config

You will now be able to configure the code generation in openapitools.json. This makes it more convenient to generate code for every file that matches the given glob expression. For more information, please check out the configuration documentation blow.

Installation

Locally (recommended)

npm install @openapitools/openapi-generator-cli

or using yarn

yarn add @openapitools/openapi-generator-cli

After the installation has finished you can run npx openapi-generator-cli or add a script like this:

{
  "name": "my-cool-package",
  "version": "0.0.0",
  "scripts": {
    "my-awesome-script-name": "openapi-generator-cli generate -i docs/openapi.yaml -g typescript-angular -o generated-sources/openapi --additional-properties=ngVersion=6.1.7,npmName=restClient,supportsES6=true,npmVersion=6.9.0,withInterfaces=true",
  }
}

Note the whitespace sensitivity when using multiple additional-properties:

--additional-properties=ngVersion=6.1.7,npmName=restClient,supportsES6=true,npmVersion=6.9.0,withInterfaces=true

Globally

npm install -g @openapitools/openapi-generator-cli

or using yarn

yarn global add @openapitools/openapi-generator-cli

After the installation has finished you can run openapi-generator-cli

Usage

Mac/Linux:

openapi-generator-cli generate -g ruby -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /var/tmp/ruby-client

Windows:

openapi-generator-cli generate -g ruby -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o C:\temp\ruby-client

Configuration

If you have installed the package locally and executed the command openapi-generator-cli at least once, you will find a new file called openapitools.json along with the package.json. Please add this file to your VCS.

Initially the file has the following content:

{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "4.3.1" // or the current latest version ;)
  }
}

This configuration indicates the following:

  • the json file shall be formatted using 2 spaces
  • the jar files shall be downloaded to ./my/custom/storage/dir
  • the generator-cli version 4.3.1 is used

Further it is also possible to configure generators, for example:

{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "4.3.1",
    "storageDir": "~/my/custom/storage/dir", // optional
    "generators": { // optional
      "v2.0": { // any name you like (just printed to the console log) 
        "generatorName": "typescript-angular",
        "output": "#{cwd}/output/v2.0/#{ext}/#{name}",
        "glob": "examples/v2.0/{json,yaml}/*.{json,yaml}",
        "additionalProperties": {
          "ngVersion": "6.1.7",
          "npmName": "restClient",
          "supportsES6": "true",
          "npmVersion": "6.9.0",
          "withInterfaces": true
        }
      },
      "v3.0": { // any name you like (just printed to the console log) 
        "generatorName": "typescript-fetch",
        "output": "#{cwd}/output/v3.0/#{ext}/#{name}",
        "glob": "examples/v3.0/petstore.{json,yaml}"
      }
    }
  }
}

If openapi-generator-cli generate is called without further arguments, then the configuration is automatically used to generate your code. 🎉

Available placeholders
placeholder description example
name just file name auth
Name just file name, but starting with a capital letter Auth
cwd the current cwd /Users/some-user/projects/some-project
base file name and extension auth.yaml
path full path and filename /Users/some-user/projects/some-project/docs/auth.yaml
dir path without the filename /Users/some-user/projects/some-project/docs
relDir directory name of file relative to the glob provided docs
relPath file name and extension of file relative to the glob provided docs/auth.yaml
ext just file extension yaml

Further Documentation

Please refer to the official openapi-generator docs for more information about the possible arguments and a detailed usage manual of the command line interface.

Install previous version

npm install @openapitools/[email protected]
npm i @openapitools/[email protected]                                         

or using yarn

yarn add @openapitools/[email protected]
yarn add @openapitools/[email protected]

You like the package?

Please leave a star.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].