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/08/27 03:47:13 UTC
[apisix] branch master updated: plugin(fault-injection): use draft7
way to rewrite the JSON Schema. (#2105)
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 4d5ecc1 plugin(fault-injection): use draft7 way to rewrite the JSON Schema. (#2105)
4d5ecc1 is described below
commit 4d5ecc1a4001d3c511f0f540076561aa8cd53d03
Author: YuanSheng Wang <me...@gmail.com>
AuthorDate: Thu Aug 27 11:47:04 2020 +0800
plugin(fault-injection): use draft7 way to rewrite the JSON Schema. (#2105)
fix #2088
---
apisix/plugins/fault-injection.lua | 7 +++++--
doc/plugins/fault-injection.md | 4 ++--
doc/zh-cn/plugins/fault-injection.md | 8 ++++----
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/apisix/plugins/fault-injection.lua b/apisix/plugins/fault-injection.lua
index 3e72494..8484352 100644
--- a/apisix/plugins/fault-injection.lua
+++ b/apisix/plugins/fault-injection.lua
@@ -19,6 +19,7 @@ local sleep = ngx.sleep
local plugin_name = "fault-injection"
+
local schema = {
type = "object",
properties = {
@@ -28,19 +29,20 @@ local schema = {
http_status = {type = "integer", minimum = 200},
body = {type = "string", minLength = 0},
},
- required = {"http_status"}
+ minProperties = 1,
},
delay = {
type = "object",
properties = {
duration = {type = "number", minimum = 0},
},
- required = {"duration"}
+ minProperties = 1,
}
},
minProperties = 1,
}
+
local _M = {
version = 0.1,
priority = 11000,
@@ -48,6 +50,7 @@ local _M = {
schema = schema,
}
+
function _M.check_schema(conf)
local ok, err = core.schema.check(schema, conf)
if not ok then
diff --git a/doc/plugins/fault-injection.md b/doc/plugins/fault-injection.md
index 30ab7db..f2e9681 100644
--- a/doc/plugins/fault-injection.md
+++ b/doc/plugins/fault-injection.md
@@ -27,9 +27,9 @@ Fault injection plugin, this plugin can be used with other plugins and will be e
|Name |Requirement |Description|
|------- |-----|------|
-|abort.http_status|required|user-specified http code returned to the client|
+|abort.http_status|optional|user-specified http code returned to the client|
|abort.body|optional|response data returned to the client|
-|delay.duration|required|delay time(can be decimal)|
+|delay.duration|optional|delay time(can be decimal)|
Note: `abort` and `delay` must have at least one.
diff --git a/doc/zh-cn/plugins/fault-injection.md b/doc/zh-cn/plugins/fault-injection.md
index e5d8b3b..9274173 100644
--- a/doc/zh-cn/plugins/fault-injection.md
+++ b/doc/zh-cn/plugins/fault-injection.md
@@ -27,11 +27,11 @@
|名称 |必须|描述|
|------- |-----|------|
-|abort.http_status|是|返回给客户端的 http 状态码|
-|abort.body|否|返回给客户端的响应数据|
-|delay.duration|是|延迟时间,可以指定小数|
+|abort.http_status|可选|返回给客户端的 http 状态码|
+|abort.body|可选|返回给客户端的响应数据|
+|delay.duration|可选|延迟时间,可以指定小数|
-注:参数 abort 和 delay 至少要存在一个
+注:参数 abort 和 delay 至少要存在一个。
## 示例