Skip to content
OpenAPI 3.0 CodeGen plus Node.js minus the Java and emojis
JavaScript Shell Dockerfile
Branch: master
Clone or download

Latest commit

Latest commit 076dad8 Feb 19, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github fixes / server improvements / checkJs Nov 17, 2017
bin test: update README and checkTs.sh for typescript-axios Mar 22, 2019
configs Add support for TypeScript Axios Feb 22, 2019
defs
docs docs: lambda examples weren't rendering in markdown doc Jan 17, 2020
lib/orange fix: general hardening Feb 19, 2020
schemas docs: minor updates to lambdas descriptions, update schema for genera… Jan 17, 2020
server fix; improvements from testing bash Nov 24, 2017
templates add php specific features (#73) Jan 17, 2020
test fix: fixup lint errors on test/lambdas.js Jan 17, 2020
.dockerignore fix; docker ignore out directory Nov 22, 2017
.editorconfig Add .editorconfig Mar 16, 2018
.eslintrc.json
.gitattributes Try to fix language detection Nov 15, 2017
.gitignore chore: remove added .vscode settings Jan 17, 2020
.travis.yml build: node 10 is baseline now Jan 13, 2020
CHANGELOG.md
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Nov 15, 2017
CONTRIBUTING.md docs: update CONTRIBUTING.md with package-lock.json guidance Feb 21, 2019
CONTRIBUTORS.md docs; Add CONTRIBUTORS.md Nov 26, 2017
Dockerfile feat; Docker support Nov 17, 2017
LICENSE Update LICENSE Nov 21, 2017
MERGE_BASE Update templates Mar 1, 2018
README.md docs: update with start of remote details Jan 17, 2020
adaptor.js fix: general hardening Feb 19, 2020
cg.js
jsconfig.json Add jsconfig.json to squash ES2017-related warnings May 11, 2018
lambdas.js Add custom lambdas support Jan 17, 2020
local.js feat: calling APIs of swagger-codegen / openapi-generator to list tem… Jan 17, 2020
package-lock.json 2.0.1 Feb 19, 2020
package.json 2.0.1 Feb 19, 2020
remote.js fix: general hardening Feb 19, 2020
webpack.config.js webpack; add webpack v4 Jul 5, 2018

README.md

OpenAPI-CodeGen

Build status Greenkeeper badge

Node.js-based codegen for OpenAPI documents. This project was initially a 24-hour hackathon. The local model adaptor code is entirely original and has been reverse-engineered from the existing documentation and template usage.

Work in progress

Supports OpenAPI 3.0.x natively, and Swagger/OpenAPI 1.2 and 2.0 by internal conversion. Node.js LTS versions are supported.

Usage

Installing

npm i -g openapi-codegen

or

  • clone the repository, and
  • npm i

or

npx -p openapi-codegen cg ...

CLI

cg [options] {[path]configName} {openapi-definition}

Options:
  --help           Show help                                           [boolean]
  --version        Show version number                                 [boolean]
  --filter         Filter term to use with --list                       [string]
  --list           List available templates for provider (og or sc)     [string]
  -d, --debug      Turn on debugging information in the model          [boolean]
  -f, --flat       Do not include config-name in output directory structure
                                                                       [boolean]
  -l, --lint       Lint input definition                               [boolean]
  -o, --output     Specify output directory         [string] [default: "./out/"]
  -s, --stools     Use swagger-tools to validate OpenAPI 2.0 definitions
                                                                       [boolean]
  -t, --templates  Specify templates directory                          [string]
  -v, --verbose    Increase verbosity                                  [boolean]
  -z, --zip        Create a .zip file instead of individual files      [boolean]

e.g.

node cg --verbose nodejs defs/generator.yaml

In this case, the generated code will be written to the .out/nodejs directory.

You can also load the OpenAPI definition from a URL.

API

const renderer = require('openapi-codegen');
// load a config and a definition
renderer.main(definition,config,configName);

Templates

The local templates were taken directly from swagger-codegen. This project is also licensed under Apache-2.0 for this reason. Generated code is explicitly covered by the Unlicense. Code to downconvert OpenAPI 3.0 definitions is taken from Angular-Swagger-UI and is MIT licensed.

You can also use the latest online templates from two providers: og (openapi-generator) and sc (swagger-codegen). The --list and --filter options allow you to see which templates are available. Note that using the online templates involves sending your API definition to a remote server.

Contributors

See here for a partial list of template contributors.

Status of the template configurations

The local templates with a status have a working (if not necessarily tested) configuration in the configs directory. Contributions are welcomed from the community of new and updated configurations and template updates.

Click here to expand...
Template Type Status README Authors (TODO) Config Maintainer
_common meta contains Apache-2.0 and Unlicense licenses
Ada client Untested
akka-scala
android
apache2 configuration needs work
apex
aspnetcore
bash client Syntax ok, needs testing @bkryza @MikeRalphson
clojure client Untested
codegen meta Demo only @MikeRalphson
confluenceWikiDocs documentation Tested with Docker server
cpprest
csharp
csharp-dotnet2 client Untested
dart
debug meta used for dumping the model state @Mermade @MikeRalphson
Eiffel
elixir
erlang-client client Untested
erlang-server server
finch
flash
flaskConnexion server Needs testing
go client Builds, needs testing
go-server server Builds and runs
Groovy ? untested
haskell-http-client client
haskell-servant server Untested
htmlDocs documentation Appears to work
htmlDocs2 documentation Appears to work, no console errors logged
Java
JavaInflector
JavaJaxRS
JavaPlayFramework
Javascript client Untested
Javascript-Closure-Angular client Untested
JavaSpring
JavaVertXServer
JMeter meta Untested
kotlin-client
lua client Compiles OK
lumen
MSF4J
nancyfx
nodejs server tested @jfiala @MikeRalphson
objc
openapi meta outputs the input definition (in OpenAPI 3.0.x form) @Mermade @MikeRalphson
perl
php
php-silex ? untested
php-symfony
pistache-server
powershell
python client needs testing @mpnordland
qt5cpp
r
rails5
restbed server Untested
ruby
rust
rust-server
scala
scalatra
scalaz client Untested
sinatra server Syntax checks OK
slim server Untested
swagger meta outputs the input definition (in original form if OpenAPI 2.0)
swagger-static documentation tested template modified to include partials
swift
swift3
swift4
tizen
typescript-angular
typescript-angularjs
typescript-axios client tested jaredpalmer
typescript-aurelia
typescript-fetch client compiles with tsc ok
typescript-jquery
typescript-node client compiles with tsc ok
undertow
validator meta uses swagger2openapi's OpenAPI 3.0 validator internally
ze-ph

New Templates

These templates are examples of how features of OpenAPI Codegen may be used, and best-practices in naming model properties.

Template Type Status README Authors Config Maintainer
testing.dredd testing In progress README @Mermade @MikeRalphson

Documentation

You can’t perform that action at this time.