swagger-interface

0.2.30 • Public • Published

swagger-interface

根据 swagger 自动生成 interface 与 API

安装

yarn add swagger-interface -D

配置文件

  1. 在根目录创建 swagger-config 文件夹
  2. 新建 swagger-config/swagger.config.js 文件
module.exports = {
  // rootDir: 'src/api',// 文件目录 默认 src/api
  // rootApiDir: 'modules', // 存放interfaces的目录名 默认 modules
  basePath: '/xxxx', // 默认值的path路
  swaggers: [
    {
      url: 'http://xxx.xxx.com/xx/v2/api-docs', // swagger地址路径
      apiDir: 'xxx', // api 放置的文件目录
      baseGroupName: 'xxx', // api默认分组
      basePath: '/xxx', // 默认值的path路
      paths: [
        {
          url: '/api/order/detail{?orderId}',
          operationId: 'fetchOrderDetails',
          groupName: 'order',
          summary: '查询订单详情',
        },
        {
          url: '/api/order/page',
          operationId: 'fetchOrderPage',
          groupName: 'order',
          summary: '查询订单列表',
        },
      ],
    },
  ],
};

配置 script

package.json

 "scripts": {
    "swagger-interface": "swagger-interface"
  },

执行脚本

    npm run swagger-interface

每个服务都会生成对应的 interface,API

Readme

Keywords

Package Sidebar

Install

npm i swagger-interface

Weekly Downloads

0

Version

0.2.30

License

MIT

Unpacked Size

136 kB

Total Files

116

Last publish

Collaborators

  • banxing