Skip to content

Commit a511337

Browse files
committed
Clean
1 parent 805632d commit a511337

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
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/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)