Conversation
…into id and anchor, ignore other properties of ref objects.
…s and items validations.
|
The previous commit was umarshaling the draft7 fields, and adapting it to the draft2020 new field. For example splitting the dependencies field into the DependentRequired and DependentSchemas, and then use those for the validation. I had to introduce 2 helper structs to map the union types for the Dependencies field and for the Items field |
…n to explicit use DependencySchemas
| {"/allOf/1", s.AllOf[1]}, | ||
| {"/definitions/~1~0", s.Definitions["/~"]}, | ||
| {"/definitions/~01", s.Definitions["~1"]}, | ||
| {"/items/0", s.ItemsArray[0]}, |
There was a problem hiding this comment.
Let's add a case for /items when Items is non-nil.
There was a problem hiding this comment.
Items and ItemsArray are mutually exclusive, which is one of the validations done in basicChecks.
I was already checking non-nil items in {"/items/1/items", s.ItemsArray[1].Items}.
Adding an Items value to the root of the test Schema will break the "/items/0" tests, since lookupSchemaField will retrieve the Items Schema when processing the "items" segment.
It will not throw an error since the basicCheck happens during resolution which we are skipping here.
jba
left a comment
There was a problem hiding this comment.
Also there should be a comment somewhere that notes why the schema field map has the right value for "dependencies". Maybe it has to do with the order they're listed somewhere? If so, note that the order matters, and why.
|
The value of "dependencies" is defined after a sort of schemaFieldInfos. This sort is unstable and is comparing the json.names of DependencyStrings and DependencySchemas which are both "dependencies". Since the sort is unstable it cannot be guarantied that "dependencies" has the correct value and it should be treated as an edge case. if name == "dependencies" {
return v.FieldByName("DependencySchemas")
}
if sf, ok := schemaFieldMap[name]; ok {I'll add a quick comment explaining that then |
For #4
Supersedes #6
Added draft-7 conformance tests, including format.json which is ignored for draft 2020.
Added Draft to resolved.
When marshaling, kept @slimslenderslacks logic to use prefix items + items. Added logic to separate dependencies field, separate id behavior into id and anchor, replace Ref to items.
When resolving and validating ignore other properties of ref objects