[refactor][bug] bind params to struct error should response error with 400 status
now it response normal.
here is an example:
$ curl http://127.0.0.1:8080/apisix/admin/services/1 -X PUT -i -d '
{
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "roundrobin"
},
"labels": {
"env": ["production", "release"]
},
"desc": "new service"
}'
@ShiningRush please take a look~
ping @ShiningRush
I'm still considering the solution, if there are any results, I will sync here
if this is not urgent, feel free to move it to milestone 2.1.
error format ofenv
{
caseDesc: "create consumers with invalid format of label value",
Object: MangerApiExpect(t),
Path: "/apisix/admin/consumers",
Method: http.MethodPost,
Body: `{
"username":"case_10",
"desc": "new consumer",
"labels": {
"env": ["production", "release"]
}
}`,
Headers: map[string]string{"Authorization": token},
ExpectStatus: http.StatusBadRequest,
},
miss , in json
{
Object: MangerApiExpect(t),
Method: http.MethodPut,
Path: "/apisix/admin/routes/r1",
Body: `{
"uris": ["/hello","/status"]
"upstream": {
"type": "roundrobin",
"nodes": [{
"host": "172.16.238.20",
"port": 1980,
"weight": 1
}]
}
}`,
Headers: map[string]string{"Authorization": token},
ExpectStatus: http. StatusBadRequest,
Sleep: sleepTime,
}
bad methods
{
caseDesc: "add route with invalid uri",
Object: MangerApiExpect(t),
Method: http.MethodPut,
Path: "/apisix/admin/routes/r1",
Body: `{
"uri": "/hello",
"methods": [99999999999999999],
"upstream": {
"type": "roundrobin",
"nodes": [{
"host": "172.16.238.20",
"port": 1980,
"weight": 1
}]
}
}`,
Headers: map[string]string{"Authorization": token},
ExpectStatus: http. StatusBadRequest,
},
bad priority
{
caseDesc: "add route with invalid data type priority",
Object: MangerApiExpect(t),
Method: http.MethodPut,
Path: "/apisix/admin/routes/r1",
Body: `{
"uri": "/hello",
"priority": "dfssdfs",
"upstream": {
"type": "roundrobin",
"nodes": [{
"host": "172.16.238.20",
"port": 1980,
"weight": 1
}]
}
}`,
Headers: map[string]string{"Authorization": token},
ExpectStatus: http.StatusBadRequest,
},
it return 200 now.
I think JSON Schema can check this case
I think
JSON Schemacan check this case
It has returned before the json schema verification