Baoyuantop commented on code in PR #12795:
URL: https://github.com/apache/apisix/pull/12795#discussion_r2617828905


##########
t/plugin/ai-proxy-multi.t:
##########
@@ -128,6 +128,47 @@ run_tests();
 
 __DATA__
 
+=== TEST 0: schema accepts 'logging' and ignores unknown 'logging_schema'

Review Comment:
   We should add it to the end of the existing test.



##########
t/plugin/ai-proxy.t:
##########
@@ -181,6 +181,36 @@ run_tests();
 
 __DATA__
 
+=== TEST 0: schema accepts 'logging' and ignores unknown 'logging_schema'
+--- config
+    location /t {
+        content_by_lua_block {
+            local plugin = require("apisix.plugins.ai-proxy")
+
+            local ok1, err1 = plugin.check_schema({
+                provider = "openai",
+                auth = { header = { apikey = "token" } },
+                options = { model = "gpt-4" },
+                logging = { summaries = true, payloads = false },
+            })
+
+            local ok2, err2 = plugin.check_schema({
+                provider = "openai",
+                auth = { header = { apikey = "token" } },
+                options = { model = "gpt-4" },
+                logging_schema = { summaries = true },
+            })
+
+            -- APISIX schema allows additional properties unless explicitly 
disallowed.
+            -- So unknown field 'logging_schema' should be ignored and still 
pass.
+            ngx.say((ok1 and "ok" or ("bad:" .. (err1 or ""))), ":", (ok2 and 
"ok" or "invalid"))

Review Comment:
   This is too complicated. Please use if else statements for easier code 
understanding.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to