JSON模式验证器以验证字符串长度

时间:2020-04-07 12:34:53

标签: spring-boot json-schema-validator

我们正在使用JSON模式验证器来验证POST请求正文。我们有一个属性'description',其类型为字符串,最大长度为1000。以下是JSON配置。问题是,对于请求,如果它具有应像@那样编码的字符,并且具有编码字符,则此验证无法按预期进行。也就是说,由于@被编码为%40,因此失败。

我阅读了文档,发现默认情况下,模式验证器不会解码字符串。但是应该有一些配置可以让我对其进行解码。我尝试使用contentEncoding属性,但没有帮助。有人对此有任何建议

"$schema": "http://json-schema.org/draft-03/schema#",
"type": "object",
"title": "Create ",
"description": "Create",
"properties": {
    "description": {
        "type": ["string", "null"],
        "maxLength": 1000,
        "required": false
    }
}

0 个答案:

没有答案