diff --git a/Cargo.lock b/Cargo.lock index 728639d..e60f010 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,12 +141,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "core-foundation" version = "0.9.4" @@ -186,15 +180,23 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.18" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ - "convert_case", "proc-macro2", "quote", - "rustc_version", "syn", + "unicode-xid", ] [[package]] @@ -1042,15 +1044,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "rustix" version = "0.38.34" @@ -1562,6 +1555,12 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "untrusted" version = "0.9.0" diff --git a/Cargo.toml b/Cargo.toml index fbb0fc5..af061b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ conformance = ["validation", "reqwest", "prettytable-rs", "colored"] [dependencies] bytes = "1.7" -derive_more = "0.99" +derive_more = { version = "1", features = ["display", "error", "from"] } futures-util = "0.3" http = "1" log = "0.4" diff --git a/src/conformance/operation.rs b/src/conformance/operation.rs index f5134ac..0364cf4 100644 --- a/src/conformance/operation.rs +++ b/src/conformance/operation.rs @@ -1,4 +1,4 @@ -use derive_more::Display; +use derive_more::derive::Display; use http::Method; use log::debug; @@ -6,10 +6,10 @@ use crate::{spec::Operation, validation::Error as ValidationError, Spec}; #[derive(Debug, Clone, Display)] pub enum OperationSpec { - #[display(fmt = "{} {}", method, path)] + #[display("{} {}", method, path)] Parts { method: Method, path: String }, - #[display(fmt = "OpID: {}", _0)] + #[display("OpID: {}", _0)] OperationId(String), } diff --git a/src/error.rs b/src/error.rs index 9d66a52..497e45a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,7 +2,7 @@ use std::io; -use derive_more::{Display, Error, From}; +use derive_more::derive::{Display, Error, From}; use crate::spec::Error as SpecError; #[cfg(feature = "validation")] @@ -11,23 +11,23 @@ use crate::validation::Error as ValidationError; /// Top-level errors. #[derive(Debug, Display, Error, From)] pub enum Error { - #[display(fmt = "I/O error")] + #[display("I/O error")] Io(io::Error), - #[display(fmt = "YAML error")] + #[display("YAML error")] Yaml(serde_yml::Error), - #[display(fmt = "JSON error")] + #[display("JSON error")] Serialize(serde_json::Error), - #[display(fmt = "Spec error")] + #[display("Spec error")] Spec(SpecError), #[cfg(feature = "validation")] - #[display(fmt = "Validation error")] + #[display("Validation error")] Validation(ValidationError), #[cfg(feature = "conformance")] - #[display(fmt = "Reqwest error")] + #[display("Reqwest error")] Reqwest(reqwest::Error), } diff --git a/src/spec/error.rs b/src/spec/error.rs index a0190a5..2f8da8d 100644 --- a/src/spec/error.rs +++ b/src/spec/error.rs @@ -1,4 +1,4 @@ -use derive_more::{Display, Error, From}; +use derive_more::derive::{Display, Error, From}; use semver::{Error as SemVerError, Version}; use crate::spec::{r#ref::RefError, schema::Error as SchemaError}; @@ -6,15 +6,15 @@ use crate::spec::{r#ref::RefError, schema::Error as SchemaError}; /// Spec Errors #[derive(Debug, Display, Error, From)] pub enum Error { - #[display(fmt = "Reference error")] + #[display("Reference error")] Ref(RefError), - #[display(fmt = "Schema error")] + #[display("Schema error")] Schema(SchemaError), - #[display(fmt = "Semver error")] + #[display("Semver error")] SemVerError(SemVerError), - #[display(fmt = "Unsupported spec file version ({})", _0)] + #[display("Unsupported spec file version ({})", _0)] UnsupportedSpecFileVersion(#[error(not(source))] Version), } diff --git a/src/spec/mod.rs b/src/spec/mod.rs index 1c379f3..61b7758 100644 --- a/src/spec/mod.rs +++ b/src/spec/mod.rs @@ -4,7 +4,7 @@ use std::{collections::BTreeMap, iter::Iterator}; -use derive_more::Error; +use derive_more::derive::Error; use http::Method; use log::debug; use serde::{Deserialize, Serialize}; diff --git a/src/spec/ref.rs b/src/spec/ref.rs index 010b2a1..d110c26 100644 --- a/src/spec/ref.rs +++ b/src/spec/ref.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use derive_more::{Display, Error}; +use derive_more::derive::{Display, Error}; use log::trace; use once_cell::sync::Lazy; use regex::Regex; @@ -36,14 +36,14 @@ where #[derive(Clone, Debug, PartialEq, Display, Error)] pub enum RefError { - #[display(fmt = "Invalid type: {}", _0)] + #[display("Invalid type: {}", _0)] InvalidType(#[error(not(source))] String), - #[display(fmt = "Mismatched type: cannot reference a {} as a {}", _0, _1)] + #[display("Mismatched type: cannot reference a {} as a {}", _0, _1)] MismatchedType(RefType, RefType), // TODO: use some kind of path structure - #[display(fmt = "Unresolvable path: {}", _0)] + #[display("Unresolvable path: {}", _0)] Unresolvable(#[error(not(source))] String), } diff --git a/src/spec/schema.rs b/src/spec/schema.rs index 2a253db..e605458 100644 --- a/src/spec/schema.rs +++ b/src/spec/schema.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; -use derive_more::{Display, Error}; +use derive_more::derive::{Display, Error}; use serde::{Deserialize, Serialize}; use crate::spec::{FromRef, ObjectOrReference, Ref, RefError, RefType, Spec}; @@ -10,13 +10,13 @@ use crate::spec::{FromRef, ObjectOrReference, Ref, RefError, RefType, Spec}; /// Schema Errors #[derive(Debug, Clone, PartialEq, Display, Error)] pub enum Error { - #[display(fmt = "Missing type property")] + #[display("Missing type property")] NoType, - #[display(fmt = "Unknown type: {}", _0)] + #[display("Unknown type: {}", _0)] UnknownType(#[error(not(source))] String), - #[display(fmt = "Required fields specified on a non-object schema")] + #[display("Required fields specified on a non-object schema")] RequiredSpecifiedOnNonObject, } diff --git a/src/validation/error.rs b/src/validation/error.rs index b2b0c8e..896e29b 100644 --- a/src/validation/error.rs +++ b/src/validation/error.rs @@ -1,6 +1,6 @@ use std::fmt; -use derive_more::{Display, Error}; +use derive_more::derive::{Display, Error}; use http::{Method, StatusCode}; use serde_json::Value as JsonValue; @@ -45,45 +45,45 @@ pub enum Error { // // Wrapped Errors // - #[display(fmt = "Schema error")] + #[display("Schema error")] Schema(SchemaError), // // Leaf Errors // - #[display(fmt = "Not JSON")] + #[display("Not JSON")] NotJson, - #[display(fmt = "{} is not one of {:?}", _0, _1)] + #[display("{} is not one of {:?}", _0, _1)] TypeMismatch(Path, SchemaTypeSet), - #[display(fmt = "Array item type mismatch: {}", _0)] + #[display("Array item type mismatch: {}", _0)] ArrayItemTypeMismatch(JsonValue, #[error(source)] Box), - #[display(fmt = "Undocumented field: {}", _0)] + #[display("Undocumented field: {}", _0)] UndocumentedField(#[error(not(source))] String), - #[display(fmt = "Status mismatch: expected {}; got {}", _0, _1)] + #[display("Status mismatch: expected {}; got {}", _0, _1)] StatusMismatch(StatusCode, StatusCode), - #[display(fmt = "Required field missing: {}", _0)] + #[display("Required field missing: {}", _0)] RequiredFieldMissing(#[error(not(source))] Path), - #[display(fmt = "Type did not match any `anyOf` variant: {}\n{}", _0, _1)] + #[display("Type did not match any `anyOf` variant: {}\n{}", _0, _1)] OneOfNoMatch(Path, AggregateError), - #[display(fmt = "Non-nullable field was null: {}", _0)] + #[display("Non-nullable field was null: {}", _0)] InvalidNull(#[error(not(source))] Path), - #[display(fmt = "Operation not found: {} {}", _0, _1)] + #[display("Operation not found: {} {}", _0, _1)] OperationNotFound(Method, String), - #[display(fmt = "Operation ID not found: {}", _0)] + #[display("Operation ID not found: {}", _0)] OperationIdNotFound(#[error(not(source))] String), - #[display(fmt = "Parameter not found: {}", _0)] + #[display("Parameter not found: {}", _0)] ParameterNotFound(#[error(not(source))] String), - #[display(fmt = "Invalid parameter location: {}", _0)] + #[display("Invalid parameter location: {}", _0)] InvalidParameterLocation(#[error(not(source))] String), }