Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/networknt/schema/utils/JsonNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static <T extends JsonNode> T get(JsonNode node, JsonNodePath path) {
@SuppressWarnings("unchecked")
public static <T extends JsonNode> T get(JsonNode node, Object propertyOrIndex) {
JsonNode value = null;
if (propertyOrIndex instanceof Number) {
if (propertyOrIndex instanceof Number && node.isArray()) {
value = node.get(((Number) propertyOrIndex).intValue());
} else {
value = node.get(propertyOrIndex.toString());
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/com/networknt/schema/oas/OpenApi30Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.networknt.schema.oas;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -64,4 +65,16 @@ void validateMetaSchema() {
assertEquals("required", list.get(1).getType());
assertEquals("bark", list.get(1).getProperty());
}

/**
* Tests that schema location with number in fragment can resolve.
*/
@Test
void jsonPointerWithNumberInFragment() {
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V7, builder -> builder
.metaSchema(OpenApi30.getInstance()).defaultMetaSchemaIri(OpenApi30.getInstance().getIri()));
JsonSchema schema = factory.getSchema(SchemaLocation.of(
"classpath:schema/oas/3.0/petstore.yaml#/paths/~1pet/post/responses/200/content/application~1json/schema"));
assertNotNull(schema);
}
}