You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

openapi-codegen

Package Overview
Dependencies
18
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-codegen

OpenAPI 3.0 CodeGen


Version published
Maintainers
1
Created

Readme

Source

OpenAPI-CodeGen

Build status

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...
TemplateTypeStatusREADMEAuthors (TODO)Config Maintainer
_commonmetacontains Apache-2.0 and Unlicense licenses
AdaclientUntested
akka-scala
android
apache2configurationneeds work
apex
aspnetcore
bashclientSyntax ok, needs testing@bkryza@MikeRalphson
clojureclientUntested
codegenmetaDemo only@MikeRalphson
confluenceWikiDocsdocumentationTested with Docker server
cpprest
csharp
csharp-dotnet2clientUntested
dart
debugmetaused for dumping the model state@Mermade@MikeRalphson
Eiffel
elixir
erlang-clientclientUntested
erlang-serverserver
finch
flash
flaskConnexionserverNeeds testing
goclientBuilds, needs testing
go-serverserverBuilds and runs
Groovy?untested
haskell-http-clientclient
haskell-servantserverUntested
htmlDocsdocumentationAppears to work
htmlDocs2documentationAppears to work, no console errors logged
Java
JavaInflector
JavaJaxRS
JavaPlayFramework
JavascriptclientUntested
Javascript-Closure-AngularclientUntested
JavaSpring
JavaVertXServer
JMetermetaUntested
kotlin-client
luaclientCompiles OK
lumen
MSF4J
nancyfx
nodejsservertested :white_check_mark:@jfiala@MikeRalphson
objc
openapimetaoutputs the input definition (in OpenAPI 3.0.x form) :white_check_mark:@Mermade@MikeRalphson
perl
php
php-silex?untested
php-symfony
pistache-server
powershell
pythonclientneeds testing@mpnordland
qt5cpp
r
rails5
restbedserverUntested
ruby
rust
rust-server
scala
scalatra
scalazclientUntested
sinatraserverSyntax checks OK
slimserverUntested
swaggermetaoutputs the input definition (in original form if OpenAPI 2.0) :white_check_mark:
swagger-staticdocumentationtested template modified to include partials
swift
swift3
swift4
tizen
typescript-angular
typescript-angularjs
typescript-axiosclienttestedjaredpalmer
typescript-aurelia
typescript-fetchclientcompiles with tsc ok
typescript-jquery
typescript-nodeclientcompiles with tsc ok
undertow
validatormetauses swagger2openapi's OpenAPI 3.0 validator internally :white_check_mark:
ze-ph

New Templates

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

TemplateTypeStatusREADMEAuthorsConfig Maintainer
testing.dreddtestingIn progressREADME@Mermade@MikeRalphson

Documentation

Keywords

FAQs

Package last updated on 24 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc