Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate nodejs from Swagger spec

So I've documented my whole API with swagger editor, and now I have my .yaml file. I'm really confused how I take that and generate the whole nodejs stuff now so that all those functions are already defined and then I just fill them in with the appropriate code.

like image 531
Gargoyle Avatar asked Apr 19 '17 21:04

Gargoyle


1 Answers

Swagger Codegen generates server stubs and client SDKs for a variety of languages and frameworks, including Node.js.

To generate a Node.js server stub, run codegen with the -l nodejs-server argument.

Windows example:

java -jar swagger-codegen-cli-2-2-2.jar generate -i petstore.yaml -l nodejs-server -o .\PetstoreServer

You get:

.
├── api
|    └── swagger.yaml
├── controllers
|    ├── Pet.js
|    ├── PetService.js
|    ├── Store.js
|    ├── StoreService.js
|    ├── User.js
|    └── UserService.js
├── index.js
├── package.json
├── README.md
└── .swagger-codegen-ignore
like image 62
Helen Avatar answered Sep 22 '22 06:09

Helen