Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed Apr 9, 2024
1 parent e6eb484 commit e7cb853
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion progenitor-client/src/progenitor_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl<E> RequestBuilderExt<E> for RequestBuilder {
self,
iter: I,
) -> Result<Self, Error<E>> {
use reqwest::multipart::{Form};
use reqwest::multipart::Form;

let mut form = Form::new();
for (name, value) in iter {
Expand Down
24 changes: 12 additions & 12 deletions progenitor-impl/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,19 +315,19 @@ impl Generator {
OperationParameterKind::Body(_) => unreachable!(),
};

let OperationParameterType::Type(arg_type_id) = &param.typ else {
let OperationParameterType::Type(arg_type_id) = &param.typ
else {
panic!()
};
let arg_type = self.type_space.get_type(arg_type_id).unwrap();
let arg_details = arg_type.details();
let arg_type_name = match &arg_details{
let arg_type_name = match &arg_details {
typify::TypeDetails::Option(opt_id) => {
let inner_type = self.type_space.get_type(opt_id).unwrap();
let inner_type =
self.type_space.get_type(opt_id).unwrap();
inner_type.ident()
}
_ => {
arg_type.ident()
}
_ => arg_type.ident(),
};

let help = param.description.as_ref().map(|description| {
Expand Down Expand Up @@ -410,21 +410,21 @@ impl Generator {
let arg_name = param.name.to_kebab_case();
let arg_fn_name = sanitize(&param.name, Case::Snake);
let arg_fn = format_ident!("{}", arg_fn_name);
let OperationParameterType::Type(arg_type_id) = &param.typ else {
let OperationParameterType::Type(arg_type_id) = &param.typ
else {
panic!()
};
let arg_type = self.type_space.get_type(arg_type_id).unwrap();

// TODO this really should be simpler.
let arg_details = arg_type.details();
let arg_type_name = match &arg_details{
let arg_type_name = match &arg_details {
typify::TypeDetails::Option(opt_id) => {
let inner_type = self.type_space.get_type(opt_id).unwrap();
let inner_type =
self.type_space.get_type(opt_id).unwrap();
inner_type.ident()
}
_ => {
arg_type.ident()
}
_ => arg_type.ident(),
};

quote! {
Expand Down
2 changes: 1 addition & 1 deletion progenitor-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use std::collections::{HashMap, HashSet};

use openapiv3::OpenAPI;
use indexmap::IndexSet;
use openapiv3::OpenAPI;
use proc_macro2::TokenStream;
use quote::quote;
use serde::Deserialize;
Expand Down
2 changes: 1 addition & 1 deletion progenitor-impl/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ impl Generator {
typify::TypeDetails::Array(item, _) => {
Some(DropshotPagination { item })
}
_ => None
_ => None,
}
}

Expand Down
7 changes: 4 additions & 3 deletions progenitor-impl/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ impl PathTemplate {
if let Component::Parameter(n) = &component {
let param = format_ident!(
"{}",
rename
.get(&n)
.unwrap_or_else(|| panic!("missing path name mapping {}", n)),
rename.get(&n).unwrap_or_else(|| panic!(
"missing path name mapping {}",
n
)),
);
Some(quote! {
encode_path(&#param.to_string())
Expand Down
18 changes: 14 additions & 4 deletions progenitor-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,21 @@ fn do_generate_api(item: TokenStream) -> Result<TokenStream, syn::Error> {

// Force a rebuild when the given file is modified.
const _: &str = include_str!(#path_str);

};

let output = expander::Expander::new(format!("{}", std::path::PathBuf::from(spec.value()).file_name().unwrap().to_string_lossy()))
.fmt(expander::Edition::_2021)
.verbose(true)
.write_to_out_dir(output).expect("Writing file works. qed");
println!("cargo::rerun-if-changed={}", path_str);

let output = expander::Expander::new(format!(
"{}",
std::path::PathBuf::from(spec.value())
.file_name()
.unwrap()
.to_string_lossy()
))
.fmt(expander::Edition::_2021)
.verbose(true)
.write_to_out_dir(output)
.expect("Writing file works. qed");
Ok(output.into())
}

0 comments on commit e7cb853

Please sign in to comment.