Skip to content

Commit acd5839

Browse files
authored
schema path fixes in oneOf,allOf and anyOf validators (#628)
Co-authored-by: Prashanth Josyula <[email protected]>
1 parent ba3c84a commit acd5839

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/main/java/com/networknt/schema/AllOfValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public AllOfValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentS
3434
int size = schemaNode.size();
3535
for (int i = 0; i < size; i++) {
3636
schemas.add(new JsonSchema(validationContext,
37-
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue(),
37+
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue() + "/" + i,
3838
parentSchema.getCurrentUri(),
3939
schemaNode.get(i),
4040
parentSchema));

src/main/java/com/networknt/schema/AnyOfValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public AnyOfValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentS
3737
int size = schemaNode.size();
3838
for (int i = 0; i < size; i++) {
3939
schemas.add(new JsonSchema(validationContext,
40-
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue(),
40+
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue() + "/" + i,
4141
parentSchema.getCurrentUri(),
4242
schemaNode.get(i),
4343
parentSchema));

src/main/java/com/networknt/schema/BaseJsonValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ protected void preloadJsonSchemas(final Collection<JsonSchema> schemas) {
182182
}
183183

184184
protected boolean isPartOfOneOfMultipleType() {
185-
return parentSchema.schemaPath.endsWith(ValidatorTypeCode.ONE_OF.getValue());
185+
return parentSchema.schemaPath.contains("/" + ValidatorTypeCode.ONE_OF.getValue() + "/");
186186
}
187187

188188
/* ********************** START OF OpenAPI 3.0.x DISCRIMINATOR METHODS ********************************* */

src/main/java/com/networknt/schema/OneOfValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public OneOfValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentS
119119
int size = schemaNode.size();
120120
for (int i = 0; i < size; i++) {
121121
JsonNode childNode = schemaNode.get(i);
122-
JsonSchema childSchema = new JsonSchema(validationContext, parentSchema.getSchemaPath() + "/" + getValidatorType().getValue(), parentSchema.getCurrentUri(), childNode, parentSchema);
122+
JsonSchema childSchema = new JsonSchema(validationContext, parentSchema.getSchemaPath() + "/" + getValidatorType().getValue() + "/" + i, parentSchema.getCurrentUri(), childNode, parentSchema);
123123
schemas.add(new ShortcutValidator(childNode, parentSchema, validationContext, childSchema));
124124
}
125125
parseErrorCode(getValidatorType().getErrorCodeKey());

0 commit comments

Comments
 (0)