@lsongzhi/openapi-typescript-codegen
NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.
Last updated 3 months ago by lsongzhi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @lsongzhi/openapi-typescript-codegen 
SYNC missed versions from official npm registry.

OpenAPI Typescript Codegen

NPM License Build Status Codecov Quality

NodeJS library that generates Typescript clients based on the OpenAPI specification.

This is a fork of openapi-typescript-codegen with some bugfixes and customizations:

  • support x-enum-varnames: string[] and x-enum-descriptions in schema to generate enums with names and descriptions in the field.
  • changed service parameters style

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 and XHR http clients.
  • Supports OpenAPI specification v2.0 and v3.0.
  • Supports JSON and YAML files for input.

Known issues:

  • If you use enums inside your models / definitions then those enums are now inside a namespace with the same name as your model. This is called declaration merging. However Babel 7 now support compiling of Typescript and right now they do not support namespaces.

Installation

npm install @lsongzhi/openapi-typescript-codegen --save-dev

Example

package.json

{
    "scripts": {
        "generate": "openapi --input ./api/openapi.json --output ./dist"
    }
    ...
}

Command line

npm install openapi-typescript-codegen -g

openapi ./api/openapi.json ./dist

NodeJS API:

const OpenAPI = require('openapi-typescript-codegen');

OpenAPI.generate(
    './api/openapi.json',
    './dist'
);

Current Tags

  • 0.1.20                                ...           latest (3 months ago)

8 Versions

  • 0.1.20                                ...           3 months ago
  • 0.1.19                                ...           3 months ago
  • 0.1.18                                ...           3 months ago
  • 0.1.17                                ...           4 months ago
  • 0.1.16                                ...           4 months ago
  • 0.1.15                                ...           4 months ago
  • 0.1.14                                ...           4 months ago
  • 0.1.13                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |