api-document-webpack-plugin

1.0.1 • Public • Published

api-document-webpack-plugin

Ts API document generation based on webpack

Install

npm i api-document-webpack-plugin

Usage

const ApiDocumentWebpackPlugin = require('api-document-webpack-plugin');
module.exports = {
    mode: 'production',
    plugins: [
        new ApiDocumentWebpackPlugin({
            filePath: './api' // 接口目录或文件
        })
    ]
};
'filePath' means Directory or file where the API interface resides

example

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:

login

description: 用户登录功能 api: /api/login dataType: application/json requestType: post returnType: {code:200/400,msg:'登录成功/失败'}

Parameters:

  • username(string)
  • password(string)

Package Sidebar

Install

npm i api-document-webpack-plugin

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

6.22 kB

Total Files

6

Last publish

Collaborators

  • hinrichguo