Add schema tests (#1260)#1261
Conversation
0379bf3 to
90b380b
Compare
|
Yes, the root cause of the issue described in GitHub Issue #1260 #1260 is a set of syntax errors in the Root Cause Analysis1. Misplacement of allOf inside propertiesIn the user's schema: Because "allOf" is defined inside the "properties" block of "questions" , the validator treats "allOf" as a property name rather than the JSON Schema allOf According to the JSON Schema specification, the schema for any property under "properties" must be a valid JSON Schema (which can only be a JSON object or a │ SchemaException: Schema at […]/allOf must be object or boolean but was ARRAY 2. Invalid Subschema syntaxFurthermore, inside the array, they wrote: This is also invalid JSON Schema syntax (it is an object using a custom property key assessmentDate with a string value, rather than a proper {"$ref": ...} Why it worked in v3.0.4 but fails in v3.0.5• In v3.0.4 : The library did not validate loaded schema node types at compilation/load time. Because the input JSON never actually contained a property named How to Fix the SchemaThe user's schema should be corrected to place allOf as a sibling keyword of properties rather than nesting it inside, and specify the subschemas correctly: |
Add extra tests for stricter schema validation. These tests pass against 3.0.4 (pre networknt#1250) as well as 3.0.5 (post networknt#1250).
90b380b to
3f0478b
Compare
|
@stevehu Thanks for your thorough analysis. I must admit that that specific part of the JSON Schema draft was always a bit foggy. I've updated the schema in the PR, and the tests now pass against 3.0.4 as well as 3.0.5. Might be worth including these to avoid future regressions. Merge, or close, at your discretion. |
These tests pass against 3.0.4 as well as 3.0.5.