Skip to content

Commit 3e07f47

Browse files
committed
Clean
1 parent 805632d commit 3e07f47

File tree

4 files changed

+15
-31
lines changed

4 files changed

+15
-31
lines changed

src/main/java/com/networknt/schema/keyword/UnionTypeValidator.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ public UnionTypeValidator(SchemaLocation schemaLocation, JsonNode schemaNode, Sc
5757
sep = ", ";
5858

5959
if (n.isObject()) {
60-
// TODO: Check if the evaluation path is really as follows...
61-
schemas.add(schemaContext.newSchema(schemaLocation.append(KeywordType.TYPE.getValue()),
62-
n, parentSchema));
60+
schemas.add(schemaContext.newSchema(schemaLocation.append(i), n, parentSchema));
6361
} else {
64-
schemas.add(new TypeValidator(schemaLocation.append(i), n, parentSchema,
65-
schemaContext));
62+
schemas.add(new TypeValidator(schemaLocation.append(i), n, parentSchema, schemaContext));
6663
}
6764
i++;
6865
}

src/main/java/com/networknt/schema/utils/JsonNodeTypes.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class JsonNodeTypes {
1717

1818
public static boolean isNodeNullable(JsonNode schema){
1919
JsonNode nullable = schema.get(NULLABLE);
20-
return nullable != null && nullable.asBoolean();
20+
return nullable != null && nullable.asBoolean();
2121
}
2222

2323
public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Schema parentSchema, SchemaContext schemaContext, ExecutionContext executionContext) {
@@ -53,18 +53,18 @@ public static boolean equalsToSchemaType(JsonNode node, JsonType schemaType, Sch
5353
if (!config.isStrict("type", Boolean.TRUE) && isEnumObjectSchema(parentSchema, executionContext)) {
5454
return true;
5555
}
56-
if (config != null && config.isTypeLoose()) {
56+
if (config.isTypeLoose()) {
5757
// if typeLoose is true, everything can be a size 1 array
5858
if (schemaType == JsonType.ARRAY) {
5959
return true;
6060
}
6161
if (nodeType == JsonType.STRING) {
6262
if (schemaType == JsonType.INTEGER) {
63-
return Strings.isInteger(node.textValue());
63+
return Strings.isInteger(node.textValue());
6464
} else if (schemaType == JsonType.BOOLEAN) {
65-
return Strings.isBoolean(node.textValue());
65+
return Strings.isBoolean(node.textValue());
6666
} else if (schemaType == JsonType.NUMBER) {
67-
return Strings.isNumeric(node.textValue());
67+
return Strings.isNumeric(node.textValue());
6868
}
6969
}
7070
}

src/test/java/com/networknt/schema/Issue1091Test.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,17 @@
1818
import static org.junit.jupiter.api.Assertions.assertEquals;
1919

2020
import java.util.List;
21-
import java.util.stream.Collectors;
2221

2322
import org.junit.jupiter.api.Disabled;
2423
import org.junit.jupiter.api.Test;
2524

26-
import com.fasterxml.jackson.databind.JsonNode;
27-
import com.networknt.schema.serialization.JsonMapperFactory;
28-
2925
class Issue1091Test {
3026
@Test
3127
@Disabled // Disabled as this test takes quite long to run for ci
3228
void testHasAdjacentKeywordInEvaluationPath() throws Exception {
33-
SchemaRegistryConfig config = SchemaRegistryConfig.builder().cacheRefs(false).build();
34-
35-
Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4, builder -> builder.schemaRegistryConfig(config))
29+
Schema schema = SchemaRegistry.withDefaultDialect(SpecificationVersion.DRAFT_4)
3630
.getSchema(SchemaLocation.of("classpath:schema/issue1091.json"));
37-
JsonNode node = JsonMapperFactory.getInstance()
38-
.readTree(Issue1091Test.class.getClassLoader().getResource("data/issue1091.json"));
39-
40-
List<String> messages = schema.validate(node)
41-
.stream()
42-
.map(Error::getMessage)
43-
.collect(Collectors.toList());
44-
45-
assertEquals(0, messages.size());
31+
List<Error> errors = schema.validate(AbsoluteIri.of("classpath:data/issue1091.json"), InputFormat.JSON);
32+
assertEquals(0, errors.size());
4633
}
4734
}

src/test/java/com/networknt/schema/PatternPropertiesValidatorTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ void annotation() {
135135
+ "}";
136136
OutputUnit outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> {
137137
executionContext.executionConfig(executionConfig -> executionConfig
138-
.annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true));
139-
});
138+
.annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true));
139+
});
140140
Set<String> patternProperties = (Set<String>) outputUnit.getAnnotations().get("patternProperties");
141141
assertTrue(patternProperties.isEmpty());
142142

@@ -146,12 +146,12 @@ void annotation() {
146146
+ "}";
147147
outputUnit = schema.validate(inputData, InputFormat.JSON, OutputFormat.HIERARCHICAL, executionContext -> {
148148
executionContext.executionConfig(executionConfig -> executionConfig
149-
.annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true));
150-
});
149+
.annotationCollectionEnabled(true).annotationCollectionFilter(keyword -> true));
150+
});
151151
patternProperties = (Set<String>) outputUnit.getAnnotations().get("patternProperties");
152152
Set<String> all = new HashSet<>();
153153
all.add("valid_array");
154154
all.add("valid_string");
155-
assertTrue(patternProperties.containsAll(patternProperties));
155+
assertTrue(patternProperties.containsAll(all));
156156
}
157157
}

0 commit comments

Comments
 (0)