1

我无法弄清楚如何正确设置超模式以与 json-schema-validator 一起使用。我使用的是 json-schema-validator 的 java 版本,版本是 2.2.5。

我的架构是:

{
"$schema": "http://json-schema.org/draftv4/hyper-schema#",
"title": "User object",
"description": "A user representation",
"type": "object",
"properties": {
    "email": {
        "description": "The user's email address",
        "format":"email",
        "maxLength": 255
    },
    "picture": {
        "description": "The user's picture",
        "type": "string",
        "media": {
            "binaryEncoding": "base64",
            "type": "image/png"
        }
    }
}
}

我的 json 对象是:

{"email":"k@w.de",
"picture":null}

现在,当我将架构加载到JsonSchemaFactory并打算开始验证时,我收到以下警告:

warning: the following keywords are unknown and will be ignored: [media]
level: "warning"
schema: {"loadingURI":"#","pointer":"/properties/picture"}
domain: "syntax"
ignored: ["media"]

除了 $schema 字段之外,还有什么可以配置使用超模式的吗?

4

1 回答 1

0

这是因为您的 $schema 错误!

应该是http://json-schema.org/draft-04/hyper-schema#。有关知名 URI 的列表,请参阅核心规范的第 6 节。

于 2014-11-02T18:07:05.717 回答