Ts API document generation based on webpack
npm i api-document-webpack-plugin
const ApiDocumentWebpackPlugin = require('api-document-webpack-plugin');
module.exports = {
mode: 'production',
plugins: [
new ApiDocumentWebpackPlugin({
filePath: './api' // 接口目录或文件
})
]
};
Input:
interface responseData {
code: Number;
msg: String;
}
/**
* @description 用户登录功能
* @api /api/login
* @dataType application/json
* @requestType post
* @returnType {code:200/400,msg:'登录成功/失败'}
*
*/
function login(username: string, password: string): responseData {
return {
code: 200,
msg: "登录成功",
};
}
outPut:
description: 用户登录功能 api: /api/login dataType: application/json requestType: post returnType: {code:200/400,msg:'登录成功/失败'}
- username(string)
- password(string)