Skip to content

Commit

Permalink
fixes #187 SchemaValidatorsConfig not propagated
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu committed Oct 4, 2019
1 parent f9b467d commit 6db536a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/networknt/schema/JsonSchemaFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private JsonSchema newJsonSchema(final URI schemaUri, final JsonNode schemaNode,

protected ValidationContext createValidationContext(final JsonNode schemaNode) {
final JsonMetaSchema jsonMetaSchema = findMetaSchemaForSchema(schemaNode);
return new ValidationContext(this.uriFactory, jsonMetaSchema, this);
return new ValidationContext(this.uriFactory, jsonMetaSchema, this, null);
}

private JsonMetaSchema findMetaSchemaForSchema(final JsonNode schemaNode) {
Expand Down Expand Up @@ -299,7 +299,7 @@ public JsonSchema getSchema(final URI schemaUri, final SchemaValidatorsConfig co
final JsonMetaSchema jsonMetaSchema = findMetaSchemaForSchema(schemaNode);

if (idMatchesSourceUri(jsonMetaSchema, schemaNode, schemaUri)) {
return new JsonSchema(new ValidationContext(this.uriFactory, jsonMetaSchema, this), mappedUri, schemaNode, true /*retrieved via id, resolving will not change anything*/);
return new JsonSchema(new ValidationContext(this.uriFactory, jsonMetaSchema, this, config), mappedUri, schemaNode, true /*retrieved via id, resolving will not change anything*/);
}

return newJsonSchema(mappedUri, schemaNode, config);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/networknt/schema/ValidationContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ValidationContext {
private SchemaValidatorsConfig config;
private final Map<String, JsonSchemaRef> refParsingInProgress = new HashMap<>();

public ValidationContext(URIFactory uriFactory, JsonMetaSchema metaSchema, JsonSchemaFactory jsonSchemaFactory) {
public ValidationContext(URIFactory uriFactory, JsonMetaSchema metaSchema, JsonSchemaFactory jsonSchemaFactory, SchemaValidatorsConfig config) {
if (uriFactory == null) {
throw new IllegalArgumentException("URIFactory must not be null");
}
Expand All @@ -42,6 +42,7 @@ public ValidationContext(URIFactory uriFactory, JsonMetaSchema metaSchema, JsonS
this.uriFactory = uriFactory;
this.metaSchema = metaSchema;
this.jsonSchemaFactory = jsonSchemaFactory;
this.config = config;
}

public JsonValidator newValidator(String schemaPath, String keyword /* keyword */, JsonNode schemaNode,
Expand Down

0 comments on commit 6db536a

Please sign in to comment.