gs-type
v1.1.3
Published
generate type based on swagger
Downloads
1
Readme
gs-type
根据swagger文档地址,生成请求和响应的typescript的类型文件
Installation
npm install -D gs-type
如何使用
在项目的root目录创建swagger.config.js 然后添加配置,eg.
export default {
swaggerModules: [
{
swaggerDocUrl: 'https://xxx/v1/api-docs',
outputDir: '/api/test123',
moduleList: [
{
moduleName: 'aaa222',
apiList: [{
url: '/chargeBillDetail/queryByOperationsPage',
interfaceName: 'queryByOperationsPage',
isUpdate: true, // 是否更新 dsdsd
params: {
comment: '请求注释123',
exclude: ['pageSize', 'currentPage'],
optionalFields: ['bid', 'billNo'], // 可选的fields - 请求
},
responses: {
comment: '响应注释456',
exclude: ['currentPage', 'headerList', 'pageSize', 'dataList.bid'], // 排除 - 响应
optionalFields: ['dataStatistics'] // 可选的fields ---------------------------------------------- pms-dev.saas.cmsk1979.com
}
}, '/chargeBillDetail/queryByPropertyPage']
}
]
},
{
swaggerDocUrl: 'https://xxxx/pmpgw/dashboard/v1/v2/api-docs',
outputDir: '/tttt',
moduleList: [
{
moduleName: 'personal',
apiList: [
'/reminderNotice/noticeRead',
'/reminderNotice/queryHomePageNotice',
'/reminderNotice/queryNoticeAll',
'/reminderNotice/queryPieInfo'
]
}
]
}
],
}
在package.json里添加
"scripts": {
"gs-type": "gs-type"
}
在执行 npm run gs-type