Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(grpc-transcode): adjust the position of enums in pb_option_def #11448

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apisix/plugins/grpc-transcode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ local plugin_name = "grpc-transcode"
local pb_option_def = {
{ description = "enum as result",
type = "string",
enum = {"int64_as_number", "int64_as_string", "int64_as_hexstring"},
enum = {"enum_as_name", "enum_as_value"},
},
{ description = "int64 as result",
type = "string",
enum = {"enum_as_name", "enum_as_value"},
enum = {"int64_as_number", "int64_as_string", "int64_as_hexstring"},
},
{ description ="default values option",
type = "string",
Expand Down
43 changes: 43 additions & 0 deletions t/plugin/grpc-transcode3.t
Original file line number Diff line number Diff line change
Expand Up @@ -576,3 +576,46 @@ location /t {
}
--- response_body
passed



=== TEST 14: pb_option - check the matchings between enum and category
--- config
location /t {
content_by_lua_block {
local ngx_re_match = ngx.re.match
local plugin = require("apisix.plugins.grpc-transcode")

local pb_option_def = plugin.schema.properties.pb_option.items.anyOf

local patterns = {
[[^enum_as_.+$]],
[[^int64_as_.+$]],
[[^.+_default_.+$]],
[[^.+_hooks$]],
}

local function check_pb_option_enum_category()
for i, category in ipairs(pb_option_def) do
for _, enum in ipairs(category.enum) do
if not ngx_re_match(enum, patterns[i], "jo") then
return ([[mismatch between enum("%s") and category("%s")]]):format(
enum, category.description)
end
end
end
end

local err = check_pb_option_enum_category()
if err then
ngx.say(err)
return
end

ngx.say("done")
}
}
--- request
GET /t
--- response_body
done
Loading