|
| 1 | +/* |
| 2 | + * Copyright (c) 2026 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.networknt.schema; |
| 17 | + |
| 18 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 19 | + |
| 20 | +import org.junit.jupiter.api.Test; |
| 21 | + |
| 22 | +class Issue1246Test { |
| 23 | + @Test |
| 24 | + void draft4SchemaIdResolutionIgnoresNonTextIdPropertySchemas() { |
| 25 | + String schemaData = "{\n" |
| 26 | + + " \"id\": \"https://www.example.org/schema#\",\n" |
| 27 | + + " \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n" |
| 28 | + + " \"type\": \"object\",\n" |
| 29 | + + " \"properties\": {\n" |
| 30 | + + " \"title\": {\n" |
| 31 | + + " \"$ref\": \"http://json-schema.org/draft-04/schema#/properties/title\"\n" |
| 32 | + + " }\n" |
| 33 | + + " }\n" |
| 34 | + + "}"; |
| 35 | + Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4) |
| 36 | + .getSchema(schemaData); |
| 37 | + |
| 38 | + assertTrue(schema.validate("{\"title\":\"Sample API\"}", InputFormat.JSON).isEmpty()); |
| 39 | + } |
| 40 | +} |
0 commit comments