forked from loafle/openapi-generator-original
[Rust Server] Support objects as query parameters (#5338)
- Support objects as query parameters - Update samples
This commit is contained in:
committed by
GitHub
parent
71f532072b
commit
71aef72bbd
@@ -192,8 +192,8 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("ByteArray", bytesType);
|
||||
typeMapping.put("binary", bytesType);
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("date", "chrono::DateTime<chrono::Utc>");
|
||||
typeMapping.put("DateTime", "chrono::DateTime<chrono::Utc>");
|
||||
typeMapping.put("date", "chrono::DateTime::<chrono::Utc>");
|
||||
typeMapping.put("DateTime", "chrono::DateTime::<chrono::Utc>");
|
||||
typeMapping.put("password", "String");
|
||||
typeMapping.put("File", bytesType);
|
||||
typeMapping.put("file", bytesType);
|
||||
|
||||
@@ -102,7 +102,31 @@ impl ::std::ops::DerefMut for {{{classname}}} {
|
||||
}
|
||||
}
|
||||
|
||||
{{/dataType}}{{^dataType}}
|
||||
{{#additionalPropertiesType}}
|
||||
/// Converts the {{{classname}}} value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for {{{classname}}} {
|
||||
fn to_string(&self) -> String {
|
||||
// Skipping additionalProperties in query parameter serialization
|
||||
"".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a {{{classname}}} value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for {{{classname}}} {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
// Parsing additionalProperties in this style is not supported yet
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
{{/additionalPropertiesType}}
|
||||
{{/dataType}}
|
||||
{{^dataType}}
|
||||
// Methods for converting between IntoHeaderValue<{{{classname}}}> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<{{{classname}}}>> for HeaderValue {
|
||||
@@ -188,9 +212,37 @@ impl ::std::ops::DerefMut for {{{classname}}} {
|
||||
}
|
||||
}
|
||||
|
||||
{{/arrayModelType}}{{^arrayModelType}}{{! general struct}}#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]{{#xmlName}}
|
||||
#[serde(rename = "{{{xmlName}}}")]{{/xmlName}}
|
||||
/// Converts the {{{classname}}} value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for {{{classname}}} {
|
||||
fn to_string(&self) -> String {
|
||||
self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a {{{classname}}} value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for {{{classname}}} {
|
||||
type Err = <{{{arrayModelType}}} as ::std::str::FromStr>::Err;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut items = vec![];
|
||||
for item in s.split(',')
|
||||
{
|
||||
items.push(item.parse()?);
|
||||
}
|
||||
Ok({{{classname}}}(items))
|
||||
}
|
||||
}
|
||||
|
||||
{{/arrayModelType}}{{^arrayModelType}}{{! general struct}}
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
{{#xmlName}}
|
||||
#[serde(rename = "{{{xmlName}}}")]
|
||||
{{/xmlName}}
|
||||
pub struct {{{classname}}} {
|
||||
{{#vars}}{{#description}} /// {{{description}}}
|
||||
{{/description}}{{#isEnum}} // Note: inline enums are not fully supported by openapi-generator
|
||||
@@ -215,6 +267,131 @@ impl {{{classname}}} {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the {{{classname}}} value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for {{{classname}}} {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
{{#vars}}
|
||||
{{#isByteArray}}
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
{{/isBinary}}
|
||||
{{#isMapContainer}}
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
{{/isMapContainer}}
|
||||
{{^isPrimitiveType}}
|
||||
// Skipping {{baseName}} in query parameter serialization
|
||||
{{/isPrimitiveType}}
|
||||
{{^isByteArray}}{{^isBinary}}{{^isMapContainer}}{{#isPrimitiveType}}
|
||||
{{#required}}
|
||||
params.push("{{{baseName}}}".to_string());
|
||||
{{^isListContainer}}
|
||||
{{#isNullable}}
|
||||
params.push(self.{{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string()));
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
params.push(self.{{{name}}}.to_string());
|
||||
{{/isNullable}}
|
||||
{{/isListContainer}}
|
||||
{{#isListContainer}}
|
||||
params.push(self.{{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string());
|
||||
{{/isListContainer}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if let Some(ref {{{name}}}) = self.{{{name}}} {
|
||||
params.push("{{{baseName}}}".to_string());
|
||||
{{^isListContainer}}
|
||||
{{#isNullable}}
|
||||
params.push({{{name}}}.as_ref().map_or("null".to_string(), |x| x.to_string()));
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
params.push({{{name}}}.to_string());
|
||||
{{/isNullable}}
|
||||
{{/isListContainer}}
|
||||
{{#isListContainer}}
|
||||
params.push({{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string());
|
||||
{{/isListContainer}}
|
||||
}
|
||||
{{/required}}
|
||||
{{/isPrimitiveType}}{{/isMapContainer}}{{/isBinary}}{{/isByteArray}}
|
||||
{{/vars}}
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a {{{classname}}} value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for {{{classname}}} {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
{{#vars}}
|
||||
pub {{{name}}}: Vec<{{{dataType}}}>,
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
{{#vars}}
|
||||
{{#isBinary}}
|
||||
"{{{baseName}}}" => return Err(()), // Parsing binary data in this style is not supported yet
|
||||
{{/isBinary}}
|
||||
{{#isByteArray}}
|
||||
"{{{baseName}}}" => return Err(()), // Parsing binary data in this style is not supported yet
|
||||
{{/isByteArray}}
|
||||
{{#isContainer}}
|
||||
"{{{baseName}}}" => return Err(()), // Parsing a container in this style is not supported yet
|
||||
{{/isContainer}}
|
||||
{{#isNullable}}
|
||||
"{{{baseName}}}" => return Err(()), // Parsing a nullable type in this style is not supported yet
|
||||
{{/isNullable}}
|
||||
{{^isByteArray}}{{^isBinary}}{{^isContainer}}{{^isNullable}}
|
||||
"{{{baseName}}}" => intermediate_rep.{{{name}}}.push({{{dataType}}}::from_str(val).map_err(|x| ())?),
|
||||
{{/isNullable}}{{/isContainer}}{{/isBinary}}{{/isByteArray}}
|
||||
{{/vars}}
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok({{{classname}}} {
|
||||
{{#vars}}
|
||||
{{#isNullable}}
|
||||
{{{name}}}: Err(())?,
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{{{name}}}: intermediate_rep.{{{name}}}.into_iter().next(){{#required}}.ok_or(())?{{/required}},
|
||||
{{/isNullable}}
|
||||
{{/vars}}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
{{/arrayModelType}}
|
||||
{{/dataType}}
|
||||
{{/isEnum}}
|
||||
|
||||
@@ -1303,6 +1303,15 @@ definitions:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/Animal'
|
||||
ObjectContainingObjectWithOnlyAdditionalProperties:
|
||||
type: object
|
||||
properties:
|
||||
inner:
|
||||
$ref: '#/definitions/ObjectWithOnlyAdditionalProperties'
|
||||
ObjectWithOnlyAdditionalProperties:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
List:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
@@ -45,6 +45,41 @@ paths:
|
||||
description: 'OK'
|
||||
'400':
|
||||
description: Bad Request
|
||||
/paramget:
|
||||
get:
|
||||
summary: Get some stuff with parameters.
|
||||
parameters:
|
||||
- description: The stuff to get
|
||||
explode: false
|
||||
in: query
|
||||
name: uuid
|
||||
required: false
|
||||
schema:
|
||||
$ref: "#/components/schemas/UuidObject"
|
||||
style: form
|
||||
- description: Some object to pass as query parameter
|
||||
explode: false
|
||||
in: query
|
||||
name: someObject
|
||||
required: false
|
||||
schema:
|
||||
$ref: "#/components/schemas/ObjectParam"
|
||||
style: form
|
||||
- description: Some list to pass as query parameter
|
||||
explode: false
|
||||
in: query
|
||||
name: someList
|
||||
required: false
|
||||
schema:
|
||||
$ref: "#/components/schemas/MyIDList"
|
||||
style: form
|
||||
responses:
|
||||
200:
|
||||
description: JSON rsp
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/anotherXmlObject"
|
||||
/multiget:
|
||||
get:
|
||||
summary: Get some stuff.
|
||||
@@ -296,6 +331,15 @@ components:
|
||||
$ref: '#/components/schemas/MyID'
|
||||
MyID:
|
||||
type: integer
|
||||
ObjectParam:
|
||||
type: object
|
||||
required:
|
||||
- requiredParam
|
||||
properties:
|
||||
requiredParam:
|
||||
type: boolean
|
||||
optionalParam:
|
||||
type: integer
|
||||
ObjectHeader:
|
||||
type: object
|
||||
required:
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
//! Server implementation of multipart_v3.
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use futures::{self, Future};
|
||||
use chrono;
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use swagger;
|
||||
use swagger::{Has, XSpanIdString};
|
||||
|
||||
use multipart_v3::{Api, ApiError,
|
||||
MultipartRequestPostResponse
|
||||
};
|
||||
use multipart_v3::models;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Server<C> {
|
||||
marker: PhantomData<C>,
|
||||
}
|
||||
|
||||
impl<C> Server<C> {
|
||||
pub fn new() -> Self {
|
||||
Server{marker: PhantomData}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
|
||||
|
||||
|
||||
fn multipart_request_post(&self, string_field: String, binary_field: swagger::ByteArray, optional_string_field: Option<String>, object_field: Option<models::MultipartRequestObjectField>, context: &C) -> Box<dyn Future<Item=MultipartRequestPostResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("multipart_request_post(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", string_field, binary_field, optional_string_field, object_field, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,6 @@ use std::str::FromStr;
|
||||
use header::IntoHeaderValue;
|
||||
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<MultipartRelatedRequest> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<MultipartRelatedRequest>> for HeaderValue {
|
||||
@@ -26,6 +25,7 @@ impl From<HeaderValue> for IntoHeaderValue<MultipartRelatedRequest> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct MultipartRelatedRequest {
|
||||
@@ -52,6 +52,77 @@ impl MultipartRelatedRequest {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the MultipartRelatedRequest value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for MultipartRelatedRequest {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
// Skipping object_field in query parameter serialization
|
||||
|
||||
// Skipping optional_binary_field in query parameter serialization
|
||||
// Skipping optional_binary_field in query parameter serialization
|
||||
|
||||
// Skipping required_binary_field in query parameter serialization
|
||||
// Skipping required_binary_field in query parameter serialization
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a MultipartRelatedRequest value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for MultipartRelatedRequest {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub object_field: Vec<models::MultipartRequestObjectField>,
|
||||
pub optional_binary_field: Vec<swagger::ByteArray>,
|
||||
pub required_binary_field: Vec<swagger::ByteArray>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"object_field" => intermediate_rep.object_field.push(models::MultipartRequestObjectField::from_str(val).map_err(|x| ())?),
|
||||
|
||||
"optional_binary_field" => return Err(()), // Parsing binary data in this style is not supported yet
|
||||
|
||||
"required_binary_field" => return Err(()), // Parsing binary data in this style is not supported yet
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(MultipartRelatedRequest {
|
||||
object_field: intermediate_rep.object_field.into_iter().next(),
|
||||
optional_binary_field: intermediate_rep.optional_binary_field.into_iter().next(),
|
||||
required_binary_field: intermediate_rep.required_binary_field.into_iter().next().ok_or(())?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<MultipartRequest> and HeaderValue
|
||||
@@ -68,6 +139,7 @@ impl From<HeaderValue> for IntoHeaderValue<MultipartRequest> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct MultipartRequest {
|
||||
@@ -98,6 +170,90 @@ impl MultipartRequest {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the MultipartRequest value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for MultipartRequest {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
params.push("string_field".to_string());
|
||||
params.push(self.string_field.to_string());
|
||||
|
||||
|
||||
if let Some(ref optional_string_field) = self.optional_string_field {
|
||||
params.push("optional_string_field".to_string());
|
||||
params.push(optional_string_field.to_string());
|
||||
}
|
||||
|
||||
// Skipping object_field in query parameter serialization
|
||||
|
||||
// Skipping binary_field in query parameter serialization
|
||||
// Skipping binary_field in query parameter serialization
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a MultipartRequest value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for MultipartRequest {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub string_field: Vec<String>,
|
||||
pub optional_string_field: Vec<String>,
|
||||
pub object_field: Vec<models::MultipartRequestObjectField>,
|
||||
pub binary_field: Vec<swagger::ByteArray>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"string_field" => intermediate_rep.string_field.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
|
||||
"optional_string_field" => intermediate_rep.optional_string_field.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
|
||||
"object_field" => intermediate_rep.object_field.push(models::MultipartRequestObjectField::from_str(val).map_err(|x| ())?),
|
||||
|
||||
"binary_field" => return Err(()), // Parsing binary data in this style is not supported yet
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(MultipartRequest {
|
||||
string_field: intermediate_rep.string_field.into_iter().next().ok_or(())?,
|
||||
optional_string_field: intermediate_rep.optional_string_field.into_iter().next(),
|
||||
object_field: intermediate_rep.object_field.into_iter().next(),
|
||||
binary_field: intermediate_rep.binary_field.into_iter().next().ok_or(())?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<MultipartRequestObjectField> and HeaderValue
|
||||
@@ -114,6 +270,7 @@ impl From<HeaderValue> for IntoHeaderValue<MultipartRequestObjectField> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct MultipartRequestObjectField {
|
||||
@@ -135,3 +292,73 @@ impl MultipartRequestObjectField {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the MultipartRequestObjectField value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for MultipartRequestObjectField {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
params.push("field_a".to_string());
|
||||
params.push(self.field_a.to_string());
|
||||
|
||||
|
||||
if let Some(ref field_b) = self.field_b {
|
||||
params.push("field_b".to_string());
|
||||
params.push(field_b.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string());
|
||||
}
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a MultipartRequestObjectField value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for MultipartRequestObjectField {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub field_a: Vec<String>,
|
||||
pub field_b: Vec<Vec<String>>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"field_a" => intermediate_rep.field_a.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
"field_b" => return Err(()), // Parsing a container in this style is not supported yet
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(MultipartRequestObjectField {
|
||||
field_a: intermediate_rep.field_a.into_iter().next().ok_or(())?,
|
||||
field_b: intermediate_rep.field_b.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ To run a client, follow one of the following simple steps:
|
||||
cargo run --example client MandatoryRequestHeaderGet
|
||||
cargo run --example client MultigetGet
|
||||
cargo run --example client MultipleAuthSchemeGet
|
||||
cargo run --example client ParamgetGet
|
||||
cargo run --example client ReadonlyAuthSchemeGet
|
||||
cargo run --example client RequiredOctetStreamPut
|
||||
cargo run --example client ResponsesWithHeadersGet
|
||||
@@ -109,6 +110,7 @@ Method | HTTP request | Description
|
||||
[****](docs/default_api.md#) | **GET** /mandatory-request-header |
|
||||
[****](docs/default_api.md#) | **GET** /multiget | Get some stuff.
|
||||
[****](docs/default_api.md#) | **GET** /multiple_auth_scheme |
|
||||
[****](docs/default_api.md#) | **GET** /paramget | Get some stuff with parameters.
|
||||
[****](docs/default_api.md#) | **GET** /readonly_auth_scheme |
|
||||
[****](docs/default_api.md#) | **PUT** /required_octet_stream |
|
||||
[****](docs/default_api.md#) | **GET** /responses_with_headers |
|
||||
@@ -131,6 +133,7 @@ Method | HTTP request | Description
|
||||
- [MyId](docs/MyId.md)
|
||||
- [MyIdList](docs/MyIdList.md)
|
||||
- [ObjectHeader](docs/ObjectHeader.md)
|
||||
- [ObjectParam](docs/ObjectParam.md)
|
||||
- [ObjectWithArrayOfObjects](docs/ObjectWithArrayOfObjects.md)
|
||||
- [OptionalObjectHeader](docs/OptionalObjectHeader.md)
|
||||
- [RequiredObjectHeader](docs/RequiredObjectHeader.md)
|
||||
|
||||
@@ -30,6 +30,41 @@ paths:
|
||||
description: OK
|
||||
"400":
|
||||
description: Bad Request
|
||||
/paramget:
|
||||
get:
|
||||
parameters:
|
||||
- description: The stuff to get
|
||||
explode: false
|
||||
in: query
|
||||
name: uuid
|
||||
required: false
|
||||
schema:
|
||||
$ref: '#/components/schemas/UuidObject'
|
||||
style: form
|
||||
- description: Some object to pass as query parameter
|
||||
explode: false
|
||||
in: query
|
||||
name: someObject
|
||||
required: false
|
||||
schema:
|
||||
$ref: '#/components/schemas/ObjectParam'
|
||||
style: form
|
||||
- description: Some list to pass as query parameter
|
||||
explode: false
|
||||
in: query
|
||||
name: someList
|
||||
required: false
|
||||
schema:
|
||||
$ref: '#/components/schemas/MyIDList'
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/anotherXmlObject'
|
||||
description: JSON rsp
|
||||
summary: Get some stuff with parameters.
|
||||
/multiget:
|
||||
get:
|
||||
responses:
|
||||
@@ -282,6 +317,15 @@ components:
|
||||
type: array
|
||||
MyID:
|
||||
type: integer
|
||||
ObjectParam:
|
||||
properties:
|
||||
requiredParam:
|
||||
type: boolean
|
||||
optionalParam:
|
||||
type: integer
|
||||
required:
|
||||
- requiredParam
|
||||
type: object
|
||||
ObjectHeader:
|
||||
properties:
|
||||
requiredObjectHeader:
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# ObjectParam
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**required_param** | **bool** | |
|
||||
**optional_param** | **isize** | | [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)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ Method | HTTP request | Description
|
||||
****](default_api.md#) | **GET** /mandatory-request-header |
|
||||
****](default_api.md#) | **GET** /multiget | Get some stuff.
|
||||
****](default_api.md#) | **GET** /multiple_auth_scheme |
|
||||
****](default_api.md#) | **GET** /paramget | Get some stuff with parameters.
|
||||
****](default_api.md#) | **GET** /readonly_auth_scheme |
|
||||
****](default_api.md#) | **PUT** /required_octet_stream |
|
||||
****](default_api.md#) | **GET** /responses_with_headers |
|
||||
@@ -87,6 +88,40 @@ This endpoint does not need any parameter.
|
||||
|
||||
[[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)
|
||||
|
||||
# ****
|
||||
> models::AnotherXmlObject (optional)
|
||||
Get some stuff with parameters.
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**uuid** | [****](.md)| The stuff to get |
|
||||
**some_object** | [****](.md)| Some object to pass as query parameter |
|
||||
**some_list** | [****](.md)| Some list to pass as query parameter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**models::AnotherXmlObject**](anotherXmlObject.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json,
|
||||
|
||||
[[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, )
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ use openapi_v3::{Api, ApiNoContext, Client, ContextWrapperExt,
|
||||
MandatoryRequestHeaderGetResponse,
|
||||
MultigetGetResponse,
|
||||
MultipleAuthSchemeGetResponse,
|
||||
ParamgetGetResponse,
|
||||
ReadonlyAuthSchemeGetResponse,
|
||||
RequiredOctetStreamPutResponse,
|
||||
ResponsesWithHeadersGetResponse,
|
||||
@@ -41,6 +42,8 @@ fn main() {
|
||||
|
||||
"MultipleAuthSchemeGet",
|
||||
|
||||
"ParamgetGet",
|
||||
|
||||
"ReadonlyAuthSchemeGet",
|
||||
|
||||
"RequiredOctetStreamPut",
|
||||
@@ -125,6 +128,16 @@ fn main() {
|
||||
println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
|
||||
},
|
||||
|
||||
Some("ParamgetGet") => {
|
||||
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let result = rt.block_on(client.paramget_get(
|
||||
Some(serde_json::from_str::<uuid::Uuid>("38400000-8cf0-11bd-b23e-10b96e4ef00d").expect("Failed to parse JSON example")),
|
||||
None,
|
||||
None
|
||||
));
|
||||
println!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has<XSpanIdString>).get().clone());
|
||||
},
|
||||
|
||||
Some("ReadonlyAuthSchemeGet") => {
|
||||
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let result = rt.block_on(client.readonly_auth_scheme_get(
|
||||
|
||||
@@ -20,6 +20,7 @@ use openapi_v3::{Api, ApiError,
|
||||
MandatoryRequestHeaderGetResponse,
|
||||
MultigetGetResponse,
|
||||
MultipleAuthSchemeGetResponse,
|
||||
ParamgetGetResponse,
|
||||
ReadonlyAuthSchemeGetResponse,
|
||||
RequiredOctetStreamPutResponse,
|
||||
ResponsesWithHeadersGetResponse,
|
||||
@@ -66,6 +67,13 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Get some stuff with parameters.
|
||||
fn paramget_get(&self, uuid: Option<uuid::Uuid>, some_object: Option<models::ObjectParam>, some_list: Option<models::MyIdList>, context: &C) -> Box<Future<Item=ParamgetGetResponse, Error=ApiError> + Send> {
|
||||
let context = context.clone();
|
||||
println!("paramget_get({:?}, {:?}, {:?}) - X-Span-ID: {:?}", uuid, some_object, some_list, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn readonly_auth_scheme_get(&self, context: &C) -> Box<Future<Item=ReadonlyAuthSchemeGetResponse, Error=ApiError> + Send> {
|
||||
let context = context.clone();
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
//! Server implementation of openapi_v3.
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use futures::{self, Future};
|
||||
use chrono;
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use swagger;
|
||||
use swagger::{Has, XSpanIdString};
|
||||
use uuid;
|
||||
|
||||
use openapi_v3::{Api, ApiError,
|
||||
MultigetGetResponse,
|
||||
MultipleAuthSchemeGetResponse,
|
||||
ReadonlyAuthSchemeGetResponse,
|
||||
RequiredOctetStreamPutResponse,
|
||||
ResponsesWithHeadersGetResponse,
|
||||
UuidGetResponse,
|
||||
XmlExtraPostResponse,
|
||||
XmlOtherPostResponse,
|
||||
XmlOtherPutResponse,
|
||||
XmlPostResponse,
|
||||
XmlPutResponse
|
||||
};
|
||||
use openapi_v3::models;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Server<C> {
|
||||
marker: PhantomData<C>,
|
||||
}
|
||||
|
||||
impl<C> Server<C> {
|
||||
pub fn new() -> Self {
|
||||
Server{marker: PhantomData}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
|
||||
|
||||
/// Get some stuff.
|
||||
fn multiget_get(&self, context: &C) -> Box<dyn 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<dyn Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("multiple_auth_scheme_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn readonly_auth_scheme_get(&self, context: &C) -> Box<dyn Future<Item=ReadonlyAuthSchemeGetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("readonly_auth_scheme_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn required_octet_stream_put(&self, body: swagger::ByteArray, context: &C) -> Box<dyn 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 responses_with_headers_get(&self, context: &C) -> Box<dyn Future<Item=ResponsesWithHeadersGetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("responses_with_headers_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn uuid_get(&self, context: &C) -> Box<dyn Future<Item=UuidGetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("uuid_get() - X-Span-ID: {:?}", 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<dyn Future<Item=XmlExtraPostResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("xml_extra_post({:?}) - X-Span-ID: {:?}", duplicate_xml_object, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn xml_other_post(&self, another_xml_object: Option<models::AnotherXmlObject>, context: &C) -> Box<dyn Future<Item=XmlOtherPostResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("xml_other_post({:?}) - X-Span-ID: {:?}", another_xml_object, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn xml_other_put(&self, string: Option<models::AnotherXmlArray>, context: &C) -> Box<dyn Future<Item=XmlOtherPutResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("xml_other_put({:?}) - X-Span-ID: {:?}", string, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Post an array
|
||||
fn xml_post(&self, string: Option<models::XmlArray>, context: &C) -> Box<dyn Future<Item=XmlPostResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("xml_post({:?}) - X-Span-ID: {:?}", string, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn xml_put(&self, xml_object: Option<models::XmlObject>, context: &C) -> Box<dyn Future<Item=XmlPutResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("xml_put({:?}) - X-Span-ID: {:?}", xml_object, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,7 @@ use {Api,
|
||||
MandatoryRequestHeaderGetResponse,
|
||||
MultigetGetResponse,
|
||||
MultipleAuthSchemeGetResponse,
|
||||
ParamgetGetResponse,
|
||||
ReadonlyAuthSchemeGetResponse,
|
||||
RequiredOctetStreamPutResponse,
|
||||
ResponsesWithHeadersGetResponse,
|
||||
@@ -569,6 +570,98 @@ impl<C, F> Api<C> for Client<F> where
|
||||
|
||||
}
|
||||
|
||||
fn paramget_get(&self, param_uuid: Option<uuid::Uuid>, param_some_object: Option<models::ObjectParam>, param_some_list: Option<models::MyIdList>, context: &C) -> Box<dyn Future<Item=ParamgetGetResponse, Error=ApiError> + Send> {
|
||||
let mut uri = format!(
|
||||
"{}/paramget",
|
||||
self.base_path
|
||||
);
|
||||
|
||||
// Query parameters
|
||||
let mut query_string = url::form_urlencoded::Serializer::new("".to_owned());
|
||||
if let Some(param_uuid) = param_uuid {
|
||||
query_string.append_pair("uuid", ¶m_uuid.to_string());
|
||||
}
|
||||
if let Some(param_some_object) = param_some_object {
|
||||
query_string.append_pair("someObject", ¶m_some_object.to_string());
|
||||
}
|
||||
if let Some(param_some_list) = param_some_list {
|
||||
query_string.append_pair("someList", ¶m_some_list.to_string());
|
||||
}
|
||||
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(future::err(ApiError(format!("Unable to build URI: {}", err)))),
|
||||
};
|
||||
|
||||
let mut request = match hyper::Request::builder()
|
||||
.method("GET")
|
||||
.uri(uri)
|
||||
.body(Body::empty()) {
|
||||
Ok(req) => req,
|
||||
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create request: {}", e))))
|
||||
};
|
||||
|
||||
|
||||
let header = HeaderValue::from_str((context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str());
|
||||
request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header {
|
||||
Ok(h) => h,
|
||||
Err(e) => return Box::new(future::err(ApiError(format!("Unable to create X-Span ID header value: {}", e))))
|
||||
});
|
||||
|
||||
|
||||
Box::new(self.client_service.request(request)
|
||||
.map_err(|e| ApiError(format!("No response received: {}", e)))
|
||||
.and_then(|mut response| {
|
||||
match response.status().as_u16() {
|
||||
200 => {
|
||||
let body = response.into_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| {
|
||||
ParamgetGetResponse::JSONRsp
|
||||
(body)
|
||||
})
|
||||
) as Box<dyn Future<Item=_, Error=_> + Send>
|
||||
},
|
||||
code => {
|
||||
let headers = response.headers().clone();
|
||||
Box::new(response.into_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<dyn Future<Item=_, Error=_> + Send>
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
}
|
||||
|
||||
fn readonly_auth_scheme_get(&self, context: &C) -> Box<dyn Future<Item=ReadonlyAuthSchemeGetResponse, Error=ApiError> + Send> {
|
||||
let mut uri = format!(
|
||||
"{}/readonly_auth_scheme",
|
||||
|
||||
@@ -117,6 +117,13 @@ pub enum MultipleAuthSchemeGetResponse {
|
||||
CheckThatLimitingToMultipleRequiredAuthSchemesWorks
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ParamgetGetResponse {
|
||||
/// JSON rsp
|
||||
JSONRsp
|
||||
(models::AnotherXmlObject)
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ReadonlyAuthSchemeGetResponse {
|
||||
/// Check that limiting to a single required auth scheme works
|
||||
@@ -212,6 +219,9 @@ pub trait Api<C> {
|
||||
|
||||
fn multiple_auth_scheme_get(&self, context: &C) -> Box<dyn Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError> + Send>;
|
||||
|
||||
/// Get some stuff with parameters.
|
||||
fn paramget_get(&self, uuid: Option<uuid::Uuid>, some_object: Option<models::ObjectParam>, some_list: Option<models::MyIdList>, context: &C) -> Box<dyn Future<Item=ParamgetGetResponse, Error=ApiError> + Send>;
|
||||
|
||||
|
||||
fn readonly_auth_scheme_get(&self, context: &C) -> Box<dyn Future<Item=ReadonlyAuthSchemeGetResponse, Error=ApiError> + Send>;
|
||||
|
||||
@@ -253,6 +263,9 @@ pub trait ApiNoContext {
|
||||
|
||||
fn multiple_auth_scheme_get(&self) -> Box<dyn Future<Item=MultipleAuthSchemeGetResponse, Error=ApiError> + Send>;
|
||||
|
||||
/// Get some stuff with parameters.
|
||||
fn paramget_get(&self, uuid: Option<uuid::Uuid>, some_object: Option<models::ObjectParam>, some_list: Option<models::MyIdList>) -> Box<dyn Future<Item=ParamgetGetResponse, Error=ApiError> + Send>;
|
||||
|
||||
|
||||
fn readonly_auth_scheme_get(&self) -> Box<dyn Future<Item=ReadonlyAuthSchemeGetResponse, Error=ApiError> + Send>;
|
||||
|
||||
@@ -311,6 +324,11 @@ impl<'a, T: Api<C>, C> ApiNoContext for ContextWrapper<'a, T, C> {
|
||||
self.api().multiple_auth_scheme_get(&self.context())
|
||||
}
|
||||
|
||||
/// Get some stuff with parameters.
|
||||
fn paramget_get(&self, uuid: Option<uuid::Uuid>, some_object: Option<models::ObjectParam>, some_list: Option<models::MyIdList>) -> Box<dyn Future<Item=ParamgetGetResponse, Error=ApiError> + Send> {
|
||||
self.api().paramget_get(uuid, some_object, some_list, &self.context())
|
||||
}
|
||||
|
||||
|
||||
fn readonly_auth_scheme_get(&self) -> Box<dyn Future<Item=ReadonlyAuthSchemeGetResponse, Error=ApiError> + Send> {
|
||||
self.api().readonly_auth_scheme_get(&self.context())
|
||||
|
||||
@@ -24,6 +24,9 @@ pub mod responses {
|
||||
/// Create &str objects for the response content types for MultigetGet
|
||||
pub static MULTIGET_GET_DUPLICATE_RESPONSE_LONG_TEXT_3: &str = "application/json";
|
||||
|
||||
/// Create &str objects for the response content types for ParamgetGet
|
||||
pub static PARAMGET_GET_JSON_RSP: &str = "application/json";
|
||||
|
||||
/// Create &str objects for the response content types for ResponsesWithHeadersGet
|
||||
pub static RESPONSES_WITH_HEADERS_GET_SUCCESS: &str = "application/json";
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ use std::str::FromStr;
|
||||
use header::IntoHeaderValue;
|
||||
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<AnotherXmlArray> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<AnotherXmlArray>> for HeaderValue {
|
||||
@@ -99,6 +98,31 @@ impl ::std::ops::DerefMut for AnotherXmlArray {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the AnotherXmlArray value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for AnotherXmlArray {
|
||||
fn to_string(&self) -> String {
|
||||
self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a AnotherXmlArray value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for AnotherXmlArray {
|
||||
type Err = <String as ::std::str::FromStr>::Err;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut items = vec![];
|
||||
for item in s.split(',')
|
||||
{
|
||||
items.push(item.parse()?);
|
||||
}
|
||||
Ok(AnotherXmlArray(items))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl AnotherXmlArray {
|
||||
/// Helper function to allow us to convert this model to an XML string.
|
||||
@@ -157,7 +181,6 @@ impl AnotherXmlInner {
|
||||
}
|
||||
|
||||
/// An XML object
|
||||
|
||||
// Methods for converting between IntoHeaderValue<AnotherXmlObject> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<AnotherXmlObject>> for HeaderValue {
|
||||
@@ -172,6 +195,7 @@ impl From<HeaderValue> for IntoHeaderValue<AnotherXmlObject> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
#[serde(rename = "snake_another_xml_object")]
|
||||
@@ -190,6 +214,68 @@ impl AnotherXmlObject {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the AnotherXmlObject value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for AnotherXmlObject {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
if let Some(ref inner_string) = self.inner_string {
|
||||
params.push("inner_string".to_string());
|
||||
params.push(inner_string.to_string());
|
||||
}
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a AnotherXmlObject value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for AnotherXmlObject {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub inner_string: Vec<String>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"inner_string" => intermediate_rep.inner_string.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(AnotherXmlObject {
|
||||
inner_string: intermediate_rep.inner_string.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl AnotherXmlObject {
|
||||
/// Associated constant for this model's XML namespace.
|
||||
#[allow(dead_code)]
|
||||
@@ -209,7 +295,6 @@ impl AnotherXmlObject {
|
||||
}
|
||||
|
||||
/// An XML object
|
||||
|
||||
// Methods for converting between IntoHeaderValue<DuplicateXmlObject> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<DuplicateXmlObject>> for HeaderValue {
|
||||
@@ -224,6 +309,7 @@ impl From<HeaderValue> for IntoHeaderValue<DuplicateXmlObject> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
#[serde(rename = "camelDuplicateXmlObject")]
|
||||
@@ -247,6 +333,75 @@ impl DuplicateXmlObject {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the DuplicateXmlObject value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for DuplicateXmlObject {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
if let Some(ref inner_string) = self.inner_string {
|
||||
params.push("inner_string".to_string());
|
||||
params.push(inner_string.to_string());
|
||||
}
|
||||
|
||||
// Skipping inner_array in query parameter serialization
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a DuplicateXmlObject value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for DuplicateXmlObject {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub inner_string: Vec<String>,
|
||||
pub inner_array: Vec<models::XmlArray>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"inner_string" => intermediate_rep.inner_string.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
|
||||
"inner_array" => intermediate_rep.inner_array.push(models::XmlArray::from_str(val).map_err(|x| ())?),
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(DuplicateXmlObject {
|
||||
inner_string: intermediate_rep.inner_string.into_iter().next(),
|
||||
inner_array: intermediate_rep.inner_array.into_iter().next().ok_or(())?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl DuplicateXmlObject {
|
||||
/// Associated constant for this model's XML namespace.
|
||||
#[allow(dead_code)]
|
||||
@@ -313,7 +468,6 @@ impl EnumWithStarObject {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<InlineResponse201> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<InlineResponse201>> for HeaderValue {
|
||||
@@ -328,6 +482,7 @@ impl From<HeaderValue> for IntoHeaderValue<InlineResponse201> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct InlineResponse201 {
|
||||
@@ -345,6 +500,68 @@ impl InlineResponse201 {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the InlineResponse201 value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for InlineResponse201 {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
if let Some(ref foo) = self.foo {
|
||||
params.push("foo".to_string());
|
||||
params.push(foo.to_string());
|
||||
}
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a InlineResponse201 value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for InlineResponse201 {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub foo: Vec<String>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"foo" => intermediate_rep.foo.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(InlineResponse201 {
|
||||
foo: intermediate_rep.foo.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl InlineResponse201 {
|
||||
/// Helper function to allow us to convert this model to an XML string.
|
||||
/// Will panic if serialisation fails.
|
||||
@@ -394,7 +611,6 @@ impl MyId {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<MyIdList> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<MyIdList>> for HeaderValue {
|
||||
@@ -471,6 +687,31 @@ impl ::std::ops::DerefMut for MyIdList {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the MyIdList value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for MyIdList {
|
||||
fn to_string(&self) -> String {
|
||||
self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a MyIdList value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for MyIdList {
|
||||
type Err = <i32 as ::std::str::FromStr>::Err;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut items = vec![];
|
||||
for item in s.split(',')
|
||||
{
|
||||
items.push(item.parse()?);
|
||||
}
|
||||
Ok(MyIdList(items))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl MyIdList {
|
||||
/// Helper function to allow us to convert this model to an XML string.
|
||||
@@ -481,7 +722,6 @@ impl MyIdList {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<ObjectHeader> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<ObjectHeader>> for HeaderValue {
|
||||
@@ -496,6 +736,7 @@ impl From<HeaderValue> for IntoHeaderValue<ObjectHeader> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct ObjectHeader {
|
||||
@@ -517,6 +758,77 @@ impl ObjectHeader {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the ObjectHeader value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for ObjectHeader {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
params.push("requiredObjectHeader".to_string());
|
||||
params.push(self.required_object_header.to_string());
|
||||
|
||||
|
||||
if let Some(ref optional_object_header) = self.optional_object_header {
|
||||
params.push("optionalObjectHeader".to_string());
|
||||
params.push(optional_object_header.to_string());
|
||||
}
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a ObjectHeader value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for ObjectHeader {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub required_object_header: Vec<bool>,
|
||||
pub optional_object_header: Vec<isize>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"requiredObjectHeader" => intermediate_rep.required_object_header.push(bool::from_str(val).map_err(|x| ())?),
|
||||
|
||||
|
||||
"optionalObjectHeader" => intermediate_rep.optional_object_header.push(isize::from_str(val).map_err(|x| ())?),
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(ObjectHeader {
|
||||
required_object_header: intermediate_rep.required_object_header.into_iter().next().ok_or(())?,
|
||||
optional_object_header: intermediate_rep.optional_object_header.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl ObjectHeader {
|
||||
/// Helper function to allow us to convert this model to an XML string.
|
||||
/// Will panic if serialisation fails.
|
||||
@@ -526,6 +838,121 @@ impl ObjectHeader {
|
||||
}
|
||||
}
|
||||
|
||||
// Methods for converting between IntoHeaderValue<ObjectParam> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<ObjectParam>> for HeaderValue {
|
||||
fn from(hdr_value: IntoHeaderValue<ObjectParam>) -> Self {
|
||||
HeaderValue::from_str(&hdr_value.to_string()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HeaderValue> for IntoHeaderValue<ObjectParam> {
|
||||
fn from(hdr_value: HeaderValue) -> Self {
|
||||
IntoHeaderValue(ObjectParam::from_str(hdr_value.to_str().unwrap()).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct ObjectParam {
|
||||
#[serde(rename = "requiredParam")]
|
||||
pub required_param: bool,
|
||||
|
||||
#[serde(rename = "optionalParam")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub optional_param: Option<isize>,
|
||||
|
||||
}
|
||||
|
||||
impl ObjectParam {
|
||||
pub fn new(required_param: bool, ) -> ObjectParam {
|
||||
ObjectParam {
|
||||
required_param: required_param,
|
||||
optional_param: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the ObjectParam value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for ObjectParam {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
params.push("requiredParam".to_string());
|
||||
params.push(self.required_param.to_string());
|
||||
|
||||
|
||||
if let Some(ref optional_param) = self.optional_param {
|
||||
params.push("optionalParam".to_string());
|
||||
params.push(optional_param.to_string());
|
||||
}
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a ObjectParam value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for ObjectParam {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub required_param: Vec<bool>,
|
||||
pub optional_param: Vec<isize>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"requiredParam" => intermediate_rep.required_param.push(bool::from_str(val).map_err(|x| ())?),
|
||||
|
||||
|
||||
"optionalParam" => intermediate_rep.optional_param.push(isize::from_str(val).map_err(|x| ())?),
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(ObjectParam {
|
||||
required_param: intermediate_rep.required_param.into_iter().next().ok_or(())?,
|
||||
optional_param: intermediate_rep.optional_param.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl ObjectParam {
|
||||
/// 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")
|
||||
}
|
||||
}
|
||||
|
||||
// Methods for converting between IntoHeaderValue<ObjectWithArrayOfObjects> and HeaderValue
|
||||
|
||||
@@ -541,6 +968,7 @@ impl From<HeaderValue> for IntoHeaderValue<ObjectWithArrayOfObjects> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct ObjectWithArrayOfObjects {
|
||||
@@ -558,6 +986,67 @@ impl ObjectWithArrayOfObjects {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the ObjectWithArrayOfObjects value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for ObjectWithArrayOfObjects {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
if let Some(ref object_array) = self.object_array {
|
||||
params.push("objectArray".to_string());
|
||||
params.push(object_array.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string());
|
||||
}
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a ObjectWithArrayOfObjects value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for ObjectWithArrayOfObjects {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub object_array: Vec<Vec<models::StringObject>>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
"objectArray" => return Err(()), // Parsing a container in this style is not supported yet
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(ObjectWithArrayOfObjects {
|
||||
object_array: intermediate_rep.object_array.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl ObjectWithArrayOfObjects {
|
||||
/// Helper function to allow us to convert this model to an XML string.
|
||||
/// Will panic if serialisation fails.
|
||||
@@ -734,7 +1223,6 @@ impl UuidObject {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<XmlArray> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<XmlArray>> for HeaderValue {
|
||||
@@ -820,6 +1308,31 @@ impl ::std::ops::DerefMut for XmlArray {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the XmlArray value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for XmlArray {
|
||||
fn to_string(&self) -> String {
|
||||
self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a XmlArray value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for XmlArray {
|
||||
type Err = <String as ::std::str::FromStr>::Err;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut items = vec![];
|
||||
for item in s.split(',')
|
||||
{
|
||||
items.push(item.parse()?);
|
||||
}
|
||||
Ok(XmlArray(items))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl XmlArray {
|
||||
/// Helper function to allow us to convert this model to an XML string.
|
||||
@@ -878,7 +1391,6 @@ impl XmlInner {
|
||||
}
|
||||
|
||||
/// An XML object
|
||||
|
||||
// Methods for converting between IntoHeaderValue<XmlObject> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<XmlObject>> for HeaderValue {
|
||||
@@ -893,6 +1405,7 @@ impl From<HeaderValue> for IntoHeaderValue<XmlObject> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
#[serde(rename = "camelXmlObject")]
|
||||
@@ -916,6 +1429,79 @@ impl XmlObject {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the XmlObject value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for XmlObject {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
if let Some(ref inner_string) = self.inner_string {
|
||||
params.push("innerString".to_string());
|
||||
params.push(inner_string.to_string());
|
||||
}
|
||||
|
||||
|
||||
if let Some(ref other_inner_rename) = self.other_inner_rename {
|
||||
params.push("other_inner_rename".to_string());
|
||||
params.push(other_inner_rename.to_string());
|
||||
}
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a XmlObject value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for XmlObject {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub inner_string: Vec<String>,
|
||||
pub other_inner_rename: Vec<isize>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"innerString" => intermediate_rep.inner_string.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
|
||||
"other_inner_rename" => intermediate_rep.other_inner_rename.push(isize::from_str(val).map_err(|x| ())?),
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(XmlObject {
|
||||
inner_string: intermediate_rep.inner_string.into_iter().next(),
|
||||
other_inner_rename: intermediate_rep.other_inner_rename.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl XmlObject {
|
||||
/// Associated constant for this model's XML namespace.
|
||||
#[allow(dead_code)]
|
||||
|
||||
@@ -24,6 +24,7 @@ use {Api,
|
||||
MandatoryRequestHeaderGetResponse,
|
||||
MultigetGetResponse,
|
||||
MultipleAuthSchemeGetResponse,
|
||||
ParamgetGetResponse,
|
||||
ReadonlyAuthSchemeGetResponse,
|
||||
RequiredOctetStreamPutResponse,
|
||||
ResponsesWithHeadersGetResponse,
|
||||
@@ -49,6 +50,7 @@ mod paths {
|
||||
r"^/mandatory-request-header$",
|
||||
r"^/multiget$",
|
||||
r"^/multiple_auth_scheme$",
|
||||
r"^/paramget$",
|
||||
r"^/readonly_auth_scheme$",
|
||||
r"^/required_octet_stream$",
|
||||
r"^/responses_with_headers$",
|
||||
@@ -62,13 +64,14 @@ mod paths {
|
||||
pub static ID_MANDATORY_REQUEST_HEADER: usize = 0;
|
||||
pub static ID_MULTIGET: usize = 1;
|
||||
pub static ID_MULTIPLE_AUTH_SCHEME: usize = 2;
|
||||
pub static ID_READONLY_AUTH_SCHEME: usize = 3;
|
||||
pub static ID_REQUIRED_OCTET_STREAM: usize = 4;
|
||||
pub static ID_RESPONSES_WITH_HEADERS: usize = 5;
|
||||
pub static ID_UUID: usize = 6;
|
||||
pub static ID_XML: usize = 7;
|
||||
pub static ID_XML_EXTRA: usize = 8;
|
||||
pub static ID_XML_OTHER: usize = 9;
|
||||
pub static ID_PARAMGET: usize = 3;
|
||||
pub static ID_READONLY_AUTH_SCHEME: usize = 4;
|
||||
pub static ID_REQUIRED_OCTET_STREAM: usize = 5;
|
||||
pub static ID_RESPONSES_WITH_HEADERS: usize = 6;
|
||||
pub static ID_UUID: usize = 7;
|
||||
pub static ID_XML: usize = 8;
|
||||
pub static ID_XML_EXTRA: usize = 9;
|
||||
pub static ID_XML_OTHER: usize = 10;
|
||||
}
|
||||
|
||||
pub struct MakeService<T, RC> {
|
||||
@@ -413,6 +416,73 @@ where
|
||||
}) as Self::Future
|
||||
},
|
||||
|
||||
// ParamgetGet - GET /paramget
|
||||
&hyper::Method::GET if path.matched(paths::ID_PARAMGET) => {
|
||||
|
||||
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
|
||||
let query_params = form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes()).collect::<Vec<_>>();
|
||||
let param_uuid = query_params.iter().filter(|e| e.0 == "uuid").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
|
||||
let param_uuid = param_uuid.and_then(|param_uuid| param_uuid.parse::<>().ok());
|
||||
let param_some_object = query_params.iter().filter(|e| e.0 == "someObject").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
|
||||
let param_some_object = param_some_object.and_then(|param_some_object| param_some_object.parse::<>().ok());
|
||||
let param_some_list = query_params.iter().filter(|e| e.0 == "someList").map(|e| e.1.to_owned())
|
||||
.nth(0);
|
||||
|
||||
let param_some_list = param_some_list.and_then(|param_some_list| param_some_list.parse::<>().ok());
|
||||
Box::new({
|
||||
{{
|
||||
Box::new(
|
||||
api_impl.paramget_get(
|
||||
param_uuid,
|
||||
param_some_object,
|
||||
param_some_list,
|
||||
&context
|
||||
).then(move |result| {
|
||||
let mut response = Response::new(Body::empty());
|
||||
response.headers_mut().insert(
|
||||
HeaderName::from_static("x-span-id"),
|
||||
HeaderValue::from_str((&context as &dyn Has<XSpanIdString>).get().0.clone().to_string().as_str())
|
||||
.expect("Unable to create X-Span-ID header value"));
|
||||
|
||||
|
||||
match result {
|
||||
Ok(rsp) => match rsp {
|
||||
ParamgetGetResponse::JSONRsp
|
||||
|
||||
(body)
|
||||
|
||||
|
||||
=> {
|
||||
*response.status_mut() = StatusCode::from_u16(200).expect("Unable to turn 200 into a StatusCode");
|
||||
|
||||
response.headers_mut().insert(
|
||||
CONTENT_TYPE,
|
||||
HeaderValue::from_str(mimetypes::responses::PARAMGET_GET_JSON_RSP)
|
||||
.expect("Unable to create Content-Type header for PARAMGET_GET_JSON_RSP"));
|
||||
|
||||
let body = serde_json::to_string(&body).expect("impossible to fail to serialize");
|
||||
*response.body_mut() = Body::from(body);
|
||||
},
|
||||
},
|
||||
Err(_) => {
|
||||
// Application code returned an error. This should not happen, as the implementation should
|
||||
// return a valid response.
|
||||
*response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
||||
*response.body_mut() = Body::from("An internal error occurred");
|
||||
},
|
||||
}
|
||||
|
||||
future::ok(response)
|
||||
}
|
||||
))
|
||||
}}
|
||||
}) as Self::Future
|
||||
},
|
||||
|
||||
// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
|
||||
&hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => {
|
||||
{
|
||||
@@ -1106,6 +1176,9 @@ impl<T> RequestParser<T> for ApiRequestParser {
|
||||
// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
||||
&hyper::Method::GET if path.matched(paths::ID_MULTIPLE_AUTH_SCHEME) => Ok("MultipleAuthSchemeGet"),
|
||||
|
||||
// ParamgetGet - GET /paramget
|
||||
&hyper::Method::GET if path.matched(paths::ID_PARAMGET) => Ok("ParamgetGet"),
|
||||
|
||||
// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
|
||||
&hyper::Method::GET if path.matched(paths::ID_READONLY_AUTH_SCHEME) => Ok("ReadonlyAuthSchemeGet"),
|
||||
|
||||
|
||||
@@ -1,325 +0,0 @@
|
||||
//! Server implementation of ops_v3.
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use futures::{self, Future};
|
||||
use chrono;
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use swagger;
|
||||
use swagger::{Has, XSpanIdString};
|
||||
|
||||
use ops_v3::{Api, ApiError,
|
||||
Op10GetResponse,
|
||||
Op11GetResponse,
|
||||
Op12GetResponse,
|
||||
Op13GetResponse,
|
||||
Op14GetResponse,
|
||||
Op15GetResponse,
|
||||
Op16GetResponse,
|
||||
Op17GetResponse,
|
||||
Op18GetResponse,
|
||||
Op19GetResponse,
|
||||
Op1GetResponse,
|
||||
Op20GetResponse,
|
||||
Op21GetResponse,
|
||||
Op22GetResponse,
|
||||
Op23GetResponse,
|
||||
Op24GetResponse,
|
||||
Op25GetResponse,
|
||||
Op26GetResponse,
|
||||
Op27GetResponse,
|
||||
Op28GetResponse,
|
||||
Op29GetResponse,
|
||||
Op2GetResponse,
|
||||
Op30GetResponse,
|
||||
Op31GetResponse,
|
||||
Op32GetResponse,
|
||||
Op33GetResponse,
|
||||
Op34GetResponse,
|
||||
Op35GetResponse,
|
||||
Op36GetResponse,
|
||||
Op37GetResponse,
|
||||
Op3GetResponse,
|
||||
Op4GetResponse,
|
||||
Op5GetResponse,
|
||||
Op6GetResponse,
|
||||
Op7GetResponse,
|
||||
Op8GetResponse,
|
||||
Op9GetResponse
|
||||
};
|
||||
use ops_v3::models;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Server<C> {
|
||||
marker: PhantomData<C>,
|
||||
}
|
||||
|
||||
impl<C> Server<C> {
|
||||
pub fn new() -> Self {
|
||||
Server{marker: PhantomData}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
|
||||
|
||||
|
||||
fn op10_get(&self, context: &C) -> Box<dyn Future<Item=Op10GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op10_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op11_get(&self, context: &C) -> Box<dyn Future<Item=Op11GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op11_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op12_get(&self, context: &C) -> Box<dyn Future<Item=Op12GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op12_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op13_get(&self, context: &C) -> Box<dyn Future<Item=Op13GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op13_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op14_get(&self, context: &C) -> Box<dyn Future<Item=Op14GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op14_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op15_get(&self, context: &C) -> Box<dyn Future<Item=Op15GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op15_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op16_get(&self, context: &C) -> Box<dyn Future<Item=Op16GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op16_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op17_get(&self, context: &C) -> Box<dyn Future<Item=Op17GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op17_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op18_get(&self, context: &C) -> Box<dyn Future<Item=Op18GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op18_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op19_get(&self, context: &C) -> Box<dyn Future<Item=Op19GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op19_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op1_get(&self, context: &C) -> Box<dyn Future<Item=Op1GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op1_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op20_get(&self, context: &C) -> Box<dyn Future<Item=Op20GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op20_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op21_get(&self, context: &C) -> Box<dyn Future<Item=Op21GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op21_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op22_get(&self, context: &C) -> Box<dyn Future<Item=Op22GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op22_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op23_get(&self, context: &C) -> Box<dyn Future<Item=Op23GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op23_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op24_get(&self, context: &C) -> Box<dyn Future<Item=Op24GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op24_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op25_get(&self, context: &C) -> Box<dyn Future<Item=Op25GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op25_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op26_get(&self, context: &C) -> Box<dyn Future<Item=Op26GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op26_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op27_get(&self, context: &C) -> Box<dyn Future<Item=Op27GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op27_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op28_get(&self, context: &C) -> Box<dyn Future<Item=Op28GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op28_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op29_get(&self, context: &C) -> Box<dyn Future<Item=Op29GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op29_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op2_get(&self, context: &C) -> Box<dyn Future<Item=Op2GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op2_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op30_get(&self, context: &C) -> Box<dyn Future<Item=Op30GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op30_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op31_get(&self, context: &C) -> Box<dyn Future<Item=Op31GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op31_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op32_get(&self, context: &C) -> Box<dyn Future<Item=Op32GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op32_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op33_get(&self, context: &C) -> Box<dyn Future<Item=Op33GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op33_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op34_get(&self, context: &C) -> Box<dyn Future<Item=Op34GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op34_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op35_get(&self, context: &C) -> Box<dyn Future<Item=Op35GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op35_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op36_get(&self, context: &C) -> Box<dyn Future<Item=Op36GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op36_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op37_get(&self, context: &C) -> Box<dyn Future<Item=Op37GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op37_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op3_get(&self, context: &C) -> Box<dyn Future<Item=Op3GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op3_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op4_get(&self, context: &C) -> Box<dyn Future<Item=Op4GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op4_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op5_get(&self, context: &C) -> Box<dyn Future<Item=Op5GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op5_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op6_get(&self, context: &C) -> Box<dyn Future<Item=Op6GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op6_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op7_get(&self, context: &C) -> Box<dyn Future<Item=Op7GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op7_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op8_get(&self, context: &C) -> Box<dyn Future<Item=Op8GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op8_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn op9_get(&self, context: &C) -> Box<dyn Future<Item=Op9GetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("op9_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -191,6 +191,8 @@ Method | HTTP request | Description
|
||||
- [ModelReturn](docs/ModelReturn.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [ObjectContainingObjectWithOnlyAdditionalProperties](docs/ObjectContainingObjectWithOnlyAdditionalProperties.md)
|
||||
- [ObjectWithOnlyAdditionalProperties](docs/ObjectWithOnlyAdditionalProperties.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [OuterBoolean](docs/OuterBoolean.md)
|
||||
- [OuterComposite](docs/OuterComposite.md)
|
||||
|
||||
@@ -1364,6 +1364,15 @@ components:
|
||||
$ref: '#/components/schemas/Animal'
|
||||
type: object
|
||||
type: object
|
||||
ObjectContainingObjectWithOnlyAdditionalProperties:
|
||||
properties:
|
||||
inner:
|
||||
$ref: '#/components/schemas/ObjectWithOnlyAdditionalProperties'
|
||||
type: object
|
||||
ObjectWithOnlyAdditionalProperties:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
List:
|
||||
properties:
|
||||
"123-list":
|
||||
|
||||
@@ -12,8 +12,8 @@ Name | Type | Description | Notes
|
||||
**string** | **String** | | [optional] [default to None]
|
||||
**byte** | [***swagger::ByteArray**](ByteArray.md) | |
|
||||
**binary** | [***swagger::ByteArray**](file.md) | | [optional] [default to None]
|
||||
**date** | [***chrono::DateTime<chrono::Utc>**](date.md) | |
|
||||
**date_time** | [**chrono::DateTime<chrono::Utc>**](DateTime.md) | | [optional] [default to None]
|
||||
**date** | [***chrono::DateTime::<chrono::Utc>**](date.md) | |
|
||||
**date_time** | [**chrono::DateTime::<chrono::Utc>**](DateTime.md) | | [optional] [default to None]
|
||||
**uuid** | [***uuid::Uuid**](UUID.md) | | [optional] [default to None]
|
||||
**password** | **String** | |
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**uuid** | [***uuid::Uuid**](UUID.md) | | [optional] [default to None]
|
||||
**date_time** | [**chrono::DateTime<chrono::Utc>**](DateTime.md) | | [optional] [default to None]
|
||||
**date_time** | [**chrono::DateTime::<chrono::Utc>**](DateTime.md) | | [optional] [default to None]
|
||||
**map** | [**HashMap<String, models::Animal>**](Animal.md) | | [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)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# ObjectContainingObjectWithOnlyAdditionalProperties
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**inner** | [***models::ObjectWithOnlyAdditionalProperties**](ObjectWithOnlyAdditionalProperties.md) | | [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)
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# ObjectWithOnlyAdditionalProperties
|
||||
|
||||
## 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)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Name | Type | Description | Notes
|
||||
**id** | **i64** | | [optional] [default to None]
|
||||
**pet_id** | **i64** | | [optional] [default to None]
|
||||
**quantity** | **i32** | | [optional] [default to None]
|
||||
**ship_date** | [**chrono::DateTime<chrono::Utc>**](DateTime.md) | | [optional] [default to None]
|
||||
**ship_date** | [**chrono::DateTime::<chrono::Utc>**](DateTime.md) | | [optional] [default to None]
|
||||
**status** | **String** | Order Status | [optional] [default to None]
|
||||
**complete** | **bool** | | [optional] [default to Some(false)]
|
||||
|
||||
|
||||
@@ -265,8 +265,8 @@ Name | Type | Description | Notes
|
||||
**float** | **f32**| None |
|
||||
**string** | **String**| None |
|
||||
**binary** | **swagger::ByteArray**| None |
|
||||
**date** | **chrono::DateTime<chrono::Utc>**| None |
|
||||
**date_time** | **chrono::DateTime<chrono::Utc>**| None |
|
||||
**date** | **chrono::DateTime::<chrono::Utc>**| None |
|
||||
**date_time** | **chrono::DateTime::<chrono::Utc>**| None |
|
||||
**password** | **String**| None |
|
||||
**callback** | **String**| None |
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
|
||||
}
|
||||
|
||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
fn test_endpoint_parameters(&self, number: f64, double: f64, pattern_without_delimiter: String, byte: swagger::ByteArray, integer: Option<i32>, int32: Option<i32>, int64: Option<i64>, float: Option<f32>, string: Option<String>, binary: Option<swagger::ByteArray>, date: Option<chrono::DateTime<chrono::Utc>>, date_time: Option<chrono::DateTime<chrono::Utc>>, password: Option<String>, callback: Option<String>, context: &C) -> Box<Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send> {
|
||||
fn test_endpoint_parameters(&self, number: f64, double: f64, pattern_without_delimiter: String, byte: swagger::ByteArray, integer: Option<i32>, int32: Option<i32>, int64: Option<i64>, float: Option<f32>, string: Option<String>, binary: Option<swagger::ByteArray>, date: Option<chrono::DateTime::<chrono::Utc>>, date_time: Option<chrono::DateTime::<chrono::Utc>>, password: Option<String>, callback: Option<String>, context: &C) -> Box<Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send> {
|
||||
let context = context.clone();
|
||||
println!("test_endpoint_parameters({}, {}, \"{}\", {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, date, date_time, password, callback, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
//! Server implementation of petstore_with_fake_endpoints_models_for_testing.
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use futures::{self, Future};
|
||||
use chrono;
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use swagger;
|
||||
use swagger::{Has, XSpanIdString};
|
||||
use uuid;
|
||||
|
||||
use petstore_with_fake_endpoints_models_for_testing::{Api, ApiError,
|
||||
TestSpecialTagsResponse,
|
||||
FakeOuterBooleanSerializeResponse,
|
||||
FakeOuterCompositeSerializeResponse,
|
||||
FakeOuterNumberSerializeResponse,
|
||||
FakeOuterStringSerializeResponse,
|
||||
HyphenParamResponse,
|
||||
TestBodyWithQueryParamsResponse,
|
||||
TestClientModelResponse,
|
||||
TestEndpointParametersResponse,
|
||||
TestEnumParametersResponse,
|
||||
TestInlineAdditionalPropertiesResponse,
|
||||
TestJsonFormDataResponse,
|
||||
TestClassnameResponse,
|
||||
AddPetResponse,
|
||||
DeletePetResponse,
|
||||
FindPetsByStatusResponse,
|
||||
FindPetsByTagsResponse,
|
||||
GetPetByIdResponse,
|
||||
UpdatePetResponse,
|
||||
UpdatePetWithFormResponse,
|
||||
UploadFileResponse,
|
||||
DeleteOrderResponse,
|
||||
GetInventoryResponse,
|
||||
GetOrderByIdResponse,
|
||||
PlaceOrderResponse,
|
||||
CreateUserResponse,
|
||||
CreateUsersWithArrayInputResponse,
|
||||
CreateUsersWithListInputResponse,
|
||||
DeleteUserResponse,
|
||||
GetUserByNameResponse,
|
||||
LoginUserResponse,
|
||||
LogoutUserResponse,
|
||||
UpdateUserResponse
|
||||
};
|
||||
use petstore_with_fake_endpoints_models_for_testing::models;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Server<C> {
|
||||
marker: PhantomData<C>,
|
||||
}
|
||||
|
||||
impl<C> Server<C> {
|
||||
pub fn new() -> Self {
|
||||
Server{marker: PhantomData}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
|
||||
|
||||
/// To test special tags
|
||||
fn test_special_tags(&self, body: models::Client, context: &C) -> Box<dyn Future<Item=TestSpecialTagsResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("test_special_tags({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn fake_outer_boolean_serialize(&self, body: Option<models::OuterBoolean>, context: &C) -> Box<dyn Future<Item=FakeOuterBooleanSerializeResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("fake_outer_boolean_serialize({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn fake_outer_composite_serialize(&self, body: Option<models::OuterComposite>, context: &C) -> Box<dyn Future<Item=FakeOuterCompositeSerializeResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("fake_outer_composite_serialize({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn fake_outer_number_serialize(&self, body: Option<models::OuterNumber>, context: &C) -> Box<dyn Future<Item=FakeOuterNumberSerializeResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("fake_outer_number_serialize({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn fake_outer_string_serialize(&self, body: Option<models::OuterString>, context: &C) -> Box<dyn Future<Item=FakeOuterStringSerializeResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("fake_outer_string_serialize({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn hyphen_param(&self, hyphen_param: String, context: &C) -> Box<dyn Future<Item=HyphenParamResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("hyphen_param(\"{}\") - X-Span-ID: {:?}", hyphen_param, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn test_body_with_query_params(&self, query: String, body: models::User, context: &C) -> Box<dyn Future<Item=TestBodyWithQueryParamsResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("test_body_with_query_params(\"{}\", {:?}) - X-Span-ID: {:?}", query, body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// To test \"client\" model
|
||||
fn test_client_model(&self, body: models::Client, context: &C) -> Box<dyn Future<Item=TestClientModelResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("test_client_model({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
fn test_endpoint_parameters(&self, number: f64, double: f64, pattern_without_delimiter: String, byte: swagger::ByteArray, integer: Option<i32>, int32: Option<i32>, int64: Option<i64>, float: Option<f32>, string: Option<String>, binary: Option<swagger::ByteArray>, date: Option<chrono::DateTime<chrono::Utc>>, date_time: Option<chrono::DateTime<chrono::Utc>>, password: Option<String>, callback: Option<String>, context: &C) -> Box<dyn Future<Item=TestEndpointParametersResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("test_endpoint_parameters({}, {}, \"{}\", {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, date, date_time, password, callback, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// To test enum parameters
|
||||
fn test_enum_parameters(&self, enum_header_string_array: Option<&Vec<String>>, enum_header_string: Option<String>, enum_query_string_array: Option<&Vec<String>>, enum_query_string: Option<String>, enum_query_integer: Option<i32>, enum_query_double: Option<f64>, enum_form_string: Option<String>, context: &C) -> Box<dyn Future<Item=TestEnumParametersResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("test_enum_parameters({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", enum_header_string_array, enum_header_string, enum_query_string_array, enum_query_string, enum_query_integer, enum_query_double, enum_form_string, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// test inline additionalProperties
|
||||
fn test_inline_additional_properties(&self, param: HashMap<String, String>, context: &C) -> Box<dyn Future<Item=TestInlineAdditionalPropertiesResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("test_inline_additional_properties({:?}) - X-Span-ID: {:?}", param, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// test json serialization of form data
|
||||
fn test_json_form_data(&self, param: String, param2: String, context: &C) -> Box<dyn Future<Item=TestJsonFormDataResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("test_json_form_data(\"{}\", \"{}\") - X-Span-ID: {:?}", param, param2, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// To test class name in snake case
|
||||
fn test_classname(&self, body: models::Client, context: &C) -> Box<dyn Future<Item=TestClassnameResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("test_classname({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Add a new pet to the store
|
||||
fn add_pet(&self, body: models::Pet, context: &C) -> Box<dyn Future<Item=AddPetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("add_pet({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Deletes a pet
|
||||
fn delete_pet(&self, pet_id: i64, api_key: Option<String>, context: &C) -> Box<dyn Future<Item=DeletePetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("delete_pet({}, {:?}) - X-Span-ID: {:?}", pet_id, api_key, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Finds Pets by status
|
||||
fn find_pets_by_status(&self, status: &Vec<String>, context: &C) -> Box<dyn Future<Item=FindPetsByStatusResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("find_pets_by_status({:?}) - X-Span-ID: {:?}", status, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
fn find_pets_by_tags(&self, tags: &Vec<String>, context: &C) -> Box<dyn Future<Item=FindPetsByTagsResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("find_pets_by_tags({:?}) - X-Span-ID: {:?}", tags, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
fn get_pet_by_id(&self, pet_id: i64, context: &C) -> Box<dyn Future<Item=GetPetByIdResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("get_pet_by_id({}) - X-Span-ID: {:?}", pet_id, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
fn update_pet(&self, body: models::Pet, context: &C) -> Box<dyn Future<Item=UpdatePetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("update_pet({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data
|
||||
fn update_pet_with_form(&self, pet_id: i64, name: Option<String>, status: Option<String>, context: &C) -> Box<dyn Future<Item=UpdatePetWithFormResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("update_pet_with_form({}, {:?}, {:?}) - X-Span-ID: {:?}", pet_id, name, status, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// uploads an image
|
||||
fn upload_file(&self, pet_id: i64, additional_metadata: Option<String>, file: Option<swagger::ByteArray>, context: &C) -> Box<dyn Future<Item=UploadFileResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("upload_file({}, {:?}, {:?}) - X-Span-ID: {:?}", pet_id, additional_metadata, file, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Delete purchase order by ID
|
||||
fn delete_order(&self, order_id: String, context: &C) -> Box<dyn Future<Item=DeleteOrderResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("delete_order(\"{}\") - X-Span-ID: {:?}", order_id, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Returns pet inventories by status
|
||||
fn get_inventory(&self, context: &C) -> Box<dyn Future<Item=GetInventoryResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("get_inventory() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
fn get_order_by_id(&self, order_id: i64, context: &C) -> Box<dyn Future<Item=GetOrderByIdResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("get_order_by_id({}) - X-Span-ID: {:?}", order_id, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
fn place_order(&self, body: models::Order, context: &C) -> Box<dyn Future<Item=PlaceOrderResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("place_order({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Create user
|
||||
fn create_user(&self, body: models::User, context: &C) -> Box<dyn Future<Item=CreateUserResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("create_user({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
fn create_users_with_array_input(&self, body: &Vec<models::User>, context: &C) -> Box<dyn Future<Item=CreateUsersWithArrayInputResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("create_users_with_array_input({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
fn create_users_with_list_input(&self, body: &Vec<models::User>, context: &C) -> Box<dyn Future<Item=CreateUsersWithListInputResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("create_users_with_list_input({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Delete user
|
||||
fn delete_user(&self, username: String, context: &C) -> Box<dyn Future<Item=DeleteUserResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("delete_user(\"{}\") - X-Span-ID: {:?}", username, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Get user by user name
|
||||
fn get_user_by_name(&self, username: String, context: &C) -> Box<dyn Future<Item=GetUserByNameResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("get_user_by_name(\"{}\") - X-Span-ID: {:?}", username, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
fn login_user(&self, username: String, password: String, context: &C) -> Box<dyn Future<Item=LoginUserResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("login_user(\"{}\", \"{}\") - X-Span-ID: {:?}", username, password, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
fn logout_user(&self, context: &C) -> Box<dyn Future<Item=LogoutUserResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("logout_user() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Updated user
|
||||
fn update_user(&self, username: String, body: models::User, context: &C) -> Box<dyn Future<Item=UpdateUserResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("update_user(\"{}\", {:?}) - X-Span-ID: {:?}", username, body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -946,7 +946,7 @@ impl<C, F> Api<C> for Client<F> where
|
||||
|
||||
}
|
||||
|
||||
fn test_endpoint_parameters(&self, param_number: f64, param_double: f64, param_pattern_without_delimiter: String, param_byte: swagger::ByteArray, param_integer: Option<i32>, param_int32: Option<i32>, param_int64: Option<i64>, param_float: Option<f32>, param_string: Option<String>, param_binary: Option<swagger::ByteArray>, param_date: Option<chrono::DateTime<chrono::Utc>>, param_date_time: Option<chrono::DateTime<chrono::Utc>>, param_password: Option<String>, param_callback: Option<String>, context: &C) -> Box<dyn Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send> {
|
||||
fn test_endpoint_parameters(&self, param_number: f64, param_double: f64, param_pattern_without_delimiter: String, param_byte: swagger::ByteArray, param_integer: Option<i32>, param_int32: Option<i32>, param_int64: Option<i64>, param_float: Option<f32>, param_string: Option<String>, param_binary: Option<swagger::ByteArray>, param_date: Option<chrono::DateTime::<chrono::Utc>>, param_date_time: Option<chrono::DateTime::<chrono::Utc>>, param_password: Option<String>, param_callback: Option<String>, context: &C) -> Box<dyn Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send> {
|
||||
let mut uri = format!(
|
||||
"{}/v2/fake",
|
||||
self.base_path
|
||||
@@ -3183,7 +3183,7 @@ impl<C, F> Api<C> for Client<F> where
|
||||
{
|
||||
body: body,
|
||||
x_rate_limit: (*Into::<header::IntoHeaderValue<i32>>::into(response_x_rate_limit)).clone(),
|
||||
x_expires_after: (*Into::<header::IntoHeaderValue<chrono::DateTime<chrono::Utc>>>::into(response_x_expires_after)).clone(),
|
||||
x_expires_after: (*Into::<header::IntoHeaderValue<chrono::DateTime::<chrono::Utc>>>::into(response_x_expires_after)).clone(),
|
||||
}
|
||||
})
|
||||
) as Box<dyn Future<Item=_, Error=_> + Send>
|
||||
|
||||
@@ -325,7 +325,7 @@ pub enum LoginUserResponse {
|
||||
{
|
||||
body: String,
|
||||
x_rate_limit: i32,
|
||||
x_expires_after: chrono::DateTime<chrono::Utc>,
|
||||
x_expires_after: chrono::DateTime::<chrono::Utc>,
|
||||
}
|
||||
,
|
||||
/// Invalid username/password supplied
|
||||
@@ -376,7 +376,7 @@ pub trait Api<C> {
|
||||
fn test_client_model(&self, body: models::Client, context: &C) -> Box<dyn Future<Item=TestClientModelResponse, Error=ApiError> + Send>;
|
||||
|
||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
fn test_endpoint_parameters(&self, number: f64, double: f64, pattern_without_delimiter: String, byte: swagger::ByteArray, integer: Option<i32>, int32: Option<i32>, int64: Option<i64>, float: Option<f32>, string: Option<String>, binary: Option<swagger::ByteArray>, date: Option<chrono::DateTime<chrono::Utc>>, date_time: Option<chrono::DateTime<chrono::Utc>>, password: Option<String>, callback: Option<String>, context: &C) -> Box<dyn Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send>;
|
||||
fn test_endpoint_parameters(&self, number: f64, double: f64, pattern_without_delimiter: String, byte: swagger::ByteArray, integer: Option<i32>, int32: Option<i32>, int64: Option<i64>, float: Option<f32>, string: Option<String>, binary: Option<swagger::ByteArray>, date: Option<chrono::DateTime::<chrono::Utc>>, date_time: Option<chrono::DateTime::<chrono::Utc>>, password: Option<String>, callback: Option<String>, context: &C) -> Box<dyn Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send>;
|
||||
|
||||
/// To test enum parameters
|
||||
fn test_enum_parameters(&self, enum_header_string_array: Option<&Vec<String>>, enum_header_string: Option<String>, enum_query_string_array: Option<&Vec<String>>, enum_query_string: Option<String>, enum_query_integer: Option<i32>, enum_query_double: Option<f64>, enum_form_string: Option<String>, context: &C) -> Box<dyn Future<Item=TestEnumParametersResponse, Error=ApiError> + Send>;
|
||||
@@ -480,7 +480,7 @@ pub trait ApiNoContext {
|
||||
fn test_client_model(&self, body: models::Client) -> Box<dyn Future<Item=TestClientModelResponse, Error=ApiError> + Send>;
|
||||
|
||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
fn test_endpoint_parameters(&self, number: f64, double: f64, pattern_without_delimiter: String, byte: swagger::ByteArray, integer: Option<i32>, int32: Option<i32>, int64: Option<i64>, float: Option<f32>, string: Option<String>, binary: Option<swagger::ByteArray>, date: Option<chrono::DateTime<chrono::Utc>>, date_time: Option<chrono::DateTime<chrono::Utc>>, password: Option<String>, callback: Option<String>) -> Box<dyn Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send>;
|
||||
fn test_endpoint_parameters(&self, number: f64, double: f64, pattern_without_delimiter: String, byte: swagger::ByteArray, integer: Option<i32>, int32: Option<i32>, int64: Option<i64>, float: Option<f32>, string: Option<String>, binary: Option<swagger::ByteArray>, date: Option<chrono::DateTime::<chrono::Utc>>, date_time: Option<chrono::DateTime::<chrono::Utc>>, password: Option<String>, callback: Option<String>) -> Box<dyn Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send>;
|
||||
|
||||
/// To test enum parameters
|
||||
fn test_enum_parameters(&self, enum_header_string_array: Option<&Vec<String>>, enum_header_string: Option<String>, enum_query_string_array: Option<&Vec<String>>, enum_query_string: Option<String>, enum_query_integer: Option<i32>, enum_query_double: Option<f64>, enum_form_string: Option<String>) -> Box<dyn Future<Item=TestEnumParametersResponse, Error=ApiError> + Send>;
|
||||
@@ -611,7 +611,7 @@ impl<'a, T: Api<C>, C> ApiNoContext for ContextWrapper<'a, T, C> {
|
||||
}
|
||||
|
||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
fn test_endpoint_parameters(&self, number: f64, double: f64, pattern_without_delimiter: String, byte: swagger::ByteArray, integer: Option<i32>, int32: Option<i32>, int64: Option<i64>, float: Option<f32>, string: Option<String>, binary: Option<swagger::ByteArray>, date: Option<chrono::DateTime<chrono::Utc>>, date_time: Option<chrono::DateTime<chrono::Utc>>, password: Option<String>, callback: Option<String>) -> Box<dyn Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send> {
|
||||
fn test_endpoint_parameters(&self, number: f64, double: f64, pattern_without_delimiter: String, byte: swagger::ByteArray, integer: Option<i32>, int32: Option<i32>, int64: Option<i64>, float: Option<f32>, string: Option<String>, binary: Option<swagger::ByteArray>, date: Option<chrono::DateTime::<chrono::Utc>>, date_time: Option<chrono::DateTime::<chrono::Utc>>, password: Option<String>, callback: Option<String>) -> Box<dyn Future<Item=TestEndpointParametersResponse, Error=ApiError> + Send> {
|
||||
self.api().test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer, int32, int64, float, string, binary, date, date_time, password, callback, &self.context())
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,129 +0,0 @@
|
||||
# \default
|
||||
|
||||
All URIs are relative to *http://localhost*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**Default**](defaultapi.md#Default) | **GET** /dummy | A dummy endpoint to make the spec valid.
|
||||
[**Default**](defaultapi.md#Default) | **PUT** /dummy |
|
||||
[**Default**](defaultapi.md#Default) | **GET** /file_response | Get a file
|
||||
[**Default**](defaultapi.md#Default) | **POST** /html | Test HTML handling
|
||||
[**Default**](defaultapi.md#Default) | **GET** /raw_json | Get an arbitrary JSON blob.
|
||||
|
||||
|
||||
# **DummyGet**
|
||||
> DummyGet()
|
||||
A dummy endpoint to make the spec valid.
|
||||
|
||||
### Required Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **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)
|
||||
|
||||
# **DummyPut**
|
||||
> DummyPut(nested_response)
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**nested_response** | [**InlineObject**](InlineObject.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **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)
|
||||
|
||||
# **FileResponseGet**
|
||||
> swagger::ByteArray FileResponseGet()
|
||||
Get a file
|
||||
|
||||
### Required Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**swagger::ByteArray**](file.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json,
|
||||
|
||||
[[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)
|
||||
|
||||
# **HtmlPost**
|
||||
> String HtmlPost(body)
|
||||
Test HTML handling
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **String**| |
|
||||
|
||||
### Return type
|
||||
|
||||
[**String**](string.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: text/html
|
||||
- **Accept**: text/html,
|
||||
|
||||
[[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)
|
||||
|
||||
# **RawJsonGet**
|
||||
> object RawJsonGet()
|
||||
Get an arbitrary JSON blob.
|
||||
|
||||
### Required Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**object**](object.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: */*
|
||||
|
||||
[[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)
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
//! Server implementation of rust_server_test.
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use futures::{self, Future};
|
||||
use chrono;
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use swagger;
|
||||
use swagger::{Has, XSpanIdString};
|
||||
|
||||
use rust_server_test::{Api, ApiError,
|
||||
DummyGetResponse,
|
||||
DummyPutResponse,
|
||||
FileResponseGetResponse,
|
||||
HtmlPostResponse,
|
||||
RawJsonGetResponse
|
||||
};
|
||||
use rust_server_test::models;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Server<C> {
|
||||
marker: PhantomData<C>,
|
||||
}
|
||||
|
||||
impl<C> Server<C> {
|
||||
pub fn new() -> Self {
|
||||
Server{marker: PhantomData}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> Api<C> for Server<C> where C: Has<XSpanIdString>{
|
||||
|
||||
/// A dummy endpoint to make the spec valid.
|
||||
fn dummy_get(&self, context: &C) -> Box<dyn Future<Item=DummyGetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("dummy_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
|
||||
fn dummy_put(&self, nested_response: models::InlineObject, context: &C) -> Box<dyn Future<Item=DummyPutResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("dummy_put({:?}) - X-Span-ID: {:?}", nested_response, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Get a file
|
||||
fn file_response_get(&self, context: &C) -> Box<dyn Future<Item=FileResponseGetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("file_response_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Test HTML handling
|
||||
fn html_post(&self, body: String, context: &C) -> Box<dyn Future<Item=HtmlPostResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("html_post(\"{}\") - X-Span-ID: {:?}", body, context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
/// Get an arbitrary JSON blob.
|
||||
fn raw_json_get(&self, context: &C) -> Box<dyn Future<Item=RawJsonGetResponse, Error=ApiError>> {
|
||||
let context = context.clone();
|
||||
println!("raw_json_get() - X-Span-ID: {:?}", context.get().0.clone());
|
||||
Box::new(futures::failed("Generic failure".into()))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,6 @@ use std::str::FromStr;
|
||||
use header::IntoHeaderValue;
|
||||
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<ANullableContainer> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<ANullableContainer>> for HeaderValue {
|
||||
@@ -26,6 +25,7 @@ impl From<HeaderValue> for IntoHeaderValue<ANullableContainer> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct ANullableContainer {
|
||||
@@ -49,6 +49,75 @@ impl ANullableContainer {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the ANullableContainer value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for ANullableContainer {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
if let Some(ref nullable_thing) = self.nullable_thing {
|
||||
params.push("NullableThing".to_string());
|
||||
params.push(nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()));
|
||||
}
|
||||
|
||||
|
||||
params.push("RequiredNullableThing".to_string());
|
||||
params.push(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()));
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a ANullableContainer value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for ANullableContainer {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub nullable_thing: Vec<String>,
|
||||
pub required_nullable_thing: Vec<String>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
"NullableThing" => return Err(()), // Parsing a nullable type in this style is not supported yet
|
||||
|
||||
"RequiredNullableThing" => return Err(()), // Parsing a nullable type in this style is not supported yet
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(ANullableContainer {
|
||||
nullable_thing: Err(())?,
|
||||
required_nullable_thing: Err(())?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// An additionalPropertiesObject
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -81,7 +150,27 @@ impl ::std::ops::DerefMut for AdditionalPropertiesObject {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the AdditionalPropertiesObject value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for AdditionalPropertiesObject {
|
||||
fn to_string(&self) -> String {
|
||||
// Skipping additionalProperties in query parameter serialization
|
||||
"".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a AdditionalPropertiesObject value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for AdditionalPropertiesObject {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
// Parsing additionalProperties in this style is not supported yet
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<InlineObject> and HeaderValue
|
||||
@@ -98,6 +187,7 @@ impl From<HeaderValue> for IntoHeaderValue<InlineObject> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct InlineObject {
|
||||
@@ -119,9 +209,79 @@ impl InlineObject {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the InlineObject value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for InlineObject {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
params.push("id".to_string());
|
||||
params.push(self.id.to_string());
|
||||
|
||||
|
||||
if let Some(ref password) = self.password {
|
||||
params.push("password".to_string());
|
||||
params.push(password.to_string());
|
||||
}
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a InlineObject value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for InlineObject {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub id: Vec<String>,
|
||||
pub password: Vec<String>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"id" => intermediate_rep.id.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
|
||||
"password" => intermediate_rep.password.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(InlineObject {
|
||||
id: intermediate_rep.id.into_iter().next().ok_or(())?,
|
||||
password: intermediate_rep.password.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// An object of objects
|
||||
|
||||
// Methods for converting between IntoHeaderValue<ObjectOfObjects> and HeaderValue
|
||||
|
||||
impl From<IntoHeaderValue<ObjectOfObjects>> for HeaderValue {
|
||||
@@ -136,6 +296,7 @@ impl From<HeaderValue> for IntoHeaderValue<ObjectOfObjects> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct ObjectOfObjects {
|
||||
@@ -153,6 +314,63 @@ impl ObjectOfObjects {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the ObjectOfObjects value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for ObjectOfObjects {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
// Skipping inner in query parameter serialization
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a ObjectOfObjects value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for ObjectOfObjects {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub inner: Vec<models::ObjectOfObjectsInner>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"inner" => intermediate_rep.inner.push(models::ObjectOfObjectsInner::from_str(val).map_err(|x| ())?),
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(ObjectOfObjects {
|
||||
inner: intermediate_rep.inner.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Methods for converting between IntoHeaderValue<ObjectOfObjectsInner> and HeaderValue
|
||||
@@ -169,6 +387,7 @@ impl From<HeaderValue> for IntoHeaderValue<ObjectOfObjectsInner> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(LabelledGeneric))]
|
||||
pub struct ObjectOfObjectsInner {
|
||||
@@ -190,3 +409,74 @@ impl ObjectOfObjectsInner {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the ObjectOfObjectsInner value to the Query Parameters representation (style=form, explode=false)
|
||||
/// specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde serializer
|
||||
impl ::std::string::ToString for ObjectOfObjectsInner {
|
||||
fn to_string(&self) -> String {
|
||||
let mut params: Vec<String> = vec![];
|
||||
|
||||
params.push("required_thing".to_string());
|
||||
params.push(self.required_thing.to_string());
|
||||
|
||||
|
||||
if let Some(ref optional_thing) = self.optional_thing {
|
||||
params.push("optional_thing".to_string());
|
||||
params.push(optional_thing.to_string());
|
||||
}
|
||||
|
||||
params.join(",").to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a ObjectOfObjectsInner value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl ::std::str::FromStr for ObjectOfObjectsInner {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[derive(Default)]
|
||||
// An intermediate representation of the struct to use for parsing.
|
||||
struct IntermediateRep {
|
||||
pub required_thing: Vec<String>,
|
||||
pub optional_thing: Vec<isize>,
|
||||
}
|
||||
|
||||
let mut intermediate_rep = IntermediateRep::default();
|
||||
|
||||
// Parse into intermediate representation
|
||||
let mut string_iter = s.split(',').into_iter();
|
||||
let mut key_result = string_iter.next();
|
||||
|
||||
while key_result.is_some() {
|
||||
let val = match string_iter.next() {
|
||||
Some(x) => x,
|
||||
None => return Err(())
|
||||
};
|
||||
|
||||
if let Some(key) = key_result {
|
||||
match key {
|
||||
|
||||
"required_thing" => intermediate_rep.required_thing.push(String::from_str(val).map_err(|x| ())?),
|
||||
|
||||
|
||||
"optional_thing" => intermediate_rep.optional_thing.push(isize::from_str(val).map_err(|x| ())?),
|
||||
|
||||
_ => return Err(()) // Parse error - unexpected key
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next key
|
||||
key_result = string_iter.next();
|
||||
}
|
||||
|
||||
// Use the intermediate representation to return the struct
|
||||
Ok(ObjectOfObjectsInner {
|
||||
required_thing: intermediate_rep.required_thing.into_iter().next().ok_or(())?,
|
||||
optional_thing: intermediate_rep.optional_thing.into_iter().next(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user