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

AlinsRan pushed a commit to branch feat/oas-validator-plugin
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 75279ce4b5f425792fe9946e4699c8ee9355ed0b
Author: AlinsRan <[email protected]>
AuthorDate: Sat May 9 11:29:36 2026 +0800

    fix(oas-validator): fix priority conflict and test upstream addresses
    
    - Change priority from 510 to 512 to avoid conflict with mcp-bridge
    - Move plugin registration position in config.lua accordingly
    - Add fake upstream server on port 1971 in test preprocessor
    - Replace unreachable port 6969/1980 with port 1971 in test upstreams
    - Fix oas-validator2.t: replace 1980 with 1970 for TEST 22/24/26
    - Remove trailing scheme/pass_host fields from updated upstream blocks
    
    Co-authored-by: Copilot <[email protected]>
---
 apisix/cli/config.lua            |  2 +-
 apisix/plugins/oas-validator.lua |  2 +-
 t/plugin/oas-validator.t         | 55 ++++++++++++++++++++++------------------
 t/plugin/oas-validator2.t        | 18 +++++--------
 4 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/apisix/cli/config.lua b/apisix/cli/config.lua
index 52be5b0ed..2af80eb35 100644
--- a/apisix/cli/config.lua
+++ b/apisix/cli/config.lua
@@ -244,13 +244,13 @@ local _M = {
     "limit-conn",
     "limit-count",
     "limit-req",
-    "oas-validator",
     "gzip",
     -- deprecated and will be removed in a future release
     -- "server-info",
     "traffic-split",
     "redirect",
     "response-rewrite",
+    "oas-validator",
     "mcp-bridge",
     "degraphql",
     "kafka-proxy",
diff --git a/apisix/plugins/oas-validator.lua b/apisix/plugins/oas-validator.lua
index b48d456d9..791c0303d 100644
--- a/apisix/plugins/oas-validator.lua
+++ b/apisix/plugins/oas-validator.lua
@@ -171,7 +171,7 @@ end
 
 local _M = {
     version = 0.1,
-    priority = 510,
+    priority = 512,
     name = plugin_name,
     schema = schema,
     metadata_schema = metadata_schema,
diff --git a/t/plugin/oas-validator.t b/t/plugin/oas-validator.t
index 9cb88fc1b..11539a3f3 100644
--- a/t/plugin/oas-validator.t
+++ b/t/plugin/oas-validator.t
@@ -24,6 +24,21 @@ no_root_location();
 add_block_preprocessor(sub {
     my ($block) = @_;
 
+    my $http_config = $block->http_config // <<_EOC_;
+    # fake upstream server for pass-through validation tests
+    server {
+        listen 1971;
+        location / {
+            content_by_lua_block {
+                ngx.status = 200
+                ngx.say("ok")
+            }
+        }
+    }
+_EOC_
+
+    $block->set_value("http_config", $http_config);
+
     if (!$block->request) {
         $block->set_value("request", "GET /t");
     }
@@ -92,7 +107,7 @@ invalid JSON string provided, err: Expected value but found 
invalid token at cha
                      "upstream": {
                        "type": "roundrobin",
                        "nodes": {
-                         "127.0.0.1:6969": 1
+                         "127.0.0.1:1971": 1
                        }
                      }
                 }]], spec)
@@ -209,10 +224,8 @@ error occurred while validating request
                      "upstream": {
                        "type": "roundrobin",
                        "nodes": {
-                         "127.0.0.1:1980": 1
-                       },
-                       "scheme": "http",
-                       "pass_host": "pass"
+                         "127.0.0.1:1971": 1
+                       }
                      }
                 }]], spec)
                 )
@@ -260,10 +273,8 @@ Content-Type: application/json
                      "upstream": {
                        "type": "roundrobin",
                        "nodes": {
-                         "127.0.0.1:1980": 1
-                       },
-                       "scheme": "http",
-                       "pass_host": "pass"
+                         "127.0.0.1:1971": 1
+                       }
                      }
                 }]], spec)
                 )
@@ -309,10 +320,8 @@ Content-Type: not-application/json
                      "upstream": {
                        "type": "roundrobin",
                        "nodes": {
-                         "127.0.0.1:1980": 1
-                       },
-                       "scheme": "http",
-                       "pass_host": "pass"
+                         "127.0.0.1:1971": 1
+                       }
                      }
                 }]], spec)
                 )
@@ -358,10 +367,8 @@ Content-Type: application/json
                      "upstream": {
                        "type": "roundrobin",
                        "nodes": {
-                         "127.0.0.1:1980": 1
-                       },
-                       "scheme": "http",
-                       "pass_host": "pass"
+                         "127.0.0.1:1971": 1
+                       }
                      }
                 }]], spec)
                 )
@@ -491,7 +498,7 @@ upstream reached
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:6969": 1
+                            "127.0.0.1:1971": 1
                         }
                     }
                 }]], spec)
@@ -542,7 +549,7 @@ error occurred while validating request
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:6969": 1
+                            "127.0.0.1:1971": 1
                         }
                     }
                 }]], spec)
@@ -593,7 +600,7 @@ error occurred while validating request
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:6969": 1
+                            "127.0.0.1:1971": 1
                         }
                     }
                 }]], spec)
@@ -643,7 +650,7 @@ error occurred while validating request
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:6969": 1
+                            "127.0.0.1:1971": 1
                         }
                     }
                 }]], spec)
@@ -680,7 +687,7 @@ error occurred while validating request
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:6969": 1
+                            "127.0.0.1:1971": 1
                         }
                     }
                 }]], spec)
@@ -717,7 +724,7 @@ error occurred while validating request
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:6969": 1
+                            "127.0.0.1:1971": 1
                         }
                     }
                 }]], spec)
@@ -754,7 +761,7 @@ passed
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:6969": 1
+                            "127.0.0.1:1971": 1
                         }
                     }
                 }]], spec)
diff --git a/t/plugin/oas-validator2.t b/t/plugin/oas-validator2.t
index 6e9804c6f..f3bc151d4 100644
--- a/t/plugin/oas-validator2.t
+++ b/t/plugin/oas-validator2.t
@@ -445,10 +445,8 @@ error occurred while validating request
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:1980": 1
-                        },
-                        "scheme": "http",
-                        "pass_host": "pass"
+                            "127.0.0.1:1970": 1
+                        }
                     }
                 }]], spec)
             )
@@ -495,10 +493,8 @@ Content-Type: application/json
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:1980": 1
-                        },
-                        "scheme": "http",
-                        "pass_host": "pass"
+                            "127.0.0.1:1970": 1
+                        }
                     }
                 }]], spec)
             )
@@ -543,10 +539,8 @@ Content-Type: application/json
                     "upstream": {
                         "type": "roundrobin",
                         "nodes": {
-                            "127.0.0.1:1980": 1
-                        },
-                        "scheme": "http",
-                        "pass_host": "pass"
+                            "127.0.0.1:1970": 1
+                        }
                     }
                 }]], spec)
             )

Reply via email to