OpenAPI 3.0 CodeGen plus Node.js minus the Java and emojis
Clone or download
Permalink
Failed to load latest commit information.
.github fixes / server improvements / checkJs Nov 17, 2017
bin travis; show bash/ruby versions Apr 2, 2018
configs config; typescript angular fixes Apr 2, 2018
defs fix; improvements from testing bash Nov 24, 2017
docs docs; update patches.md Nov 26, 2017
lib/orange downconverter; rename response.links to x-links, refs #19 Mar 16, 2018
schemas schema; allow perApi/perModel default overrides Mar 31, 2018
server fix; improvements from testing bash Nov 24, 2017
templates config; fix lua Mar 31, 2018
test test; fix for perApi templates Nov 23, 2017
.dockerignore fix; docker ignore out directory Nov 22, 2017
.editorconfig Add .editorconfig Mar 16, 2018
.eslintrc.json tests; show go version. Linter fixes Mar 3, 2018
.gitattributes Try to fix language detection Nov 15, 2017
.gitignore misc; update .gitignore Mar 31, 2018
.travis.yml fix; travis for npm/node 10/greenkeeper Jul 3, 2018
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Nov 15, 2017
CONTRIBUTING.md docs; update CONTRIBUTING.md Nov 21, 2017
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 README.md [ci skip] Apr 6, 2018
adaptor.js Fix model enums / Node 10 issue, refs #46 Sep 20, 2018
cg.js Add Typescript-checking annotations, refs #31 May 11, 2018
index.js Switch to using circularClone func, refs #47 Sep 20, 2018
jsconfig.json Add jsconfig.json to squash ES2017-related warnings May 11, 2018
package-lock.json deps; update yargs Jul 5, 2018
package.json deps; update yargs Jul 5, 2018
webpack.config.js webpack; add webpack v4 Jul 5, 2018

README.md

OpenAPI-CodeGen

Build status Greenkeeper badge

Experimental port of swagger-codegen templates to Node.js. This project was initially a 24-hour hackathon. The 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

Usage

Installing

npm i -g openapi-codegen

or

  • clone the repository, and
  • npm i

CLI

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

Options:
  --help           Show help                                           [boolean]
  --version        Show version number                                 [boolean]
  -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.

If you are using Node 6.x or lower, please specify the --harmony flag.

API

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

Templates

Templates are 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.

Contributors

See here for a partial list of template contributors.

Status of the template configurations

The templates with a status have a working (if not necessarily tested) configuration in the configs directory.

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-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

See also

These projects use their own template model, not that of swagger-codegen