forked from loafle/openapi-generator-original
[rust] Added support for text/plain to reqwest clients (#20643)
* [rust] Added support for text/plain to reqwest-trait client * Updated samples * [rust] Added support for text/plain to reqwest client * Updated samples * cleanup * reduced compiler warnings * fixed text/plain content with charset * Only deserialize text/plain if the API produces it
This commit is contained in:
parent
515c8827b2
commit
4ba87ae0e7
@ -315,6 +315,24 @@ public class CodegenOperation {
|
||||
return isRestfulIndex() || isRestfulShow() || isRestfulCreate() || isRestfulUpdate() || isRestfulDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if operation produces text/plain responses.
|
||||
* NOTE: This does not mean it _only_ produces text/plain, just that it is one of the produces types.
|
||||
*
|
||||
* @return true if at least one produces is text/plain
|
||||
*/
|
||||
public boolean producesTextPlain() {
|
||||
if (produces != null) {
|
||||
for (Map<String, String> produce : produces) {
|
||||
if ("text/plain".equalsIgnoreCase(produce.get("mediaType").split(";")[0].trim())
|
||||
&& "String".equals(returnType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the substring except baseName from path
|
||||
*
|
||||
|
@ -841,17 +841,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
if (NATIVE.equals(getLibrary()) || APACHE.equals(getLibrary())) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
Pattern methodPattern = Pattern.compile("^(.*):([^:]*)$");
|
||||
for (CodegenOperation op : operationList) {
|
||||
// add extension to indicate content type is `text/plain` and the response type is `String`
|
||||
if (op.produces != null) {
|
||||
for (Map<String, String> produce : op.produces) {
|
||||
if ("text/plain".equalsIgnoreCase(produce.get("mediaType").split(";")[0].trim())
|
||||
&& "String".equals(op.returnType)) {
|
||||
op.vendorExtensions.put("x-java-text-plain-string", true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ("String".equals(op.returnType) && op.producesTextPlain()) {
|
||||
op.vendorExtensions.put("x-java-text-plain-string", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -677,6 +677,10 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
operation.vendorExtensions.put("x-group-parameters", Boolean.TRUE);
|
||||
}
|
||||
|
||||
if (operation.producesTextPlain() && "String".equals(operation.returnType)) {
|
||||
operation.vendorExtensions.put("x-supports-plain-text", Boolean.TRUE);
|
||||
}
|
||||
|
||||
// update return type to conform to rust standard
|
||||
/*
|
||||
if (operation.returnType != null) {
|
||||
|
@ -7,9 +7,10 @@ use mockall::automock;
|
||||
{{/mockall}}
|
||||
use reqwest;
|
||||
use std::sync::Arc;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use crate::apis::ContentType;
|
||||
|
||||
{{#mockall}}
|
||||
#[cfg_attr(feature = "mockall", automock)]
|
||||
@ -336,6 +337,16 @@ impl {{classname}} for {{classname}}Client {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
{{^supportMultipleResponses}}
|
||||
{{#returnType}}
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
{{/returnType}}
|
||||
{{/supportMultipleResponses}}
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
@ -344,7 +355,16 @@ impl {{classname}} for {{classname}}Client {
|
||||
Ok(())
|
||||
{{/returnType}}
|
||||
{{#returnType}}
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
{{#vendorExtensions.x-supports-plain-text}}
|
||||
ContentType::Text => return Ok(local_var_content),
|
||||
{{/vendorExtensions.x-supports-plain-text}}
|
||||
{{^vendorExtensions.x-supports-plain-text}}
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `{{returnType}}`"))),
|
||||
{{/vendorExtensions.x-supports-plain-text}}
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `{{returnType}}`")))),
|
||||
}
|
||||
{{/returnType}}
|
||||
{{/supportMultipleResponses}}
|
||||
{{#supportMultipleResponses}}
|
||||
|
@ -128,6 +128,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
pub mod {{{classFilename}}};
|
||||
|
@ -1,9 +1,9 @@
|
||||
{{>partial_header}}
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
@ -355,6 +355,18 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
|
||||
let resp = configuration.client.execute(req){{#supportAsync}}.await{{/supportAsync}}?;
|
||||
|
||||
let status = resp.status();
|
||||
{{^supportMultipleResponses}}
|
||||
{{^isResponseFile}}
|
||||
{{#returnType}}
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
{{/returnType}}
|
||||
{{/isResponseFile}}
|
||||
{{/supportMultipleResponses}}
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
{{^supportMultipleResponses}}
|
||||
@ -367,7 +379,16 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
|
||||
{{/returnType}}
|
||||
{{#returnType}}
|
||||
let content = resp.text(){{#supportAsync}}.await{{/supportAsync}}?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
{{#vendorExtensions.x-supports-plain-text}}
|
||||
ContentType::Text => return Ok(content),
|
||||
{{/vendorExtensions.x-supports-plain-text}}
|
||||
{{^vendorExtensions.x-supports-plain-text}}
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `{{returnType}}`"))),
|
||||
{{/vendorExtensions.x-supports-plain-text}}
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `{{returnType}}`")))),
|
||||
}
|
||||
{{/returnType}}
|
||||
{{/isResponseFile}}
|
||||
{{/supportMultipleResponses}}
|
||||
|
@ -134,6 +134,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
pub mod {{{classFilename}}};
|
||||
|
@ -495,6 +495,10 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
|
||||
'400':
|
||||
description: Invalid username/password supplied
|
||||
/user/logout:
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`repro`]
|
||||
@ -36,10 +36,20 @@ pub fn repro(configuration: &configuration::Configuration, ) -> Result<models::P
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Parent`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Parent`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<ReproError> = serde_json::from_str(&content).ok();
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod default_api;
|
||||
|
||||
pub mod configuration;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`demo_color_get`]
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod default_api;
|
||||
|
||||
pub mod configuration;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`create_state`]
|
||||
@ -69,10 +69,20 @@ pub fn get_state(configuration: &configuration::Configuration, ) -> Result<model
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetState200Response`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetState200Response`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetStateError> = serde_json::from_str(&content).ok();
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod default_api;
|
||||
|
||||
pub mod configuration;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`endpoint_get`]
|
||||
@ -36,10 +36,20 @@ pub fn endpoint_get(configuration: &configuration::Configuration, ) -> Result<mo
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EmptyObject`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EmptyObject`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<EndpointGetError> = serde_json::from_str(&content).ok();
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod default_api;
|
||||
|
||||
pub mod configuration;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`root_get`]
|
||||
@ -43,10 +43,20 @@ pub fn root_get(configuration: &configuration::Configuration, ) -> Result<models
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Fruit`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Fruit`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<RootGetError> = serde_json::from_str(&content).ok();
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod default_api;
|
||||
|
||||
pub mod configuration;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`get_fruit`]
|
||||
@ -36,10 +36,20 @@ pub fn get_fruit(configuration: &configuration::Configuration, ) -> Result<model
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Fruit`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Fruit`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetFruitError> = serde_json::from_str(&content).ok();
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod default_api;
|
||||
|
||||
pub mod configuration;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`create_bar`]
|
||||
@ -39,10 +39,20 @@ pub fn create_bar(configuration: &configuration::Configuration, bar_create: mode
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Bar`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Bar`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<CreateBarError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`create_foo`]
|
||||
@ -46,10 +46,20 @@ pub fn create_foo(configuration: &configuration::Configuration, foo: Option<mode
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooRefOrValue`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooRefOrValue`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<CreateFooError> = serde_json::from_str(&content).ok();
|
||||
@ -70,10 +80,20 @@ pub fn get_all_foos(configuration: &configuration::Configuration, ) -> Result<Ve
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::FooRefOrValue>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::FooRefOrValue>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetAllFoosError> = serde_json::from_str(&content).ok();
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod bar_api;
|
||||
pub mod foo_api;
|
||||
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -14,9 +14,10 @@ use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use reqwest;
|
||||
use std::sync::Arc;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use crate::apis::ContentType;
|
||||
|
||||
#[cfg_attr(feature = "mockall", automock)]
|
||||
#[async_trait]
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod fake_api;
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
|
@ -14,9 +14,10 @@ use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use reqwest;
|
||||
use std::sync::Arc;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use crate::apis::ContentType;
|
||||
|
||||
#[cfg_attr(feature = "mockall", automock)]
|
||||
#[async_trait]
|
||||
@ -90,10 +91,20 @@ impl PetApi for PetApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Pet`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<AddPetError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
@ -165,10 +176,20 @@ impl PetApi for PetApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<FindPetsByStatusError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
@ -200,10 +221,20 @@ impl PetApi for PetApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<FindPetsByTagsError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
@ -236,10 +267,20 @@ impl PetApi for PetApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Pet`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<GetPetByIdError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
@ -268,10 +309,20 @@ impl PetApi for PetApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Pet`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<UpdatePetError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
@ -344,10 +395,20 @@ impl PetApi for PetApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiResponse`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ApiResponse`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<UploadFileError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
|
@ -14,9 +14,10 @@ use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use reqwest;
|
||||
use std::sync::Arc;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use crate::apis::ContentType;
|
||||
|
||||
#[cfg_attr(feature = "mockall", automock)]
|
||||
#[async_trait]
|
||||
@ -108,10 +109,20 @@ impl StoreApi for StoreApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, i32>`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, i32>`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<GetInventoryError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
@ -136,10 +147,20 @@ impl StoreApi for StoreApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Order`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<GetOrderByIdError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
@ -165,10 +186,20 @@ impl StoreApi for StoreApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::Order`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<PlaceOrderError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
|
@ -14,9 +14,10 @@ use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use reqwest;
|
||||
use std::sync::Arc;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use crate::apis::ContentType;
|
||||
|
||||
#[cfg_attr(feature = "mockall", automock)]
|
||||
#[async_trait]
|
||||
@ -63,10 +64,20 @@ impl TestingApi for TestingApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::path::PathBuf`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `std::path::PathBuf`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<TestsFileResponseGetError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
@ -90,10 +101,20 @@ impl TestingApi for TestingApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TypeTesting`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::TypeTesting`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<TestsTypeTestingGetError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
|
@ -14,9 +14,10 @@ use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use reqwest;
|
||||
use std::sync::Arc;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use crate::apis::ContentType;
|
||||
|
||||
#[cfg_attr(feature = "mockall", automock)]
|
||||
#[async_trait]
|
||||
@ -231,10 +232,20 @@ impl UserApi for UserApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::User`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<GetUserByNameError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
@ -261,10 +272,20 @@ impl UserApi for UserApiClient {
|
||||
let local_var_resp = local_var_client.execute(local_var_req).await?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content_type = local_var_resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let local_var_content_type = super::ContentType::from(local_var_content_type);
|
||||
let local_var_content = local_var_resp.text().await?;
|
||||
|
||||
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
|
||||
serde_json::from_str(&local_var_content).map_err(Error::from)
|
||||
match local_var_content_type {
|
||||
ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
|
||||
ContentType::Text => return Ok(local_var_content),
|
||||
ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `String`")))),
|
||||
}
|
||||
} else {
|
||||
let local_var_entity: Option<LoginUserError> = serde_json::from_str(&local_var_content).ok();
|
||||
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`get_parameter_name_mapping`]
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod fake_api;
|
||||
|
||||
pub mod configuration;
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`test_nullable_required_param`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -99,6 +99,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod fake_api;
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`add_pet`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`delete_order`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed successes of method [`tests_file_response_get`]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`create_user`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`test_nullable_required_param`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -93,6 +93,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod fake_api;
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`add_pet`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`delete_order`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed successes of method [`tests_file_response_get`]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`create_user`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`test_nullable_required_param`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod fake_api;
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`add_pet`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`delete_order`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed successes of method [`tests_file_response_get`]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`create_user`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`test_nullable_required_param`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod fake_api;
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`add_pet`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`delete_order`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed successes of method [`tests_file_response_get`]
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
/// struct for passing parameters to the method [`create_user`]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`test_nullable_required_param`]
|
||||
|
@ -94,6 +94,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod fake_api;
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`add_pet`]
|
||||
@ -115,10 +115,20 @@ pub fn add_pet(configuration: &configuration::Configuration, pet: models::Pet) -
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pet`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<AddPetError> = serde_json::from_str(&content).ok();
|
||||
@ -215,10 +225,20 @@ pub fn find_pets_by_status(configuration: &configuration::Configuration, status:
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<FindPetsByStatusError> = serde_json::from_str(&content).ok();
|
||||
@ -262,10 +282,20 @@ pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<FindPetsByTagsError> = serde_json::from_str(&content).ok();
|
||||
@ -310,10 +340,20 @@ pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64)
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pet`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetPetByIdError> = serde_json::from_str(&content).ok();
|
||||
@ -354,10 +394,20 @@ pub fn update_pet(configuration: &configuration::Configuration, pet: models::Pet
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pet`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<UpdatePetError> = serde_json::from_str(&content).ok();
|
||||
@ -459,10 +509,20 @@ pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, ad
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiResponse`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApiResponse`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`delete_order`]
|
||||
@ -110,10 +110,20 @@ pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result<s
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, i32>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, i32>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
|
||||
@ -137,10 +147,20 @@ pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Order`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
|
||||
@ -165,10 +185,20 @@ pub fn place_order(configuration: &configuration::Configuration, order: models::
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Order`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`tests_file_response_get`]
|
||||
@ -66,10 +66,20 @@ pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) ->
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TypeTesting`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TypeTesting`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<TestsTypeTestingGetError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`create_user`]
|
||||
@ -290,10 +290,20 @@ pub fn get_user_by_name(configuration: &configuration::Configuration, username:
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetUserByNameError> = serde_json::from_str(&content).ok();
|
||||
@ -320,10 +330,20 @@ pub fn login_user(configuration: &configuration::Configuration, username: &str,
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Ok(content),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<LoginUserError> = serde_json::from_str(&content).ok();
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`test_nullable_required_param`]
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod fake_api;
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`add_pet`]
|
||||
@ -102,10 +102,20 @@ pub fn add_pet(configuration: &configuration::Configuration, foo_pet: models::Fo
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooPet`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooPet`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<AddPetError> = serde_json::from_str(&content).ok();
|
||||
@ -176,10 +186,20 @@ pub fn find_pets_by_status(configuration: &configuration::Configuration, status:
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::FooPet>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::FooPet>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<FindPetsByStatusError> = serde_json::from_str(&content).ok();
|
||||
@ -210,10 +230,20 @@ pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::FooPet>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::FooPet>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<FindPetsByTagsError> = serde_json::from_str(&content).ok();
|
||||
@ -245,10 +275,20 @@ pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64)
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooPet`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooPet`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetPetByIdError> = serde_json::from_str(&content).ok();
|
||||
@ -276,10 +316,20 @@ pub fn update_pet(configuration: &configuration::Configuration, foo_pet: models:
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooPet`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooPet`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<UpdatePetError> = serde_json::from_str(&content).ok();
|
||||
@ -355,10 +405,20 @@ pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, ad
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooApiResponse`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooApiResponse`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`delete_order`]
|
||||
@ -97,10 +97,20 @@ pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result<s
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, i32>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, i32>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
|
||||
@ -124,10 +134,20 @@ pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooOrder`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooOrder`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
|
||||
@ -152,10 +172,20 @@ pub fn place_order(configuration: &configuration::Configuration, foo_order: mode
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooOrder`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooOrder`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`tests_file_response_get`]
|
||||
@ -66,10 +66,20 @@ pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) ->
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooTypeTesting`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooTypeTesting`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<TestsTypeTestingGetError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`create_user`]
|
||||
@ -238,10 +238,20 @@ pub fn get_user_by_name(configuration: &configuration::Configuration, username:
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooUser`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooUser`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetUserByNameError> = serde_json::from_str(&content).ok();
|
||||
@ -268,10 +278,20 @@ pub fn login_user(configuration: &configuration::Configuration, username: &str,
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Ok(content),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<LoginUserError> = serde_json::from_str(&content).ok();
|
||||
|
@ -191,7 +191,7 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
- **Accept**: application/xml, application/json, text/plain
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`test_nullable_required_param`]
|
||||
|
@ -90,6 +90,27 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
|
||||
unimplemented!("Only objects are supported with style=deepObject")
|
||||
}
|
||||
|
||||
/// Internal use only
|
||||
/// A content type supported by this client.
|
||||
#[allow(dead_code)]
|
||||
enum ContentType {
|
||||
Json,
|
||||
Text,
|
||||
Unsupported(String)
|
||||
}
|
||||
|
||||
impl From<&str> for ContentType {
|
||||
fn from(content_type: &str) -> Self {
|
||||
if content_type.starts_with("application") && content_type.contains("json") {
|
||||
return Self::Json;
|
||||
} else if content_type.starts_with("text/plain") {
|
||||
return Self::Text;
|
||||
} else {
|
||||
return Self::Unsupported(content_type.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod fake_api;
|
||||
pub mod pet_api;
|
||||
pub mod store_api;
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`add_pet`]
|
||||
@ -102,10 +102,20 @@ pub fn add_pet(configuration: &configuration::Configuration, pet: models::Pet) -
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pet`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<AddPetError> = serde_json::from_str(&content).ok();
|
||||
@ -176,10 +186,20 @@ pub fn find_pets_by_status(configuration: &configuration::Configuration, status:
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<FindPetsByStatusError> = serde_json::from_str(&content).ok();
|
||||
@ -210,10 +230,20 @@ pub fn find_pets_by_tags(configuration: &configuration::Configuration, tags: Vec
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Pet>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Pet>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<FindPetsByTagsError> = serde_json::from_str(&content).ok();
|
||||
@ -245,10 +275,20 @@ pub fn get_pet_by_id(configuration: &configuration::Configuration, pet_id: i64)
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pet`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetPetByIdError> = serde_json::from_str(&content).ok();
|
||||
@ -276,10 +316,20 @@ pub fn update_pet(configuration: &configuration::Configuration, pet: models::Pet
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Pet`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Pet`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<UpdatePetError> = serde_json::from_str(&content).ok();
|
||||
@ -355,10 +405,20 @@ pub fn upload_file(configuration: &configuration::Configuration, pet_id: i64, ad
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApiResponse`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApiResponse`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`delete_order`]
|
||||
@ -97,10 +97,20 @@ pub fn get_inventory(configuration: &configuration::Configuration, ) -> Result<s
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, i32>`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, i32>`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetInventoryError> = serde_json::from_str(&content).ok();
|
||||
@ -124,10 +134,20 @@ pub fn get_order_by_id(configuration: &configuration::Configuration, order_id: i
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Order`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetOrderByIdError> = serde_json::from_str(&content).ok();
|
||||
@ -152,10 +172,20 @@ pub fn place_order(configuration: &configuration::Configuration, order: models::
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Order`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Order`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<PlaceOrderError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`tests_file_response_get`]
|
||||
@ -66,10 +66,20 @@ pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) ->
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TypeTesting`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TypeTesting`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<TestsTypeTestingGetError> = serde_json::from_str(&content).ok();
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
|
||||
use reqwest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, de::Error as _};
|
||||
use crate::{apis::ResponseContent, models};
|
||||
use super::{Error, configuration};
|
||||
use super::{Error, configuration, ContentType};
|
||||
|
||||
|
||||
/// struct for typed errors of method [`create_user`]
|
||||
@ -238,10 +238,20 @@ pub fn get_user_by_name(configuration: &configuration::Configuration, username:
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<GetUserByNameError> = serde_json::from_str(&content).ok();
|
||||
@ -268,10 +278,20 @@ pub fn login_user(configuration: &configuration::Configuration, username: &str,
|
||||
let resp = configuration.client.execute(req)?;
|
||||
|
||||
let status = resp.status();
|
||||
let content_type = resp
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream");
|
||||
let content_type = super::ContentType::from(content_type);
|
||||
|
||||
if !status.is_client_error() && !status.is_server_error() {
|
||||
let content = resp.text()?;
|
||||
serde_json::from_str(&content).map_err(Error::from)
|
||||
match content_type {
|
||||
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
|
||||
ContentType::Text => return Ok(content),
|
||||
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
|
||||
}
|
||||
} else {
|
||||
let content = resp.text()?;
|
||||
let entity: Option<LoginUserError> = serde_json::from_str(&content).ok();
|
||||
|
Loading…
x
Reference in New Issue
Block a user