Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: tests #536

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 8 additions & 31 deletions core/src/v2/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ static PATH_TEMPLATE_REGEX: Lazy<Regex> =
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)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep default as is for now to avoid bumping msrv?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe it's a good time to bump it, though we'd need to have another breaking release but that's ok I guess

pub enum Version {
#[serde(rename = "2.0")]
#[default]
V2,
}

Expand Down Expand Up @@ -253,8 +254,9 @@ pub struct Api<P, R, S> {
}

/// 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,
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/build/cli_util.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
}
Loading