[英]Validating json payload against swagger file - json-schema-validator
[英]How to validate JSON against hyper-schema with json-schema-validator
我無法弄清楚如何正確設置超模式以與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字段外,還有其他配置要使用超模式嗎?
這是因為您的$ schema錯誤!
它應該是http://json-schema.org/draft-04/hyper-schema#
。 有關知名URI的列表,請參見核心規范的第6節 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.