Skip to content

Commit

Permalink
clippy updates
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Sep 24, 2024
1 parent 8ee17db commit 4d00351
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions openapitor/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ fn clean_url_from(path_params: &BTreeMap<String, TokenStream>) -> Result<TokenSt

clean_string = if t.is_string()? {
quote! {
#clean_string.replace(#url_string, &#name_ident)
#clean_string.replace(#url_string, #name_ident)
}
} else {
quote! {
Expand Down Expand Up @@ -1279,7 +1279,7 @@ fn get_function_body(

// Parse the json response.
// Return a human error.
serde_json::from_str(&text).map_err(|err| crate::types::error::Error::from_serde_error(format_serde_error::SerdeError::new(text.to_string(), err), status).into())
serde_json::from_str(&text).map_err(|err| crate::types::error::Error::from_serde_error(format_serde_error::SerdeError::new(text.to_string(), err), status))
}
}
"application/vnd.github.v3.object" => {
Expand All @@ -1289,7 +1289,7 @@ fn get_function_body(

// Parse the json response.
// Return a human error.
serde_json::from_str(&text).map_err(|err| crate::types::error::Error::from_serde_error(format_serde_error::SerdeError::new(text.to_string(), err), status).into())
serde_json::from_str(&text).map_err(|err| crate::types::error::Error::from_serde_error(format_serde_error::SerdeError::new(text.to_string(), err), status))
}
}
"application/scim+json" => {
Expand All @@ -1299,7 +1299,7 @@ fn get_function_body(

// Parse the json response.
// Return a human error.
serde_json::from_str(&text).map_err(|err| crate::types::error::Error::from_serde_error(format_serde_error::SerdeError::new(text.to_string(), err), status).into())
serde_json::from_str(&text).map_err(|err| crate::types::error::Error::from_serde_error(format_serde_error::SerdeError::new(text.to_string(), err), status))
}
}
_ => {
Expand Down Expand Up @@ -1345,7 +1345,7 @@ fn get_function_body(
Ok(quote! {
let mut req = self.client.client.request(
http::Method::#method_ident,
&format!("{}/{}", self.client.base_url, #path #clean_url),
format!("{}/{}", self.client.base_url, #path #clean_url),
);

// Add in our authentication.
Expand Down
12 changes: 6 additions & 6 deletions openapitor/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ pub fn generate_utils(opts: &crate::Opts) -> Option<String> {
r#"
pub mod date_time_format {{
use chrono::{{DateTime, TimeZone, Utc}};
use chrono::{{DateTime, NaiveDateTime, Utc}};
use serde::{{self, Deserialize, Deserializer}};
const FORMAT: &str = "{format}";
// The signature of a deserialize_with function must follow the pattern:
Expand All @@ -321,8 +321,8 @@ pub mod date_time_format {{
D: Deserializer<'de>,
{{
let s: String = String::deserialize(deserializer)?;
match Utc.datetime_from_str(&s, FORMAT) {{
Ok(t) => Ok(t),
match NaiveDateTime::parse_from_str(&s, FORMAT) {{
Ok(t) => Ok(t.and_utc()),
Err(_) => {{
match serde_json::from_str::<DateTime<Utc>>(&format!("\"{{}}\"", s)) {{
Ok(t) => Ok(t),
Expand All @@ -336,7 +336,7 @@ pub mod date_time_format {{
}}
pub mod nullable_date_time_format {{
use chrono::{{DateTime, TimeZone, Utc}};
use chrono::{{DateTime, NaiveDateTime, Utc}};
use serde::{{self, Deserialize, Deserializer}};
const FORMAT: &str = "{format}";
// The signature of a deserialize_with function must follow the pattern:
Expand All @@ -353,8 +353,8 @@ pub mod nullable_date_time_format {{
let s: Option<String> = Option::deserialize(deserializer)?;
if let Some(s) = s {{
// This is standard.
match Utc.datetime_from_str(&s, FORMAT) {{
Ok(t) => Ok(Some(t)),
match NaiveDateTime::parse_from_str(&s, FORMAT) {{
Ok(t) => Ok(Some(t.and_utc())),
Err(_) => {{
match serde_json::from_str::<DateTime<Utc>>(&format!("\"{{}}\"", s)) {{
Ok(t) => Ok(Some(t)),
Expand Down

0 comments on commit 4d00351

Please sign in to comment.