0.24.13 • Published 11 months ago

josh-openapi-typescript-codegen v0.24.13

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

OpenAPI Typescript Codegen

NPM License Coverage Coverage Downloads Build

Node.js library that generates Typescript clients based on the OpenAPI specification.

Why?

  • Frontend ❤️ OpenAPI, but we do not want to use JAVA codegen in our builds
  • Quick, lightweight, robust and framework-agnostic 🚀
  • Supports generation of TypeScript clients
  • Supports generations of Fetch, Node-Fetch, Axios, Angular and XHR http clients
  • Supports OpenAPI specification v2.0 and v3.0
  • Supports JSON and YAML files for input
  • Supports generation through CLI, Node.js and NPX
  • Supports tsc and @babel/plugin-transform-typescript
  • Supports aborting of requests (cancelable promise pattern)
  • Supports external references using json-schema-ref-parser

Install

npm install openapi-typescript-codegen --save-dev

Usage

$ openapi --help

  Usage: openapi [options]

  Options:
    -V, --version             output the version number
    -i, --input <value>       OpenAPI specification, can be a path, url or string content (required)
    -o, --output <value>      Output directory (required)
    -c, --client <value>      HTTP client to generate [fetch, xhr, node, axios, angular] (default: "fetch")
    --name <value>            Custom client class name
    --useOptions              Use options instead of arguments
    --useUnionTypes           Use union types instead of enums
    --exportCore <value>      Write core files to disk (default: true)
    --exportServices <value>  Write services to disk (default: true)
    --exportModels <value>    Write models to disk (default: true)
    --exportSchemas <value>   Write schemas to disk (default: false)
    --indent <value>          Indentation options [4, 2, tab] (default: "4")
    --postfixServices         Service name postfix (default: "Service")
    --postfixModels           Model name postfix
    --request <value>         Path to custom request file
    --serviceTemplate <value> Path to custom service handlebars template to generate the service files
    --clientTemplate <value>  Path to custom client handlebars template to generate the client file
    --indexTemplate <value>   Path to custom index handlebars template to generate the index file
    -h, --help                display help for command

  Examples
    $ openapi --input ./spec.json --output ./generated
    $ openapi --input ./spec.json --output ./generated --client xhr

Docker usage

To build the Docker container, execute the following command:

docker build . --tag openapi-typescript-codegen

After this is done, you can execute the CLI commands:

docker run openapi-typescript-codegen --help
docker run openapi-typescript-codegen --input sample.yaml --output client

Documentation

Support

0.24.13

11 months ago

0.24.12

11 months ago

0.24.11-debug9

11 months ago

0.24.11-debug8

11 months ago

0.24.11-debug7

11 months ago

0.24.11-debug6

11 months ago

0.24.11-debug5

11 months ago

0.24.11-debug4

11 months ago

0.24.11

11 months ago

0.24.10-debug3

11 months ago

0.24.10-debug2

11 months ago

0.24.10-debug

11 months ago

0.24.10

11 months ago

0.24.9

11 months ago

0.24.8

11 months ago

0.24.7

11 months ago

0.24.6

11 months ago

0.24.5

11 months ago

0.24.4

11 months ago

0.24.3

11 months ago

0.24.2

11 months ago

0.24.1

11 months ago

0.24.0

12 months ago