文件格式为xxx.json
moco常用配置参数写法
不指定请求资源地址,请求啥都返回一样的内容(几乎不用这个)
[
{
"description":"---第一个请求---",
"response":{
"text":"hello world!"
}
}
]
request请求体设置
uri:指定请求资源地址
[
{
"description":"登录请求",
"request":{
"uri":"/login"
},
"response":{
"text":"登录成功"
}
}
]
method:指定请求方
[
{
"description":"登录请求",
"request":{
"uri":"/login",
"method": "get"
},
"response":{
"text":"登录成功"
}
}
]
headers:指定请求头
[
{
"description":"登录请求",
"request":{
"uri": "/login",
"method": "post",
"headers":{
"Content-Type":"application/json",
"Authorization": "token"
},
"json": {
"mobile_phone": "15814666574",
"pwd": "123456"
}
},
"response":{
"text": "登录成功"
}
}
]
queries:指定查询参数
[
{
"description":"登录请求",
"request":{
"uri":"/login",
"queries":{
"mobile_phone":"15814666574",
"pwd":"123456"
}
},
"response":{
"text":"登录成功!"
}
}
]
forms:指定表单参数
[
{
"description":"登录请求",
"request":{
"uri":"/login",
"method":"get",
"forms":{
"mobile_phone":"15814666574",
"pwd":"123456"
}
},
"response":{
"text":"登录成功"
}
}
]
json请求体:指定json请求体参数(请求体和响应体都要以json的形式分别保存)
[
{
"description":"登录请求",
"request":{
"uri": "/login",
"method": "post",
"json": {
"mobile_phone": "15814666574",
"pwd": "123456"
}
},
"response":{
"text": "登录成功"
}
}
]
response响应体设置
status:指定响应状态码
[
{
"description": "-----",
"request": {
"uri": "/login",
"method": "get"
},
"response": {
"status":201
}
}
]
headers:指定响应头
[
{
"description": "-----",
"request": {
"uri": "/login",
"method": "get"
},
"response": {
"status":201,
"headers": {
"content-type": "application/json",
"content-length": "20"
}
}
}
]
cookies:指定响应cookie
[
{
"description": "-----",
"request": {
"uri": "/login",
"method": "get"
},
"response": {
"status":201,
"headers": {
"content-type": "application/json",
"content-length": "20"
},
"cookies": {
"jsessionid": "1234567"
}
}
}
]
json响应数据(请求体和响应体都要以json的形式分别保存)
[
{
"description": "登录请求",
"request": {
"uri": "/login",
"method": "post"
},
"response": {
"status": 200,
"headers": {
"Content-Type" : "application/json"
},
"cookies": {
"jsessionid": "1234567"
},
"json":{
"code": 0,
"msg": "OK"
}
}
}
]