json-schemaを使用して検証ルールを作成するのは難しいです。ここではJSON形式で自分のデータである。anyOfを使用してネストされたプロパティを検証する方法
{
"headers" : {
"api_key" : "aaa-bbb-ccc-ddd-eee"
},
"query_string" : {
"apikey" : "aaa-bbb-ccc-ddd-eee"
}
}
私が言うルールが必要です。私はそれが私が「anyOf
だと思う
{
"title": "Application Get Single",
"type": "object",
"properties": {
"headers": {
"type": "object",
"properties": {
"api_key": {
"type": "string"
}
}
},
"query_string": {
"type": "object",
"properties": {
"apikey": {
"type": "string"
}
}
}
},
"anyOf": [
{"required": ["headers"["api_key"]]}, // what should this be??
{"required": ["query_string"["apikey"]]} // what should this be??
]
}
:
ここAt least "headers->api_key" or "query_string->apikey" needs to be present in the json, but not both.
を自分のスキーマ検証はこれまでにあり探していますが、上記のネストされたjson項目を参照する方法はわかりません。
JSON syntax is malformed
私はこのためにPHPで働いていると私はJustin Rainbowを使用しています:私はエラーを取得する瞬間
。