@@ -103,40 +103,54 @@ private void doValidate(Set<ValidationMessage> errors, int i, JsonNode node, Jso
103103
104104 @ Override
105105 public Set <ValidationMessage > walk (JsonNode node , JsonNode rootNode , String at , boolean shouldValidateSchema ) {
106- if (shouldValidateSchema ) {
107- return validate (node , rootNode , at );
108- } else {
109- HashSet <ValidationMessage > validationMessages = new LinkedHashSet <ValidationMessage >();
110- if (node .isArray ()) {
111- int i = 0 ;
112- for (JsonNode n : node ) {
113- doWalk (i , n , rootNode , at );
114- i ++;
115- }
116- } else {
117- doWalk (0 , node , rootNode , at );
106+ HashSet <ValidationMessage > validationMessages = new LinkedHashSet <ValidationMessage >();
107+ if (node .isArray ()) {
108+ int i = 0 ;
109+ for (JsonNode n : node ) {
110+ doWalk (validationMessages , i , n , rootNode , at , shouldValidateSchema );
111+ i ++;
118112 }
119- return validationMessages ;
113+ } else {
114+ doWalk (validationMessages , 0 , node , rootNode , at , shouldValidateSchema );
120115 }
116+ return validationMessages ;
121117 }
122118
123- private void doWalk (int i , JsonNode node , JsonNode rootNode , String at ) {
119+ private void doWalk (HashSet <ValidationMessage > validationMessages , int i , JsonNode node , JsonNode rootNode ,
120+ String at , boolean shouldValidateSchema ) {
124121 if (schema != null ) {
122+ if (shouldValidateSchema ) {
123+ validationMessages .addAll (schema .validate (node , rootNode , at ));
124+ }
125125 // Walk the schema.
126- schema .walk (node , rootNode , at + "[" + i + "]" , false );
126+ validationMessages . addAll ( schema .walk (node , rootNode , at + "[" + i + "]" , shouldValidateSchema ) );
127127 }
128128
129129 if (tupleSchema != null ) {
130130 if (i < tupleSchema .size ()) {
131+ if (shouldValidateSchema ) {
132+ validationMessages .addAll (tupleSchema .get (i ).validate (node , rootNode , at ));
133+ }
131134 // walk tuple schema
132- tupleSchema .get (i ).walk (node , rootNode , at + "[" + i + "]" , false );
135+ validationMessages . addAll ( tupleSchema .get (i ).walk (node , rootNode , at + "[" + i + "]" , shouldValidateSchema ) );
133136 } else {
134137 if (additionalSchema != null ) {
138+ if (shouldValidateSchema ) {
139+ validationMessages .addAll (additionalSchema .validate (node , rootNode , at ));
140+ }
135141 // walk additional item schema
136- additionalSchema .walk (node , rootNode , at + "[" + i + "]" , false );
142+ validationMessages . addAll ( additionalSchema .walk (node , rootNode , at + "[" + i + "]" , shouldValidateSchema ) );
137143 }
138144 }
139145 }
140146 }
141147
148+ public List <JsonSchema > getTupleSchema () {
149+ return this .tupleSchema ;
150+ }
151+
152+ public JsonSchema getSchema () {
153+ return schema ;
154+ }
155+
142156}
0 commit comments