-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
API schema validation #6
Labels
enhancement
New feature or request
Milestone
Comments
old version which I designed, I think we can drop it. local schema = {
-- num1 = 0,
num2 = "num",
num3 = "int",
-- num4 = {0, max = 100, min = 10},
num5 = {"int", range={1, 10}, max = 10, min = 1, default = 2},
-- str1 = "",
str2 = "string",
str3 = {"string", default = "a", max_len = 10, min_len = 1, dict = {"a", "b", "c"}},
-- bool1 = true,
bool2 = "bool",
bool3 = {"bool", default = true},
-- table1 = {},
table2 = "table",
table2 = "array",
table2 = "hash",
table3 = {"array", elements = {"int", dict={3, 4, 5}, max_len = 10, min_len = 1}},
table4 = {"hash", elements = {
-- sub schema
num2 = "num",
num3 = "int",
}},
}
-- white mode: 只允许 schema 中描述定义的 key 值,不允许有任何多余
-- black mode: 允许出现 schema 描述之外的 key 存在
local conf = {
sss = 1, -- 报错
} |
Maybe you can try my https://github.com/tianchaijz/lua-resty-jsonschema validator. |
This is also a good alternative. |
implemented already: 1737fb7 |
idbeta
pushed a commit
to idbeta/apisix
that referenced
this issue
Sep 10, 2020
* feature: support more operators when compare vars. Fix apache#6.
This was referenced Mar 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the goal:
how about this:
-- JSON schema validation
https://github.com/jdesgats/ljsonschema
https://github.com/epoberezkin/ajv
The text was updated successfully, but these errors were encountered: