@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<{type}>
Example:
@param {string[]}
@param {array<string>}
Location
jmms默认会根据以下规则来给参数设置Location:
- 如果参数是路径变量,
Location=path
- 如果参数是复杂对象,
Location=body
- 如果参数类型是
file
,Location=formData
- 如果不是上面的情况,
Location=query
jmms同时也支持在@param
中定义Location
:
@param <query> {string} name
@param <body> {Object} properties
上一篇:@tags
下一篇:@param-include