Skip to content

Commit

Permalink
Add schema path in contains validator; apply proper formatting in pro…
Browse files Browse the repository at this point in the history
…per commits
  • Loading branch information
ueco authored and Stranger6667 committed Jun 18, 2021
1 parent b2a44a4 commit 61fa7ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion jsonschema/src/compilation/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<'a> CompilationContext<'a> {
Ok(CompilationContext {
scope: Cow::Borrowed(self.scope.as_ref()),
config: Cow::Borrowed(&self.config),
schema_path: self.schema_path.clone()
schema_path: self.schema_path.clone(),
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions jsonschema/src/keywords/all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ impl AllOfValidator {
) -> CompilationResult<'a> {
let mut schemas = Vec::with_capacity(items.len());
for item in items {
context.schema_path.push(item.to_string());
let validators = compile_validators(item, context)?;
context.schema_path.pop();
schemas.push(validators)
}
Ok(Box::new(AllOfValidator { schemas }))
Expand Down
9 changes: 5 additions & 4 deletions jsonschema/src/keywords/contains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ impl ContainsValidator {
#[inline]
pub(crate) fn compile<'a>(
schema: &'a Value,
context: &CompilationContext,
context: &mut CompilationContext,
) -> CompilationResult<'a> {
Ok(Box::new(ContainsValidator {
validators: compile_validators(schema, context)?,
}))
context.schema_path.push(schema.to_string());
let validators = compile_validators(schema, context)?;
context.schema_path.pop();
Ok(Box::new(ContainsValidator { validators }))
}
}

Expand Down

0 comments on commit 61fa7ab

Please # to comment.