This commit is contained in:
Joshua M. Clulow 2021-09-17 18:44:11 +00:00
parent 5e8b9d0e8c
commit 179dee4aaf
1 changed files with 16 additions and 10 deletions

View File

@ -620,7 +620,8 @@ impl TypeSpace {
"&str" "&str"
} else { } else {
n n
}.to_string()) }
.to_string())
} else { } else {
bail!("basic type {:?} does not have a name?", tid); bail!("basic type {:?} does not have a name?", tid);
} }
@ -989,10 +990,8 @@ fn gen(api: &OpenAPI, ts: &mut TypeSpace) -> Result<String> {
* Omit missing optionals from the document entirely; do * Omit missing optionals from the document entirely; do
* not inject a "null" value. * not inject a "null" value.
*/ */
a( a(" #[serde(skip_serializing_if = \
" #[serde(skip_serializing_if = \ \"Option::is_none\")]");
\"Option::is_none\")]"
);
} }
a(&format!( a(&format!(
" pub {}: {},", " pub {}: {},",
@ -1078,8 +1077,10 @@ fn gen(api: &OpenAPI, ts: &mut TypeSpace) -> Result<String> {
a(" Client::new_with_client(baseurl, client)"); a(" Client::new_with_client(baseurl, client)");
a(" }"); a(" }");
a(""); a("");
a(" pub fn new_with_client(baseurl: &str, client: reqwest::Client) \ a(
-> Client {"); " pub fn new_with_client(baseurl: &str, client: reqwest::Client) \
-> Client {",
);
a(" Client {"); a(" Client {");
a(" baseurl: baseurl.to_string(),"); a(" baseurl: baseurl.to_string(),");
a(" client,"); a(" client,");
@ -1131,7 +1132,10 @@ fn gen(api: &OpenAPI, ts: &mut TypeSpace) -> Result<String> {
if let Some(s) = &mt.schema { if let Some(s) = &mt.schema {
let tid = ts.select(None, s)?; let tid = ts.select(None, s)?;
( (
Some(format!("&{}", ts.render_type(&tid, UseContext::Return)?)), Some(format!(
"&{}",
ts.render_type(&tid, UseContext::Return)?
)),
Some("json".to_string()), Some("json".to_string()),
) )
} else { } else {
@ -1162,7 +1166,8 @@ fn gen(api: &OpenAPI, ts: &mut TypeSpace) -> Result<String> {
let nam = &parameter_data.name; let nam = &parameter_data.name;
let tid = ts.select(None, parameter_data.schema()?)?; let tid = ts.select(None, parameter_data.schema()?)?;
let typ = ts.render_type(&tid, UseContext::Parameter)?; let typ =
ts.render_type(&tid, UseContext::Parameter)?;
a(&format!(" {}: {},", nam, typ)); a(&format!(" {}: {},", nam, typ));
} }
openapiv3::Parameter::Query { openapiv3::Parameter::Query {
@ -1188,7 +1193,8 @@ fn gen(api: &OpenAPI, ts: &mut TypeSpace) -> Result<String> {
*/ */
ts.id_for_optional(&tid) ts.id_for_optional(&tid)
}; };
let typ = ts.render_type(&tid, UseContext::Parameter)?; let typ =
ts.render_type(&tid, UseContext::Parameter)?;
a(&format!(" {}: {},", nam, typ)); a(&format!(" {}: {},", nam, typ));
query.push((nam.to_string(), !parameter_data.required)); query.push((nam.to_string(), !parameter_data.required));