npm.io
0.0.9 • Published 7 years agoCLI

@l-l/swagger2

Licence
MIT
Version
0.0.9
Deps
3
Size
18 kB
Vulns
0
Weekly
0

swagger2

swagger.yml转为api.json标准格式

swagger.yml => api.json

用法

npm install @l-l/swagger2
  1. 命令行使用
swagger2 <path> <output>

例如:

swagger2 ./swagger.yml ./api.json
  1. 引入包使用
const swagger2 = require('@l-l/swagger2')
const fs = require('fs');

// 读取swagger.yml
const swaggeryml = fs.readFileSync('xx/swagger.yml').toString();

// 转换
const api = swagger2(swaggeryml);

// 写
fs.writeFileSync('xx/api.json',  JSON.stringify(api));