You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2020/10/19 01:55:21 UTC
[apisix] branch master updated: plugin(consumer-restriction): use
draft7 way to rewrite the JSON Schema. (#2440)
This is an automated email from the ASF dual-hosted git repository.
membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 5fcbb4d plugin(consumer-restriction): use draft7 way to rewrite the JSON Schema. (#2440)
5fcbb4d is described below
commit 5fcbb4de9cdaac2570f8132fca98fc2bd2a93a0a
Author: JinChen <36...@users.noreply.github.com>
AuthorDate: Mon Oct 19 09:55:08 2020 +0800
plugin(consumer-restriction): use draft7 way to rewrite the JSON Schema. (#2440)
fix: #2402
---
apisix/plugins/consumer-restriction.lua | 54 +++++++++++++++++++++------------
t/plugin/consumer-restriction.t | 7 +++--
2 files changed, 38 insertions(+), 23 deletions(-)
diff --git a/apisix/plugins/consumer-restriction.lua b/apisix/plugins/consumer-restriction.lua
index f80e096..68b1711 100644
--- a/apisix/plugins/consumer-restriction.lua
+++ b/apisix/plugins/consumer-restriction.lua
@@ -19,27 +19,41 @@ local core = require("apisix.core")
local schema = {
type = "object",
- properties = {
- type = {
- type = "string",
- enum = {"consumer_name", "service_id"},
- default = "consumer_name"
- },
- whitelist = {
- type = "array",
- items = {type = "string"},
- minItems = 1
- },
- blacklist = {
- type = "array",
- items = {type = "string"},
- minItems = 1
- },
- rejected_code = {type = "integer", minimum = 200, default = 403}
- },
oneOf = {
- {required = {"whitelist"}},
- {required = {"blacklist"}}
+ {
+ title = "blacklist",
+ properties = {
+ type = {
+ type = "string",
+ enum = {"consumer_name", "service_id"},
+ default = "consumer_name"
+ },
+ blacklist = {
+ type = "array",
+ minItems = 1,
+ items = {type = "string"}
+ },
+ rejected_code = {type = "integer", minimum = 200, default = 403}
+ },
+ required = {"blacklist"},
+ },
+ {
+ title = "whitelist",
+ properties = {
+ type = {
+ type = "string",
+ enum = {"consumer_name", "service_id"},
+ default = "consumer_name"
+ },
+ whitelist = {
+ type = "array",
+ minItems = 1,
+ items = {type = "string"}
+ },
+ rejected_code = {type = "integer", minimum = 200, default = 403}
+ },
+ required = {"whitelist"},
+ }
}
}
diff --git a/t/plugin/consumer-restriction.t b/t/plugin/consumer-restriction.t
index afa7492..bca9817 100644
--- a/t/plugin/consumer-restriction.t
+++ b/t/plugin/consumer-restriction.t
@@ -30,8 +30,9 @@ __DATA__
location /t {
content_by_lua_block {
local plugin = require("apisix.plugins.consumer-restriction")
- local conf = {
- whitelist = {
+ local conf = {
+ title = "whitelist",
+ whitelist = {
"jack1",
"jack2"
}
@@ -47,7 +48,7 @@ __DATA__
--- request
GET /t
--- response_body
-{"rejected_code":403,"type":"consumer_name","whitelist":["jack1","jack2"]}
+{"type":"consumer_name","title":"whitelist","rejected_code":403,"whitelist":["jack1","jack2"]}
--- no_error_log
[error]