forked from loafle/openapi-generator-original
[Rust Server] Handle multiple response type (#4441)
- Ensure response IDs are unique, even if the first sentence is identical - Handle responses where different responses produce a different type of data - Use the correct mime type for plain text and byte streams - Tidy up whitespace in client-mod.mustache - Specify locale for String.format - Add test for multiple response types - Update samples
This commit is contained in:
parent
2949b53820
commit
0c92b0c4a4
@ -26,6 +26,7 @@ import io.swagger.v3.oas.models.media.FileSchema;
|
|||||||
import io.swagger.v3.oas.models.media.Schema;
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
import io.swagger.v3.oas.models.media.XML;
|
import io.swagger.v3.oas.models.media.XML;
|
||||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||||
|
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.models.servers.Server;
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
@ -65,6 +66,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
private static final String uuidType = "uuid::Uuid";
|
private static final String uuidType = "uuid::Uuid";
|
||||||
private static final String bytesType = "swagger::ByteArray";
|
private static final String bytesType = "swagger::ByteArray";
|
||||||
|
|
||||||
|
private static final String xmlMimeType = "application/xml";
|
||||||
|
private static final String octetMimeType = "application/octet-stream";
|
||||||
|
private static final String plainMimeType = "text/plain";
|
||||||
|
private static final String jsonMimeType = "application/json";
|
||||||
|
|
||||||
public RustServerCodegen() {
|
public RustServerCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -485,11 +491,11 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMimetypeXml(String mimetype) {
|
private boolean isMimetypeXml(String mimetype) {
|
||||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("application/xml");
|
return mimetype.toLowerCase(Locale.ROOT).startsWith(xmlMimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMimetypePlainText(String mimetype) {
|
private boolean isMimetypePlainText(String mimetype) {
|
||||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("text/plain");
|
return mimetype.toLowerCase(Locale.ROOT).startsWith(plainMimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMimetypeHtmlText(String mimetype) {
|
private boolean isMimetypeHtmlText(String mimetype) {
|
||||||
@ -505,7 +511,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMimetypeOctetStream(String mimetype) {
|
private boolean isMimetypeOctetStream(String mimetype) {
|
||||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("application/octet-stream");
|
return mimetype.toLowerCase(Locale.ROOT).startsWith(octetMimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMimetypePlain(String mimetype) {
|
private boolean isMimetypePlain(String mimetype) {
|
||||||
@ -563,36 +569,17 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
processParam(param, op);
|
processParam(param, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> consumes = new ArrayList<String>();
|
// We keep track of the 'default' model type for this API. If there are
|
||||||
|
// *any* XML responses, then we set the default to XML, otherwise we
|
||||||
boolean consumesPlainText = false;
|
// let the default be JSON. It would be odd for an API to want to use
|
||||||
boolean consumesXml = false;
|
// both XML and JSON on a single operation, and if we don't know
|
||||||
// if "consumes" is defined (per operation or using global definition)
|
// anything then JSON is a more modern (ergo reasonable) choice.
|
||||||
if (consumes != null && !consumes.isEmpty()) {
|
boolean defaultsToXml = false;
|
||||||
consumes.addAll(getConsumesInfo(this.openAPI, operation));
|
|
||||||
List<Map<String, String>> c = new ArrayList<Map<String, String>>();
|
|
||||||
for (String mimeType : consumes) {
|
|
||||||
Map<String, String> mediaType = new HashMap<String, String>();
|
|
||||||
|
|
||||||
if (isMimetypeXml(mimeType)) {
|
|
||||||
additionalProperties.put("usesXml", true);
|
|
||||||
consumesXml = true;
|
|
||||||
} else if (isMimetypePlain(mimeType)) {
|
|
||||||
consumesPlainText = true;
|
|
||||||
} else if (isMimetypeWwwFormUrlEncoded(mimeType)) {
|
|
||||||
additionalProperties.put("usesUrlEncodedForm", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
mediaType.put("mediaType", mimeType);
|
|
||||||
c.add(mediaType);
|
|
||||||
}
|
|
||||||
op.consumes = c;
|
|
||||||
op.hasConsumes = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
List<String> produces = new ArrayList<String>(getProducesInfo(this.openAPI, operation));
|
|
||||||
|
|
||||||
|
// Determine the types that this operation produces. `getProducesInfo`
|
||||||
|
// simply lists all the types, and then we add the correct imports to
|
||||||
|
// the generated library.
|
||||||
|
List<String> produces = new ArrayList<String>(getProducesInfo(openAPI, operation));
|
||||||
boolean producesXml = false;
|
boolean producesXml = false;
|
||||||
boolean producesPlainText = false;
|
boolean producesPlainText = false;
|
||||||
if (produces != null && !produces.isEmpty()) {
|
if (produces != null && !produces.isEmpty()) {
|
||||||
@ -602,6 +589,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
if (isMimetypeXml(mimeType)) {
|
if (isMimetypeXml(mimeType)) {
|
||||||
additionalProperties.put("usesXml", true);
|
additionalProperties.put("usesXml", true);
|
||||||
|
defaultsToXml = true;
|
||||||
producesXml = true;
|
producesXml = true;
|
||||||
} else if (isMimetypePlain(mimeType)) {
|
} else if (isMimetypePlain(mimeType)) {
|
||||||
producesPlainText = true;
|
producesPlainText = true;
|
||||||
@ -621,32 +609,132 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
param.vendorExtensions.put("typeName", toModelName(param.baseName));
|
param.vendorExtensions.put("typeName", toModelName(param.baseName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set for deduplication of response IDs
|
||||||
|
Set<String> responseIds = new HashSet();
|
||||||
|
|
||||||
for (CodegenResponse rsp : op.responses) {
|
for (CodegenResponse rsp : op.responses) {
|
||||||
|
|
||||||
|
// Get the original API response so we get process the schema
|
||||||
|
// directly.
|
||||||
|
ApiResponse original;
|
||||||
|
if (rsp.code == "0") {
|
||||||
|
original = operation.getResponses().get("default");
|
||||||
|
} else {
|
||||||
|
original = operation.getResponses().get(rsp.code);
|
||||||
|
}
|
||||||
String[] words = rsp.message.split("[^A-Za-z ]");
|
String[] words = rsp.message.split("[^A-Za-z ]");
|
||||||
|
|
||||||
|
// Create a unique responseID for this response.
|
||||||
String responseId;
|
String responseId;
|
||||||
|
|
||||||
if (rsp.vendorExtensions.containsKey("x-responseId")) {
|
if (rsp.vendorExtensions.containsKey("x-responseId")) {
|
||||||
|
// If it's been specified directly, use that.
|
||||||
responseId = (String) rsp.vendorExtensions.get("x-responseId");
|
responseId = (String) rsp.vendorExtensions.get("x-responseId");
|
||||||
} else if (words.length != 0) {
|
} else if (words.length != 0) {
|
||||||
|
// If there's a description, build it from the description.
|
||||||
responseId = camelize(words[0].replace(" ", "_"));
|
responseId = camelize(words[0].replace(" ", "_"));
|
||||||
} else {
|
} else {
|
||||||
|
// Otherwise fall back to the http response code.
|
||||||
responseId = "Status" + rsp.code;
|
responseId = "Status" + rsp.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deduplicate response IDs that would otherwise contain the same
|
||||||
|
// text. We rely on the ID being unique, but since we form it from
|
||||||
|
// the raw description field we can't require that the spec writer
|
||||||
|
// provides unique descriptions.
|
||||||
|
int idTieBreaker = 2;
|
||||||
|
while (responseIds.contains(responseId)) {
|
||||||
|
String trial = String.format(Locale.ROOT, "%s_%d", responseId, idTieBreaker);
|
||||||
|
if (!responseIds.contains(trial)) {
|
||||||
|
responseId = trial;
|
||||||
|
} else {
|
||||||
|
idTieBreaker++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
responseIds.add(responseId);
|
||||||
|
|
||||||
rsp.vendorExtensions.put("x-responseId", responseId);
|
rsp.vendorExtensions.put("x-responseId", responseId);
|
||||||
rsp.vendorExtensions.put("x-uppercaseResponseId", underscore(responseId).toUpperCase(Locale.ROOT));
|
rsp.vendorExtensions.put("x-uppercaseResponseId", underscore(responseId).toUpperCase(Locale.ROOT));
|
||||||
rsp.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase(Locale.ROOT));
|
rsp.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase(Locale.ROOT));
|
||||||
if (rsp.dataType != null) {
|
if (rsp.dataType != null) {
|
||||||
rsp.vendorExtensions.put("uppercase_data_type", (rsp.dataType.replace("models::", "")).toUpperCase(Locale.ROOT));
|
rsp.vendorExtensions.put("uppercase_data_type", (rsp.dataType.replace("models::", "")).toUpperCase(Locale.ROOT));
|
||||||
|
|
||||||
// Default to producing json if nothing else is specified
|
// Get the mimetype which is produced by this response. Note
|
||||||
|
// that although in general responses produces a set of
|
||||||
|
// different mimetypes currently we only support 1 per
|
||||||
|
// response.
|
||||||
|
String firstProduces = null;
|
||||||
|
|
||||||
|
if (original.getContent() != null) {
|
||||||
|
for (String mimetype : original.getContent().keySet()) {
|
||||||
|
firstProduces = mimetype;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The output mime type. This allows us to do sensible fallback
|
||||||
|
// to JSON/XML rather than using only the default operation
|
||||||
|
// mimetype.
|
||||||
|
String outputMime;
|
||||||
|
|
||||||
|
if (firstProduces == null) {
|
||||||
|
if (producesXml) {
|
||||||
|
outputMime = xmlMimeType;
|
||||||
|
} else if (producesPlainText) {
|
||||||
|
if (rsp.dataType.equals(bytesType)) {
|
||||||
|
outputMime = octetMimeType;
|
||||||
|
} else {
|
||||||
|
outputMime = plainMimeType;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
outputMime = jsonMimeType;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If we know exactly what mimetype this response is
|
||||||
|
// going to produce, then use that. If we have not found
|
||||||
|
// anything, then we'll fall back to the 'producesXXX'
|
||||||
|
// definitions we worked out above for the operation as a
|
||||||
|
// whole.
|
||||||
|
if (isMimetypeXml(firstProduces)) {
|
||||||
|
producesXml = true;
|
||||||
|
producesPlainText = false;
|
||||||
|
} else if (isMimetypePlain(firstProduces)) {
|
||||||
|
producesXml = false;
|
||||||
|
producesPlainText = true;
|
||||||
|
} else {
|
||||||
|
producesXml = false;
|
||||||
|
producesPlainText = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
outputMime = firstProduces;
|
||||||
|
}
|
||||||
|
|
||||||
|
rsp.vendorExtensions.put("mimeType", outputMime);
|
||||||
|
|
||||||
|
// Write out the type of data we actually expect this response
|
||||||
|
// to make.
|
||||||
if (producesXml) {
|
if (producesXml) {
|
||||||
rsp.vendorExtensions.put("producesXml", true);
|
rsp.vendorExtensions.put("producesXml", true);
|
||||||
} else if (producesPlainText && rsp.dataType.equals(bytesType)) {
|
} else if (producesPlainText) {
|
||||||
|
// Plain text means that there is not structured data in
|
||||||
|
// this response. So it'll either be a UTF-8 encoded string
|
||||||
|
// 'plainText' or some generic 'bytes'.
|
||||||
|
//
|
||||||
|
// Note that we don't yet distinguish between string/binary
|
||||||
|
// and string/bytes - that is we don't auto-detect whether
|
||||||
|
// base64 encoding should be done. They both look like
|
||||||
|
// 'producesBytes'.
|
||||||
|
if (rsp.dataType.equals(bytesType)) {
|
||||||
|
rsp.vendorExtensions.put("producesBytes", true);
|
||||||
|
} else {
|
||||||
rsp.vendorExtensions.put("producesPlainText", true);
|
rsp.vendorExtensions.put("producesPlainText", true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rsp.vendorExtensions.put("producesJson", true);
|
rsp.vendorExtensions.put("producesJson", true);
|
||||||
// If the data type is just "object", then ensure that the Rust data type
|
// If the data type is just "object", then ensure that the
|
||||||
// is "serde_json::Value". This allows us to define APIs that
|
// Rust data type is "serde_json::Value". This allows us
|
||||||
// can return arbitrary JSON bodies.
|
// to define APIs that can return arbitrary JSON bodies.
|
||||||
if (rsp.dataType.equals("object")) {
|
if (rsp.dataType.equals("object")) {
|
||||||
rsp.dataType = "serde_json::Value";
|
rsp.dataType = "serde_json::Value";
|
||||||
}
|
}
|
||||||
@ -686,7 +774,6 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||||
|
|
||||||
|
|
||||||
for (CodegenOperation op : operationList) {
|
for (CodegenOperation op : operationList) {
|
||||||
boolean consumesPlainText = false;
|
boolean consumesPlainText = false;
|
||||||
boolean consumesXml = false;
|
boolean consumesXml = false;
|
||||||
|
@ -491,23 +491,29 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
.and_then(|body|
|
.and_then(|body|
|
||||||
{{#vendorExtensions}}
|
{{#vendorExtensions}}
|
||||||
{{#producesPlainText}}
|
{{#producesBytes}}
|
||||||
Ok(swagger::ByteArray(body.to_vec()))
|
Ok(swagger::ByteArray(body.to_vec()))
|
||||||
{{/producesPlainText}}{{^producesPlainText}}
|
{{/producesBytes}}
|
||||||
|
{{^producesBytes}}
|
||||||
str::from_utf8(&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|
|
||||||
{{#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)
|
||||||
.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)))
|
||||||
{{/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}}
|
{{/producesJson}}
|
||||||
|
{{#producesPlainText}}
|
||||||
|
Ok(body.to_string())
|
||||||
|
{{/producesPlainText}}
|
||||||
)
|
)
|
||||||
{{/producesPlainText}}{{/vendorExtensions}}
|
{{/producesBytes}}
|
||||||
|
{{/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}}
|
||||||
|
@ -7,7 +7,7 @@ pub mod responses {
|
|||||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#responses}}{{#produces}}{{#-first}}{{#dataType}}
|
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#responses}}{{#produces}}{{#-first}}{{#dataType}}
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create Mime objects for the response content types for {{{operationId}}}
|
/// Create Mime objects for the response content types for {{{operationId}}}
|
||||||
pub static ref {{#vendorExtensions}}{{{uppercase_operation_id}}}_{{x-uppercaseResponseId}}{{/vendorExtensions}}: Mime = "{{{mediaType}}}".parse().unwrap();
|
pub static ref {{#vendorExtensions}}{{{uppercase_operation_id}}}_{{x-uppercaseResponseId}}: Mime = "{{{mimeType}}}".parse().unwrap();{{/vendorExtensions}}
|
||||||
}
|
}
|
||||||
{{/dataType}}{{/-first}}{{/produces}}{{/responses}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
{{/dataType}}{{/-first}}{{/produces}}{{/responses}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||||
}
|
}
|
||||||
|
@ -444,18 +444,28 @@ where
|
|||||||
response.headers_mut().set(ContentType(mimetypes::responses::{{#vendorExtensions}}{{{uppercase_operation_id}}}_{{x-uppercaseResponseId}}{{/vendorExtensions}}.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::{{#vendorExtensions}}{{{uppercase_operation_id}}}_{{x-uppercaseResponseId}}{{/vendorExtensions}}.clone()));
|
||||||
{{/dataType}}{{/-first}}{{/produces}}
|
{{/dataType}}{{/-first}}{{/produces}}
|
||||||
{{#dataType}}
|
{{#dataType}}
|
||||||
{{#vendorExtensions}}{{#producesXml}}{{^has_namespace}}
|
{{#vendorExtensions}}
|
||||||
|
{{#producesXml}}
|
||||||
|
{{^has_namespace}}
|
||||||
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
||||||
{{/has_namespace}}{{#has_namespace}}
|
{{/has_namespace}}
|
||||||
|
{{#has_namespace}}
|
||||||
let mut namespaces = BTreeMap::new();
|
let mut namespaces = BTreeMap::new();
|
||||||
// An empty string is used to indicate a global namespace in xmltree.
|
// An empty string is used to indicate a global namespace in xmltree.
|
||||||
namespaces.insert("".to_string(), {{{dataType}}}::NAMESPACE.to_string());
|
namespaces.insert("".to_string(), {{{dataType}}}::NAMESPACE.to_string());
|
||||||
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}}{{#producesPlainText}}
|
{{/producesJson}}
|
||||||
|
{{#producesBytes}}
|
||||||
let body = body.0;
|
let body = body.0;
|
||||||
{{/producesPlainText}}{{/vendorExtensions}}
|
{{/producesBytes}}
|
||||||
|
{{#producesPlainText}}
|
||||||
|
let body = body;
|
||||||
|
{{/producesPlainText}}
|
||||||
|
{{/vendorExtensions}}
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
{{/dataType}}
|
{{/dataType}}
|
||||||
},
|
},
|
||||||
|
@ -45,6 +45,56 @@ paths:
|
|||||||
description: 'OK'
|
description: 'OK'
|
||||||
'400':
|
'400':
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
|
/multiget:
|
||||||
|
get:
|
||||||
|
summary: Get some stuff.
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: JSON rsp
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/anotherXmlObject"
|
||||||
|
201:
|
||||||
|
description: XML rsp
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
foo:
|
||||||
|
type: string
|
||||||
|
202:
|
||||||
|
description: octet rsp
|
||||||
|
content:
|
||||||
|
application/octet-stream:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
203:
|
||||||
|
description: string rsp
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
204:
|
||||||
|
description: Duplicate Response long text. One.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/anotherXmlObject"
|
||||||
|
205:
|
||||||
|
description: Duplicate Response long text. Two.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/anotherXmlObject"
|
||||||
|
206:
|
||||||
|
description: Duplicate Response long text. Three.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/anotherXmlObject"
|
||||||
/xml_other:
|
/xml_other:
|
||||||
post:
|
post:
|
||||||
requestBody:
|
requestBody:
|
||||||
|
@ -61,6 +61,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 MultigetGet
|
||||||
cargo run --example client MultipleAuthSchemeGet
|
cargo run --example client MultipleAuthSchemeGet
|
||||||
cargo run --example client ReadonlyAuthSchemeGet
|
cargo run --example client ReadonlyAuthSchemeGet
|
||||||
cargo run --example client RequiredOctetStreamPut
|
cargo run --example client RequiredOctetStreamPut
|
||||||
@ -104,6 +105,7 @@ All URIs are relative to *http://localhost*
|
|||||||
|
|
||||||
Method | HTTP request | Description
|
Method | HTTP request | Description
|
||||||
------------- | ------------- | -------------
|
------------- | ------------- | -------------
|
||||||
|
[****](docs/default_api.md#) | **GET** /multiget | Get some stuff.
|
||||||
[****](docs/default_api.md#) | **GET** /multiple_auth_scheme |
|
[****](docs/default_api.md#) | **GET** /multiple_auth_scheme |
|
||||||
[****](docs/default_api.md#) | **GET** /readonly_auth_scheme |
|
[****](docs/default_api.md#) | **GET** /readonly_auth_scheme |
|
||||||
[****](docs/default_api.md#) | **PUT** /required_octet_stream |
|
[****](docs/default_api.md#) | **PUT** /required_octet_stream |
|
||||||
@ -122,6 +124,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)
|
||||||
|
- [InlineResponse201](docs/InlineResponse201.md)
|
||||||
- [UuidObject](docs/UuidObject.md)
|
- [UuidObject](docs/UuidObject.md)
|
||||||
- [XmlArray](docs/XmlArray.md)
|
- [XmlArray](docs/XmlArray.md)
|
||||||
- [XmlInner](docs/XmlInner.md)
|
- [XmlInner](docs/XmlInner.md)
|
||||||
|
@ -30,6 +30,53 @@ paths:
|
|||||||
description: OK
|
description: OK
|
||||||
400:
|
400:
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
|
/multiget:
|
||||||
|
get:
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/anotherXmlObject'
|
||||||
|
description: JSON rsp
|
||||||
|
201:
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/inline_response_201'
|
||||||
|
description: XML rsp
|
||||||
|
202:
|
||||||
|
content:
|
||||||
|
application/octet-stream:
|
||||||
|
schema:
|
||||||
|
format: binary
|
||||||
|
type: string
|
||||||
|
description: octet rsp
|
||||||
|
203:
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
description: string rsp
|
||||||
|
204:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/anotherXmlObject'
|
||||||
|
description: Duplicate Response long text. One.
|
||||||
|
205:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/anotherXmlObject'
|
||||||
|
description: Duplicate Response long text. Two.
|
||||||
|
206:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/anotherXmlObject'
|
||||||
|
description: Duplicate Response long text. Three.
|
||||||
|
summary: Get some stuff.
|
||||||
/xml_other:
|
/xml_other:
|
||||||
post:
|
post:
|
||||||
requestBody:
|
requestBody:
|
||||||
@ -186,6 +233,8 @@ components:
|
|||||||
name: snake_another_xml_inner
|
name: snake_another_xml_inner
|
||||||
anotherXmlObject:
|
anotherXmlObject:
|
||||||
description: An XML object
|
description: An XML object
|
||||||
|
example:
|
||||||
|
inner_string: inner_string
|
||||||
properties:
|
properties:
|
||||||
inner_string:
|
inner_string:
|
||||||
type: string
|
type: string
|
||||||
@ -193,6 +242,10 @@ components:
|
|||||||
xml:
|
xml:
|
||||||
name: snake_another_xml_object
|
name: snake_another_xml_object
|
||||||
namespace: http://foo.bar
|
namespace: http://foo.bar
|
||||||
|
inline_response_201:
|
||||||
|
properties:
|
||||||
|
foo:
|
||||||
|
type: string
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
authScheme:
|
authScheme:
|
||||||
flows:
|
flows:
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
# InlineResponse201
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**foo** | **String** | | [optional] [default to None]
|
||||||
|
|
||||||
|
[[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#) | **GET** /multiget | Get some stuff.
|
||||||
****](default_api.md#) | **GET** /multiple_auth_scheme |
|
****](default_api.md#) | **GET** /multiple_auth_scheme |
|
||||||
****](default_api.md#) | **GET** /readonly_auth_scheme |
|
****](default_api.md#) | **GET** /readonly_auth_scheme |
|
||||||
****](default_api.md#) | **PUT** /required_octet_stream |
|
****](default_api.md#) | **PUT** /required_octet_stream |
|
||||||
@ -16,6 +17,28 @@ Method | HTTP request | Description
|
|||||||
****](default_api.md#) | **PUT** /xml |
|
****](default_api.md#) | **PUT** /xml |
|
||||||
|
|
||||||
|
|
||||||
|
# ****
|
||||||
|
> models::AnotherXmlObject ()
|
||||||
|
Get some stuff.
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**models::AnotherXmlObject**](anotherXmlObject.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/json, application/octet-stream, application/xml, text/plain,
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
# ****
|
# ****
|
||||||
> (ctx, )
|
> (ctx, )
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
MultigetGetResponse,
|
||||||
MultipleAuthSchemeGetResponse,
|
MultipleAuthSchemeGetResponse,
|
||||||
ReadonlyAuthSchemeGetResponse,
|
ReadonlyAuthSchemeGetResponse,
|
||||||
RequiredOctetStreamPutResponse,
|
RequiredOctetStreamPutResponse,
|
||||||
@ -37,6 +38,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(&[
|
||||||
|
"MultigetGet",
|
||||||
"MultipleAuthSchemeGet",
|
"MultipleAuthSchemeGet",
|
||||||
"ReadonlyAuthSchemeGet",
|
"ReadonlyAuthSchemeGet",
|
||||||
"RequiredOctetStreamPut",
|
"RequiredOctetStreamPut",
|
||||||
@ -87,6 +89,11 @@ fn main() {
|
|||||||
|
|
||||||
match matches.value_of("operation") {
|
match matches.value_of("operation") {
|
||||||
|
|
||||||
|
Some("MultigetGet") => {
|
||||||
|
let result = core.run(client.multiget_get());
|
||||||
|
println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &Has<XSpanIdString>).get().clone());
|
||||||
|
},
|
||||||
|
|
||||||
Some("MultipleAuthSchemeGet") => {
|
Some("MultipleAuthSchemeGet") => {
|
||||||
let result = core.run(client.multiple_auth_scheme_get());
|
let result = core.run(client.multiple_auth_scheme_get());
|
||||||
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::{Has, XSpanIdString};
|
|||||||
use uuid;
|
use uuid;
|
||||||
|
|
||||||
use openapi_v3::{Api, ApiError,
|
use openapi_v3::{Api, ApiError,
|
||||||
|
MultigetGetResponse,
|
||||||
MultipleAuthSchemeGetResponse,
|
MultipleAuthSchemeGetResponse,
|
||||||
ReadonlyAuthSchemeGetResponse,
|
ReadonlyAuthSchemeGetResponse,
|
||||||
RequiredOctetStreamPutResponse,
|
RequiredOctetStreamPutResponse,
|
||||||
@ -37,6 +38,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>{
|
||||||
|
|
||||||
|
/// Get some stuff.
|
||||||
|
fn multiget_get(&self, context: &C) -> Box<Future<Item=MultigetGetResponse, Error=ApiError>> {
|
||||||
|
let context = context.clone();
|
||||||
|
println!("multiget_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||||
|
Box::new(futures::failed("Generic failure".into()))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn multiple_auth_scheme_get(&self, context: &C) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>> {
|
fn multiple_auth_scheme_get(&self, context: &C) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>> {
|
||||||
let context = context.clone();
|
let context = context.clone();
|
||||||
|
@ -37,6 +37,7 @@ use swagger;
|
|||||||
use swagger::{ApiError, XSpanId, XSpanIdString, Has, AuthData};
|
use swagger::{ApiError, XSpanId, XSpanIdString, Has, AuthData};
|
||||||
|
|
||||||
use {Api,
|
use {Api,
|
||||||
|
MultigetGetResponse,
|
||||||
MultipleAuthSchemeGetResponse,
|
MultipleAuthSchemeGetResponse,
|
||||||
ReadonlyAuthSchemeGetResponse,
|
ReadonlyAuthSchemeGetResponse,
|
||||||
RequiredOctetStreamPutResponse,
|
RequiredOctetStreamPutResponse,
|
||||||
@ -252,6 +253,187 @@ 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> + Has<Option<AuthData>>{
|
C: Has<XSpanIdString> + Has<Option<AuthData>>{
|
||||||
|
|
||||||
|
fn multiget_get(&self, context: &C) -> Box<Future<Item=MultigetGetResponse, Error=ApiError>> {
|
||||||
|
let mut uri = format!(
|
||||||
|
"{}/multiget",
|
||||||
|
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::Get, uri);
|
||||||
|
|
||||||
|
|
||||||
|
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(
|
||||||
|
body
|
||||||
|
.concat2()
|
||||||
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
str::from_utf8(&body)
|
||||||
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
serde_json::from_str::<models::AnotherXmlObject>(body)
|
||||||
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map(move |body| {
|
||||||
|
MultigetGetResponse::JSONRsp(body)
|
||||||
|
})
|
||||||
|
) as Box<Future<Item=_, Error=_>>
|
||||||
|
},
|
||||||
|
201 => {
|
||||||
|
let body = response.body();
|
||||||
|
Box::new(
|
||||||
|
body
|
||||||
|
.concat2()
|
||||||
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
str::from_utf8(&body)
|
||||||
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
// 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
|
||||||
|
serde_xml_rs::from_str::<models::InlineResponse201>(body)
|
||||||
|
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map(move |body| {
|
||||||
|
MultigetGetResponse::XMLRsp(body)
|
||||||
|
})
|
||||||
|
) as Box<Future<Item=_, Error=_>>
|
||||||
|
},
|
||||||
|
202 => {
|
||||||
|
let body = response.body();
|
||||||
|
Box::new(
|
||||||
|
body
|
||||||
|
.concat2()
|
||||||
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
Ok(swagger::ByteArray(body.to_vec()))
|
||||||
|
)
|
||||||
|
.map(move |body| {
|
||||||
|
MultigetGetResponse::OctetRsp(body)
|
||||||
|
})
|
||||||
|
) as Box<Future<Item=_, Error=_>>
|
||||||
|
},
|
||||||
|
203 => {
|
||||||
|
let body = response.body();
|
||||||
|
Box::new(
|
||||||
|
body
|
||||||
|
.concat2()
|
||||||
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
str::from_utf8(&body)
|
||||||
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
Ok(body.to_string())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map(move |body| {
|
||||||
|
MultigetGetResponse::StringRsp(body)
|
||||||
|
})
|
||||||
|
) as Box<Future<Item=_, Error=_>>
|
||||||
|
},
|
||||||
|
204 => {
|
||||||
|
let body = response.body();
|
||||||
|
Box::new(
|
||||||
|
body
|
||||||
|
.concat2()
|
||||||
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
str::from_utf8(&body)
|
||||||
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
serde_json::from_str::<models::AnotherXmlObject>(body)
|
||||||
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map(move |body| {
|
||||||
|
MultigetGetResponse::DuplicateResponseLongText(body)
|
||||||
|
})
|
||||||
|
) as Box<Future<Item=_, Error=_>>
|
||||||
|
},
|
||||||
|
205 => {
|
||||||
|
let body = response.body();
|
||||||
|
Box::new(
|
||||||
|
body
|
||||||
|
.concat2()
|
||||||
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
str::from_utf8(&body)
|
||||||
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
serde_json::from_str::<models::AnotherXmlObject>(body)
|
||||||
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map(move |body| {
|
||||||
|
MultigetGetResponse::DuplicateResponseLongText_2(body)
|
||||||
|
})
|
||||||
|
) as Box<Future<Item=_, Error=_>>
|
||||||
|
},
|
||||||
|
206 => {
|
||||||
|
let body = response.body();
|
||||||
|
Box::new(
|
||||||
|
body
|
||||||
|
.concat2()
|
||||||
|
.map_err(|e| ApiError(format!("Failed to read response: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
str::from_utf8(&body)
|
||||||
|
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))
|
||||||
|
.and_then(|body|
|
||||||
|
serde_json::from_str::<models::AnotherXmlObject>(body)
|
||||||
|
.map_err(|e| e.into())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map(move |body| {
|
||||||
|
MultigetGetResponse::DuplicateResponseLongText_3(body)
|
||||||
|
})
|
||||||
|
) 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 multiple_auth_scheme_get(&self, context: &C) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>> {
|
fn multiple_auth_scheme_get(&self, context: &C) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>> {
|
||||||
let mut uri = format!(
|
let mut uri = format!(
|
||||||
"{}/multiple_auth_scheme",
|
"{}/multiple_auth_scheme",
|
||||||
@ -503,15 +685,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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| {
|
||||||
ResponsesWithHeadersGetResponse::Success{ body: body, success_info: response_success_info }
|
ResponsesWithHeadersGetResponse::Success{ body: body, success_info: response_success_info }
|
||||||
@ -600,15 +779,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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::<uuid::Uuid>(body)
|
serde_json::from_str::<uuid::Uuid>(body)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
.map(move |body| {
|
.map(move |body| {
|
||||||
UuidGetResponse::DuplicateResponseLongText(body)
|
UuidGetResponse::DuplicateResponseLongText(body)
|
||||||
|
@ -51,6 +51,37 @@ 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 MultigetGetResponse {
|
||||||
|
/// JSON rsp
|
||||||
|
JSONRsp
|
||||||
|
(models::AnotherXmlObject)
|
||||||
|
,
|
||||||
|
/// XML rsp
|
||||||
|
XMLRsp
|
||||||
|
(models::InlineResponse201)
|
||||||
|
,
|
||||||
|
/// octet rsp
|
||||||
|
OctetRsp
|
||||||
|
(swagger::ByteArray)
|
||||||
|
,
|
||||||
|
/// string rsp
|
||||||
|
StringRsp
|
||||||
|
(String)
|
||||||
|
,
|
||||||
|
/// Duplicate Response long text. One.
|
||||||
|
DuplicateResponseLongText
|
||||||
|
(models::AnotherXmlObject)
|
||||||
|
,
|
||||||
|
/// Duplicate Response long text. Two.
|
||||||
|
DuplicateResponseLongText_2
|
||||||
|
(models::AnotherXmlObject)
|
||||||
|
,
|
||||||
|
/// Duplicate Response long text. Three.
|
||||||
|
DuplicateResponseLongText_3
|
||||||
|
(models::AnotherXmlObject)
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum MultipleAuthSchemeGetResponse {
|
pub enum MultipleAuthSchemeGetResponse {
|
||||||
/// Check that limiting to multiple required auth schemes works
|
/// Check that limiting to multiple required auth schemes works
|
||||||
@ -142,6 +173,9 @@ pub enum XmlPutResponse {
|
|||||||
/// API
|
/// API
|
||||||
pub trait Api<C> {
|
pub trait Api<C> {
|
||||||
|
|
||||||
|
/// Get some stuff.
|
||||||
|
fn multiget_get(&self, context: &C) -> Box<Future<Item=MultigetGetResponse, Error=ApiError>>;
|
||||||
|
|
||||||
|
|
||||||
fn multiple_auth_scheme_get(&self, context: &C) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>>;
|
fn multiple_auth_scheme_get(&self, context: &C) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>>;
|
||||||
|
|
||||||
@ -177,6 +211,9 @@ pub trait Api<C> {
|
|||||||
/// API without a `Context`
|
/// API without a `Context`
|
||||||
pub trait ApiNoContext {
|
pub trait ApiNoContext {
|
||||||
|
|
||||||
|
/// Get some stuff.
|
||||||
|
fn multiget_get(&self) -> Box<Future<Item=MultigetGetResponse, Error=ApiError>>;
|
||||||
|
|
||||||
|
|
||||||
fn multiple_auth_scheme_get(&self) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>>;
|
fn multiple_auth_scheme_get(&self) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>>;
|
||||||
|
|
||||||
@ -223,6 +260,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> {
|
||||||
|
|
||||||
|
/// Get some stuff.
|
||||||
|
fn multiget_get(&self) -> Box<Future<Item=MultigetGetResponse, Error=ApiError>> {
|
||||||
|
self.api().multiget_get(&self.context())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn multiple_auth_scheme_get(&self) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>> {
|
fn multiple_auth_scheme_get(&self) -> Box<Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>> {
|
||||||
self.api().multiple_auth_scheme_get(&self.context())
|
self.api().multiple_auth_scheme_get(&self.context())
|
||||||
|
@ -5,6 +5,41 @@ pub mod responses {
|
|||||||
|
|
||||||
// The macro is called per-operation to beat the recursion limit
|
// The macro is called per-operation to beat the recursion limit
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
/// Create Mime objects for the response content types for MultigetGet
|
||||||
|
pub static ref MULTIGET_GET_JSON_RSP: Mime = "application/json".parse().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
/// Create Mime objects for the response content types for MultigetGet
|
||||||
|
pub static ref MULTIGET_GET_XML_RSP: Mime = "application/xml".parse().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
/// Create Mime objects for the response content types for MultigetGet
|
||||||
|
pub static ref MULTIGET_GET_OCTET_RSP: Mime = "application/octet-stream".parse().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
/// Create Mime objects for the response content types for MultigetGet
|
||||||
|
pub static ref MULTIGET_GET_STRING_RSP: Mime = "text/plain".parse().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
/// Create Mime objects for the response content types for MultigetGet
|
||||||
|
pub static ref MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT: Mime = "application/json".parse().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
/// Create Mime objects for the response content types for MultigetGet
|
||||||
|
pub static ref MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_2: Mime = "application/json".parse().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
/// Create Mime objects for the response content types for MultigetGet
|
||||||
|
pub static ref MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_3: Mime = "application/json".parse().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create Mime objects for the response content types for ResponsesWithHeadersGet
|
/// Create Mime objects for the response content types for ResponsesWithHeadersGet
|
||||||
pub static ref RESPONSES_WITH_HEADERS_GET_SUCCESS: Mime = "application/json".parse().unwrap();
|
pub static ref RESPONSES_WITH_HEADERS_GET_SUCCESS: Mime = "application/json".parse().unwrap();
|
||||||
|
@ -218,6 +218,32 @@ impl DuplicateXmlObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||||
|
pub struct InlineResponse201 {
|
||||||
|
#[serde(rename = "foo")]
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub foo: Option<String>,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InlineResponse201 {
|
||||||
|
pub fn new() -> InlineResponse201 {
|
||||||
|
InlineResponse201 {
|
||||||
|
foo: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InlineResponse201 {
|
||||||
|
/// 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Test a model containing a UUID
|
/// Test a model containing a UUID
|
||||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||||
|
@ -35,6 +35,7 @@ use swagger::{ApiError, XSpanId, XSpanIdString, Has, RequestParser};
|
|||||||
use swagger::auth::Scopes;
|
use swagger::auth::Scopes;
|
||||||
|
|
||||||
use {Api,
|
use {Api,
|
||||||
|
MultigetGetResponse,
|
||||||
MultipleAuthSchemeGetResponse,
|
MultipleAuthSchemeGetResponse,
|
||||||
ReadonlyAuthSchemeGetResponse,
|
ReadonlyAuthSchemeGetResponse,
|
||||||
RequiredOctetStreamPutResponse,
|
RequiredOctetStreamPutResponse,
|
||||||
@ -58,6 +59,7 @@ mod paths {
|
|||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
|
pub static ref GLOBAL_REGEX_SET: regex::RegexSet = regex::RegexSet::new(vec![
|
||||||
|
r"^/multiget$",
|
||||||
r"^/multiple_auth_scheme$",
|
r"^/multiple_auth_scheme$",
|
||||||
r"^/readonly_auth_scheme$",
|
r"^/readonly_auth_scheme$",
|
||||||
r"^/required_octet_stream$",
|
r"^/required_octet_stream$",
|
||||||
@ -68,14 +70,15 @@ mod paths {
|
|||||||
r"^/xml_other$"
|
r"^/xml_other$"
|
||||||
]).unwrap();
|
]).unwrap();
|
||||||
}
|
}
|
||||||
pub static ID_MULTIPLE_AUTH_SCHEME: usize = 0;
|
pub static ID_MULTIGET: usize = 0;
|
||||||
pub static ID_READONLY_AUTH_SCHEME: usize = 1;
|
pub static ID_MULTIPLE_AUTH_SCHEME: usize = 1;
|
||||||
pub static ID_REQUIRED_OCTET_STREAM: usize = 2;
|
pub static ID_READONLY_AUTH_SCHEME: usize = 2;
|
||||||
pub static ID_RESPONSES_WITH_HEADERS: usize = 3;
|
pub static ID_REQUIRED_OCTET_STREAM: usize = 3;
|
||||||
pub static ID_UUID: usize = 4;
|
pub static ID_RESPONSES_WITH_HEADERS: usize = 4;
|
||||||
pub static ID_XML: usize = 5;
|
pub static ID_UUID: usize = 5;
|
||||||
pub static ID_XML_EXTRA: usize = 6;
|
pub static ID_XML: usize = 6;
|
||||||
pub static ID_XML_OTHER: usize = 7;
|
pub static ID_XML_EXTRA: usize = 7;
|
||||||
|
pub static ID_XML_OTHER: usize = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NewService<T, C> {
|
pub struct NewService<T, C> {
|
||||||
@ -141,6 +144,124 @@ 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 {
|
||||||
|
|
||||||
|
// MultigetGet - GET /multiget
|
||||||
|
&hyper::Method::Get if path.matched(paths::ID_MULTIGET) => {
|
||||||
|
Box::new({
|
||||||
|
{{
|
||||||
|
Box::new(api_impl.multiget_get(&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 {
|
||||||
|
MultigetGetResponse::JSONRsp
|
||||||
|
|
||||||
|
(body)
|
||||||
|
|
||||||
|
|
||||||
|
=> {
|
||||||
|
response.set_status(StatusCode::try_from(200).unwrap());
|
||||||
|
|
||||||
|
response.headers_mut().set(ContentType(mimetypes::responses::MULTIGET_GET_JSON_RSP.clone()));
|
||||||
|
|
||||||
|
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
response.set_body(body);
|
||||||
|
},
|
||||||
|
MultigetGetResponse::XMLRsp
|
||||||
|
|
||||||
|
(body)
|
||||||
|
|
||||||
|
|
||||||
|
=> {
|
||||||
|
response.set_status(StatusCode::try_from(201).unwrap());
|
||||||
|
|
||||||
|
response.headers_mut().set(ContentType(mimetypes::responses::MULTIGET_GET_XML_RSP.clone()));
|
||||||
|
|
||||||
|
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
response.set_body(body);
|
||||||
|
},
|
||||||
|
MultigetGetResponse::OctetRsp
|
||||||
|
|
||||||
|
(body)
|
||||||
|
|
||||||
|
|
||||||
|
=> {
|
||||||
|
response.set_status(StatusCode::try_from(202).unwrap());
|
||||||
|
|
||||||
|
response.headers_mut().set(ContentType(mimetypes::responses::MULTIGET_GET_OCTET_RSP.clone()));
|
||||||
|
|
||||||
|
let body = body.0;
|
||||||
|
response.set_body(body);
|
||||||
|
},
|
||||||
|
MultigetGetResponse::StringRsp
|
||||||
|
|
||||||
|
(body)
|
||||||
|
|
||||||
|
|
||||||
|
=> {
|
||||||
|
response.set_status(StatusCode::try_from(203).unwrap());
|
||||||
|
|
||||||
|
response.headers_mut().set(ContentType(mimetypes::responses::MULTIGET_GET_STRING_RSP.clone()));
|
||||||
|
|
||||||
|
let body = body;
|
||||||
|
response.set_body(body);
|
||||||
|
},
|
||||||
|
MultigetGetResponse::DuplicateResponseLongText
|
||||||
|
|
||||||
|
(body)
|
||||||
|
|
||||||
|
|
||||||
|
=> {
|
||||||
|
response.set_status(StatusCode::try_from(204).unwrap());
|
||||||
|
|
||||||
|
response.headers_mut().set(ContentType(mimetypes::responses::MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT.clone()));
|
||||||
|
|
||||||
|
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
response.set_body(body);
|
||||||
|
},
|
||||||
|
MultigetGetResponse::DuplicateResponseLongText_2
|
||||||
|
|
||||||
|
(body)
|
||||||
|
|
||||||
|
|
||||||
|
=> {
|
||||||
|
response.set_status(StatusCode::try_from(205).unwrap());
|
||||||
|
|
||||||
|
response.headers_mut().set(ContentType(mimetypes::responses::MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_2.clone()));
|
||||||
|
|
||||||
|
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
response.set_body(body);
|
||||||
|
},
|
||||||
|
MultigetGetResponse::DuplicateResponseLongText_3
|
||||||
|
|
||||||
|
(body)
|
||||||
|
|
||||||
|
|
||||||
|
=> {
|
||||||
|
response.set_status(StatusCode::try_from(206).unwrap());
|
||||||
|
|
||||||
|
response.headers_mut().set(ContentType(mimetypes::responses::MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_3.clone()));
|
||||||
|
|
||||||
|
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
response.set_body(body);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
))
|
||||||
|
}}
|
||||||
|
}) as Box<Future<Item=Response, Error=Error>>
|
||||||
|
},
|
||||||
|
|
||||||
// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
||||||
&hyper::Method::Get if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => {
|
&hyper::Method::Get if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => {
|
||||||
{
|
{
|
||||||
@ -339,9 +460,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::RESPONSES_WITH_HEADERS_GET_SUCCESS.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::RESPONSES_WITH_HEADERS_GET_SUCCESS.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
ResponsesWithHeadersGetResponse::PreconditionFailed
|
ResponsesWithHeadersGetResponse::PreconditionFailed
|
||||||
@ -397,9 +516,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::UUID_GET_DUPLICATE_RESPONSE_LONG_TEXT.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::UUID_GET_DUPLICATE_RESPONSE_LONG_TEXT.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -771,6 +888,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() {
|
||||||
|
|
||||||
|
// MultigetGet - GET /multiget
|
||||||
|
&hyper::Method::Get if path.matched(paths::ID_MULTIGET) => Ok("MultigetGet"),
|
||||||
|
|
||||||
// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
||||||
&hyper::Method::Get if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => Ok("MultipleAuthSchemeGet"),
|
&hyper::Method::Get if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => Ok("MultipleAuthSchemeGet"),
|
||||||
|
|
||||||
|
@ -319,15 +319,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -403,15 +400,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -486,15 +480,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -569,15 +560,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -652,15 +640,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -796,15 +781,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -1210,15 +1192,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -1452,7 +1431,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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|
|
||||||
@ -1461,7 +1439,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
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)
|
||||||
@ -1549,7 +1526,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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|
|
||||||
@ -1558,7 +1534,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
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)
|
||||||
@ -1646,7 +1621,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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|
|
||||||
@ -1655,7 +1629,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
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)
|
||||||
@ -1976,15 +1949,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -2133,15 +2103,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -2207,7 +2174,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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|
|
||||||
@ -2216,7 +2182,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
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)
|
||||||
@ -2304,7 +2269,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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|
|
||||||
@ -2313,7 +2277,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
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)
|
||||||
@ -2654,7 +2617,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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|
|
||||||
@ -2663,7 +2625,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
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)
|
||||||
@ -2759,7 +2720,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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|
|
||||||
@ -2768,7 +2728,6 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
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 }
|
||||||
|
@ -42,17 +42,17 @@ pub mod responses {
|
|||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create Mime objects for the response content types for FindPetsByStatus
|
/// Create Mime objects for the response content types for FindPetsByStatus
|
||||||
pub static ref FIND_PETS_BY_STATUS_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
|
pub static ref FIND_PETS_BY_STATUS_SUCCESSFUL_OPERATION: Mime = "application/xml".parse().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create Mime objects for the response content types for FindPetsByTags
|
/// Create Mime objects for the response content types for FindPetsByTags
|
||||||
pub static ref FIND_PETS_BY_TAGS_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
|
pub static ref FIND_PETS_BY_TAGS_SUCCESSFUL_OPERATION: Mime = "application/xml".parse().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create Mime objects for the response content types for GetPetById
|
/// Create Mime objects for the response content types for GetPetById
|
||||||
pub static ref GET_PET_BY_ID_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
|
pub static ref GET_PET_BY_ID_SUCCESSFUL_OPERATION: Mime = "application/xml".parse().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@ -67,22 +67,22 @@ pub mod responses {
|
|||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create Mime objects for the response content types for GetOrderById
|
/// Create Mime objects for the response content types for GetOrderById
|
||||||
pub static ref GET_ORDER_BY_ID_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
|
pub static ref GET_ORDER_BY_ID_SUCCESSFUL_OPERATION: Mime = "application/xml".parse().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create Mime objects for the response content types for PlaceOrder
|
/// Create Mime objects for the response content types for PlaceOrder
|
||||||
pub static ref PLACE_ORDER_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
|
pub static ref PLACE_ORDER_SUCCESSFUL_OPERATION: Mime = "application/xml".parse().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create Mime objects for the response content types for GetUserByName
|
/// Create Mime objects for the response content types for GetUserByName
|
||||||
pub static ref GET_USER_BY_NAME_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
|
pub static ref GET_USER_BY_NAME_SUCCESSFUL_OPERATION: Mime = "application/xml".parse().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Create Mime objects for the response content types for LoginUser
|
/// Create Mime objects for the response content types for LoginUser
|
||||||
pub static ref LOGIN_USER_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
|
pub static ref LOGIN_USER_SUCCESSFUL_OPERATION: Mime = "application/xml".parse().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -258,9 +258,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::TEST_SPECIAL_TAGS_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::TEST_SPECIAL_TAGS_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -325,9 +323,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::FAKE_OUTER_BOOLEAN_SERIALIZE_OUTPUT_BOOLEAN.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::FAKE_OUTER_BOOLEAN_SERIALIZE_OUTPUT_BOOLEAN.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -392,9 +388,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::FAKE_OUTER_COMPOSITE_SERIALIZE_OUTPUT_COMPOSITE.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::FAKE_OUTER_COMPOSITE_SERIALIZE_OUTPUT_COMPOSITE.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -459,9 +453,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::FAKE_OUTER_NUMBER_SERIALIZE_OUTPUT_NUMBER.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::FAKE_OUTER_NUMBER_SERIALIZE_OUTPUT_NUMBER.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -526,9 +518,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::FAKE_OUTER_STRING_SERIALIZE_OUTPUT_STRING.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::FAKE_OUTER_STRING_SERIALIZE_OUTPUT_STRING.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -671,9 +661,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::TEST_CLIENT_MODEL_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::TEST_CLIENT_MODEL_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -986,9 +974,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::TEST_CLASSNAME_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::TEST_CLASSNAME_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1232,9 +1218,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::FIND_PETS_BY_STATUS_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::FIND_PETS_BY_STATUS_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
FindPetsByStatusResponse::InvalidStatusValue
|
FindPetsByStatusResponse::InvalidStatusValue
|
||||||
@ -1313,9 +1297,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::FIND_PETS_BY_TAGS_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::FIND_PETS_BY_TAGS_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
FindPetsByTagsResponse::InvalidTagValue
|
FindPetsByTagsResponse::InvalidTagValue
|
||||||
@ -1386,9 +1368,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::GET_PET_BY_ID_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::GET_PET_BY_ID_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
GetPetByIdResponse::InvalidIDSupplied
|
GetPetByIdResponse::InvalidIDSupplied
|
||||||
@ -1711,9 +1691,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::UPLOAD_FILE_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::UPLOAD_FILE_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1822,9 +1800,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::GET_INVENTORY_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::GET_INVENTORY_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1879,9 +1855,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::GET_ORDER_BY_ID_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::GET_ORDER_BY_ID_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
GetOrderByIdResponse::InvalidIDSupplied
|
GetOrderByIdResponse::InvalidIDSupplied
|
||||||
@ -1961,9 +1935,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::PLACE_ORDER_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::PLACE_ORDER_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
PlaceOrderResponse::InvalidOrder
|
PlaceOrderResponse::InvalidOrder
|
||||||
@ -2273,9 +2245,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::GET_USER_BY_NAME_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::GET_USER_BY_NAME_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
GetUserByNameResponse::InvalidUsernameSupplied
|
GetUserByNameResponse::InvalidUsernameSupplied
|
||||||
@ -2358,9 +2328,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::LOGIN_USER_SUCCESSFUL_OPERATION.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::LOGIN_USER_SUCCESSFUL_OPERATION.clone()));
|
||||||
|
|
||||||
|
|
||||||
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
LoginUserResponse::InvalidUsername
|
LoginUserResponse::InvalidUsername
|
||||||
|
@ -406,15 +406,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -484,15 +481,11 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
@ -558,15 +551,12 @@ impl<F, C> Api<C> for Client<F> where
|
|||||||
.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|
|
.and_then(|body|
|
||||||
|
|
||||||
str::from_utf8(&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)
|
||||||
|
@ -244,9 +244,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::FILE_RESPONSE_GET_SUCCESS.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::FILE_RESPONSE_GET_SUCCESS.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -300,9 +298,7 @@ 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 = body;
|
||||||
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
|
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -345,9 +341,7 @@ where
|
|||||||
|
|
||||||
response.headers_mut().set(ContentType(mimetypes::responses::RAW_JSON_GET_SUCCESS.clone()));
|
response.headers_mut().set(ContentType(mimetypes::responses::RAW_JSON_GET_SUCCESS.clone()));
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
response.set_body(body);
|
response.set_body(body);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user