File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
main/java/com/networknt/schema
test/java/com/networknt/schema/oas Expand file tree Collapse file tree 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) {
369369 Object segment = fragment .getElement (x );
370370 JsonNode subSchemaNode = getNode (parentNode , segment );
371371 if (subSchemaNode != null ) {
372- if (segment instanceof Number ) {
372+ if (segment instanceof Number && parentNode . isArray () ) {
373373 int index = ((Number ) segment ).intValue ();
374374 schemaLocation = schemaLocation .append (index );
375375 evaluationPath = evaluationPath .append (index );
Original file line number Diff line number Diff line change 2828import com .networknt .schema .InputFormat ;
2929import com .networknt .schema .JsonSchema ;
3030import com .networknt .schema .JsonSchemaFactory ;
31+ import com .networknt .schema .PathType ;
3132import com .networknt .schema .SchemaLocation ;
33+ import com .networknt .schema .SchemaValidatorsConfig ;
3234import com .networknt .schema .SpecVersion .VersionFlag ;
3335import com .networknt .schema .ValidationMessage ;
3436
@@ -74,7 +76,10 @@ void jsonPointerWithNumberInFragment() {
7476 JsonSchemaFactory factory = JsonSchemaFactory .getInstance (VersionFlag .V7 , builder -> builder
7577 .metaSchema (OpenApi30 .getInstance ()).defaultMetaSchemaIri (OpenApi30 .getInstance ().getIri ()));
7678 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 ());
7881 assertNotNull (schema );
82+ assertEquals ("$.paths['/pet'].post.responses['200'].content['application/json'].schema" ,
83+ schema .getEvaluationPath ().toString ());
7984 }
8085}
You can’t perform that action at this time.
0 commit comments