JSPM

  • Created
  • Published
  • Downloads 312282
  • Score
    100M100P100Q177183F
  • License MIT

Create typescript api module from swagger schema

Package Exports

  • swagger-typescript-api

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (swagger-typescript-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

swagger-typescript-api

Generate api via swagger scheme.
Supports OA 3.0, 2.0, JSON, yaml

📄 Usage

Usage: sta [options]
Usage: swagger-typescript-api [options]

Options:
  -v, --version          output the current version
  -p, --path <path>      path to swagger scheme
  -o, --output <output>  output path of typescript api file (default: ".")
  -n, --name <name>      name of output typescript api file (default: "api.ts")
  -h, --help             output usage information

Also you can use npx:

 npx swagger-typescript-api -p ./swagger.json -o ./src -n myApi.ts

You can use this package from nodejs:

const { generateApi } = require('swagger-typescript-api');

generateApi({
  name,
  url: 'http://api.com/swagger.json',
  input: resolve(process.cwd(), './foo/swagger.json')
})
  .then(sourceFile => {
    fs.writeFile(path, sourceFile)
  })
  .catch(e => {
    console.error(e)
  })

🚀 Examples

sta -p ./swagger.json

Input swagger scheme - file
Output typescript api - file

📝 License

Licensed under the MIT License.