0.18.6 • Published 2 years ago

@36node/swagen v0.18.6

Weekly downloads
147
License
MIT
Repository
github
Last release
2 years ago

@36node/swagen

version downloads

Install

yarn global add @36node/template-cli

Usage

$ swagen -h

Usage: swagen [options] [command]

Options:
  -V, --version      output the version number
  -h, --help         output usage information

Commands:
  koa [options]      Generate code for koa server api
  sdk [options]      Generate code for client sdk
  postman [options]  Transform openapi file to postman collection file

Generate client sdk code

$ swagen sdk -h

Usage: sdk [options] [yamlFile] [name] [dist]

Generate code for client sdk

Options:
  -h, --help  output usage information


# example, default name is filename of yaml file or specified by name option
$ swagen sdk ./petstore.yaml ./sdk petstore

Generate koa server api code

$ swagen koa -h

Usage: koa [options] [yamlFile] [dist]

Generate code for koa server api

Options:
  -h, --help  output usage information


# example, if dist not specified, current dir will be used as default dist
$ swagen koa ./petstore.yaml ./koa

Generate postman collection from openapi

$ swagen postman -h

Usage: postman [options] [yamlFile] [targetFile]

Transform openapi file to postman collection file

Options:
  -h, --help  output usage information

# example, default targetFile name is the openapi info title properity
$ swagen postman ./petstore.yaml ./petstore.postman_collection.json

# will generate petstore.postman_collection.json in pwd
# then can use fastman to import collection to postman

$ fastman import ./petstore.postman_collection.json

Generate mock collection from openapi

$ swagen mock -h

Usage: mock [options] [yamlFile] [dist]

Transform openapi file to json-server data file

Options:
  -c, --count [count]  Add count of mock data to generate, default is 10
  -h, --help           output usage information

# example, default targetFile name is the openapi info title properity
$ swagen mock ./petstore.yaml ./mock/

# will generate data.json and routes.json in mock
# then can use json-server with these data and routes

$ json-server ./mock/db.json --routes ./mock/routes.json

More about json-server you can see here

Use remote file

# set name with 'petstore'
swagen sdk https://api.36node.com/petstore/v0/openapi.yaml . petstore

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b feature/a-new-command
  3. Commit your changes: git commit -am 'Add a new command'
  4. Push to the branch: git push origin feature/a-new-command
  5. Submit a pull request :D

Add new template

  1. Add new generator js file in src/generators, filename is the template name.
  2. In new generator js file, export default function which generate template.

Author

template-cli © 36node, Released under the MIT License.

Authored and maintained by 36node with help from contributors (list).

github.com/zzswang · GitHub @36node · Twitter @y

0.18.6

2 years ago

0.18.4

3 years ago

0.18.3

3 years ago

0.18.2

3 years ago

0.18.1

3 years ago

0.18.0

3 years ago

0.17.12

3 years ago

0.17.11

4 years ago

0.17.10

4 years ago

0.17.8

4 years ago

0.17.9

4 years ago

0.17.5

4 years ago

0.17.6

4 years ago

0.17.7

4 years ago

0.17.4

4 years ago

0.17.3

4 years ago

0.17.2

4 years ago

0.17.1

4 years ago

0.17.0

4 years ago

0.15.0

4 years ago

0.15.1

4 years ago

0.15.2

4 years ago

0.14.0

4 years ago

0.13.8

4 years ago

0.13.6

4 years ago

0.13.5

4 years ago

0.13.4

5 years ago

0.13.3

5 years ago

0.13.2

5 years ago

0.13.1

5 years ago

0.13.0

5 years ago

0.12.6

5 years ago

0.12.5

5 years ago

0.12.4

5 years ago

0.12.3

5 years ago

0.12.2

5 years ago

0.12.1

5 years ago

0.12.0

5 years ago

0.11.5

5 years ago

0.11.4

5 years ago

0.11.2

5 years ago

0.11.0

5 years ago

0.9.5

5 years ago

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.0

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.8

5 years ago

0.6.7

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago