[Rust Server] Retire mimetypes modules (#5560)

* Retire mimetypes module to prevent collision in mimetype identifiers
* Update samples
This commit is contained in:
Richard Whitehouse 2020-03-23 13:04:29 +00:00 committed by GitHub
parent be983b5212
commit 806562bb05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 73 additions and 577 deletions

View File

@ -238,7 +238,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("context.mustache", "src", "context.rs"));
supportingFiles.add(new SupportingFile("models.mustache", "src", "models.rs"));
supportingFiles.add(new SupportingFile("header.mustache", "src", "header.rs"));
supportingFiles.add(new SupportingFile("mimetypes.mustache", "src", "mimetypes.rs"));
supportingFiles.add(new SupportingFile("server-mod.mustache", "src/server", "mod.rs"));
supportingFiles.add(new SupportingFile("client-mod.mustache", "src/client", "mod.rs"));
supportingFiles.add(new SupportingFile("example-server-main.mustache", "examples/server", "main.rs"));

View File

@ -30,9 +30,6 @@ The following tree shows which templates include which:
- `header.mustache`
- `lib.mustache`
- `response.mustache`
- `mimetypes.mustache`
- `mimetypes-request.mustache`
- `mimetypes-response.mustache`
- `model_doc.mustache`
- `models.mustache`
- `openapi.mustache`

View File

@ -39,7 +39,6 @@ use uuid;
use serde_xml_rs;
{{/usesXml}}
use mimetypes;
use models;
use header;

View File

@ -143,7 +143,7 @@
];
let body = serde_urlencoded::to_string(params).expect("impossible to fail to serialize");
let header = &mimetypes::requests::{{#vendorExtensions}}{{{uppercase_operation_id}}}{{/vendorExtensions}};
let header = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/json{{/consumes}}";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -203,7 +203,7 @@
// Add the message body to the request object.
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::{{#vendorExtensions}}{{{uppercase_operation_id}}}{{/vendorExtensions}};
let header = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/json{{/consumes}}";
request.headers_mut().insert(CONTENT_TYPE,
match HeaderValue::from_bytes(
&[header.as_bytes(), "; boundary=".as_bytes(), &boundary, "; type=\"application/json\"".as_bytes()].concat()
@ -261,7 +261,7 @@
}
{{/required}}
let header = &mimetypes::requests::{{#vendorExtensions}}{{{uppercase_operation_id}}}{{/vendorExtensions}};
let header = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/json{{/consumes}}";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))

View File

@ -91,9 +91,6 @@ use std::io::Error;
#[allow(unused_imports)]
use std::collections::HashMap;
#[cfg(any(feature = "client", feature = "server"))]
mod mimetypes;
#[deprecated(note = "Import swagger-rs directly")]
pub use swagger::{ApiError, ContextWrapper};
#[deprecated(note = "Import futures directly")]

View File

@ -1,22 +0,0 @@
{{^vendorExtensions.consumesMultipart}}
{{#bodyParam}}
/// Create &str objects for the request content types for {{{operationId}}}
pub static {{{vendorExtensions.uppercase_operation_id}}}: &str = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/json{{/consumes}}";
{{/bodyParam}}
{{^bodyParam}}
{{#vendorExtensions}}
{{#formParams}}
{{#-first}}
/// Create &str objects for the request content types for {{{operationId}}}
pub static {{{uppercase_operation_id}}}: &str = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/x-www-form-urlencoded{{/consumes}}";
{{/-first}}
{{/formParams}}
{{#relatedParams}}
{{#-first}}
/// Create &str objects for the request content types for {{{operationId}}}
pub static {{{uppercase_operation_id}}}: &str = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}multipart/related{{/consumes}}";
{{/-first}}
{{/relatedParams}}
{{/vendorExtensions}}
{{/bodyParam}}
{{/vendorExtensions.consumesMultipart}}

View File

@ -1,10 +0,0 @@
{{#responses}}
{{#produces}}
{{#-first}}
{{#dataType}}
/// Create &str objects for the response content types for {{{operationId}}}
pub static {{#vendorExtensions}}{{{uppercase_operation_id}}}_{{x-uppercaseResponseId}}: &str = "{{{mimeType}}}";{{/vendorExtensions}}
{{/dataType}}
{{/-first}}
{{/produces}}
{{/responses}}

View File

@ -1,39 +0,0 @@
/// mime types for requests and responses
pub mod responses {
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
{{>mimetypes-response}}
{{#callbacks}}
{{#urls}}
{{#requests}}
{{>mimetypes-response}}
{{/requests}}
{{/urls}}
{{/callbacks}}
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
}
pub mod requests {
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
{{>mimetypes-request}}
{{#callbacks}}
{{#urls}}
{{#requests}}
{{>mimetypes-request}}
{{/requests}}
{{/urls}}
{{/callbacks}}
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
}

View File

@ -6,7 +6,6 @@ use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded;
use mimetypes;
use serde_json;
use std::io;
#[allow(unused_imports)]

View File

@ -499,7 +499,7 @@
{{#vendorExtensions}}
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::{{{uppercase_operation_id}}}_{{x-uppercaseResponseId}})
HeaderValue::from_str("{{{mimeType}}}")
.expect("Unable to create Content-Type header for {{{uppercase_operation_id}}}_{{x-uppercaseResponseId}}"));
{{/vendorExtensions}}
{{/dataType}}

View File

@ -29,7 +29,6 @@ use hyper_0_10::header::{Headers, ContentType};
header! { (ContentId, "Content-ID") => [String] }
use mime_multipart::{Node, Part, generate_boundary, write_multipart};
use mimetypes;
use models;
use header;
@ -356,7 +355,7 @@ impl<C, F> Api<C> for Client<F> where
// Add the message body to the request object.
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::MULTIPART_RELATED_REQUEST_POST;
let header = "multipart/related";
request.headers_mut().insert(CONTENT_TYPE,
match HeaderValue::from_bytes(
&[header.as_bytes(), "; boundary=".as_bytes(), &boundary, "; type=\"application/json\"".as_bytes()].concat()
@ -634,7 +633,7 @@ impl<C, F> Api<C> for Client<F> where
// Add the message body to the request object.
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::MULTIPLE_IDENTICAL_MIME_TYPES_POST;
let header = "multipart/related";
request.headers_mut().insert(CONTENT_TYPE,
match HeaderValue::from_bytes(
&[header.as_bytes(), "; boundary=".as_bytes(), &boundary, "; type=\"application/json\"".as_bytes()].concat()

View File

@ -68,9 +68,6 @@ use std::io::Error;
#[allow(unused_imports)]
use std::collections::HashMap;
#[cfg(any(feature = "client", feature = "server"))]
mod mimetypes;
#[deprecated(note = "Import swagger-rs directly")]
pub use swagger::{ApiError, ContextWrapper};
#[deprecated(note = "Import futures directly")]

View File

@ -1,17 +0,0 @@
/// mime types for requests and responses
pub mod responses {
}
pub mod requests {
/// Create &str objects for the request content types for MultipartRelatedRequestPost
pub static MULTIPART_RELATED_REQUEST_POST: &str = "multipart/related";
/// Create &str objects for the request content types for MultipleIdenticalMimeTypesPost
pub static MULTIPLE_IDENTICAL_MIME_TYPES_POST: &str = "multipart/related";
}

View File

@ -6,7 +6,6 @@ use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded;
use mimetypes;
use serde_json;
use std::io;
#[allow(unused_imports)]

View File

@ -23,7 +23,6 @@ use swagger::{ApiError, Connector, client::Service, XSpanIdString, Has, AuthData
use url::form_urlencoded;
use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET};
use mimetypes;
use models;
use header;
@ -289,7 +288,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::OP_GET;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))

View File

@ -59,9 +59,6 @@ use std::io::Error;
#[allow(unused_imports)]
use std::collections::HashMap;
#[cfg(any(feature = "client", feature = "server"))]
mod mimetypes;
#[deprecated(note = "Import swagger-rs directly")]
pub use swagger::{ApiError, ContextWrapper};
#[deprecated(note = "Import futures directly")]

View File

@ -1,11 +0,0 @@
/// mime types for requests and responses
pub mod responses {
}
pub mod requests {
/// Create &str objects for the request content types for OpGet
pub static OP_GET: &str = "application/json";
}

View File

@ -6,7 +6,6 @@ use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded;
use mimetypes;
use serde_json;
use std::io;
#[allow(unused_imports)]

View File

@ -6,7 +6,6 @@ use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded;
use mimetypes;
use serde_json;
use std::io;
#[allow(unused_imports)]

View File

@ -25,7 +25,6 @@ use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_
use uuid;
use serde_xml_rs;
use mimetypes;
use models;
use header;
@ -1158,7 +1157,7 @@ impl<C, F> Api<C> for Client<F> where
let body = param_body.0;
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::REQUIRED_OCTET_STREAM_PUT;
let header = "application/octet-stream";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1482,7 +1481,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::UNTYPED_PROPERTY_GET;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1649,7 +1648,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::XML_EXTRA_POST;
let header = "application/xml";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1741,7 +1740,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::XML_OTHER_POST;
let header = "application/xml";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1833,7 +1832,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::XML_OTHER_PUT;
let header = "application/xml";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1925,7 +1924,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::XML_POST;
let header = "application/xml";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -2018,7 +2017,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::XML_PUT;
let header = "application/xml";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))

View File

@ -59,9 +59,6 @@ use std::io::Error;
#[allow(unused_imports)]
use std::collections::HashMap;
#[cfg(any(feature = "client", feature = "server"))]
mod mimetypes;
#[deprecated(note = "Import swagger-rs directly")]
pub use swagger::{ApiError, ContextWrapper};
#[deprecated(note = "Import futures directly")]

View File

@ -1,91 +0,0 @@
/// mime types for requests and responses
pub mod responses {
/// Create &str objects for the response content types for MergePatchJsonGet
pub static MERGE_PATCH_JSON_GET_MERGE: &str = "application/merge-patch+json";
/// Create &str objects for the response content types for MultigetGet
pub static MULTIGET_GET_JSON_RSP: &str = "application/json";
/// Create &str objects for the response content types for MultigetGet
pub static MULTIGET_GET_XML_RSP: &str = "application/xml";
/// Create &str objects for the response content types for MultigetGet
pub static MULTIGET_GET_OCTET_RSP: &str = "application/octet-stream";
/// Create &str objects for the response content types for MultigetGet
pub static MULTIGET_GET_STRING_RSP: &str = "text/plain";
/// Create &str objects for the response content types for MultigetGet
pub static MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT: &str = "application/json";
/// Create &str objects for the response content types for MultigetGet
pub static MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_2: &str = "application/json";
/// Create &str objects for the response content types for MultigetGet
pub static MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_3: &str = "application/json";
/// Create &str objects for the response content types for ParamgetGet
pub static PARAMGET_GET_JSON_RSP: &str = "application/json";
/// Create &str objects for the response content types for ResponsesWithHeadersGet
pub static RESPONSES_WITH_HEADERS_GET_SUCCESS: &str = "application/json";
/// Create &str objects for the response content types for Rfc7807Get
pub static RFC7807_GET_OK: &str = "application/json";
/// Create &str objects for the response content types for Rfc7807Get
pub static RFC7807_GET_NOT_FOUND: &str = "application/problem+json";
/// Create &str objects for the response content types for Rfc7807Get
pub static RFC7807_GET_NOT_ACCEPTABLE: &str = "application/problem+xml";
/// Create &str objects for the response content types for UuidGet
pub static UUID_GET_DUPLICATE_RESPONSE_LONG_TEXT: &str = "application/json";
}
pub mod requests {
/// Create &str objects for the request content types for RequiredOctetStreamPut
pub static REQUIRED_OCTET_STREAM_PUT: &str = "application/octet-stream";
/// Create &str objects for the request content types for UntypedPropertyGet
pub static UNTYPED_PROPERTY_GET: &str = "application/json";
/// Create &str objects for the request content types for XmlExtraPost
pub static XML_EXTRA_POST: &str = "application/xml";
/// Create &str objects for the request content types for XmlOtherPost
pub static XML_OTHER_POST: &str = "application/xml";
/// Create &str objects for the request content types for XmlOtherPut
pub static XML_OTHER_PUT: &str = "application/xml";
/// Create &str objects for the request content types for XmlPost
pub static XML_POST: &str = "application/xml";
/// Create &str objects for the request content types for XmlPut
pub static XML_PUT: &str = "application/xml";
}

View File

@ -25,7 +25,6 @@ use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_
use uuid;
use serde_xml_rs;
use mimetypes;
use models;
use header;

View File

@ -6,7 +6,6 @@ use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded;
use mimetypes;
use serde_json;
use std::io;
#[allow(unused_imports)]
@ -366,7 +365,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::MERGE_PATCH_JSON_GET_MERGE)
HeaderValue::from_str("application/merge-patch+json")
.expect("Unable to create Content-Type header for MERGE_PATCH_JSON_GET_MERGE"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -409,7 +408,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::MULTIGET_GET_JSON_RSP)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for MULTIGET_GET_JSON_RSP"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -420,7 +419,7 @@ where
*response.status_mut() = StatusCode::from_u16(201).expect("Unable to turn 201 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::MULTIGET_GET_XML_RSP)
HeaderValue::from_str("application/xml")
.expect("Unable to create Content-Type header for MULTIGET_GET_XML_RSP"));
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -431,7 +430,7 @@ where
*response.status_mut() = StatusCode::from_u16(202).expect("Unable to turn 202 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::MULTIGET_GET_OCTET_RSP)
HeaderValue::from_str("application/octet-stream")
.expect("Unable to create Content-Type header for MULTIGET_GET_OCTET_RSP"));
let body = body.0;
*response.body_mut() = Body::from(body);
@ -442,7 +441,7 @@ where
*response.status_mut() = StatusCode::from_u16(203).expect("Unable to turn 203 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::MULTIGET_GET_STRING_RSP)
HeaderValue::from_str("text/plain")
.expect("Unable to create Content-Type header for MULTIGET_GET_STRING_RSP"));
let body = body;
*response.body_mut() = Body::from(body);
@ -453,7 +452,7 @@ where
*response.status_mut() = StatusCode::from_u16(204).expect("Unable to turn 204 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -464,7 +463,7 @@ where
*response.status_mut() = StatusCode::from_u16(205).expect("Unable to turn 205 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_2)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_2"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -475,7 +474,7 @@ where
*response.status_mut() = StatusCode::from_u16(206).expect("Unable to turn 206 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_3)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_3"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -599,7 +598,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::PARAMGET_GET_JSON_RSP)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for PARAMGET_GET_JSON_RSP"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -835,7 +834,7 @@ where
);
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::RESPONSES_WITH_HEADERS_GET_SUCCESS)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for RESPONSES_WITH_HEADERS_GET_SUCCESS"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -894,7 +893,7 @@ where
*response.status_mut() = StatusCode::from_u16(204).expect("Unable to turn 204 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::RFC7807_GET_OK)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for RFC7807_GET_OK"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -905,7 +904,7 @@ where
*response.status_mut() = StatusCode::from_u16(404).expect("Unable to turn 404 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::RFC7807_GET_NOT_FOUND)
HeaderValue::from_str("application/problem+json")
.expect("Unable to create Content-Type header for RFC7807_GET_NOT_FOUND"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -916,7 +915,7 @@ where
*response.status_mut() = StatusCode::from_u16(406).expect("Unable to turn 406 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::RFC7807_GET_NOT_ACCEPTABLE)
HeaderValue::from_str("application/problem+xml")
.expect("Unable to create Content-Type header for RFC7807_GET_NOT_ACCEPTABLE"));
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -1028,7 +1027,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::UUID_GET_DUPLICATE_RESPONSE_LONG_TEXT)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for UUID_GET_DUPLICATE_RESPONSE_LONG_TEXT"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);

View File

@ -23,7 +23,6 @@ use swagger::{ApiError, Connector, client::Service, XSpanIdString, Has, AuthData
use url::form_urlencoded;
use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET};
use mimetypes;
use models;
use header;

View File

@ -59,9 +59,6 @@ use std::io::Error;
#[allow(unused_imports)]
use std::collections::HashMap;
#[cfg(any(feature = "client", feature = "server"))]
mod mimetypes;
#[deprecated(note = "Import swagger-rs directly")]
pub use swagger::{ApiError, ContextWrapper};
#[deprecated(note = "Import futures directly")]

View File

@ -1,81 +0,0 @@
/// mime types for requests and responses
pub mod responses {
}
pub mod requests {
}

View File

@ -6,7 +6,6 @@ use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded;
use mimetypes;
use serde_json;
use std::io;
#[allow(unused_imports)]

View File

@ -28,7 +28,6 @@ use multipart::client::lazy::Multipart;
use uuid;
use serde_xml_rs;
use mimetypes;
use models;
use header;
@ -328,7 +327,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::TEST_SPECIAL_TAGS;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -496,7 +495,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::FAKE_OUTER_BOOLEAN_SERIALIZE;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -592,7 +591,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::FAKE_OUTER_COMPOSITE_SERIALIZE;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -688,7 +687,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::FAKE_OUTER_NUMBER_SERIALIZE;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -784,7 +783,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
}
let header = &mimetypes::requests::FAKE_OUTER_STRING_SERIALIZE;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1022,7 +1021,7 @@ impl<C, F> Api<C> for Client<F> where
let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::TEST_BODY_WITH_QUERY_PARAMS;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1102,7 +1101,7 @@ impl<C, F> Api<C> for Client<F> where
let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::TEST_CLIENT_MODEL;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1222,7 +1221,7 @@ impl<C, F> Api<C> for Client<F> where
];
let body = serde_urlencoded::to_string(params).expect("impossible to fail to serialize");
let header = &mimetypes::requests::TEST_ENDPOINT_PARAMETERS;
let header = "application/x-www-form-urlencoded";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1348,7 +1347,7 @@ impl<C, F> Api<C> for Client<F> where
];
let body = serde_urlencoded::to_string(params).expect("impossible to fail to serialize");
let header = &mimetypes::requests::TEST_ENUM_PARAMETERS;
let header = "application/x-www-form-urlencoded";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1446,7 +1445,7 @@ impl<C, F> Api<C> for Client<F> where
let body = serde_json::to_string(&param_param).expect("impossible to fail to serialize");
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::TEST_INLINE_ADDITIONAL_PROPERTIES;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1530,7 +1529,7 @@ impl<C, F> Api<C> for Client<F> where
];
let body = serde_urlencoded::to_string(params).expect("impossible to fail to serialize");
let header = &mimetypes::requests::TEST_JSON_FORM_DATA;
let header = "application/x-www-form-urlencoded";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1618,7 +1617,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::TEST_CLASSNAME;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -1719,7 +1718,7 @@ impl<C, F> Api<C> for Client<F> where
let body = param_body.to_xml();
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::ADD_PET;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -2246,7 +2245,7 @@ impl<C, F> Api<C> for Client<F> where
let body = param_body.to_xml();
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::UPDATE_PET;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -2365,7 +2364,7 @@ impl<C, F> Api<C> for Client<F> where
];
let body = serde_urlencoded::to_string(params).expect("impossible to fail to serialize");
let header = &mimetypes::requests::UPDATE_PET_WITH_FORM;
let header = "application/x-www-form-urlencoded";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -2891,7 +2890,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::PLACE_ORDER;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -2995,7 +2994,7 @@ impl<C, F> Api<C> for Client<F> where
let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::CREATE_USER;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -3075,7 +3074,7 @@ impl<C, F> Api<C> for Client<F> where
let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::CREATE_USERS_WITH_ARRAY_INPUT;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -3155,7 +3154,7 @@ impl<C, F> Api<C> for Client<F> where
let body = serde_json::to_string(&param_body).expect("impossible to fail to serialize");
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::CREATE_USERS_WITH_LIST_INPUT;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -3602,7 +3601,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::UPDATE_USER;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))

View File

@ -63,9 +63,6 @@ use std::io::Error;
#[allow(unused_imports)]
use std::collections::HashMap;
#[cfg(any(feature = "client", feature = "server"))]
mod mimetypes;
#[deprecated(note = "Import swagger-rs directly")]
pub use swagger::{ApiError, ContextWrapper};
#[deprecated(note = "Import futures directly")]

View File

@ -1,149 +0,0 @@
/// mime types for requests and responses
pub mod responses {
/// Create &str objects for the response content types for TestSpecialTags
pub static TEST_SPECIAL_TAGS_SUCCESSFUL_OPERATION: &str = "application/json";
/// Create &str objects for the response content types for FakeOuterBooleanSerialize
pub static FAKE_OUTER_BOOLEAN_SERIALIZE_OUTPUT_BOOLEAN: &str = "*/*";
/// Create &str objects for the response content types for FakeOuterCompositeSerialize
pub static FAKE_OUTER_COMPOSITE_SERIALIZE_OUTPUT_COMPOSITE: &str = "*/*";
/// Create &str objects for the response content types for FakeOuterNumberSerialize
pub static FAKE_OUTER_NUMBER_SERIALIZE_OUTPUT_NUMBER: &str = "*/*";
/// Create &str objects for the response content types for FakeOuterStringSerialize
pub static FAKE_OUTER_STRING_SERIALIZE_OUTPUT_STRING: &str = "*/*";
/// Create &str objects for the response content types for TestClientModel
pub static TEST_CLIENT_MODEL_SUCCESSFUL_OPERATION: &str = "application/json";
/// Create &str objects for the response content types for TestClassname
pub static TEST_CLASSNAME_SUCCESSFUL_OPERATION: &str = "application/json";
/// Create &str objects for the response content types for FindPetsByStatus
pub static FIND_PETS_BY_STATUS_SUCCESSFUL_OPERATION: &str = "application/xml";
/// Create &str objects for the response content types for FindPetsByTags
pub static FIND_PETS_BY_TAGS_SUCCESSFUL_OPERATION: &str = "application/xml";
/// Create &str objects for the response content types for GetPetById
pub static GET_PET_BY_ID_SUCCESSFUL_OPERATION: &str = "application/xml";
/// Create &str objects for the response content types for UploadFile
pub static UPLOAD_FILE_SUCCESSFUL_OPERATION: &str = "application/json";
/// Create &str objects for the response content types for GetInventory
pub static GET_INVENTORY_SUCCESSFUL_OPERATION: &str = "application/json";
/// Create &str objects for the response content types for GetOrderById
pub static GET_ORDER_BY_ID_SUCCESSFUL_OPERATION: &str = "application/xml";
/// Create &str objects for the response content types for PlaceOrder
pub static PLACE_ORDER_SUCCESSFUL_OPERATION: &str = "application/xml";
/// Create &str objects for the response content types for GetUserByName
pub static GET_USER_BY_NAME_SUCCESSFUL_OPERATION: &str = "application/xml";
/// Create &str objects for the response content types for LoginUser
pub static LOGIN_USER_SUCCESSFUL_OPERATION: &str = "application/xml";
}
pub mod requests {
/// Create &str objects for the request content types for TestSpecialTags
pub static TEST_SPECIAL_TAGS: &str = "application/json";
/// Create &str objects for the request content types for FakeOuterBooleanSerialize
pub static FAKE_OUTER_BOOLEAN_SERIALIZE: &str = "application/json";
/// Create &str objects for the request content types for FakeOuterCompositeSerialize
pub static FAKE_OUTER_COMPOSITE_SERIALIZE: &str = "application/json";
/// Create &str objects for the request content types for FakeOuterNumberSerialize
pub static FAKE_OUTER_NUMBER_SERIALIZE: &str = "application/json";
/// Create &str objects for the request content types for FakeOuterStringSerialize
pub static FAKE_OUTER_STRING_SERIALIZE: &str = "application/json";
/// Create &str objects for the request content types for TestBodyWithQueryParams
pub static TEST_BODY_WITH_QUERY_PARAMS: &str = "application/json";
/// Create &str objects for the request content types for TestClientModel
pub static TEST_CLIENT_MODEL: &str = "application/json";
/// Create &str objects for the request content types for TestEndpointParameters
pub static TEST_ENDPOINT_PARAMETERS: &str = "application/x-www-form-urlencoded";
/// Create &str objects for the request content types for TestEnumParameters
pub static TEST_ENUM_PARAMETERS: &str = "application/x-www-form-urlencoded";
/// Create &str objects for the request content types for TestInlineAdditionalProperties
pub static TEST_INLINE_ADDITIONAL_PROPERTIES: &str = "application/json";
/// Create &str objects for the request content types for TestJsonFormData
pub static TEST_JSON_FORM_DATA: &str = "application/x-www-form-urlencoded";
/// Create &str objects for the request content types for TestClassname
pub static TEST_CLASSNAME: &str = "application/json";
/// Create &str objects for the request content types for AddPet
pub static ADD_PET: &str = "application/json";
/// Create &str objects for the request content types for UpdatePet
pub static UPDATE_PET: &str = "application/json";
/// Create &str objects for the request content types for UpdatePetWithForm
pub static UPDATE_PET_WITH_FORM: &str = "application/x-www-form-urlencoded";
/// Create &str objects for the request content types for PlaceOrder
pub static PLACE_ORDER: &str = "application/json";
/// Create &str objects for the request content types for CreateUser
pub static CREATE_USER: &str = "application/json";
/// Create &str objects for the request content types for CreateUsersWithArrayInput
pub static CREATE_USERS_WITH_ARRAY_INPUT: &str = "application/json";
/// Create &str objects for the request content types for CreateUsersWithListInput
pub static CREATE_USERS_WITH_LIST_INPUT: &str = "application/json";
/// Create &str objects for the request content types for UpdateUser
pub static UPDATE_USER: &str = "application/json";
}

View File

@ -6,7 +6,6 @@ use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded;
use mimetypes;
use serde_json;
use std::io;
#[allow(unused_imports)]
@ -296,7 +295,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::TEST_SPECIAL_TAGS_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for TEST_SPECIAL_TAGS_SUCCESSFUL_OPERATION"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -408,7 +407,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::FAKE_OUTER_BOOLEAN_SERIALIZE_OUTPUT_BOOLEAN)
HeaderValue::from_str("*/*")
.expect("Unable to create Content-Type header for FAKE_OUTER_BOOLEAN_SERIALIZE_OUTPUT_BOOLEAN"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -484,7 +483,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::FAKE_OUTER_COMPOSITE_SERIALIZE_OUTPUT_COMPOSITE)
HeaderValue::from_str("*/*")
.expect("Unable to create Content-Type header for FAKE_OUTER_COMPOSITE_SERIALIZE_OUTPUT_COMPOSITE"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -560,7 +559,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::FAKE_OUTER_NUMBER_SERIALIZE_OUTPUT_NUMBER)
HeaderValue::from_str("*/*")
.expect("Unable to create Content-Type header for FAKE_OUTER_NUMBER_SERIALIZE_OUTPUT_NUMBER"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -636,7 +635,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::FAKE_OUTER_STRING_SERIALIZE_OUTPUT_STRING)
HeaderValue::from_str("*/*")
.expect("Unable to create Content-Type header for FAKE_OUTER_STRING_SERIALIZE_OUTPUT_STRING"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -916,7 +915,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::TEST_CLIENT_MODEL_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for TEST_CLIENT_MODEL_SUCCESSFUL_OPERATION"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -1295,7 +1294,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::TEST_CLASSNAME_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for TEST_CLASSNAME_SUCCESSFUL_OPERATION"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -1588,7 +1587,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::FIND_PETS_BY_STATUS_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/xml")
.expect("Unable to create Content-Type header for FIND_PETS_BY_STATUS_SUCCESSFUL_OPERATION"));
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -1672,7 +1671,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::FIND_PETS_BY_TAGS_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/xml")
.expect("Unable to create Content-Type header for FIND_PETS_BY_TAGS_SUCCESSFUL_OPERATION"));
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -1753,7 +1752,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::GET_PET_BY_ID_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/xml")
.expect("Unable to create Content-Type header for GET_PET_BY_ID_SUCCESSFUL_OPERATION"));
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -2148,7 +2147,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::UPLOAD_FILE_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for UPLOAD_FILE_SUCCESSFUL_OPERATION"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -2272,7 +2271,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::GET_INVENTORY_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for GET_INVENTORY_SUCCESSFUL_OPERATION"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -2339,7 +2338,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::GET_ORDER_BY_ID_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/xml")
.expect("Unable to create Content-Type header for GET_ORDER_BY_ID_SUCCESSFUL_OPERATION"));
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -2427,7 +2426,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::PLACE_ORDER_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/xml")
.expect("Unable to create Content-Type header for PLACE_ORDER_SUCCESSFUL_OPERATION"));
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -2805,7 +2804,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::GET_USER_BY_NAME_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/xml")
.expect("Unable to create Content-Type header for GET_USER_BY_NAME_SUCCESSFUL_OPERATION"));
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -2903,7 +2902,7 @@ where
);
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::LOGIN_USER_SUCCESSFUL_OPERATION)
HeaderValue::from_str("application/xml")
.expect("Unable to create Content-Type header for LOGIN_USER_SUCCESSFUL_OPERATION"));
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);

View File

@ -23,7 +23,6 @@ use swagger::{ApiError, Connector, client::Service, XSpanIdString, Has, AuthData
use url::form_urlencoded;
use url::percent_encoding::{utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, QUERY_ENCODE_SET};
use mimetypes;
use models;
use header;
@ -449,7 +448,7 @@ impl<C, F> Api<C> for Client<F> where
let body = serde_json::to_string(&param_nested_response).expect("impossible to fail to serialize");
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::DUMMY_PUT;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -694,7 +693,7 @@ impl<C, F> Api<C> for Client<F> where
let body = param_body;
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::HTML_POST;
let header = "text/html";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -785,7 +784,7 @@ impl<C, F> Api<C> for Client<F> where
let body = param_value;
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::POST_YAML;
let header = "application/yaml";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))
@ -949,7 +948,7 @@ impl<C, F> Api<C> for Client<F> where
*request.body_mut() = Body::from(body);
let header = &mimetypes::requests::SOLO_OBJECT_POST;
let header = "application/json";
request.headers_mut().insert(CONTENT_TYPE, match HeaderValue::from_str(header) {
Ok(h) => h,
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", header, e))))

View File

@ -59,9 +59,6 @@ use std::io::Error;
#[allow(unused_imports)]
use std::collections::HashMap;
#[cfg(any(feature = "client", feature = "server"))]
mod mimetypes;
#[deprecated(note = "Import swagger-rs directly")]
pub use swagger::{ApiError, ContextWrapper};
#[deprecated(note = "Import futures directly")]

View File

@ -1,43 +0,0 @@
/// mime types for requests and responses
pub mod responses {
/// Create &str objects for the response content types for AllOfGet
pub static ALL_OF_GET_OK: &str = "*/*";
/// Create &str objects for the response content types for FileResponseGet
pub static FILE_RESPONSE_GET_SUCCESS: &str = "application/json";
/// Create &str objects for the response content types for GetStructuredYaml
pub static GET_STRUCTURED_YAML_OK: &str = "application/yaml";
/// Create &str objects for the response content types for HtmlPost
pub static HTML_POST_SUCCESS: &str = "text/html";
/// Create &str objects for the response content types for RawJsonGet
pub static RAW_JSON_GET_SUCCESS: &str = "*/*";
}
pub mod requests {
/// Create &str objects for the request content types for DummyPut
pub static DUMMY_PUT: &str = "application/json";
/// Create &str objects for the request content types for HtmlPost
pub static HTML_POST: &str = "text/html";
/// Create &str objects for the request content types for PostYaml
pub static POST_YAML: &str = "application/yaml";
/// Create &str objects for the request content types for SoloObjectPost
pub static SOLO_OBJECT_POST: &str = "application/json";
}

View File

@ -6,7 +6,6 @@ use hyper;
use hyper::{Request, Response, Error, StatusCode, Body, HeaderMap};
use hyper::header::{HeaderName, HeaderValue, CONTENT_TYPE};
use url::form_urlencoded;
use mimetypes;
use serde_json;
use std::io;
#[allow(unused_imports)]
@ -166,7 +165,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::ALL_OF_GET_OK)
HeaderValue::from_str("*/*")
.expect("Unable to create Content-Type header for ALL_OF_GET_OK"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -324,7 +323,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::FILE_RESPONSE_GET_SUCCESS)
HeaderValue::from_str("application/json")
.expect("Unable to create Content-Type header for FILE_RESPONSE_GET_SUCCESS"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);
@ -367,7 +366,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::GET_STRUCTURED_YAML_OK)
HeaderValue::from_str("application/yaml")
.expect("Unable to create Content-Type header for GET_STRUCTURED_YAML_OK"));
let body = body;
*response.body_mut() = Body::from(body);
@ -435,7 +434,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::HTML_POST_SUCCESS)
HeaderValue::from_str("text/html")
.expect("Unable to create Content-Type header for HTML_POST_SUCCESS"));
let body = body;
*response.body_mut() = Body::from(body);
@ -551,7 +550,7 @@ where
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_str(mimetypes::responses::RAW_JSON_GET_SUCCESS)
HeaderValue::from_str("*/*")
.expect("Unable to create Content-Type header for RAW_JSON_GET_SUCCESS"));
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
*response.body_mut() = Body::from(body);