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
8 changes: 4 additions & 4 deletions src/main/java/com/networknt/schema/dialect/Dialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ public String readDynamicAnchor(JsonNode schemaNode) {
return null;
}

private static String readText(JsonNode node, String field) {
JsonNode fieldNode = node.get(field);
return fieldNode == null ? null : fieldNode.asString();
}
private static String readText(JsonNode node, String field) {
JsonNode fieldNode = node.get(field);
return fieldNode == null ? null : fieldNode.stringValue(null);
}

public String getId() {
return this.id;
Expand Down
40 changes: 40 additions & 0 deletions src/test/java/com/networknt/schema/Issue1246Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2026 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.networknt.schema;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

class Issue1246Test {
@Test
void draft4SchemaIdResolutionIgnoresNonTextIdPropertySchemas() {
String schemaData = "{\n"
+ " \"id\": \"https://www.example.org/schema#\",\n"
+ " \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n"
+ " \"type\": \"object\",\n"
+ " \"properties\": {\n"
+ " \"title\": {\n"
+ " \"$ref\": \"http://json-schema.org/draft-04/schema#/properties/title\"\n"
+ " }\n"
+ " }\n"
+ "}";
Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4)
.getSchema(schemaData);

assertTrue(schema.validate("{\"title\":\"Sample API\"}", InputFormat.JSON).isEmpty());
}
}
Loading