1.0.1 • Published 2 years ago

api-document-webpack-plugin v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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)