API标签
jmms支持swagger tag的设置,tag可以用于将多个API操作进行归类。
配置全局标签
Since 0.5.2
全局标签通过app/tags.json
进行定义:
[
{
"name": "Tag1",
"description": "The desc"
},
{
"name": "Tag2",
"description": "The desc"
},
]
基于路径自动设置操作标签
Example :
├── operations
│ └── msg
│ ├── @tags.json
│ ├── cancel@post.js
│ ├── notify@post.js
│ └── send@post.js
在API操作的路径(目录)下创建@tags.json
文件,可以为当前路径(以及子路径)的所有操作自动设置tag。
tags.json
的格式如下:
- 单个tag
{
"name" : "tag name",
"description" : "tag description"
}
如果
name
不指定,默认使用当前的目录名
- 多个tag
[
{
"name": "tag 1",
"description": "The description"
},
{
"name": "tag 2",
"description": "The description"
}
]
@tags.json中的标签可以引用全局标签,如果不存在会自动创建一个新的标签
单独设置某个操作标签
在操作定义文件中通过@tags
和@tag
可以单独为某个操作设置标签。
@tag 从0.5.2才开始支持
Example :
hello.js
/**
* @tags tag 1, tag2
*/
function _() {
}
或
/**
* @tag tag 1
* @tag tag2
*/
function _() {
}
如果设置的标签不存在,则会自动创建一个新的标签。
实体操作标签自动设置
默认情况下,jmms会自动为每个实体创建一个tag
,并自动为实体路径下的所有操作进行设置
上一篇:API操作