File tree 2 files changed +7
-2
lines changed
main/java/com/networknt/schema
test/java/com/networknt/schema/oas
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -369,7 +369,7 @@ public JsonSchema getSubSchema(JsonNodePath fragment) {
369
369
Object segment = fragment .getElement (x );
370
370
JsonNode subSchemaNode = getNode (parentNode , segment );
371
371
if (subSchemaNode != null ) {
372
- if (segment instanceof Number ) {
372
+ if (segment instanceof Number && parentNode . isArray () ) {
373
373
int index = ((Number ) segment ).intValue ();
374
374
schemaLocation = schemaLocation .append (index );
375
375
evaluationPath = evaluationPath .append (index );
Original file line number Diff line number Diff line change 28
28
import com .networknt .schema .InputFormat ;
29
29
import com .networknt .schema .JsonSchema ;
30
30
import com .networknt .schema .JsonSchemaFactory ;
31
+ import com .networknt .schema .PathType ;
31
32
import com .networknt .schema .SchemaLocation ;
33
+ import com .networknt .schema .SchemaValidatorsConfig ;
32
34
import com .networknt .schema .SpecVersion .VersionFlag ;
33
35
import com .networknt .schema .ValidationMessage ;
34
36
@@ -74,7 +76,10 @@ void jsonPointerWithNumberInFragment() {
74
76
JsonSchemaFactory factory = JsonSchemaFactory .getInstance (VersionFlag .V7 , builder -> builder
75
77
.metaSchema (OpenApi30 .getInstance ()).defaultMetaSchemaIri (OpenApi30 .getInstance ().getIri ()));
76
78
JsonSchema schema = factory .getSchema (SchemaLocation .of (
77
- "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/responses/200/content/application~1json/schema" ));
79
+ "classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/responses/200/content/application~1json/schema" ),
80
+ SchemaValidatorsConfig .builder ().pathType (PathType .JSON_PATH ).build ());
78
81
assertNotNull (schema );
82
+ assertEquals ("$.paths['/pet'].post.responses['200'].content['application/json'].schema" ,
83
+ schema .getEvaluationPath ().toString ());
79
84
}
80
85
}
You can’t perform that action at this time.
0 commit comments