Closed mrehder closed 4 years ago
Hi. Can you please post a complete code example (with the head and base objects) that generates the error you mention? Thanks.
I can't share the full schemas. This is the essential info.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"X": {
"type": "array",
"mergeStrategy": "arrayMergeById",
"mergeOptions": {
"idRef": "/Y"
},
"items": {
"type": "object",
"anyOf": [
{
"required": [
"Y",
"Z"
]
},
{
"required": [
"Y",
"K"
]
}
],
"properties": {
"Y": {
"type": "string"
},
"Z": {
"type": "string"
},
"K": {
"type": "string"
}
},
"additionalProperties": false
},
"minItems": 1,
"uniqueItems": true
}
}
I suspect you're just missing a "mergeStrategy": "objectMerge"
at the same level as the anyOf
keyword.
What would it do at that level (under "type":"object" as a peer of "properties"?). This definition fragment defines no JSON content so it should be ignored in the merge. Basically "anyOf"/"oneOf" of "required" arrays should be skipped.
Also if the strategy is declared as a peer of the anyOf within the object of an array items, this could override the "arraymergeById" strategy declared above for the array.
No, sorry. Given the sparse information you provided (no actual error message, no data and code to reproduce your problem apart from the partial schema), the best guess I can give you is in my previous comment. If you would like to learn more about why jsonmerge handles anyOf/allOf keywords the way it does, I invite you to browse the commit logs and search past issues (e.g. #29). I also suggest you read through jsonmerge's README file. I'm not going to discuss this further.
I can't provide actual examples due to them being proprietary.
This is the traceback ( you didn't mention you needed that):
Traceback (most recent call last):
File "/usr/bin/jsonmerge", line 38, in
Thanks Mike
From: Tomaž Šolc notifications@github.com Sent: Monday, December 9, 2019 11:44 AM To: avian2/jsonmerge jsonmerge@noreply.github.com Cc: Michael Rehder Michael.Rehder@Amdocs.com; Author author@noreply.github.com Subject: Re: [avian2/jsonmerge] oneOf/anyOf of required incorrectly treated as branch (#45)
No, sorry. Given the sparse information you provided (no actual error message, no data and code to reproduce your problem apart from the partial schema), the best guess I can give you is in my previous comment. If you would like to learn more about why jsonmerge handles anyOf/allOf keywords the way it does, I invite you to browse the commit logs and search past issues (e.g. #29https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Favian2%2Fjsonmerge%2Fpull%2F29&data=02%7C01%7CMichael.Rehder%40Amdocs.com%7Cac7224b625b9441ec91308d77cc72431%7Cc8eca3ca127646d59d9da0f2a028920f%7C0%7C0%7C637115067053715604&sdata=UIOvFnAvKWcF3LGj0zEsu4Pqo6wUuexBwX9LrWDmXFo%3D&reserved=0). I also suggest you read through jsonmerge's README file. I'm not going to discuss this further.
- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Favian2%2Fjsonmerge%2Fissues%2F45%3Femail_source%3Dnotifications%26email_token%3DAC44PZ2R4DLUNVXCVS7ALNTQXZYVTA5CNFSM4JXA5YA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGJ2ZYQ%23issuecomment-563326178&data=02%7C01%7CMichael.Rehder%40Amdocs.com%7Cac7224b625b9441ec91308d77cc72431%7Cc8eca3ca127646d59d9da0f2a028920f%7C0%7C0%7C637115067053725598&sdata=09wuUCQcaMxXIAj4kzPfmb8ijWo068jP1FxkSTCo7Og%3D&reserved=0, or unsubscribehttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAC44PZ3BXGHENALJLUMVTJTQXZYVTANCNFSM4JXA5YAQ&data=02%7C01%7CMichael.Rehder%40Amdocs.com%7Cac7224b625b9441ec91308d77cc72431%7Cc8eca3ca127646d59d9da0f2a028920f%7C0%7C0%7C637115067053725598&sdata=qBDRKlDc9qo6DAg5P6G0dYOGA%2FVz%2BCWOgh9Wiv%2FP2fA%3D&reserved=0. This email and the information contained herein is proprietary and confidential and subject to the Amdocs Email Terms of Service, which you may review at https://www.amdocs.com/about/email-terms-of-service https://www.amdocs.com/about/email-terms-of-service
The below JSON Schema construct is purely about enforcement and not structure. This implements a variant schema enforcement (in the below it says that either A&B must be present or A&C must be present). This should be ignored for descent and not generate an error.
{ "type" : "object", "anyOf" : [ { "required" : [ "A", "B" ] }, { "required" : [ "A", "C" ] } ],