You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sh...@apache.org on 2021/04/25 13:05:04 UTC
[apisix] branch master updated: refactor: remove duplicate HTTP
method schema definition (#4125)
This is an automated email from the ASF dual-hosted git repository.
shuyangw 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 8b4a36b refactor: remove duplicate HTTP method schema definition (#4125)
8b4a36b is described below
commit 8b4a36b0c233e9ceb750f3120bd5f4798ac199b8
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Sun Apr 25 21:04:58 2021 +0800
refactor: remove duplicate HTTP method schema definition (#4125)
Signed-off-by: spacewander <sp...@gmail.com>
---
apisix/plugins/batch-requests.lua | 11 ++++-------
apisix/plugins/consumer-restriction.lua | 6 +-----
apisix/plugins/proxy-cache.lua | 7 +------
apisix/schema_def.lua | 16 ++++++++++------
4 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/apisix/plugins/batch-requests.lua b/apisix/plugins/batch-requests.lua
index fc4dc64..6b7f14e 100644
--- a/apisix/plugins/batch-requests.lua
+++ b/apisix/plugins/batch-requests.lua
@@ -45,6 +45,9 @@ local metadata_schema = {
additionalProperties = false,
}
+local method_schema = core.table.clone(core.schema.method_schema)
+method_schema.default = "GET"
+
local req_schema = {
type = "object",
properties = {
@@ -73,13 +76,7 @@ local req_schema = {
enum = {1.0, 1.1},
default = 1.1,
},
- method = {
- description = "HTTP method",
- type = "string",
- enum = {"GET", "POST", "PUT", "DELETE", "PATCH", "HEAD",
- "OPTIONS", "CONNECT", "TRACE"},
- default = "GET"
- },
+ method = method_schema,
path = {
type = "string",
minLength = 1,
diff --git a/apisix/plugins/consumer-restriction.lua b/apisix/plugins/consumer-restriction.lua
index f7d685d..0c38ad1 100644
--- a/apisix/plugins/consumer-restriction.lua
+++ b/apisix/plugins/consumer-restriction.lua
@@ -46,11 +46,7 @@ local schema = {
methods = {
type = "array",
minItems = 1,
- items = {
- type = "string",
- enum = {"GET", "POST", "PUT", "DELETE", "PATCH", "HEAD",
- "OPTIONS", "CONNECT", "TRACE"},
- }
+ items = core.schema.method_schema,
}
}
}
diff --git a/apisix/plugins/proxy-cache.lua b/apisix/plugins/proxy-cache.lua
index 78a2858..326b529 100644
--- a/apisix/plugins/proxy-cache.lua
+++ b/apisix/plugins/proxy-cache.lua
@@ -63,12 +63,7 @@ local schema = {
cache_method = {
type = "array",
minItems = 1,
- items = {
- description = "http method",
- type = "string",
- enum = {"GET", "POST", "PUT", "DELETE", "PATCH", "HEAD",
- "OPTIONS", "CONNECT", "TRACE"},
- },
+ items = core.schema.method_schema,
uniqueItems = true,
default = {"GET", "HEAD"},
},
diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua
index 809f556..a391e99 100644
--- a/apisix/schema_def.lua
+++ b/apisix/schema_def.lua
@@ -435,6 +435,15 @@ _M.upstream_hash_vars_combinations_schema = {
}
+local method_schema = {
+ description = "HTTP method",
+ type = "string",
+ enum = {"GET", "POST", "PUT", "DELETE", "PATCH", "HEAD",
+ "OPTIONS", "CONNECT", "TRACE"},
+}
+_M.method_schema = method_schema
+
+
_M.route = {
type = "object",
properties = {
@@ -456,12 +465,7 @@ _M.route = {
methods = {
type = "array",
- items = {
- description = "HTTP method",
- type = "string",
- enum = {"GET", "POST", "PUT", "DELETE", "PATCH", "HEAD",
- "OPTIONS", "CONNECT", "TRACE"}
- },
+ items = method_schema,
uniqueItems = true,
},
host = host_def,