@@ -67,4 +67,57 @@ void annotationsOnlyDroppedAtTheEndOfSchemaProcessing() {
6767 assertEquals ("unevaluatedProperties" , assertions .get (1 ).getType ());
6868 assertEquals ("key4" , assertions .get (1 ).getProperty ());
6969 }
70+
71+ /**
72+ * Issue 967.
73+ */
74+ @ Test
75+ void subschemaProcessing () {
76+ String schemaData = "{\r \n "
77+ + " \" $schema\" : \" https://json-schema.org/draft/2019-09/schema\" ,\r \n "
78+ + " \" $defs\" : {\r \n "
79+ + " \" subschema\" : {\r \n "
80+ + " \" type\" : \" object\" ,\r \n "
81+ + " \" required\" : [\" group\" ],\r \n "
82+ + " \" properties\" : {\r \n "
83+ + " \" group\" : {\r \n "
84+ + " \" type\" : \" object\" ,\r \n "
85+ + " \" additionalProperties\" : false,\r \n "
86+ + " \" required\" : [\" parentprop\" ],\r \n "
87+ + " \" properties\" : {\r \n "
88+ + " \" parentprop\" : {\r \n "
89+ + " \" type\" : \" string\" \r \n "
90+ + " }\r \n "
91+ + " }\r \n "
92+ + " }\r \n "
93+ + " }\r \n "
94+ + " }\r \n "
95+ + " },\r \n "
96+ + " \" type\" : \" object\" ,\r \n "
97+ + " \" unevaluatedProperties\" : false,\r \n "
98+ + " \" allOf\" : [\r \n "
99+ + " {\" properties\" : { \" group\" : {\" type\" :\" object\" } } },\r \n "
100+ + " {\" $ref\" : \" #/$defs/subschema\" }\r \n "
101+ + " ],\r \n "
102+ + " \" required\" : [\" childprop\" ],\r \n "
103+ + " \" properties\" : {\r \n "
104+ + " \" childprop\" : {\r \n "
105+ + " \" type\" : \" string\" \r \n "
106+ + " }\r \n "
107+ + " }\r \n "
108+ + "}" ;
109+ String inputData = "{\r \n "
110+ + " \" childprop\" : \" something\" ,\r \n "
111+ + " \" group\" : {\r \n "
112+ + " \" parentprop\" :\" something\" ,\r \n "
113+ + " \" notallowed\" : false\r \n "
114+ + " }\r \n "
115+ + "}" ;
116+ JsonSchema schema = JsonSchemaFactory .getInstance (VersionFlag .V201909 ).getSchema (schemaData );
117+ Set <ValidationMessage > messages = schema .validate (inputData , InputFormat .JSON );
118+ assertEquals (1 , messages .size ());
119+ List <ValidationMessage > assertions = messages .stream ().collect (Collectors .toList ());
120+ assertEquals ("additionalProperties" , assertions .get (0 ).getType ());
121+ assertEquals ("notallowed" , assertions .get (0 ).getProperty ());
122+ }
70123}
0 commit comments