测试示例
测试示例
其它一些示例演示
apis
1. struct数组
version: 1.0.2.1
GET /user/demo/struct_array
Response:
//StatusCode: 200 demo struct array
[ //array[handler.DemoData]
{ //object(handler.DemoData)
"count": 0, //int
"description": "string", //string
"float_array": [ //array[float64]
1.23
],
"int_array": [ //array[int]
0
],
"int_pointer": 0, //int
"map": { //object(map[string]int)
"string": 0 //int
},
"object_1": { //object(handler.DemoObject)
"name": "string" //string
},
"object_2": { //object(handler.DemoObject)
"name": "string" //string
},
"title": "string" //string, 标题
}
]
2. struct嵌套
GET /user/demo/struct_nested
Response:
//StatusCode: 200 nested struct
{ //object(handler.Struct1)
"Name": "string", //string
"Name2": "string" //string
}
3. int数组
GET /user/demo/int_array
Response:
//StatusCode: 200 demo int array
[ //array[int]
0
]
4. int
GET /user/demo/int
Response:
//StatusCode: 200 demo int
//int
0
5. map
GET /user/demo/map
Response:
//StatusCode: 200 demo map
{ //object(map[string]handler.DemoData)
"string": { //object(handler.DemoData)
"count": 0, //int
"description": "string", //string
"float_array": [ //array[float64]
1.23
],
"int_array": [ //array[int]
0
],
"int_pointer": 0, //int
"map": { //object(map[string]int)
"string": 0 //int
},
"object_1": { //object(handler.DemoObject)
"name": "string" //string
},
"object_2": { //object(handler.DemoObject)
"name": "string" //string
},
"title": "string" //string, 标题
}
}
6. xml
author: alovn
GET /user/demo/xml
Request:
| parameter | parameterType | dataType | required | validate | example | description |
|---|---|---|---|---|---|---|
| id | param | int64 | false | DemoID |
body:
<request> //object(handler.DemoXMLRequest), XML测试请求对象
<id>0</id> //int64, DemoID
</request>
Response:
//StatusCode: 200
<response> //object(common.Response), 通用返回结果
<code>0</code> //int, 返回状态码
<demo> //object(handler.DemoXMLResponse), XML测试返回对象
<address>string</address> //string, 地址信息
<city_id>0</city_id> //int64, 城市ID
<id>0</id> //int64, 地址ID
</demo>
<msg>success</msg> //string, 返回消息
</response>
//StatusCode: 200
<response> //object(common.Response), 通用返回结果
<code>0</code> //int, 返回状态码
<data> //object(handler.DemoXMLResponse2), XML测试返回对象2
<address>string</address> //string, 地址信息
<city_id>0</city_id> //int64, 城市ID
<id>0</id> //int64, 地址ID
</data>
<msg>success</msg> //string, 返回消息
</response>
//StatusCode: 200
<response> //object(common.Response), 通用返回结果
<code>10010</code> //int, 返回状态码
<msg>sme error</msg> //string, 返回消息
</response>
7. time
author: alovn
GET /user/demo/time
Response:
//StatusCode: 200
{ //object(common.Response), 通用返回结果
"code": 0, //int, 返回状态码
"data": { //object(handler.DemoTime)
"time_1": "2022-05-16T16:47:48.741899+08:00", //object(time.Time), example1
"time_2": "2022-05-14 15:04:05", //object(time.Time), example2
"time_3": "2022-05-16T16:47:48.741899+08:00" //object(time.Time)
},
"msg": "success" //string, 返回消息
}