print_nanny_client/apis/
schema_api.rs

1/*
2 * print-nanny-client
3 *
4 * Official API client library for print-nanny.com
5 *
6 * The version of the OpenAPI document: 0.0.0
7 * Contact: leigh@print-nanny.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`schema_retrieve`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum SchemaRetrieveError {
22    UnknownValue(serde_json::Value),
23}
24
25
26/// OpenApi3 schema for this API. Format can be selected via content negotiation.  - YAML: application/vnd.oai.openapi - JSON: application/vnd.oai.openapi+json
27pub async fn schema_retrieve(configuration: &configuration::Configuration, lang: Option<&str>) -> Result<::std::collections::HashMap<String, serde_json::Value>, Error<SchemaRetrieveError>> {
28    let local_var_configuration = configuration;
29
30    let local_var_client = &local_var_configuration.client;
31
32    let local_var_uri_str = format!("{}/api/schema/", local_var_configuration.base_path);
33    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
34
35    if let Some(ref local_var_str) = lang {
36        local_var_req_builder = local_var_req_builder.query(&[("lang", &local_var_str.to_string())]);
37    }
38    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
39        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
40    }
41    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
42        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
43    };
44
45    let local_var_req = local_var_req_builder.build()?;
46    let local_var_resp = local_var_client.execute(local_var_req).await?;
47
48    let local_var_status = local_var_resp.status();
49    let local_var_content = local_var_resp.text().await?;
50
51    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
52        serde_json::from_str(&local_var_content).map_err(Error::from)
53    } else {
54        let local_var_entity: Option<SchemaRetrieveError> = serde_json::from_str(&local_var_content).ok();
55        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
56        Err(Error::ResponseError(local_var_error))
57    }
58}
59