-
-
Notifications
You must be signed in to change notification settings - Fork 8
自定义响应模板
kings1990 edited this page Dec 17, 2019
·
6 revisions
默认响应模板返回结果为如下格式
{
"retCode": 200,
"msg": "xxx",
"result":{}
}
如果需要返回其他格式的则需要使用自定义响应模板,分为2步
-
首先需要配置在2.1 配置介绍中加入responseConfigPath属性,值为自定义响应模板文件名,文件必须放在resource目录下,内容必须是json形式
-
参考一下demoCustomResponseTemplate.json配置,json约束:
property:字段值(必传)
description:字段描述(必传)
type:字段类型(非结果字段必传) 类型约束:参考2.1章节中responseResultType
resultFlag:结果字段标记 约束:有且必须只有1个"resultFlag": true的字段配置
demoCustomResponseTemplate.json
[
{
"property": "code",
"description": "状态码",
"type": "String"
},
{
"property": "message",
"description": "状态码",
"type": "Number"
},
{
"property": "url",
"description": "链接地址",
"type": "String"
},
{
"property": "result",
"description": "结果",
"resultFlag": true
}
]