Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

grandsilence/swagger-typescript-api-nextgen

Repository files navigation

swagger-typescript-api

Greenkeeper badge NPM badge

Generate api via swagger scheme.
Supports OA 3.0, 2.0, JSON, yaml
Generated api module use Fetch Api to make requests.



Any questions you can ask here or in our slack


👀 Examples

All examples you can find here

📄 Usage

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

Options:
  -v, --version          output the current version
  -p, --path <path>      path/url 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');

// example with url  
generateApi({
  name: "MySuperbApi.ts", // name of output typescript file
  url: 'http://api.com/swagger.json', // url where located swagger schema
})
  .then(sourceFile => fs.writeFile(path, sourceFile))
  .catch(e => console.error(e))

// example with local file  
generateApi({
  name: "ApiModule.ts", // name of output typescript file
  input: resolve(process.cwd(), './foo/swagger.json') // path to swagger schema
})
  .then(sourceFile => fs.writeFile(path, sourceFile))
  .catch(e => console.error(e))

🚀 How it looks

📝 License

Licensed under the MIT License.

About

Fork of TypeScript API generator via Swagger scheme (next generation).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 89.6%
  • JavaScript 10.4%