Skip to content

Commit

Permalink
Correcting the oneOf,anyOf and allOf child schema validators to use t…
Browse files Browse the repository at this point in the history
…he full path (#626)

Co-authored-by: Prashanth Josyula <prashanth.chaitanya@prashan-wsmtedt.internal.salesforce.com>
  • Loading branch information
prashanthjos and prashanthjos committed Dec 2, 2022
1 parent b92359f commit 63e0ceb
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,
getValidatorType().getValue(),
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue(),
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,
getValidatorType().getValue(),
parentSchema.getSchemaPath() + "/" + getValidatorType().getValue(),
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.equals(ValidatorTypeCode.ONE_OF.getValue());
return parentSchema.schemaPath.endsWith(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, getValidatorType().getValue(), parentSchema.getCurrentUri(), childNode, parentSchema);
JsonSchema childSchema = new JsonSchema(validationContext, parentSchema.getSchemaPath() + "/" + getValidatorType().getValue(), parentSchema.getCurrentUri(), childNode, parentSchema);
schemas.add(new ShortcutValidator(childNode, parentSchema, validationContext, childSchema));
}
parseErrorCode(getValidatorType().getErrorCodeKey());
Expand Down

0 comments on commit 63e0ceb

Please sign in to comment.