diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua index e3e9a05aca26..ae35ba4f0ffb 100644 --- a/apisix/schema_def.lua +++ b/apisix/schema_def.lua @@ -325,7 +325,7 @@ local nodes_schema = { type = "object", } }, - required = {"host", "port", "weight"}, + required = {"host", "weight"}, }, } } diff --git a/t/admin/schema-validate.t b/t/admin/schema-validate.t index 46f51021edfd..81698b243ee7 100644 --- a/t/admin/schema-validate.t +++ b/t/admin/schema-validate.t @@ -398,3 +398,44 @@ location /t { --- error_code: 400 --- response {"error_msg":"allOf 1 failed: value should match only one schema, but matches none"} + + + +=== TEST 13: Check node_schema optional port +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes', + ngx.HTTP_POST, + { + uri = "/hello", + upstream = { + type = "roundrobin", + nodes = { + { host = "127.0.0.1:1980", weight = 1,} + } + }, + methods = {"GET"}, + } + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + + } + } +--- request +GET /t +--- response_body +passed + + + +=== TEST 14: Test route upstream +--- request +GET /hello +--- response_body +hello world