1.13.2 • Published 3 years ago

filipeue-swagger-js-codegen v1.13.2

Weekly downloads
6
License
Apache-2.0
Repository
github
Last release
3 years ago

Swagger to JS & Typescript Codegen

This package generates a typescript or javascript class from a swagger specification url. The code is generated using mustache templates and beautified by prettier.

Installation

npm install https://github.com/bart-sk/swagger-js-codegen

or

yarn add https://github.com/bart-sk/swagger-js-codegen

Example

CLI

npx swagger2js generate {swaggerUrl} --type javascript > api.js

SwaggerUrl should be absolute url. Resulting class can be retrieved on stdout.

-t, --type
Either "javascript" or "typescript" (default: typescript)

--tags
Filter tags in swagger spec

-c --class
Class name (default: Api)

In package.json

  "scripts": {
    ...
    "generate-api": "npx swagger2js generate {swaggerUrl} > api.ts",
    ...
  },