File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
src/main/java/com/networknt/schema Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -56,15 +56,16 @@ protected JsonSchema getParentSchema() {
5656 protected JsonSchema getSubSchema () {
5757 return subSchema ;
5858 }
59-
59+
6060 protected boolean hasSubSchema () {
6161 return subSchema != null ;
6262 }
6363
6464 protected JsonSchema obainSubSchemaNode (JsonNode schemaNode ){
6565 JsonNode node = schemaNode .get ("id" );
6666 if (node == null ) return null ;
67-
67+ if (node .equals (schemaNode .get ("$schema" ))) return null ;
68+
6869 try {
6970 JsonSchemaFactory factory = new JsonSchemaFactory ();
7071 URL url = new URL (node .textValue ());
Original file line number Diff line number Diff line change @@ -62,9 +62,8 @@ public class JsonSchema extends BaseJsonValidator {
6262 */
6363 public JsonNode getRefSchemaNode (String ref ) {
6464 JsonSchema schema = findAncestor ();
65- JsonNode schemaNode = schema .getSchemaNode ();
66- JsonNode node = null ;
67-
65+ JsonNode node = schema .getSchemaNode ();
66+
6867 if (ref .startsWith ("#/" )) {
6968 // handle local ref
7069 String [] keys = ref .substring (2 ).split ("/" );
@@ -75,13 +74,16 @@ public JsonNode getRefSchemaNode(String ref) {
7574 }
7675 Matcher matcher = intPattern .matcher (key );
7776 if (matcher .matches ()) {
78- node = schemaNode .get (Integer .parseInt (key ));
77+ node = node .get (Integer .parseInt (key ));
7978 } else {
80- node = schemaNode .get (key );
79+ node = node .get (key );
8180 }
8281 if (node == null && schema .hasSubSchema ()){
8382 node = schema .getSubSchema ().getRefSchemaNode (ref );
8483 }
84+ if (node == null ){
85+ break ;
86+ }
8587 }
8688 }
8789 return node ;
You can’t perform that action at this time.
0 commit comments