Skip to content

Commit

Permalink
chore: Improve naming
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <[email protected]>
  • Loading branch information
Stranger6667 committed Oct 12, 2024
1 parent 5c08677 commit 0aa7094
Show file tree
Hide file tree
Showing 48 changed files with 258 additions and 246 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
- Improve error messages on URI resolving and parsing.
- **BREAKING**: Replace `JsonPointer` in favor of `Location`.

### Deprecated

- `PathChunkRef` in favor of `LocationSegment`.
- `JsonPointerNode` in favor of `LazyLocation`.

### Fixed

- Resolving file references on Windows. [#441](https://github.com/Stranger6667/jsonschema-rs/issues/441)
Expand Down
8 changes: 4 additions & 4 deletions crates/jsonschema-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fn to_error_message(error: &jsonschema::ValidationError<'_>) -> String {
/// If your workflow implies validating against the same schema, consider using `validator_for(...).is_valid`
/// instead.
#[pyfunction]
#[allow(unused_variables)]
#[allow(unused_variables, clippy::too_many_arguments)]
#[pyo3(signature = (schema, instance, draft=None, with_meta_schemas=false, formats=None, validate_formats=None, ignore_unknown_formats=true))]
fn is_valid(
py: Python<'_>,
Expand Down Expand Up @@ -311,7 +311,7 @@ fn is_valid(
/// If your workflow implies validating against the same schema, consider using `validator_for(...).validate`
/// instead.
#[pyfunction]
#[allow(unused_variables)]
#[allow(unused_variables, clippy::too_many_arguments)]
#[pyo3(signature = (schema, instance, draft=None, with_meta_schemas=false, formats=None, validate_formats=None, ignore_unknown_formats=true))]
fn validate(
py: Python<'_>,
Expand Down Expand Up @@ -342,7 +342,7 @@ fn validate(
/// If your workflow implies validating against the same schema, consider using `validator_for().iter_errors`
/// instead.
#[pyfunction]
#[allow(unused_variables)]
#[allow(unused_variables, clippy::too_many_arguments)]
#[pyo3(signature = (schema, instance, draft=None, with_meta_schemas=false, formats=None, validate_formats=None, ignore_unknown_formats=true))]
fn iter_errors(
py: Python<'_>,
Expand Down Expand Up @@ -571,7 +571,7 @@ impl JSONSchema {
///
/// Use it if you have your schema as a string and want to utilize Rust JSON parsing.
#[classmethod]
#[allow(unused_variables)]
#[allow(unused_variables, clippy::too_many_arguments)]
#[pyo3(signature = (string, draft=None, with_meta_schemas=false, formats=None, validate_formats=None, ignore_unknown_formats=true))]
fn from_str(
_: &Bound<'_, PyType>,
Expand Down
4 changes: 2 additions & 2 deletions crates/jsonschema/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
},
node::SchemaNode,
options::ValidationOptions,
paths::{Location, PathChunkRef},
paths::{Location, LocationSegment},
primitive_type::{PrimitiveType, PrimitiveTypesBitMap},
retriever::RetrieverAdapter,
ValidationError, Validator,
Expand Down Expand Up @@ -88,7 +88,7 @@ impl<'a> Context<'a> {
}

#[inline]
pub(crate) fn new_at_location(&'a self, chunk: impl Into<PathChunkRef<'a>>) -> Self {
pub(crate) fn new_at_location(&'a self, chunk: impl Into<LocationSegment<'a>>) -> Self {
let location = self.location.join(chunk);
Context {
config: Arc::clone(&self.config),
Expand Down
6 changes: 3 additions & 3 deletions crates/jsonschema/src/keywords/additional_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
error::{error, no_error, ErrorIterator, ValidationError},
keywords::{boolean::FalseValidator, CompilationResult},
node::SchemaNode,
paths::{JsonPointerNode, Location},
paths::{LazyLocation, Location},
primitive_type::{PrimitiveType, PrimitiveTypesBitMap},
validator::Validate,
};
Expand Down Expand Up @@ -43,7 +43,7 @@ impl Validate for AdditionalItemsObjectValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Array(items) = instance {
let errors: Vec<_> = items
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Validate for AdditionalItemsBooleanValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Array(items) = instance {
if items.len() > self.items_count {
Expand Down
32 changes: 16 additions & 16 deletions crates/jsonschema/src/keywords/additional_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
keywords::CompilationResult,
node::SchemaNode,
output::{Annotations, BasicOutput, OutputUnit},
paths::{JsonPointerNode, Location},
paths::{LazyLocation, Location},
properties::*,
validator::{PartialApplication, Validate},
};
Expand Down Expand Up @@ -101,7 +101,7 @@ impl Validate for AdditionalPropertiesValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Object(item) = instance {
let errors: Vec<_> = item
Expand All @@ -117,7 +117,7 @@ impl Validate for AdditionalPropertiesValidator {
fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
if let Value::Object(item) = instance {
let mut matched_props = Vec::with_capacity(item.len());
Expand Down Expand Up @@ -170,7 +170,7 @@ impl Validate for AdditionalPropertiesFalseValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Object(item) = instance {
if let Some((_, value)) = item.iter().next() {
Expand Down Expand Up @@ -243,7 +243,7 @@ impl<M: PropertiesValidatorsMap> Validate for AdditionalPropertiesNotEmptyFalseV
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Object(item) = instance {
let mut errors = vec![];
Expand Down Expand Up @@ -274,7 +274,7 @@ impl<M: PropertiesValidatorsMap> Validate for AdditionalPropertiesNotEmptyFalseV
fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
if let Value::Object(item) = instance {
let mut unexpected = Vec::with_capacity(item.len());
Expand Down Expand Up @@ -379,7 +379,7 @@ impl<M: PropertiesValidatorsMap> Validate for AdditionalPropertiesNotEmptyValida
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Object(map) = instance {
let mut errors = vec![];
Expand All @@ -401,7 +401,7 @@ impl<M: PropertiesValidatorsMap> Validate for AdditionalPropertiesNotEmptyValida
fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
if let Value::Object(map) = instance {
let mut matched_propnames = Vec::with_capacity(map.len());
Expand Down Expand Up @@ -497,7 +497,7 @@ impl Validate for AdditionalPropertiesWithPatternsValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Object(item) = instance {
let mut errors = vec![];
Expand Down Expand Up @@ -525,7 +525,7 @@ impl Validate for AdditionalPropertiesWithPatternsValidator {
fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
if let Value::Object(item) = instance {
let mut output = BasicOutput::default();
Expand Down Expand Up @@ -621,7 +621,7 @@ impl Validate for AdditionalPropertiesWithPatternsFalseValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Object(item) = instance {
let mut errors = vec![];
Expand Down Expand Up @@ -658,7 +658,7 @@ impl Validate for AdditionalPropertiesWithPatternsFalseValidator {
fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
if let Value::Object(item) = instance {
let mut output = BasicOutput::default();
Expand Down Expand Up @@ -813,7 +813,7 @@ impl<M: PropertiesValidatorsMap> Validate for AdditionalPropertiesWithPatternsNo
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Object(item) = instance {
let mut errors = vec![];
Expand Down Expand Up @@ -851,7 +851,7 @@ impl<M: PropertiesValidatorsMap> Validate for AdditionalPropertiesWithPatternsNo
fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
if let Value::Object(item) = instance {
let mut output = BasicOutput::default();
Expand Down Expand Up @@ -983,7 +983,7 @@ impl<M: PropertiesValidatorsMap> Validate
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if let Value::Object(item) = instance {
let mut errors = vec![];
Expand Down Expand Up @@ -1031,7 +1031,7 @@ impl<M: PropertiesValidatorsMap> Validate
fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
if let Value::Object(item) = instance {
let mut output = BasicOutput::default();
Expand Down
10 changes: 5 additions & 5 deletions crates/jsonschema/src/keywords/all_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
error::{ErrorIterator, ValidationError},
node::SchemaNode,
output::BasicOutput,
paths::{JsonPointerNode, Location},
paths::{LazyLocation, Location},
primitive_type::PrimitiveType,
validator::{PartialApplication, Validate},
};
Expand Down Expand Up @@ -41,7 +41,7 @@ impl Validate for AllOfValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
let errors: Vec<_> = self
.schemas
Expand All @@ -54,7 +54,7 @@ impl Validate for AllOfValidator {
fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
self.schemas
.iter()
Expand Down Expand Up @@ -86,15 +86,15 @@ impl Validate for SingleValueAllOfValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
self.node.validate(instance, instance_path)
}

fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
self.node.apply_rooted(instance, instance_path).into()
}
Expand Down
6 changes: 3 additions & 3 deletions crates/jsonschema/src/keywords/any_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
compiler,
error::{error, no_error, ErrorIterator, ValidationError},
node::SchemaNode,
paths::{JsonPointerNode, Location},
paths::{LazyLocation, Location},
primitive_type::PrimitiveType,
validator::{PartialApplication, Validate},
};
Expand Down Expand Up @@ -49,7 +49,7 @@ impl Validate for AnyOfValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if self.is_valid(instance) {
no_error()
Expand All @@ -65,7 +65,7 @@ impl Validate for AnyOfValidator {
fn apply<'a>(
&'a self,
instance: &Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> PartialApplication<'a> {
let mut successes = Vec::new();
let mut failures = Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions crates/jsonschema/src/keywords/boolean.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::paths::{JsonPointerNode, Location};
use crate::paths::{LazyLocation, Location};

use crate::{
error::{error, ErrorIterator, ValidationError},
Expand All @@ -24,7 +24,7 @@ impl Validate for FalseValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
error(ValidationError::false_schema(
self.location.clone(),
Expand Down
14 changes: 7 additions & 7 deletions crates/jsonschema/src/keywords/const_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};
use serde_json::{Map, Number, Value};

use crate::paths::JsonPointerNode;
use crate::paths::LazyLocation;

struct ConstArrayValidator {
value: Vec<Value>,
Expand All @@ -27,7 +27,7 @@ impl Validate for ConstArrayValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if self.is_valid(instance) {
no_error()
Expand Down Expand Up @@ -66,7 +66,7 @@ impl Validate for ConstBooleanValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if self.is_valid(instance) {
no_error()
Expand Down Expand Up @@ -104,7 +104,7 @@ impl Validate for ConstNullValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if self.is_valid(instance) {
no_error()
Expand Down Expand Up @@ -147,7 +147,7 @@ impl Validate for ConstNumberValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if self.is_valid(instance) {
no_error()
Expand Down Expand Up @@ -189,7 +189,7 @@ impl Validate for ConstObjectValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if self.is_valid(instance) {
no_error()
Expand Down Expand Up @@ -231,7 +231,7 @@ impl Validate for ConstStringValidator {
fn validate<'instance>(
&self,
instance: &'instance Value,
instance_path: &JsonPointerNode,
instance_path: &LazyLocation,
) -> ErrorIterator<'instance> {
if self.is_valid(instance) {
no_error()
Expand Down
Loading

0 comments on commit 0aa7094

Please sign in to comment.