Skip to content

Commit

Permalink
feature: added desc for upstream and service in schema. (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
moonming authored Jul 22, 2019
1 parent 398579e commit e6bc004
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
4 changes: 4 additions & 0 deletions lua/apisix/core/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ local upstream_schema = {
type = "string",
enum = {"remote_addr"},
},
desc = {type = "string", maxLength = 256},
id = id_schema
},
required = {"nodes", "type"},
Expand All @@ -164,6 +165,7 @@ _M.route = [[{
},
"uniqueItems": true
},
"desc": {"type": "string", "maxLength": 256},
"plugins": ]] .. json.encode(plugins_schema) .. [[,
"upstream": ]] .. json.encode(upstream_schema) .. [[,
"uri": {
Expand Down Expand Up @@ -203,6 +205,7 @@ _M.service = {
plugins = plugins_schema,
upstream = upstream_schema,
upstream_id = id_schema,
desc = {type = "string", maxLength = 256},
},
anyOf = {
{required = {"upstream"}},
Expand All @@ -221,6 +224,7 @@ _M.consumer = {
pattern = [[^[a-zA-Z0-9_]+$]]
},
plugins = plugins_schema,
desc = {type = "string", maxLength = 256},
},
required = {"username"},
additionalProperties = false,
Expand Down
9 changes: 7 additions & 2 deletions t/admin/consumers.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ __DATA__
local code, body = t('/apisix/admin/consumers',
ngx.HTTP_PUT,
[[{
"username":"jack"
"username":"jack",
"desc": "new consumer"
}]],
[[{
"node": {
"value": {
"username": "jack"
"username": "jack",
"desc": "new consumer"
}
},
"action": "set"
Expand Down Expand Up @@ -52,6 +54,7 @@ passed
ngx.HTTP_PUT,
[[{
"username": "jack",
"desc": "new consumer",
"plugins": {
"key-auth": {
"key": "auth-one"
Expand All @@ -62,6 +65,7 @@ passed
"node": {
"value": {
"username": "jack",
"desc": "new consumer",
"plugins": {
"key-auth": {
"key": "auth-one"
Expand Down Expand Up @@ -98,6 +102,7 @@ passed
"node": {
"value": {
"username": "jack",
"desc": "new consumer",
"plugins": {
"key-auth": {
"key": "auth-one"
Expand Down
3 changes: 3 additions & 0 deletions t/admin/routes.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ __DATA__
},
"type": "roundrobin"
},
"desc": "new route",
"uri": "/index.html"
}]],
[[{
Expand All @@ -34,6 +35,7 @@ __DATA__
"GET"
],
"uri": "/index.html",
"desc": "new route",
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
Expand Down Expand Up @@ -75,6 +77,7 @@ passed
"GET"
],
"uri": "/index.html",
"desc": "new route",
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
Expand Down
9 changes: 6 additions & 3 deletions t/admin/services.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ __DATA__
"127.0.0.1:8080": 1
},
"type": "roundrobin"
}
},
"desc": "new service"
}]],
[[{
"node": {
Expand All @@ -33,7 +34,8 @@ __DATA__
"127.0.0.1:8080": 1
},
"type": "roundrobin"
}
},
"desc": "new service"
},
"key": "/apisix/services/1"
},
Expand Down Expand Up @@ -70,7 +72,8 @@ passed
"127.0.0.1:8080": 1
},
"type": "roundrobin"
}
},
"desc": "new service"
},
"key": "/apisix/services/1"
},
Expand Down
9 changes: 6 additions & 3 deletions t/admin/upstream.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ __DATA__
"nodes": {
"127.0.0.1:8080": 1
},
"type": "roundrobin"
"type": "roundrobin",
"desc": "new upstream"
}]],
[[{
"node": {
"value": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "roundrobin"
"type": "roundrobin",
"desc": "new upstream"
},
"key": "/apisix/upstreams/1"
},
Expand Down Expand Up @@ -64,7 +66,8 @@ passed
"nodes": {
"127.0.0.1:8080": 1
},
"type": "roundrobin"
"type": "roundrobin",
"desc": "new upstream"
},
"key": "/apisix/upstreams/1"
},
Expand Down
2 changes: 2 additions & 0 deletions t/plugin/limit-req.t
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ done
},
"type": "roundrobin"
},
"desc": "上游节点",
"uri": "/hello"
}]],
[[{
Expand All @@ -105,6 +106,7 @@ done
},
"type": "roundrobin"
},
"desc": "上游节点",
"uri": "/hello"
},
"key": "/apisix/routes/1"
Expand Down

0 comments on commit e6bc004

Please sign in to comment.