filipeue-swagger-js-codegen
v1.13.2
Published
A Swagger codegen for TypeScript and JavaScript
Downloads
1
Readme
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",
...
},