Skip to content

Commit

Permalink
schema path fixes in oneOf,allOf and anyOf validators (#628)
Browse files Browse the repository at this point in the history
Co-authored-by: Prashanth Josyula <prashanth.chaitanya@prashan-wsmtedt.internal.salesforce.com>
  • Loading branch information
prashanthjos and prashanthjos authored Dec 8, 2022
1 parent ba3c84a commit acd5839
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/networknt/schema/AllOfValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public AllOfValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentS
int size = schemaNode.size();
for (int i = 0; i < size; i++) {
schemas.add(new JsonSchema(validationContext,
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue(),
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue() + "/" + i,
parentSchema.getCurrentUri(),
schemaNode.get(i),
parentSchema));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/networknt/schema/AnyOfValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AnyOfValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentS
int size = schemaNode.size();
for (int i = 0; i < size; i++) {
schemas.add(new JsonSchema(validationContext,
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue(),
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue() + "/" + i,
parentSchema.getCurrentUri(),
schemaNode.get(i),
parentSchema));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/networknt/schema/BaseJsonValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected void preloadJsonSchemas(final Collection<JsonSchema> schemas) {
}

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

/* ********************** START OF OpenAPI 3.0.x DISCRIMINATOR METHODS ********************************* */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/networknt/schema/OneOfValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public OneOfValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentS
int size = schemaNode.size();
for (int i = 0; i < size; i++) {
JsonNode childNode = schemaNode.get(i);
JsonSchema childSchema = new JsonSchema(validationContext, parentSchema.getSchemaPath() + "/" + getValidatorType().getValue(), parentSchema.getCurrentUri(), childNode, parentSchema);
JsonSchema childSchema = new JsonSchema(validationContext, parentSchema.getSchemaPath() + "/" + getValidatorType().getValue() + "/" + i, parentSchema.getCurrentUri(), childNode, parentSchema);
schemas.add(new ShortcutValidator(childNode, parentSchema, validationContext, childSchema));
}
parseErrorCode(getValidatorType().getErrorCodeKey());
Expand Down

0 comments on commit acd5839

Please sign in to comment.