diff --git a/core/src/v2/models.rs b/core/src/v2/models.rs index a2882e855..92958595b 100644 --- a/core/src/v2/models.rs +++ b/core/src/v2/models.rs @@ -31,9 +31,10 @@ static PATH_TEMPLATE_REGEX: Lazy = const SPECIAL_HEADERS: &[&str] = &["content-type", "accept", "authorization"]; /// OpenAPI version. -#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, Eq, PartialEq)] pub enum Version { #[serde(rename = "2.0")] + #[default] V2, } @@ -253,8 +254,9 @@ pub struct Api { } /// The format used by spec (JSON/YAML). -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] pub enum SpecFormat { + #[default] Json, Yaml, } @@ -664,20 +666,22 @@ where } /// The location of the parameter. -#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)] #[serde(rename_all = "camelCase")] pub enum ParameterIn { Query, Header, Path, FormData, + #[default] Body, } /// Possible formats for array values in parameter. -#[derive(Clone, Copy, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)] #[serde(rename_all = "lowercase")] pub enum CollectionFormat { + #[default] Csv, Ssv, Tsv, @@ -939,14 +943,6 @@ where } } -/* Common trait impls */ - -impl Default for SpecFormat { - fn default() -> Self { - SpecFormat::Json - } -} - #[cfg(feature = "actix-base")] impl From<&Method> for HttpMethod { fn from(method: &Method) -> HttpMethod { @@ -1032,25 +1028,6 @@ impl Display for HttpMethod { } } -impl Default for Version { - fn default() -> Self { - Version::V2 - } -} - -impl Default for CollectionFormat { - fn default() -> Self { - CollectionFormat::Csv - } -} - -/// **NOTE:** This is just a stub. This is usually set explicitly. -impl Default for ParameterIn { - fn default() -> Self { - ParameterIn::Body - } -} - /* Serde helpers */ #[allow(clippy::trivially_copy_pass_by_ref)] diff --git a/src/build/cli_util.hbs b/src/build/cli_util.hbs index 2fd0bee4f..25ca5c7eb 100644 --- a/src/build/cli_util.hbs +++ b/src/build/cli_util.hbs @@ -51,7 +51,7 @@ where match resp \{ Ok(r) => Ok(r), - Err(ApiError::Failure(_, _, r)) => Ok(r.into_inner()), + Err(ApiError::Failure(_, _, r)) => Ok(r), Err(e) => return Err(e.into()), } }