Skip to content

Commit 99ad150

Browse files
committed
Add serde_path_to_error invocation to API layer
1 parent d777153 commit 99ad150

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

modules/openapi-generator/src/main/resources/rust/reqwest-trait/api.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,12 @@ impl {{classname}} for {{classname}}Client {
488488
{{/returnType}}
489489
{{#returnType}}
490490
match local_var_content_type {
491+
{{^useSerdePathToError}}
491492
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
493+
{{/useSerdePathToError}}
494+
{{#useSerdePathToError}}
495+
ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&local_var_content)).map_err(Error::from),
496+
{{/useSerdePathToError}}
492497
{{#vendorExtensions.x-supports-plain-text}}
493498
ContentType::Text => return Ok(local_var_content),
494499
{{/vendorExtensions.x-supports-plain-text}}

modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,12 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
528528
{{#returnType}}
529529
let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?;
530530
match content_type {
531+
{{^useSerdePathToError}}
531532
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
533+
{{/useSerdePathToError}}
534+
{{#useSerdePathToError}}
535+
ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from),
536+
{{/useSerdePathToError}}
532537
{{#vendorExtensions.x-supports-plain-text}}
533538
ContentType::Text => return Ok(content),
534539
{{/vendorExtensions.x-supports-plain-text}}

0 commit comments

Comments
 (0)