This is an automated email from the ASF dual-hosted git repository.

chenjunxu 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 5bdfb8f  chore: remove injected field of plugin schema from properties 
(#3299)
5bdfb8f is described below

commit 5bdfb8f8e51d3058514a4ef72869fa8352ed2a60
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Fri Jan 15 11:40:49 2021 +0800

    chore: remove injected field of plugin schema from properties (#3299)
    
    * chore: remove injected field of plugin schema from properties
---
 apisix/plugin.lua | 4 ++--
 t/admin/plugins.t | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index fc24778..9928cb5 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -114,7 +114,7 @@ local function load_plugin(name, plugins_list, 
is_stream_plugin)
     local properties = plugin.schema.properties
     local plugin_injected_schema = core.schema.plugin_injected_schema
 
-    if properties['$comment'] ~= plugin_injected_schema['$comment'] then
+    if plugin.schema['$comment'] ~= plugin_injected_schema['$comment'] then
         if properties.disable then
             core.log.error("invalid plugin [", name,
                            "]: found forbidden 'disable' field in the schema")
@@ -122,7 +122,7 @@ local function load_plugin(name, plugins_list, 
is_stream_plugin)
         end
 
         properties.disable = plugin_injected_schema.disable
-        properties['$comment'] = plugin_injected_schema['$comment']
+        plugin.schema['$comment'] = plugin_injected_schema['$comment']
     end
 
     plugin.name = name
diff --git a/t/admin/plugins.t b/t/admin/plugins.t
index eedee61..29b43c1 100644
--- a/t/admin/plugins.t
+++ b/t/admin/plugins.t
@@ -191,7 +191,7 @@ plugins:
         }
     }
 --- response_body eval
-qr/\{"metadata_schema":\{"additionalProperties":false,"properties":\{"ikey":\{"minimum":0,"type":"number"\},"skey":\{"type":"string"\}\},"required":\["ikey","skey"\],"type":"object"\},"priority":0,"schema":\{"properties":\{"\$comment":"this
 is a mark for our injected plugin 
schema","disable":\{"type":"boolean"\},"i":\{"minimum":0,"type":"number"\},"ip":\{"type":"string"\},"port":\{"type":"integer"\},"s":\{"type":"string"\},"t":\{"minItems":1,"type":"array"\}\},"required":\["i"\],"type":"
 [...]
+qr/\{"metadata_schema":\{"additionalProperties":false,"properties":\{"ikey":\{"minimum":0,"type":"number"\},"skey":\{"type":"string"\}\},"required":\["ikey","skey"\],"type":"object"\},"priority":0,"schema":\{"\$comment":"this
 is a mark for our injected plugin 
schema","properties":\{"disable":\{"type":"boolean"\},"i":\{"minimum":0,"type":"number"\},"ip":\{"type":"string"\},"port":\{"type":"integer"\},"s":\{"type":"string"\},"t":\{"minItems":1,"type":"array"\}\},"required":\["i"\],"type":"
 [...]
 --- no_error_log
 [error]
 

Reply via email to