@param

定义操作的一个输入(请求)参数。

语法

语法参考jsdoc@param做了裁剪和扩展。

@param <location> {type} name - description

1. Type Name

/**
 * @param {string} name
 */

2. Type Name Description

/**
 * @param {string} name The description.
 */

为了具有更好的阅读性,您也可以在描述前加上-字符

/**
 * @param {string} name - The description.
 */

3. Location Type Name Description

/**
 * @param <query> {string} param1 - The description.
 * @param <path> {string} param2 - The description.
 */

Type请参考data types

复杂类型

复杂类型指Swagger中的Model对象(实体也会生成Swagger Model对象)。

参数类型直接指定Model Name:

/**
 * @param {User} user 
 */

可选参数

在参数名左右加上[]表示可选,格式:[name]

Example:

@param {string} [userId]

数组类型

在类型后加[],或者使用array&lt;{type}&gt;

Example:

@param {string[]}
@param {array<string>}

Location

jmms默认会根据以下规则来给参数设置Location

  1. 如果参数是路径变量,Location=path
  2. 如果参数是复杂对象,Location=body
  3. 如果参数类型是fileLocation=formData
  4. 如果不是上面的情况,Location=query

jmms同时也支持在@param中定义Location

@param <query> {string} name
@param <body>  {Object} properties
Bingosoft            updated 2018-11-10
上一篇:@tags 下一篇:@param-include

results matching ""

    No results matching ""