forked from loafle/openapi-generator-original
[Rust Server] Support octet stream body param (#2725)
Add support for having a required octet stream as a body parameter.
This commit is contained in:
parent
16f94e7e62
commit
31734c2717
@ -64,6 +64,9 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
protected String externCrateName;
|
protected String externCrateName;
|
||||||
protected Map<String, Map<String, String>> pathSetMap = new HashMap<String, Map<String, String>>();
|
protected Map<String, Map<String, String>> pathSetMap = new HashMap<String, Map<String, String>>();
|
||||||
|
|
||||||
|
private static final String uuidType = "uuid::Uuid";
|
||||||
|
private static final String bytesType = "swagger::ByteArray";
|
||||||
|
|
||||||
public RustServerCodegen() {
|
public RustServerCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -150,16 +153,16 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("float", "f32");
|
typeMapping.put("float", "f32");
|
||||||
typeMapping.put("double", "f64");
|
typeMapping.put("double", "f64");
|
||||||
typeMapping.put("string", "String");
|
typeMapping.put("string", "String");
|
||||||
typeMapping.put("UUID", "uuid::Uuid");
|
typeMapping.put("UUID", uuidType);
|
||||||
typeMapping.put("byte", "u8");
|
typeMapping.put("byte", "u8");
|
||||||
typeMapping.put("ByteArray", "swagger::ByteArray");
|
typeMapping.put("ByteArray", bytesType);
|
||||||
typeMapping.put("binary", "swagger::ByteArray");
|
typeMapping.put("binary", bytesType);
|
||||||
typeMapping.put("boolean", "bool");
|
typeMapping.put("boolean", "bool");
|
||||||
typeMapping.put("date", "chrono::DateTime<chrono::Utc>");
|
typeMapping.put("date", "chrono::DateTime<chrono::Utc>");
|
||||||
typeMapping.put("DateTime", "chrono::DateTime<chrono::Utc>");
|
typeMapping.put("DateTime", "chrono::DateTime<chrono::Utc>");
|
||||||
typeMapping.put("password", "String");
|
typeMapping.put("password", "String");
|
||||||
typeMapping.put("File", "swagger::ByteArray");
|
typeMapping.put("File", bytesType);
|
||||||
typeMapping.put("file", "swagger::ByteArray");
|
typeMapping.put("file", bytesType);
|
||||||
typeMapping.put("array", "Vec");
|
typeMapping.put("array", "Vec");
|
||||||
typeMapping.put("map", "HashMap");
|
typeMapping.put("map", "HashMap");
|
||||||
|
|
||||||
@ -498,6 +501,18 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded");
|
return mimetype.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isMimetypeMultipartFormData(String mimetype) {
|
||||||
|
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/form-data");
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isMimetypeOctetStream(String mimetype) {
|
||||||
|
return mimetype.toLowerCase(Locale.ROOT).startsWith("application/octet-stream");
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isMimetypePlain(String mimetype) {
|
||||||
|
return isMimetypePlainText(mimetype) || isMimetypeHtmlText(mimetype) || isMimetypeOctetStream(mimetype);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
|
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List<Server> servers) {
|
||||||
Map<String, Schema> definitions = ModelUtils.getSchemas(this.openAPI);
|
Map<String, Schema> definitions = ModelUtils.getSchemas(this.openAPI);
|
||||||
@ -563,9 +578,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if (isMimetypeXml(mimeType)) {
|
if (isMimetypeXml(mimeType)) {
|
||||||
additionalProperties.put("usesXml", true);
|
additionalProperties.put("usesXml", true);
|
||||||
consumesXml = true;
|
consumesXml = true;
|
||||||
} else if (isMimetypePlainText(mimeType)) {
|
} else if (isMimetypePlain(mimeType)) {
|
||||||
consumesPlainText = true;
|
|
||||||
} else if (isMimetypeHtmlText(mimeType)) {
|
|
||||||
consumesPlainText = true;
|
consumesPlainText = true;
|
||||||
} else if (isMimetypeWwwFormUrlEncoded(mimeType)) {
|
} else if (isMimetypeWwwFormUrlEncoded(mimeType)) {
|
||||||
additionalProperties.put("usesUrlEncodedForm", true);
|
additionalProperties.put("usesUrlEncodedForm", true);
|
||||||
@ -591,9 +604,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if (isMimetypeXml(mimeType)) {
|
if (isMimetypeXml(mimeType)) {
|
||||||
additionalProperties.put("usesXml", true);
|
additionalProperties.put("usesXml", true);
|
||||||
producesXml = true;
|
producesXml = true;
|
||||||
} else if (isMimetypePlainText(mimeType)) {
|
} else if (isMimetypePlain(mimeType)) {
|
||||||
producesPlainText = true;
|
|
||||||
} else if (isMimetypeHtmlText(mimeType)) {
|
|
||||||
producesPlainText = true;
|
producesPlainText = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,7 +617,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
for (CodegenParameter param : op.headerParams) {
|
for (CodegenParameter param : op.headerParams) {
|
||||||
// If a header uses UUIDs, we need to import the UUID package.
|
// If a header uses UUIDs, we need to import the UUID package.
|
||||||
if (param.dataType.equals("uuid::Uuid")) {
|
if (param.dataType.equals(uuidType)) {
|
||||||
additionalProperties.put("apiUsesUuid", true);
|
additionalProperties.put("apiUsesUuid", true);
|
||||||
}
|
}
|
||||||
processParam(param, op);
|
processParam(param, op);
|
||||||
@ -634,7 +645,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
// Default to producing json if nothing else is specified
|
// Default to producing json if nothing else is specified
|
||||||
if (producesXml) {
|
if (producesXml) {
|
||||||
rsp.vendorExtensions.put("producesXml", true);
|
rsp.vendorExtensions.put("producesXml", true);
|
||||||
} else if (producesPlainText) {
|
} else if (producesPlainText && rsp.dataType.equals(bytesType)) {
|
||||||
rsp.vendorExtensions.put("producesPlainText", true);
|
rsp.vendorExtensions.put("producesPlainText", true);
|
||||||
} else {
|
} else {
|
||||||
rsp.vendorExtensions.put("producesJson", true);
|
rsp.vendorExtensions.put("producesJson", true);
|
||||||
@ -659,14 +670,14 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (CodegenProperty header : rsp.headers) {
|
for (CodegenProperty header : rsp.headers) {
|
||||||
if (header.dataType.equals("uuid::Uuid")) {
|
if (header.dataType.equals(uuidType)) {
|
||||||
additionalProperties.put("apiUsesUuid", true);
|
additionalProperties.put("apiUsesUuid", true);
|
||||||
}
|
}
|
||||||
header.nameInCamelCase = toModelName(header.baseName);
|
header.nameInCamelCase = toModelName(header.baseName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (CodegenProperty header : op.responseHeaders) {
|
for (CodegenProperty header : op.responseHeaders) {
|
||||||
if (header.dataType.equals("uuid::Uuid")) {
|
if (header.dataType.equals(uuidType)) {
|
||||||
additionalProperties.put("apiUsesUuid", true);
|
additionalProperties.put("apiUsesUuid", true);
|
||||||
}
|
}
|
||||||
header.nameInCamelCase = toModelName(header.baseName);
|
header.nameInCamelCase = toModelName(header.baseName);
|
||||||
@ -693,7 +704,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if (isMimetypeXml(mediaType)) {
|
if (isMimetypeXml(mediaType)) {
|
||||||
additionalProperties.put("usesXml", true);
|
additionalProperties.put("usesXml", true);
|
||||||
consumesXml = true;
|
consumesXml = true;
|
||||||
} else if (isMimetypePlainText(mediaType) || isMimetypeHtmlText(mediaType)) {
|
} else if (isMimetypePlain(mediaType)) {
|
||||||
consumesPlainText = true;
|
consumesPlainText = true;
|
||||||
} else if (isMimetypeWwwFormUrlEncoded(mediaType)) {
|
} else if (isMimetypeWwwFormUrlEncoded(mediaType)) {
|
||||||
additionalProperties.put("usesUrlEncodedForm", true);
|
additionalProperties.put("usesUrlEncodedForm", true);
|
||||||
@ -734,7 +745,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (CodegenProperty header : op.responseHeaders) {
|
for (CodegenProperty header : op.responseHeaders) {
|
||||||
if (header.dataType.equals("uuid::Uuid")) {
|
if (header.dataType.equals(uuidType)) {
|
||||||
additionalProperties.put("apiUsesUuid", true);
|
additionalProperties.put("apiUsesUuid", true);
|
||||||
}
|
}
|
||||||
header.nameInCamelCase = toModelName(header.baseName);
|
header.nameInCamelCase = toModelName(header.baseName);
|
||||||
@ -1108,6 +1119,8 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
cm.dataType = typeMapping.get(cm.dataType);
|
cm.dataType = typeMapping.get(cm.dataType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cm.vendorExtensions.put("isString", "String".equals(cm.dataType));
|
||||||
}
|
}
|
||||||
return super.postProcessModelsEnum(objs);
|
return super.postProcessModelsEnum(objs);
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
{{/-first}}
|
{{/-first}}
|
||||||
{{#vendorExtensions}}
|
{{#vendorExtensions}}
|
||||||
{{#consumesPlainText}}
|
{{#consumesPlainText}}
|
||||||
|
{{#isByteArray}}
|
||||||
|
let body = param_{{{paramName}}}.0;
|
||||||
|
{{/isByteArray}}
|
||||||
|
{{^isByteArray}}
|
||||||
let body = param_{{{paramName}}};
|
let body = param_{{{paramName}}};
|
||||||
|
{{/isByteArray}}
|
||||||
{{/consumesPlainText}}
|
{{/consumesPlainText}}
|
||||||
{{#required}}
|
{{#required}}
|
||||||
{{#consumesXml}}
|
{{#consumesXml}}
|
||||||
@ -310,7 +315,7 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
{{/bodyParam}}
|
{{/bodyParam}}
|
||||||
|
|
||||||
{{#bodyParam}}{{^required}}if let Some(body) = body {
|
{{#bodyParam}}{{^required}}if let Some(body) = body {
|
||||||
{{/required}} request.set_body(body.into_bytes());
|
{{/required}} request.set_body(body);
|
||||||
{{^required}} }{{/required}}
|
{{^required}} }{{/required}}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::{{#vendorExtensions}}{{{uppercase_operation_id}}}{{/vendorExtensions}}.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::{{#vendorExtensions}}{{{uppercase_operation_id}}}{{/vendorExtensions}}.clone()));
|
||||||
@ -353,10 +358,15 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
{{#vendorExtensions}}
|
||||||
|
{{#producesPlainText}}
|
||||||
|
Ok(swagger::ByteArray(body.to_vec()))
|
||||||
|
{{/producesPlainText}}{{^producesPlainText}}
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
{{#vendorExtensions}}{{#producesXml}}
|
{{#producesXml}}
|
||||||
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
||||||
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
||||||
serde_xml_rs::from_str::<{{{dataType}}}>(body)
|
serde_xml_rs::from_str::<{{{dataType}}}>(body)
|
||||||
@ -364,13 +374,13 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
{{/producesXml}}{{#producesJson}}
|
{{/producesXml}}{{#producesJson}}
|
||||||
serde_json::from_str::<{{{dataType}}}>(body)
|
serde_json::from_str::<{{{dataType}}}>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
{{/producesJson}}{{#producesPlainText}}
|
{{/producesJson}}
|
||||||
Ok(body.to_string())
|
)
|
||||||
{{/producesPlainText}}{{/vendorExtensions}}
|
{{/producesPlainText}}{{/vendorExtensions}}
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
{{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}}{{^headers}}(body){{/headers}}{{#headers}}{{#-first}}{ body: body, {{/-first}}{{{name}}}: response_{{{name}}}{{^-last}}, {{/-last}}{{#-last}} }{{/-last}}{{/headers}}
|
{{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}}{{^headers}}(body){{/headers}}{{#headers}}{{#-first}}{ body: body, {{/-first}}{{{name}}}: response_{{{name}}}{{^-last}}, {{/-last}}{{#-last}} }{{/-last}}{{/headers}}
|
||||||
)
|
})
|
||||||
{{/dataType}}{{^dataType}}
|
{{/dataType}}{{^dataType}}
|
||||||
future::ok(
|
future::ok(
|
||||||
{{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}}{{#headers}}{{#-first}}{ {{/-first}}{{^-first}}, {{/-first}}{{{name}}}: response_{{{name}}}{{#-last}} }{{/-last}}{{/headers}}
|
{{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}}{{#headers}}{{#-first}}{ {{/-first}}{{^-first}}, {{/-first}}{{{name}}}: response_{{{name}}}{{#-last}} }{{/-last}}{{/headers}}
|
||||||
|
@ -15,6 +15,8 @@ use std::collections::HashMap;
|
|||||||
{{/usesXml}}
|
{{/usesXml}}
|
||||||
use models;
|
use models;
|
||||||
use swagger;
|
use swagger;
|
||||||
|
use std::string::ParseError;
|
||||||
|
|
||||||
|
|
||||||
{{#models}}{{#model}}
|
{{#models}}{{#model}}
|
||||||
{{#description}}/// {{{description}}}
|
{{#description}}/// {{{description}}}
|
||||||
@ -57,6 +59,15 @@ impl ::std::convert::From<{{{dataType}}}> for {{{classname}}} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{#vendorExtensions.isString}}
|
||||||
|
impl std::str::FromStr for {{{classname}}} {
|
||||||
|
type Err = ParseError;
|
||||||
|
fn from_str(x: &str) -> Result<Self, Self::Err> {
|
||||||
|
Ok({{{classname}}}(x.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{{/vendorExtensions.isString}}
|
||||||
|
|
||||||
impl ::std::convert::From<{{{classname}}}> for {{{dataType}}} {
|
impl ::std::convert::From<{{{classname}}}> for {{{dataType}}} {
|
||||||
fn from(x: {{{classname}}}) -> Self {
|
fn from(x: {{{classname}}}) -> Self {
|
||||||
x.0
|
x.0
|
||||||
|
@ -180,7 +180,7 @@ where
|
|||||||
let param_{{{paramName}}} = match percent_encoding::percent_decode(path_params["{{{baseName}}}"].as_bytes()).decode_utf8() {
|
let param_{{{paramName}}} = match percent_encoding::percent_decode(path_params["{{{baseName}}}"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_{{{paramName}}}) => match param_{{{paramName}}}.parse::<{{{dataType}}}>() {
|
Ok(param_{{{paramName}}}) => match param_{{{paramName}}}.parse::<{{{dataType}}}>() {
|
||||||
Ok(param_{{{paramName}}}) => param_{{{paramName}}},
|
Ok(param_{{{paramName}}}) => param_{{{paramName}}},
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter {{{baseName}}}: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter {{{baseName}}}: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["{{{baseName}}}"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["{{{baseName}}}"]))))
|
||||||
};
|
};
|
||||||
@ -259,10 +259,12 @@ where
|
|||||||
{{/required}}
|
{{/required}}
|
||||||
}
|
}
|
||||||
{{/consumesPlainText}}{{#consumesPlainText}}
|
{{/consumesPlainText}}{{#consumesPlainText}}
|
||||||
match String::from_utf8(body.to_vec()) {
|
{{#isByteArray}}
|
||||||
Ok(param_{{{paramName}}}) => Some(param_{{{paramName}}}),
|
Some(swagger::ByteArray(body.to_vec()))
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse body parameter {{{baseName}}} - not valid UTF-8: {}", e)))),
|
{{/isByteArray}}
|
||||||
}
|
{{#isString}}
|
||||||
|
Some(String::from_utf8(body.to_vec()).unwrap())
|
||||||
|
{{/isString}}
|
||||||
{{/consumesPlainText}}{{/vendorExtensions}}
|
{{/consumesPlainText}}{{/vendorExtensions}}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -335,7 +337,9 @@ where
|
|||||||
let body = serde_xml_rs::to_string_with_namespaces(&body, namespaces).expect("impossible to fail to serialize");
|
let body = serde_xml_rs::to_string_with_namespaces(&body, namespaces).expect("impossible to fail to serialize");
|
||||||
{{/has_namespace}}{{/producesXml}}{{#producesJson}}
|
{{/has_namespace}}{{/producesXml}}{{#producesJson}}
|
||||||
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
|
||||||
{{/producesJson}}{{/vendorExtensions}}
|
{{/producesJson}}{{#producesPlainText}}
|
||||||
|
let body = body.0;
|
||||||
|
{{/producesPlainText}}{{/vendorExtensions}}
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
{{/dataType}}
|
{{/dataType}}
|
||||||
},
|
},
|
||||||
|
@ -76,8 +76,24 @@ paths:
|
|||||||
description: 'OK'
|
description: 'OK'
|
||||||
'400':
|
'400':
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
|
/required_octet_stream:
|
||||||
|
put:
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/octet-stream:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: byte
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: 'OK'
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
UuidObject:
|
||||||
|
description: Test a model containing a UUID
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
xml_array:
|
xml_array:
|
||||||
xml:
|
xml:
|
||||||
name: CamelXmlArray
|
name: CamelXmlArray
|
||||||
|
@ -55,6 +55,7 @@ cargo run --example server
|
|||||||
To run a client, follow one of the following simple steps:
|
To run a client, follow one of the following simple steps:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
cargo run --example client RequiredOctetStreamPut
|
||||||
cargo run --example client XmlExtraPost
|
cargo run --example client XmlExtraPost
|
||||||
cargo run --example client XmlOtherPost
|
cargo run --example client XmlOtherPost
|
||||||
cargo run --example client XmlOtherPut
|
cargo run --example client XmlOtherPut
|
||||||
@ -113,6 +114,7 @@ All URIs are relative to *http://localhost*
|
|||||||
|
|
||||||
Method | HTTP request | Description
|
Method | HTTP request | Description
|
||||||
------------- | ------------- | -------------
|
------------- | ------------- | -------------
|
||||||
|
[****](docs/default_api.md#) | **PUT** /required_octet_stream |
|
||||||
[****](docs/default_api.md#) | **POST** /xml_extra |
|
[****](docs/default_api.md#) | **POST** /xml_extra |
|
||||||
[****](docs/default_api.md#) | **POST** /xml_other |
|
[****](docs/default_api.md#) | **POST** /xml_other |
|
||||||
[****](docs/default_api.md#) | **PUT** /xml_other |
|
[****](docs/default_api.md#) | **PUT** /xml_other |
|
||||||
@ -126,6 +128,7 @@ Method | HTTP request | Description
|
|||||||
- [AnotherXmlInner](docs/AnotherXmlInner.md)
|
- [AnotherXmlInner](docs/AnotherXmlInner.md)
|
||||||
- [AnotherXmlObject](docs/AnotherXmlObject.md)
|
- [AnotherXmlObject](docs/AnotherXmlObject.md)
|
||||||
- [DuplicateXmlObject](docs/DuplicateXmlObject.md)
|
- [DuplicateXmlObject](docs/DuplicateXmlObject.md)
|
||||||
|
- [UuidObject](docs/UuidObject.md)
|
||||||
- [XmlArray](docs/XmlArray.md)
|
- [XmlArray](docs/XmlArray.md)
|
||||||
- [XmlInner](docs/XmlInner.md)
|
- [XmlInner](docs/XmlInner.md)
|
||||||
- [XmlObject](docs/XmlObject.md)
|
- [XmlObject](docs/XmlObject.md)
|
||||||
|
@ -65,8 +65,24 @@ paths:
|
|||||||
description: OK
|
description: OK
|
||||||
400:
|
400:
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
|
/required_octet_stream:
|
||||||
|
put:
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/octet-stream:
|
||||||
|
schema:
|
||||||
|
format: byte
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: OK
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
UuidObject:
|
||||||
|
description: Test a model containing a UUID
|
||||||
|
format: uuid
|
||||||
|
type: string
|
||||||
xml_array:
|
xml_array:
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/xml_inner'
|
$ref: '#/components/schemas/xml_inner'
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
# UuidObject
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
@ -4,6 +4,7 @@ All URIs are relative to *http://localhost*
|
|||||||
|
|
||||||
Method | HTTP request | Description
|
Method | HTTP request | Description
|
||||||
------------- | ------------- | -------------
|
------------- | ------------- | -------------
|
||||||
|
****](default_api.md#) | **PUT** /required_octet_stream |
|
||||||
****](default_api.md#) | **POST** /xml_extra |
|
****](default_api.md#) | **POST** /xml_extra |
|
||||||
****](default_api.md#) | **POST** /xml_other |
|
****](default_api.md#) | **POST** /xml_other |
|
||||||
****](default_api.md#) | **PUT** /xml_other |
|
****](default_api.md#) | **PUT** /xml_other |
|
||||||
@ -11,6 +12,31 @@ Method | HTTP request | Description
|
|||||||
****](default_api.md#) | **PUT** /xml |
|
****](default_api.md#) | **PUT** /xml |
|
||||||
|
|
||||||
|
|
||||||
|
# ****
|
||||||
|
> (body)
|
||||||
|
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**body** | **swagger::ByteArray**| |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/octet-stream
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[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)
|
||||||
|
|
||||||
# ****
|
# ****
|
||||||
> (optional)
|
> (optional)
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ use tokio_core::reactor;
|
|||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use openapi_v3::{ApiNoContext, ContextWrapperExt,
|
use openapi_v3::{ApiNoContext, ContextWrapperExt,
|
||||||
ApiError,
|
ApiError,
|
||||||
|
RequiredOctetStreamPutResponse,
|
||||||
XmlExtraPostResponse,
|
XmlExtraPostResponse,
|
||||||
XmlOtherPostResponse,
|
XmlOtherPostResponse,
|
||||||
XmlOtherPutResponse,
|
XmlOtherPutResponse,
|
||||||
@ -32,6 +33,7 @@ fn main() {
|
|||||||
.arg(Arg::with_name("operation")
|
.arg(Arg::with_name("operation")
|
||||||
.help("Sets the operation to run")
|
.help("Sets the operation to run")
|
||||||
.possible_values(&[
|
.possible_values(&[
|
||||||
|
"RequiredOctetStreamPut",
|
||||||
"XmlExtraPost",
|
"XmlExtraPost",
|
||||||
"XmlOtherPost",
|
"XmlOtherPost",
|
||||||
"XmlOtherPut",
|
"XmlOtherPut",
|
||||||
@ -77,6 +79,11 @@ fn main() {
|
|||||||
|
|
||||||
match matches.value_of("operation") {
|
match matches.value_of("operation") {
|
||||||
|
|
||||||
|
Some("RequiredOctetStreamPut") => {
|
||||||
|
let result = core.run(client.required_octet_stream_put(swagger::ByteArray(Vec::from("BYTE_ARRAY_DATA_HERE"))));
|
||||||
|
println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has<XSpanIdString>).get().clone());
|
||||||
|
},
|
||||||
|
|
||||||
Some("XmlExtraPost") => {
|
Some("XmlExtraPost") => {
|
||||||
let result = core.run(client.xml_extra_post(None));
|
let result = core.run(client.xml_extra_post(None));
|
||||||
println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has<XSpanIdString>).get().clone());
|
println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has<XSpanIdString>).get().clone());
|
||||||
|
@ -11,6 +11,7 @@ use swagger;
|
|||||||
use swagger::{Has, XSpanIdString};
|
use swagger::{Has, XSpanIdString};
|
||||||
|
|
||||||
use openapi_v3::{Api, ApiError,
|
use openapi_v3::{Api, ApiError,
|
||||||
|
RequiredOctetStreamPutResponse,
|
||||||
XmlExtraPostResponse,
|
XmlExtraPostResponse,
|
||||||
XmlOtherPostResponse,
|
XmlOtherPostResponse,
|
||||||
XmlOtherPutResponse,
|
XmlOtherPutResponse,
|
||||||
@ -33,6 +34,13 @@ impl<C> Server<C> {
|
|||||||
impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
|
impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
|
||||||
|
|
||||||
|
|
||||||
|
fn required_octet_stream_put(&self, body: swagger::ByteArray, context: &C) -> Box<Future<Item=RequiredOctetStreamPutResponse, Error=ApiError>> {
|
||||||
|
let context = context.clone();
|
||||||
|
println!("required_octet_stream_put({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||||
|
Box::new(futures::failed("Generic failure".into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn xml_extra_post(&self, duplicate_xml_object: Option<models::DuplicateXmlObject>, context: &C) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>> {
|
fn xml_extra_post(&self, duplicate_xml_object: Option<models::DuplicateXmlObject>, context: &C) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>> {
|
||||||
let context = context.clone();
|
let context = context.clone();
|
||||||
println!("xml_extra_post({:?}) - X-Span-ID: {:?}", duplicate_xml_object, context.get().0.clone());
|
println!("xml_extra_post({:?}) - X-Span-ID: {:?}", duplicate_xml_object, context.get().0.clone());
|
||||||
|
@ -40,6 +40,7 @@ use swagger;
|
|||||||
use swagger::{ApiError, XSpanId, XSpanIdString, Has, AuthData};
|
use swagger::{ApiError, XSpanId, XSpanIdString, Has, AuthData};
|
||||||
|
|
||||||
use {Api,
|
use {Api,
|
||||||
|
RequiredOctetStreamPutResponse,
|
||||||
XmlExtraPostResponse,
|
XmlExtraPostResponse,
|
||||||
XmlOtherPostResponse,
|
XmlOtherPostResponse,
|
||||||
XmlOtherPutResponse,
|
XmlOtherPutResponse,
|
||||||
@ -250,6 +251,76 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
F: Future<Item=hyper::Response, Error=hyper::Error> + 'static,
|
F: Future<Item=hyper::Response, Error=hyper::Error> + 'static,
|
||||||
C: Has<XSpanIdString> {
|
C: Has<XSpanIdString> {
|
||||||
|
|
||||||
|
fn required_octet_stream_put(&self, param_body: swagger::ByteArray, context: &C) -> Box<Future<Item=RequiredOctetStreamPutResponse, Error=ApiError>> {
|
||||||
|
let mut uri = format!(
|
||||||
|
"{}/required_octet_stream",
|
||||||
|
self.base_path
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut query_string = self::url::form_urlencoded::Serializer::new("".to_owned());
|
||||||
|
|
||||||
|
|
||||||
|
let query_string_str = query_string.finish();
|
||||||
|
if !query_string_str.is_empty() {
|
||||||
|
uri += "?";
|
||||||
|
uri += &query_string_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
let uri = match Uri::from_str(&uri) {
|
||||||
|
Ok(uri) => uri,
|
||||||
|
Err(err) => return Box::new(futures::done(Err(ApiError(format!("Unable to build URI: {}", err))))),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut request = hyper::Request::new(hyper::Method::Put, uri);
|
||||||
|
|
||||||
|
|
||||||
|
// Body parameter
|
||||||
|
let body = param_body.0;
|
||||||
|
|
||||||
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
|
request.headers_mut().set(ContentType(mimetypes::requests::REQUIRED_OCTET_STREAM_PUT.clone()));
|
||||||
|
request.headers_mut().set(XSpanId((context as &Has<XSpanIdString>).get().0.clone()));
|
||||||
|
|
||||||
|
|
||||||
|
Box::new(self.client_service.call(request)
|
||||||
|
.map_err(|e| ApiError(format!("No response received: {}", e)))
|
||||||
|
.and_then(|mut response| {
|
||||||
|
match response.status().as_u16() {
|
||||||
|
200 => {
|
||||||
|
let body = response.body();
|
||||||
|
Box::new(
|
||||||
|
|
||||||
|
future::ok(
|
||||||
|
RequiredOctetStreamPutResponse::OK
|
||||||
|
)
|
||||||
|
) as Box<Future<Item=_, Error=_>>
|
||||||
|
},
|
||||||
|
code => {
|
||||||
|
let headers = response.headers().clone();
|
||||||
|
Box::new(response.body()
|
||||||
|
.take(100)
|
||||||
|
.concat2()
|
||||||
|
.then(move |body|
|
||||||
|
future::err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}",
|
||||||
|
code,
|
||||||
|
headers,
|
||||||
|
match body {
|
||||||
|
Ok(ref body) => match str::from_utf8(body) {
|
||||||
|
Ok(body) => Cow::from(body),
|
||||||
|
Err(e) => Cow::from(format!("<Body was not UTF8: {:?}>", e)),
|
||||||
|
},
|
||||||
|
Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
|
||||||
|
})))
|
||||||
|
)
|
||||||
|
) as Box<Future<Item=_, Error=_>>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fn xml_extra_post(&self, param_duplicate_xml_object: Option<models::DuplicateXmlObject>, context: &C) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>> {
|
fn xml_extra_post(&self, param_duplicate_xml_object: Option<models::DuplicateXmlObject>, context: &C) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>> {
|
||||||
let mut uri = format!(
|
let mut uri = format!(
|
||||||
"{}/xml_extra",
|
"{}/xml_extra",
|
||||||
@ -272,14 +343,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
|
|
||||||
let mut request = hyper::Request::new(hyper::Method::Post, uri);
|
let mut request = hyper::Request::new(hyper::Method::Post, uri);
|
||||||
|
|
||||||
|
|
||||||
// Body parameter
|
|
||||||
let body = param_duplicate_xml_object.map(|ref body| {
|
let body = param_duplicate_xml_object.map(|ref body| {
|
||||||
body.to_xml()
|
body.to_xml()
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::XML_EXTRA_POST.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::XML_EXTRA_POST.clone()));
|
||||||
@ -359,7 +428,7 @@ if let Some(body) = body {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::XML_OTHER_POST.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::XML_OTHER_POST.clone()));
|
||||||
@ -439,7 +508,7 @@ if let Some(body) = body {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::XML_OTHER_PUT.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::XML_OTHER_PUT.clone()));
|
||||||
@ -519,7 +588,7 @@ if let Some(body) = body {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::XML_POST.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::XML_POST.clone()));
|
||||||
@ -599,7 +668,7 @@ if let Some(body) = body {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::XML_PUT.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::XML_PUT.clone()));
|
||||||
|
@ -39,6 +39,12 @@ pub const BASE_PATH: &'static str = "";
|
|||||||
pub const API_VERSION: &'static str = "1.0.7";
|
pub const API_VERSION: &'static str = "1.0.7";
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub enum RequiredOctetStreamPutResponse {
|
||||||
|
/// OK
|
||||||
|
OK ,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum XmlExtraPostResponse {
|
pub enum XmlExtraPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
@ -84,6 +90,9 @@ pub enum XmlPutResponse {
|
|||||||
pub trait Api<C> {
|
pub trait Api<C> {
|
||||||
|
|
||||||
|
|
||||||
|
fn required_octet_stream_put(&self, body: swagger::ByteArray, context: &C) -> Box<Future<Item=RequiredOctetStreamPutResponse, Error=ApiError>>;
|
||||||
|
|
||||||
|
|
||||||
fn xml_extra_post(&self, duplicate_xml_object: Option<models::DuplicateXmlObject>, context: &C) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>>;
|
fn xml_extra_post(&self, duplicate_xml_object: Option<models::DuplicateXmlObject>, context: &C) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>>;
|
||||||
|
|
||||||
|
|
||||||
@ -104,6 +113,9 @@ pub trait Api<C> {
|
|||||||
pub trait ApiNoContext {
|
pub trait ApiNoContext {
|
||||||
|
|
||||||
|
|
||||||
|
fn required_octet_stream_put(&self, body: swagger::ByteArray) -> Box<Future<Item=RequiredOctetStreamPutResponse, Error=ApiError>>;
|
||||||
|
|
||||||
|
|
||||||
fn xml_extra_post(&self, duplicate_xml_object: Option<models::DuplicateXmlObject>) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>>;
|
fn xml_extra_post(&self, duplicate_xml_object: Option<models::DuplicateXmlObject>) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>>;
|
||||||
|
|
||||||
|
|
||||||
@ -135,6 +147,11 @@ impl<'a, T: Api<C> + Sized, C> ContextWrapperExt<'a, C> for T {
|
|||||||
impl<'a, T: Api<C>, C> ApiNoContext for ContextWrapper<'a, T, C> {
|
impl<'a, T: Api<C>, C> ApiNoContext for ContextWrapper<'a, T, C> {
|
||||||
|
|
||||||
|
|
||||||
|
fn required_octet_stream_put(&self, body: swagger::ByteArray) -> Box<Future<Item=RequiredOctetStreamPutResponse, Error=ApiError>> {
|
||||||
|
self.api().required_octet_stream_put(body, &self.context())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn xml_extra_post(&self, duplicate_xml_object: Option<models::DuplicateXmlObject>) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>> {
|
fn xml_extra_post(&self, duplicate_xml_object: Option<models::DuplicateXmlObject>) -> Box<Future<Item=XmlExtraPostResponse, Error=ApiError>> {
|
||||||
self.api().xml_extra_post(duplicate_xml_object, &self.context())
|
self.api().xml_extra_post(duplicate_xml_object, &self.context())
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,10 @@ pub mod responses {
|
|||||||
|
|
||||||
pub mod requests {
|
pub mod requests {
|
||||||
use hyper::mime::*;
|
use hyper::mime::*;
|
||||||
|
/// Create Mime objects for the request content types for RequiredOctetStreamPut
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref REQUIRED_OCTET_STREAM_PUT: Mime = "application/octet-stream".parse().unwrap();
|
||||||
|
}
|
||||||
/// Create Mime objects for the request content types for XmlExtraPost
|
/// Create Mime objects for the request content types for XmlExtraPost
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref XML_EXTRA_POST: Mime = "application/xml".parse().unwrap();
|
pub static ref XML_EXTRA_POST: Mime = "application/xml".parse().unwrap();
|
||||||
|
@ -8,6 +8,8 @@ use serde::ser::Serializer;
|
|||||||
use std::collections::{HashMap, BTreeMap};
|
use std::collections::{HashMap, BTreeMap};
|
||||||
use models;
|
use models;
|
||||||
use swagger;
|
use swagger;
|
||||||
|
use std::string::ParseError;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Utility function for wrapping list elements when serializing xml
|
// Utility function for wrapping list elements when serializing xml
|
||||||
@ -100,6 +102,13 @@ impl ::std::convert::From<String> for AnotherXmlInner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::str::FromStr for AnotherXmlInner {
|
||||||
|
type Err = ParseError;
|
||||||
|
fn from_str(x: &str) -> Result<Self, Self::Err> {
|
||||||
|
Ok(AnotherXmlInner(x.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ::std::convert::From<AnotherXmlInner> for String {
|
impl ::std::convert::From<AnotherXmlInner> for String {
|
||||||
fn from(x: AnotherXmlInner) -> Self {
|
fn from(x: AnotherXmlInner) -> Self {
|
||||||
x.0
|
x.0
|
||||||
@ -206,6 +215,47 @@ impl DuplicateXmlObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test a model containing a UUID
|
||||||
|
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||||
|
|
||||||
|
pub struct UuidObject(uuid::Uuid);
|
||||||
|
|
||||||
|
impl ::std::convert::From<uuid::Uuid> for UuidObject {
|
||||||
|
fn from(x: uuid::Uuid) -> Self {
|
||||||
|
UuidObject(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl ::std::convert::From<UuidObject> for uuid::Uuid {
|
||||||
|
fn from(x: UuidObject) -> Self {
|
||||||
|
x.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::std::ops::Deref for UuidObject {
|
||||||
|
type Target = uuid::Uuid;
|
||||||
|
fn deref(&self) -> &uuid::Uuid {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::std::ops::DerefMut for UuidObject {
|
||||||
|
fn deref_mut(&mut self) -> &mut uuid::Uuid {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl UuidObject {
|
||||||
|
/// Helper function to allow us to convert this model to an XML string.
|
||||||
|
/// Will panic if serialisation fails.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) fn to_xml(&self) -> String {
|
||||||
|
serde_xml_rs::to_string(&self).expect("impossible to fail to serialize")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Utility function for wrapping list elements when serializing xml
|
// Utility function for wrapping list elements when serializing xml
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn wrap_in_camelXmlInner<S>(item: &Vec<String>, serializer: S) -> Result<S::Ok, S::Error>
|
fn wrap_in_camelXmlInner<S>(item: &Vec<String>, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@ -296,6 +346,13 @@ impl ::std::convert::From<String> for XmlInner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::str::FromStr for XmlInner {
|
||||||
|
type Err = ParseError;
|
||||||
|
fn from_str(x: &str) -> Result<Self, Self::Err> {
|
||||||
|
Ok(XmlInner(x.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ::std::convert::From<XmlInner> for String {
|
impl ::std::convert::From<XmlInner> for String {
|
||||||
fn from(x: XmlInner) -> Self {
|
fn from(x: XmlInner) -> Self {
|
||||||
x.0
|
x.0
|
||||||
|
@ -37,6 +37,7 @@ use swagger::{ApiError, XSpanId, XSpanIdString, Has, RequestParser};
|
|||||||
use swagger::auth::Scopes;
|
use swagger::auth::Scopes;
|
||||||
|
|
||||||
use {Api,
|
use {Api,
|
||||||
|
RequiredOctetStreamPutResponse,
|
||||||
XmlExtraPostResponse,
|
XmlExtraPostResponse,
|
||||||
XmlOtherPostResponse,
|
XmlOtherPostResponse,
|
||||||
XmlOtherPutResponse,
|
XmlOtherPutResponse,
|
||||||
@ -55,14 +56,16 @@ mod paths {
|
|||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(&[
|
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(&[
|
||||||
|
r"^/required_octet_stream$",
|
||||||
r"^/xml$",
|
r"^/xml$",
|
||||||
r"^/xml_extra$",
|
r"^/xml_extra$",
|
||||||
r"^/xml_other$"
|
r"^/xml_other$"
|
||||||
]).unwrap();
|
]).unwrap();
|
||||||
}
|
}
|
||||||
pub static ID_XML: usize = 0;
|
pub static ID_REQUIRED_OCTET_STREAM: usize = 0;
|
||||||
pub static ID_XML_EXTRA: usize = 1;
|
pub static ID_XML: usize = 1;
|
||||||
pub static ID_XML_OTHER: usize = 2;
|
pub static ID_XML_EXTRA: usize = 2;
|
||||||
|
pub static ID_XML_OTHER: usize = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NewService<T, C> {
|
pub struct NewService<T, C> {
|
||||||
@ -128,6 +131,71 @@ where
|
|||||||
// Please update both places if changing how this code is autogenerated.
|
// Please update both places if changing how this code is autogenerated.
|
||||||
match &method {
|
match &method {
|
||||||
|
|
||||||
|
// RequiredOctetStreamPut - PUT /required_octet_stream
|
||||||
|
&hyper::Method::Put if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Body parameters (note that non-required body parameters will ignore garbage
|
||||||
|
// values, rather than causing a 400 response). Produce warning header and logs for
|
||||||
|
// any unused fields.
|
||||||
|
Box::new(body.concat2()
|
||||||
|
.then(move |result| -> Box<Future<Item=Response, Error=Error>> {
|
||||||
|
match result {
|
||||||
|
Ok(body) => {
|
||||||
|
let param_body: Option<swagger::ByteArray> = if !body.is_empty() {
|
||||||
|
|
||||||
|
Some(swagger::ByteArray(body.to_vec()))
|
||||||
|
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let param_body = match param_body {
|
||||||
|
Some(param_body) => param_body,
|
||||||
|
None => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body("Missing required body parameter body"))),
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Box::new(api_impl.required_octet_stream_put(param_body, &context)
|
||||||
|
.then(move |result| {
|
||||||
|
let mut response = Response::new();
|
||||||
|
response.headers_mut().set(XSpanId((&context as &Has<XSpanIdString>).get().0.to_string()));
|
||||||
|
|
||||||
|
match result {
|
||||||
|
Ok(rsp) => match rsp {
|
||||||
|
RequiredOctetStreamPutResponse::OK
|
||||||
|
|
||||||
|
|
||||||
|
=> {
|
||||||
|
response.set_status(StatusCode::try_from(200).unwrap());
|
||||||
|
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Err(_) => {
|
||||||
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
|
// return a valid response.
|
||||||
|
response.set_status(StatusCode::InternalServerError);
|
||||||
|
response.set_body("An internal error occurred");
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
future::ok(response)
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
Err(e) => Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't read body parameter body: {}", e)))),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
) as Box<Future<Item=Response, Error=Error>>
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// XmlExtraPost - POST /xml_extra
|
// XmlExtraPost - POST /xml_extra
|
||||||
&hyper::Method::Post if path.matched(paths::ID_XML_EXTRA) => {
|
&hyper::Method::Post if path.matched(paths::ID_XML_EXTRA) => {
|
||||||
|
|
||||||
@ -560,6 +628,9 @@ impl RequestParser for ApiRequestParser {
|
|||||||
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
let path = paths::GLOBAL_REGEX_SET.matches(request.uri().path());
|
||||||
match request.method() {
|
match request.method() {
|
||||||
|
|
||||||
|
// RequiredOctetStreamPut - PUT /required_octet_stream
|
||||||
|
&hyper::Method::Put if path.matched(paths::ID_REQUIRED_OCTET_STREAM) => Ok("RequiredOctetStreamPut"),
|
||||||
|
|
||||||
// XmlExtraPost - POST /xml_extra
|
// XmlExtraPost - POST /xml_extra
|
||||||
&hyper::Method::Post if path.matched(paths::ID_XML_EXTRA) => Ok("XmlExtraPost"),
|
&hyper::Method::Post if path.matched(paths::ID_XML_EXTRA) => Ok("XmlExtraPost"),
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
// Body parameter
|
// Body parameter
|
||||||
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::TEST_SPECIAL_TAGS.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::TEST_SPECIAL_TAGS.clone()));
|
||||||
@ -320,17 +320,20 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<models::Client>(body)
|
serde_json::from_str::<models::Client>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
TestSpecialTagsResponse::SuccessfulOperation(body)
|
TestSpecialTagsResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -386,7 +389,7 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::FAKE_OUTER_BOOLEAN_SERIALIZE.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::FAKE_OUTER_BOOLEAN_SERIALIZE.clone()));
|
||||||
@ -403,17 +406,20 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<bool>(body)
|
serde_json::from_str::<bool>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
FakeOuterBooleanSerializeResponse::OutputBoolean(body)
|
FakeOuterBooleanSerializeResponse::OutputBoolean(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -467,7 +473,7 @@ if let Some(body) = body {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::FAKE_OUTER_COMPOSITE_SERIALIZE.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::FAKE_OUTER_COMPOSITE_SERIALIZE.clone()));
|
||||||
@ -484,17 +490,20 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<models::OuterComposite>(body)
|
serde_json::from_str::<models::OuterComposite>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
FakeOuterCompositeSerializeResponse::OutputComposite(body)
|
FakeOuterCompositeSerializeResponse::OutputComposite(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -548,7 +557,7 @@ if let Some(body) = body {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::FAKE_OUTER_NUMBER_SERIALIZE.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::FAKE_OUTER_NUMBER_SERIALIZE.clone()));
|
||||||
@ -565,17 +574,20 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<f64>(body)
|
serde_json::from_str::<f64>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
FakeOuterNumberSerializeResponse::OutputNumber(body)
|
FakeOuterNumberSerializeResponse::OutputNumber(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -629,7 +641,7 @@ if let Some(body) = body {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::FAKE_OUTER_STRING_SERIALIZE.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::FAKE_OUTER_STRING_SERIALIZE.clone()));
|
||||||
@ -646,17 +658,20 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<String>(body)
|
serde_json::from_str::<String>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
FakeOuterStringSerializeResponse::OutputString(body)
|
FakeOuterStringSerializeResponse::OutputString(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -708,7 +723,7 @@ if let Some(body) = body {
|
|||||||
|
|
||||||
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::TEST_BODY_WITH_QUERY_PARAMS.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::TEST_BODY_WITH_QUERY_PARAMS.clone()));
|
||||||
@ -776,7 +791,7 @@ if let Some(body) = body {
|
|||||||
|
|
||||||
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::TEST_CLIENT_MODEL.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::TEST_CLIENT_MODEL.clone()));
|
||||||
@ -793,17 +808,20 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<models::Client>(body)
|
serde_json::from_str::<models::Client>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
TestClientModelResponse::SuccessfulOperation(body)
|
TestClientModelResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -1047,7 +1065,7 @@ if let Some(body) = body {
|
|||||||
|
|
||||||
let body = serde_json::to_string(¶m_param).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_param).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::TEST_INLINE_ADDITIONAL_PROPERTIES.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::TEST_INLINE_ADDITIONAL_PROPERTIES.clone()));
|
||||||
@ -1191,7 +1209,7 @@ if let Some(body) = body {
|
|||||||
// Body parameter
|
// Body parameter
|
||||||
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::TEST_CLASSNAME.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::TEST_CLASSNAME.clone()));
|
||||||
@ -1208,17 +1226,20 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<models::Client>(body)
|
serde_json::from_str::<models::Client>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
TestClassnameResponse::SuccessfulOperation(body)
|
TestClassnameResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -1271,7 +1292,7 @@ if let Some(body) = body {
|
|||||||
// Body parameter
|
// Body parameter
|
||||||
let body = param_body.to_xml();
|
let body = param_body.to_xml();
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::ADD_PET.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::ADD_PET.clone()));
|
||||||
@ -1419,19 +1440,21 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
||||||
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
||||||
serde_xml_rs::from_str::<Vec<models::Pet>>(body)
|
serde_xml_rs::from_str::<Vec<models::Pet>>(body)
|
||||||
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
FindPetsByStatusResponse::SuccessfulOperation(body)
|
FindPetsByStatusResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
400 => {
|
400 => {
|
||||||
@ -1504,19 +1527,21 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
||||||
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
||||||
serde_xml_rs::from_str::<Vec<models::Pet>>(body)
|
serde_xml_rs::from_str::<Vec<models::Pet>>(body)
|
||||||
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
FindPetsByTagsResponse::SuccessfulOperation(body)
|
FindPetsByTagsResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
400 => {
|
400 => {
|
||||||
@ -1593,19 +1618,21 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
||||||
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
||||||
serde_xml_rs::from_str::<models::Pet>(body)
|
serde_xml_rs::from_str::<models::Pet>(body)
|
||||||
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
GetPetByIdResponse::SuccessfulOperation(body)
|
GetPetByIdResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
400 => {
|
400 => {
|
||||||
@ -1674,7 +1701,7 @@ if let Some(body) = body {
|
|||||||
|
|
||||||
let body = param_body.to_xml();
|
let body = param_body.to_xml();
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::UPDATE_PET.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::UPDATE_PET.clone()));
|
||||||
@ -1849,17 +1876,20 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<models::ApiResponse>(body)
|
serde_json::from_str::<models::ApiResponse>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
UploadFileResponse::SuccessfulOperation(body)
|
UploadFileResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -1999,17 +2029,20 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<HashMap<String, i32>>(body)
|
serde_json::from_str::<HashMap<String, i32>>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
GetInventoryResponse::SuccessfulOperation(body)
|
GetInventoryResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -2072,19 +2105,21 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
||||||
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
||||||
serde_xml_rs::from_str::<models::Order>(body)
|
serde_xml_rs::from_str::<models::Order>(body)
|
||||||
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
GetOrderByIdResponse::SuccessfulOperation(body)
|
GetOrderByIdResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
400 => {
|
400 => {
|
||||||
@ -2153,7 +2188,7 @@ if let Some(body) = body {
|
|||||||
|
|
||||||
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::PLACE_ORDER.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::PLACE_ORDER.clone()));
|
||||||
@ -2170,19 +2205,21 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
||||||
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
||||||
serde_xml_rs::from_str::<models::Order>(body)
|
serde_xml_rs::from_str::<models::Order>(body)
|
||||||
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
PlaceOrderResponse::SuccessfulOperation(body)
|
PlaceOrderResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
400 => {
|
400 => {
|
||||||
@ -2244,7 +2281,7 @@ if let Some(body) = body {
|
|||||||
// Body parameter
|
// Body parameter
|
||||||
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::CREATE_USER.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::CREATE_USER.clone()));
|
||||||
@ -2312,7 +2349,7 @@ if let Some(body) = body {
|
|||||||
|
|
||||||
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::CREATE_USERS_WITH_ARRAY_INPUT.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::CREATE_USERS_WITH_ARRAY_INPUT.clone()));
|
||||||
@ -2380,7 +2417,7 @@ if let Some(body) = body {
|
|||||||
|
|
||||||
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::CREATE_USERS_WITH_LIST_INPUT.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::CREATE_USERS_WITH_LIST_INPUT.clone()));
|
||||||
@ -2532,19 +2569,21 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
||||||
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
||||||
serde_xml_rs::from_str::<models::User>(body)
|
serde_xml_rs::from_str::<models::User>(body)
|
||||||
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
GetUserByNameResponse::SuccessfulOperation(body)
|
GetUserByNameResponse::SuccessfulOperation(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
400 => {
|
400 => {
|
||||||
@ -2637,19 +2676,21 @@ if let Some(body) = body {
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
// ToDo: this will move to swagger-rs and become a standard From conversion trait
|
||||||
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
|
||||||
serde_xml_rs::from_str::<String>(body)
|
serde_xml_rs::from_str::<String>(body)
|
||||||
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
LoginUserResponse::SuccessfulOperation{ body: body, x_rate_limit: response_x_rate_limit, x_expires_after: response_x_expires_after }
|
LoginUserResponse::SuccessfulOperation{ body: body, x_rate_limit: response_x_rate_limit, x_expires_after: response_x_expires_after }
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
400 => {
|
400 => {
|
||||||
@ -2772,7 +2813,7 @@ if let Some(body) = body {
|
|||||||
|
|
||||||
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::UPDATE_USER.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::UPDATE_USER.clone()));
|
||||||
|
@ -8,6 +8,8 @@ use serde::ser::Serializer;
|
|||||||
use std::collections::{HashMap, BTreeMap};
|
use std::collections::{HashMap, BTreeMap};
|
||||||
use models;
|
use models;
|
||||||
use swagger;
|
use swagger;
|
||||||
|
use std::string::ParseError;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
@ -995,6 +997,7 @@ impl ::std::convert::From<bool> for OuterBoolean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ::std::convert::From<OuterBoolean> for bool {
|
impl ::std::convert::From<OuterBoolean> for bool {
|
||||||
fn from(x: OuterBoolean) -> Self {
|
fn from(x: OuterBoolean) -> Self {
|
||||||
x.0
|
x.0
|
||||||
@ -1115,6 +1118,7 @@ impl ::std::convert::From<f64> for OuterNumber {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ::std::convert::From<OuterNumber> for f64 {
|
impl ::std::convert::From<OuterNumber> for f64 {
|
||||||
fn from(x: OuterNumber) -> Self {
|
fn from(x: OuterNumber) -> Self {
|
||||||
x.0
|
x.0
|
||||||
@ -1154,6 +1158,13 @@ impl ::std::convert::From<String> for OuterString {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::str::FromStr for OuterString {
|
||||||
|
type Err = ParseError;
|
||||||
|
fn from_str(x: &str) -> Result<Self, Self::Err> {
|
||||||
|
Ok(OuterString(x.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ::std::convert::From<OuterString> for String {
|
impl ::std::convert::From<OuterString> for String {
|
||||||
fn from(x: OuterString) -> Self {
|
fn from(x: OuterString) -> Self {
|
||||||
x.0
|
x.0
|
||||||
|
@ -1350,7 +1350,7 @@ where
|
|||||||
let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() {
|
let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_pet_id) => match param_pet_id.parse::<i64>() {
|
Ok(param_pet_id) => match param_pet_id.parse::<i64>() {
|
||||||
Ok(param_pet_id) => param_pet_id,
|
Ok(param_pet_id) => param_pet_id,
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter petId: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter petId: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))))
|
||||||
};
|
};
|
||||||
@ -1613,7 +1613,7 @@ where
|
|||||||
let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() {
|
let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_pet_id) => match param_pet_id.parse::<i64>() {
|
Ok(param_pet_id) => match param_pet_id.parse::<i64>() {
|
||||||
Ok(param_pet_id) => param_pet_id,
|
Ok(param_pet_id) => param_pet_id,
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter petId: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter petId: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))))
|
||||||
};
|
};
|
||||||
@ -1843,7 +1843,7 @@ where
|
|||||||
let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() {
|
let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_pet_id) => match param_pet_id.parse::<i64>() {
|
Ok(param_pet_id) => match param_pet_id.parse::<i64>() {
|
||||||
Ok(param_pet_id) => param_pet_id,
|
Ok(param_pet_id) => param_pet_id,
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter petId: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter petId: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))))
|
||||||
};
|
};
|
||||||
@ -1936,7 +1936,7 @@ where
|
|||||||
let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() {
|
let param_pet_id = match percent_encoding::percent_decode(path_params["petId"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_pet_id) => match param_pet_id.parse::<i64>() {
|
Ok(param_pet_id) => match param_pet_id.parse::<i64>() {
|
||||||
Ok(param_pet_id) => param_pet_id,
|
Ok(param_pet_id) => param_pet_id,
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter petId: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter petId: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["petId"]))))
|
||||||
};
|
};
|
||||||
@ -2010,7 +2010,7 @@ where
|
|||||||
let param_order_id = match percent_encoding::percent_decode(path_params["order_id"].as_bytes()).decode_utf8() {
|
let param_order_id = match percent_encoding::percent_decode(path_params["order_id"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_order_id) => match param_order_id.parse::<String>() {
|
Ok(param_order_id) => match param_order_id.parse::<String>() {
|
||||||
Ok(param_order_id) => param_order_id,
|
Ok(param_order_id) => param_order_id,
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter order_id: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter order_id: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["order_id"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["order_id"]))))
|
||||||
};
|
};
|
||||||
@ -2142,7 +2142,7 @@ where
|
|||||||
let param_order_id = match percent_encoding::percent_decode(path_params["order_id"].as_bytes()).decode_utf8() {
|
let param_order_id = match percent_encoding::percent_decode(path_params["order_id"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_order_id) => match param_order_id.parse::<i64>() {
|
Ok(param_order_id) => match param_order_id.parse::<i64>() {
|
||||||
Ok(param_order_id) => param_order_id,
|
Ok(param_order_id) => param_order_id,
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter order_id: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter order_id: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["order_id"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["order_id"]))))
|
||||||
};
|
};
|
||||||
@ -2557,7 +2557,7 @@ where
|
|||||||
let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() {
|
let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_username) => match param_username.parse::<String>() {
|
Ok(param_username) => match param_username.parse::<String>() {
|
||||||
Ok(param_username) => param_username,
|
Ok(param_username) => param_username,
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter username: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter username: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))))
|
||||||
};
|
};
|
||||||
@ -2626,7 +2626,7 @@ where
|
|||||||
let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() {
|
let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_username) => match param_username.parse::<String>() {
|
Ok(param_username) => match param_username.parse::<String>() {
|
||||||
Ok(param_username) => param_username,
|
Ok(param_username) => param_username,
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter username: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter username: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))))
|
||||||
};
|
};
|
||||||
@ -2849,7 +2849,7 @@ where
|
|||||||
let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() {
|
let param_username = match percent_encoding::percent_decode(path_params["username"].as_bytes()).decode_utf8() {
|
||||||
Ok(param_username) => match param_username.parse::<String>() {
|
Ok(param_username) => match param_username.parse::<String>() {
|
||||||
Ok(param_username) => param_username,
|
Ok(param_username) => param_username,
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter username: {}", e)))),
|
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse path parameter username: {:?}", e)))),
|
||||||
},
|
},
|
||||||
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))))
|
Err(_) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't percent-decode path parameter as UTF-8: {}", &path_params["username"]))))
|
||||||
};
|
};
|
||||||
|
@ -337,7 +337,7 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
|
|
||||||
let body = serde_json::to_string(¶m_nested_response).expect("impossible to fail to serialize");
|
let body = serde_json::to_string(¶m_nested_response).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::DUMMY_PUT.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::DUMMY_PUT.clone()));
|
||||||
@ -417,17 +417,20 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<swagger::ByteArray>(body)
|
serde_json::from_str::<swagger::ByteArray>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
FileResponseGetResponse::Success(body)
|
FileResponseGetResponse::Success(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -478,7 +481,7 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
|
|
||||||
let body = param_body;
|
let body = param_body;
|
||||||
|
|
||||||
request.set_body(body.into_bytes());
|
request.set_body(body);
|
||||||
|
|
||||||
|
|
||||||
request.headers_mut().set(ContentType(mimetypes::requests::HTML_POST.clone()));
|
request.headers_mut().set(ContentType(mimetypes::requests::HTML_POST.clone()));
|
||||||
@ -495,16 +498,20 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
Ok(body.to_string())
|
serde_json::from_str::<String>(body)
|
||||||
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
HtmlPostResponse::Success(body)
|
HtmlPostResponse::Success(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
@ -567,17 +574,20 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
body
|
body
|
||||||
.concat2()
|
.concat2()
|
||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body| str::from_utf8(&body)
|
.and_then(|body|
|
||||||
|
|
||||||
|
str::from_utf8(&body)
|
||||||
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
|
|
||||||
serde_json::from_str::<serde_json::Value>(body)
|
serde_json::from_str::<serde_json::Value>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
|
||||||
))
|
)
|
||||||
.map(move |body|
|
.map(move |body| {
|
||||||
RawJsonGetResponse::Success(body)
|
RawJsonGetResponse::Success(body)
|
||||||
)
|
})
|
||||||
) as Box<Future<Item=_, Error=_>>
|
) as Box<Future<Item=_, Error=_>>
|
||||||
},
|
},
|
||||||
code => {
|
code => {
|
||||||
|
@ -7,6 +7,8 @@ use serde::ser::Serializer;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use models;
|
use models;
|
||||||
use swagger;
|
use swagger;
|
||||||
|
use std::string::ParseError;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
@ -326,10 +326,7 @@ where
|
|||||||
Ok(body) => {
|
Ok(body) => {
|
||||||
let param_body: Option<String> = if !body.is_empty() {
|
let param_body: Option<String> = if !body.is_empty() {
|
||||||
|
|
||||||
match String::from_utf8(body.to_vec()) {
|
Some(String::from_utf8(body.to_vec()).unwrap())
|
||||||
Ok(param_body) => Some(param_body),
|
|
||||||
Err(e) => return Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't parse body parameter body - not valid UTF-8: {}", e)))),
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -358,6 +355,8 @@ where
|
|||||||
response.headers_mut().set(ContentType(mimetypes::responses::HTML_POST_SUCCESS.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::HTML_POST_SUCCESS.clone()));
|
||||||
|
|
||||||
|
|
||||||
|
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user