2021-11-12 10:05:33 +01:00
2022-01-06 18:45:44 +01:00
2022-02-02 20:45:40 +01:00
2022-02-02 20:45:40 +01:00
2021-10-08 23:34:49 +02:00
2020-09-25 10:54:39 +02:00
2020-02-11 10:50:54 +01:00
2022-01-26 19:03:06 +01:00
2022-02-05 10:07:09 +01:00
2022-01-28 17:15:55 +01:00
2022-01-24 23:01:23 +01:00
2022-02-02 20:45:40 +01:00

OpenAPI Typescript Codegen

NPM License Coverage Quality Code Climate 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: "5")
    --postfix <value>         Service name postfix (default: "Service")
    --request <value>         Path to custom request file
    -h, --help                display help for command

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

Documentation

Support

Description
NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification
Readme 59 MiB
Languages
TypeScript 83.7%
Handlebars 13.9%
JavaScript 2.3%