Giter Site home page Giter Site logo

API schema validation about apisix HOT 4 CLOSED

apache avatar apache commented on May 7, 2024
API schema validation

from apisix.

Comments (4)

membphis avatar membphis commented on May 7, 2024

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, -- 报错
}

from apisix.

tianchaijz avatar tianchaijz commented on May 7, 2024

Maybe you can try my https://github.com/tianchaijz/lua-resty-jsonschema validator.

from apisix.

membphis avatar membphis commented on May 7, 2024

https://github.com/Tencent/rapidjson/blob/master/example/schemavalidator/schemavalidator.cpp

This is also a good alternative.

from apisix.

membphis avatar membphis commented on May 7, 2024

implemented already: 1737fb7

from apisix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.