mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-04 04:57:35 +08:00
plugin(consumer-restriction): use draft7 way to rewrite the JSON Schema. (#2440)
fix: #2402
This commit is contained in:
parent
c9392627a8
commit
5fcbb4de9c
@ -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"},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user