[Inline model resolver] better handling of inline responses and bug fixes (#12353)

* better handling of inline response schemas, bug fixes

* update samples

* add new files

* better code format

* remove unused ruby files

* fix java test

* remove unused js spec files

* remove inline_response_default_test.dart

* fix webclient tests

* fix spring tests
This commit is contained in:
William Cheng
2022-05-13 10:17:59 +08:00
committed by GitHub
parent 2cf3d3805f
commit 12cdacabbf
284 changed files with 7620 additions and 1220 deletions

View File

@@ -3,9 +3,9 @@
Cargo.toml
README.md
api/openapi.yaml
docs/InlineRequest.md
docs/MultipartRelatedRequest.md
docs/MultipartRequestObjectField.md
docs/MultipleIdenticalMimeTypesPostRequest.md
docs/default_api.md
examples/ca.pem
examples/client/main.rs

View File

@@ -104,9 +104,9 @@ Method | HTTP request | Description
## Documentation For Models
- [InlineRequest](docs/InlineRequest.md)
- [MultipartRelatedRequest](docs/MultipartRelatedRequest.md)
- [MultipartRequestObjectField](docs/MultipartRequestObjectField.md)
- [MultipleIdenticalMimeTypesPostRequest](docs/MultipleIdenticalMimeTypesPostRequest.md)
## Documentation For Authorization

View File

@@ -63,7 +63,7 @@ paths:
contentType: application/octet-stream
style: form
schema:
$ref: '#/components/schemas/inline_request'
$ref: '#/components/schemas/_multiple_identical_mime_types_post_request'
required: true
responses:
"200":
@@ -98,7 +98,7 @@ components:
required:
- required_binary_field
type: object
inline_request:
_multiple_identical_mime_types_post_request:
properties:
binary1:
format: binary

View File

@@ -0,0 +1,11 @@
# MultipleIdenticalMimeTypesPostRequest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**binary1** | [***swagger::ByteArray**](file.md) | | [optional] [default to None]
**binary2** | [***swagger::ByteArray**](file.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)

View File

@@ -4,129 +4,6 @@ use crate::models;
#[cfg(any(feature = "client", feature = "server"))]
use crate::header;
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct InlineRequest {
#[serde(rename = "binary1")]
#[serde(skip_serializing_if="Option::is_none")]
pub binary1: Option<swagger::ByteArray>,
#[serde(rename = "binary2")]
#[serde(skip_serializing_if="Option::is_none")]
pub binary2: Option<swagger::ByteArray>,
}
impl InlineRequest {
pub fn new() -> InlineRequest {
InlineRequest {
binary1: None,
binary2: None,
}
}
}
/// Converts the InlineRequest 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 InlineRequest {
fn to_string(&self) -> String {
let mut params: Vec<String> = vec![];
// Skipping binary1 in query parameter serialization
// Skipping binary1 in query parameter serialization
// Skipping binary2 in query parameter serialization
// Skipping binary2 in query parameter serialization
params.join(",").to_string()
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a InlineRequest value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for InlineRequest {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
#[derive(Default)]
// An intermediate representation of the struct to use for parsing.
struct IntermediateRep {
pub binary1: Vec<swagger::ByteArray>,
pub binary2: 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 std::result::Result::Err("Missing value while parsing InlineRequest".to_string())
};
if let Some(key) = key_result {
match key {
"binary1" => return std::result::Result::Err("Parsing binary data in this style is not supported in InlineRequest".to_string()),
"binary2" => return std::result::Result::Err("Parsing binary data in this style is not supported in InlineRequest".to_string()),
_ => return std::result::Result::Err("Unexpected key while parsing InlineRequest".to_string())
}
}
// Get the next key
key_result = string_iter.next();
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(InlineRequest {
binary1: intermediate_rep.binary1.into_iter().next(),
binary2: intermediate_rep.binary2.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<InlineRequest> and hyper::header::HeaderValue
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<header::IntoHeaderValue<InlineRequest>> for hyper::header::HeaderValue {
type Error = String;
fn try_from(hdr_value: header::IntoHeaderValue<InlineRequest>) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match hyper::header::HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(
format!("Invalid header value for InlineRequest - value: {} is invalid {}",
hdr_value, e))
}
}
}
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<InlineRequest> {
type Error = String;
fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <InlineRequest as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
std::result::Result::Err(err) => std::result::Result::Err(
format!("Unable to convert header value '{}' into InlineRequest - {}",
value, err))
}
},
std::result::Result::Err(e) => std::result::Result::Err(
format!("Unable to convert header: {:?} to string: {}",
hdr_value, e))
}
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipartRelatedRequest {
@@ -384,3 +261,126 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipleIdenticalMimeTypesPostRequest {
#[serde(rename = "binary1")]
#[serde(skip_serializing_if="Option::is_none")]
pub binary1: Option<swagger::ByteArray>,
#[serde(rename = "binary2")]
#[serde(skip_serializing_if="Option::is_none")]
pub binary2: Option<swagger::ByteArray>,
}
impl MultipleIdenticalMimeTypesPostRequest {
pub fn new() -> MultipleIdenticalMimeTypesPostRequest {
MultipleIdenticalMimeTypesPostRequest {
binary1: None,
binary2: None,
}
}
}
/// Converts the MultipleIdenticalMimeTypesPostRequest 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 MultipleIdenticalMimeTypesPostRequest {
fn to_string(&self) -> String {
let mut params: Vec<String> = vec![];
// Skipping binary1 in query parameter serialization
// Skipping binary1 in query parameter serialization
// Skipping binary2 in query parameter serialization
// Skipping binary2 in query parameter serialization
params.join(",").to_string()
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a MultipleIdenticalMimeTypesPostRequest value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
#[derive(Default)]
// An intermediate representation of the struct to use for parsing.
struct IntermediateRep {
pub binary1: Vec<swagger::ByteArray>,
pub binary2: 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 std::result::Result::Err("Missing value while parsing MultipleIdenticalMimeTypesPostRequest".to_string())
};
if let Some(key) = key_result {
match key {
"binary1" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipleIdenticalMimeTypesPostRequest".to_string()),
"binary2" => return std::result::Result::Err("Parsing binary data in this style is not supported in MultipleIdenticalMimeTypesPostRequest".to_string()),
_ => return std::result::Result::Err("Unexpected key while parsing MultipleIdenticalMimeTypesPostRequest".to_string())
}
}
// Get the next key
key_result = string_iter.next();
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(MultipleIdenticalMimeTypesPostRequest {
binary1: intermediate_rep.binary1.into_iter().next(),
binary2: intermediate_rep.binary2.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> and hyper::header::HeaderValue
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>> for hyper::header::HeaderValue {
type Error = String;
fn try_from(hdr_value: header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match hyper::header::HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(
format!("Invalid header value for MultipleIdenticalMimeTypesPostRequest - value: {} is invalid {}",
hdr_value, e))
}
}
}
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> {
type Error = String;
fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <MultipleIdenticalMimeTypesPostRequest as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
std::result::Result::Err(err) => std::result::Result::Err(
format!("Unable to convert header value '{}' into MultipleIdenticalMimeTypesPostRequest - {}",
value, err))
}
},
std::result::Result::Err(e) => std::result::Result::Err(
format!("Unable to convert header: {:?} to string: {}",
hdr_value, e))
}
}
}

View File

@@ -3,7 +3,7 @@
Cargo.toml
README.md
api/openapi.yaml
docs/InlineRequest.md
docs/OpGetRequest.md
docs/default_api.md
examples/ca.pem
examples/client/main.rs

View File

@@ -99,7 +99,7 @@ Method | HTTP request | Description
## Documentation For Models
- [InlineRequest](docs/InlineRequest.md)
- [OpGetRequest](docs/OpGetRequest.md)
## Documentation For Authorization

View File

@@ -11,14 +11,14 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/inline_request'
$ref: '#/components/schemas/_op_get_request'
required: true
responses:
"200":
description: OK
components:
schemas:
inline_request:
_op_get_request:
properties:
propery:
type: string

View File

@@ -0,0 +1,10 @@
# OpGetRequest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**propery** | **String** | | [optional] [default to None]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -8,14 +8,14 @@ Method | HTTP request | Description
# ****
> (inline_request)
> (op_get_request)
### Required Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**inline_request** | [**InlineRequest**](InlineRequest.md)| |
**op_get_request** | [**OpGetRequest**](OpGetRequest.md)| |
### Return type

View File

@@ -104,11 +104,11 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
{
async fn op_get(
&self,
inline_request: models::InlineRequest,
op_get_request: models::OpGetRequest,
context: &C) -> Result<OpGetResponse, ApiError>
{
let context = context.clone();
info!("op_get({:?}) - X-Span-ID: {:?}", inline_request, context.get().0.clone());
info!("op_get({:?}) - X-Span-ID: {:?}", op_get_request, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}

View File

@@ -382,7 +382,7 @@ impl<S, C> Api<C> for Client<S, C> where
async fn op_get(
&self,
param_inline_request: models::InlineRequest,
param_op_get_request: models::OpGetRequest,
context: &C) -> Result<OpGetResponse, ApiError>
{
let mut client_service = self.client_service.clone();
@@ -415,7 +415,7 @@ impl<S, C> Api<C> for Client<S, C> where
};
// Body parameter
let body = serde_json::to_string(&param_inline_request).expect("impossible to fail to serialize");
let body = serde_json::to_string(&param_op_get_request).expect("impossible to fail to serialize");
*request.body_mut() = Body::from(body);

View File

@@ -27,7 +27,7 @@ pub trait Api<C: Send + Sync> {
async fn op_get(
&self,
inline_request: models::InlineRequest,
op_get_request: models::OpGetRequest,
context: &C) -> Result<OpGetResponse, ApiError>;
}
@@ -42,7 +42,7 @@ pub trait ApiNoContext<C: Send + Sync> {
async fn op_get(
&self,
inline_request: models::InlineRequest,
op_get_request: models::OpGetRequest,
) -> Result<OpGetResponse, ApiError>;
}
@@ -72,11 +72,11 @@ impl<T: Api<C> + Send + Sync, C: Clone + Send + Sync> ApiNoContext<C> for Contex
async fn op_get(
&self,
inline_request: models::InlineRequest,
op_get_request: models::OpGetRequest,
) -> Result<OpGetResponse, ApiError>
{
let context = self.context().clone();
self.api().op_get(inline_request, &context).await
self.api().op_get(op_get_request, &context).await
}
}

View File

@@ -6,25 +6,25 @@ use crate::header;
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct InlineRequest {
pub struct OpGetRequest {
#[serde(rename = "propery")]
#[serde(skip_serializing_if="Option::is_none")]
pub propery: Option<String>,
}
impl InlineRequest {
pub fn new() -> InlineRequest {
InlineRequest {
impl OpGetRequest {
pub fn new() -> OpGetRequest {
OpGetRequest {
propery: None,
}
}
}
/// Converts the InlineRequest value to the Query Parameters representation (style=form, explode=false)
/// Converts the OpGetRequest 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 InlineRequest {
impl std::string::ToString for OpGetRequest {
fn to_string(&self) -> String {
let mut params: Vec<String> = vec![];
@@ -37,10 +37,10 @@ impl std::string::ToString for InlineRequest {
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a InlineRequest value
/// Converts Query Parameters representation (style=form, explode=false) to a OpGetRequest value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for InlineRequest {
impl std::str::FromStr for OpGetRequest {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
@@ -59,13 +59,13 @@ impl std::str::FromStr for InlineRequest {
while key_result.is_some() {
let val = match string_iter.next() {
Some(x) => x,
None => return std::result::Result::Err("Missing value while parsing InlineRequest".to_string())
None => return std::result::Result::Err("Missing value while parsing OpGetRequest".to_string())
};
if let Some(key) = key_result {
match key {
"propery" => intermediate_rep.propery.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
_ => return std::result::Result::Err("Unexpected key while parsing InlineRequest".to_string())
_ => return std::result::Result::Err("Unexpected key while parsing OpGetRequest".to_string())
}
}
@@ -74,40 +74,40 @@ impl std::str::FromStr for InlineRequest {
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(InlineRequest {
std::result::Result::Ok(OpGetRequest {
propery: intermediate_rep.propery.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<InlineRequest> and hyper::header::HeaderValue
// Methods for converting between header::IntoHeaderValue<OpGetRequest> and hyper::header::HeaderValue
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<header::IntoHeaderValue<InlineRequest>> for hyper::header::HeaderValue {
impl std::convert::TryFrom<header::IntoHeaderValue<OpGetRequest>> for hyper::header::HeaderValue {
type Error = String;
fn try_from(hdr_value: header::IntoHeaderValue<InlineRequest>) -> std::result::Result<Self, Self::Error> {
fn try_from(hdr_value: header::IntoHeaderValue<OpGetRequest>) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match hyper::header::HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(
format!("Invalid header value for InlineRequest - value: {} is invalid {}",
format!("Invalid header value for OpGetRequest - value: {} is invalid {}",
hdr_value, e))
}
}
}
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<InlineRequest> {
impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<OpGetRequest> {
type Error = String;
fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <InlineRequest as std::str::FromStr>::from_str(value) {
match <OpGetRequest as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
std::result::Result::Err(err) => std::result::Result::Err(
format!("Unable to convert header value '{}' into InlineRequest - {}",
format!("Unable to convert header value '{}' into OpGetRequest - {}",
value, err))
}
},

View File

@@ -148,31 +148,31 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
match result {
Ok(body) => {
let mut unused_elements = Vec::new();
let param_inline_request: Option<models::InlineRequest> = if !body.is_empty() {
let param_op_get_request: Option<models::OpGetRequest> = if !body.is_empty() {
let deserializer = &mut serde_json::Deserializer::from_slice(&*body);
match serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
}) {
Ok(param_inline_request) => param_inline_request,
Ok(param_op_get_request) => param_op_get_request,
Err(e) => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't parse body parameter InlineRequest - doesn't match schema: {}", e)))
.expect("Unable to create Bad Request response for invalid body parameter InlineRequest due to schema")),
.body(Body::from(format!("Couldn't parse body parameter OpGetRequest - doesn't match schema: {}", e)))
.expect("Unable to create Bad Request response for invalid body parameter OpGetRequest due to schema")),
}
} else {
None
};
let param_inline_request = match param_inline_request {
Some(param_inline_request) => param_inline_request,
let param_op_get_request = match param_op_get_request {
Some(param_op_get_request) => param_op_get_request,
None => return Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from("Missing required body parameter InlineRequest"))
.expect("Unable to create Bad Request response for missing body parameter InlineRequest")),
.body(Body::from("Missing required body parameter OpGetRequest"))
.expect("Unable to create Bad Request response for missing body parameter OpGetRequest")),
};
let result = api_impl.op_get(
param_inline_request,
param_op_get_request,
&context
).await;
let mut response = Response::new(Body::empty());
@@ -207,8 +207,8 @@ impl<T, C> hyper::service::Service<(Request<Body>, C)> for Service<T, C> where
},
Err(e) => Ok(Response::builder()
.status(StatusCode::BAD_REQUEST)
.body(Body::from(format!("Couldn't read body parameter InlineRequest: {}", e)))
.expect("Unable to create Bad Request response due to unable to read body parameter InlineRequest")),
.body(Body::from(format!("Couldn't read body parameter OpGetRequest: {}", e)))
.expect("Unable to create Bad Request response due to unable to read body parameter OpGetRequest")),
}
},

View File

@@ -7,6 +7,7 @@ docs/AdditionalPropertiesWithList.md
docs/AnotherXmlArray.md
docs/AnotherXmlInner.md
docs/AnotherXmlObject.md
docs/AnyOfGet202Response.md
docs/AnyOfObject.md
docs/AnyOfObjectAnyOf.md
docs/AnyOfProperty.md
@@ -14,9 +15,9 @@ docs/DuplicateXmlObject.md
docs/EnumWithStarObject.md
docs/Err.md
docs/Error.md
docs/InlineResponse201.md
docs/Model12345AnyOfObject.md
docs/Model12345AnyOfObjectAnyOf.md
docs/MultigetGet201Response.md
docs/MyId.md
docs/MyIdList.md
docs/NullableTest.md
@@ -25,6 +26,7 @@ docs/ObjectParam.md
docs/ObjectUntypedProps.md
docs/ObjectWithArrayOfObjects.md
docs/Ok.md
docs/OneOfGet200Response.md
docs/OptionalObjectHeader.md
docs/RequiredObjectHeader.md
docs/Result.md

View File

@@ -153,6 +153,7 @@ Method | HTTP request | Description
- [AnotherXmlArray](docs/AnotherXmlArray.md)
- [AnotherXmlInner](docs/AnotherXmlInner.md)
- [AnotherXmlObject](docs/AnotherXmlObject.md)
- [AnyOfGet202Response](docs/AnyOfGet202Response.md)
- [AnyOfObject](docs/AnyOfObject.md)
- [AnyOfObjectAnyOf](docs/AnyOfObjectAnyOf.md)
- [AnyOfProperty](docs/AnyOfProperty.md)
@@ -160,9 +161,9 @@ Method | HTTP request | Description
- [EnumWithStarObject](docs/EnumWithStarObject.md)
- [Err](docs/Err.md)
- [Error](docs/Error.md)
- [InlineResponse201](docs/InlineResponse201.md)
- [Model12345AnyOfObject](docs/Model12345AnyOfObject.md)
- [Model12345AnyOfObjectAnyOf](docs/Model12345AnyOfObjectAnyOf.md)
- [MultigetGet201Response](docs/MultigetGet201Response.md)
- [MyId](docs/MyId.md)
- [MyIdList](docs/MyIdList.md)
- [NullableTest](docs/NullableTest.md)
@@ -171,6 +172,7 @@ Method | HTTP request | Description
- [ObjectUntypedProps](docs/ObjectUntypedProps.md)
- [ObjectWithArrayOfObjects](docs/ObjectWithArrayOfObjects.md)
- [Ok](docs/Ok.md)
- [OneOfGet200Response](docs/OneOfGet200Response.md)
- [OptionalObjectHeader](docs/OptionalObjectHeader.md)
- [RequiredObjectHeader](docs/RequiredObjectHeader.md)
- [Result](docs/Result.md)

View File

@@ -79,7 +79,7 @@ paths:
content:
application/xml:
schema:
$ref: '#/components/schemas/inline_response_201'
$ref: '#/components/schemas/_multiget_get_201_response'
description: XML rsp
"202":
content:
@@ -415,11 +415,7 @@ paths:
content:
application/json:
schema:
oneOf:
- type: integer
- items:
type: string
type: array
$ref: '#/components/schemas/_one_of_get_200_response'
description: Success
/any-of:
get:
@@ -452,9 +448,7 @@ paths:
content:
application/json:
schema:
anyOf:
- $ref: '#/components/schemas/StringObject'
- $ref: '#/components/schemas/UuidObject'
$ref: '#/components/schemas/_any_of_get_202_response'
description: AnyOfSuccess
/json-complex-query-param:
get:
@@ -671,11 +665,21 @@ components:
type: string
Result:
type: string
inline_response_201:
_multiget_get_201_response:
properties:
foo:
type: string
type: object
_one_of_get_200_response:
oneOf:
- type: integer
- items:
type: string
type: array
_any_of_get_202_response:
anyOf:
- $ref: '#/components/schemas/StringObject'
- $ref: '#/components/schemas/UuidObject'
AnyOfObject_anyOf:
enum:
- FOO

View File

@@ -0,0 +1,9 @@
# AnyOfGet202Response
## 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)

View File

@@ -0,0 +1,10 @@
# MultigetGet201Response
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**foo** | **String** | | [optional] [default to None]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,9 @@
# OneOfGet200Response
## 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)

View File

@@ -268,7 +268,7 @@ 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)
# ****
> swagger::OneOf2<i32,Vec<String>> ()
> models::OneOfGet200Response ()
### Required Parameters
@@ -276,7 +276,7 @@ This endpoint does not need any parameter.
### Return type
[**swagger::OneOf2<i32,Vec<String>>**](swagger::OneOf2<i32,Vec<String>>.md)
[**models::OneOfGet200Response**](_one_of_get_200_response.md)
### Authorization

View File

@@ -490,7 +490,7 @@ impl<S, C> Api<C> for Client<S, C> where
.map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?;
let body = str::from_utf8(&body)
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<swagger::AnyOf2<models::StringObject,models::UuidObject>>(body).map_err(|e| {
let body = serde_json::from_str::<models::AnyOfGet202Response>(body).map_err(|e| {
ApiError(format!("Response body did not match the schema: {}", e))
})?;
Ok(AnyOfGetResponse::AnyOfSuccess
@@ -1035,7 +1035,7 @@ impl<S, C> Api<C> for Client<S, C> where
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
// ToDo: this will move to swagger-rs and become a standard From conversion trait
// once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
let body = serde_xml_rs::from_str::<models::InlineResponse201>(body)
let body = serde_xml_rs::from_str::<models::MultigetGet201Response>(body)
.map_err(|e| ApiError(format!("Response body did not match the schema: {}", e)))?;
Ok(MultigetGetResponse::XMLRsp
(body)
@@ -1261,7 +1261,7 @@ impl<S, C> Api<C> for Client<S, C> where
.map_err(|e| ApiError(format!("Failed to read response: {}", e))).await?;
let body = str::from_utf8(&body)
.map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<swagger::OneOf2<i32,Vec<String>>>(body).map_err(|e| {
let body = serde_json::from_str::<models::OneOfGet200Response>(body).map_err(|e| {
ApiError(format!("Response body did not match the schema: {}", e))
})?;
Ok(OneOfGetResponse::Success

View File

@@ -25,7 +25,7 @@ pub enum AnyOfGetResponse {
,
/// AnyOfSuccess
AnyOfSuccess
(swagger::AnyOf2<models::StringObject,models::UuidObject>)
(models::AnyOfGet202Response)
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
@@ -74,7 +74,7 @@ pub enum MultigetGetResponse {
,
/// XML rsp
XMLRsp
(models::InlineResponse201)
(models::MultigetGet201Response)
,
/// octet rsp
OctetRsp
@@ -107,7 +107,7 @@ pub enum MultipleAuthSchemeGetResponse {
pub enum OneOfGetResponse {
/// Success
Success
(swagger::OneOf2<i32,Vec<String>>)
(models::OneOfGet200Response)
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]

View File

@@ -399,6 +399,116 @@ impl AnotherXmlObject {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AnyOfGet202Response {
}
impl AnyOfGet202Response {
pub fn new() -> AnyOfGet202Response {
AnyOfGet202Response {
}
}
}
/// Converts the AnyOfGet202Response 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 AnyOfGet202Response {
fn to_string(&self) -> String {
let mut params: Vec<String> = vec![];
params.join(",").to_string()
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a AnyOfGet202Response value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for AnyOfGet202Response {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
#[derive(Default)]
// An intermediate representation of the struct to use for parsing.
struct IntermediateRep {
}
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 std::result::Result::Err("Missing value while parsing AnyOfGet202Response".to_string())
};
if let Some(key) = key_result {
match key {
_ => return std::result::Result::Err("Unexpected key while parsing AnyOfGet202Response".to_string())
}
}
// Get the next key
key_result = string_iter.next();
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(AnyOfGet202Response {
})
}
}
// Methods for converting between header::IntoHeaderValue<AnyOfGet202Response> and hyper::header::HeaderValue
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<header::IntoHeaderValue<AnyOfGet202Response>> for hyper::header::HeaderValue {
type Error = String;
fn try_from(hdr_value: header::IntoHeaderValue<AnyOfGet202Response>) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match hyper::header::HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(
format!("Invalid header value for AnyOfGet202Response - value: {} is invalid {}",
hdr_value, e))
}
}
}
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<AnyOfGet202Response> {
type Error = String;
fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <AnyOfGet202Response as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
std::result::Result::Err(err) => std::result::Result::Err(
format!("Unable to convert header value '{}' into AnyOfGet202Response - {}",
value, err))
}
},
std::result::Result::Err(e) => std::result::Result::Err(
format!("Unable to convert header: {:?} to string: {}",
hdr_value, e))
}
}
}
impl AnyOfGet202Response {
/// Helper function to allow us to convert this model to an XML string.
/// Will panic if serialisation fails.
#[allow(dead_code)]
pub(crate) fn to_xml(&self) -> String {
serde_xml_rs::to_string(&self).expect("impossible to fail to serialize")
}
}
/// Test a model containing an anyOf
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
@@ -982,130 +1092,6 @@ impl Error {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct InlineResponse201 {
#[serde(rename = "foo")]
#[serde(skip_serializing_if="Option::is_none")]
pub foo: Option<String>,
}
impl InlineResponse201 {
pub fn new() -> InlineResponse201 {
InlineResponse201 {
foo: None,
}
}
}
/// 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 = String;
fn from_str(s: &str) -> std::result::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 std::result::Result::Err("Missing value while parsing InlineResponse201".to_string())
};
if let Some(key) = key_result {
match key {
"foo" => intermediate_rep.foo.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
_ => return std::result::Result::Err("Unexpected key while parsing InlineResponse201".to_string())
}
}
// Get the next key
key_result = string_iter.next();
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(InlineResponse201 {
foo: intermediate_rep.foo.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<InlineResponse201> and hyper::header::HeaderValue
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<header::IntoHeaderValue<InlineResponse201>> for hyper::header::HeaderValue {
type Error = String;
fn try_from(hdr_value: header::IntoHeaderValue<InlineResponse201>) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match hyper::header::HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(
format!("Invalid header value for InlineResponse201 - value: {} is invalid {}",
hdr_value, e))
}
}
}
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<InlineResponse201> {
type Error = String;
fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <InlineResponse201 as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
std::result::Result::Err(err) => std::result::Result::Err(
format!("Unable to convert header value '{}' into InlineResponse201 - {}",
value, err))
}
},
std::result::Result::Err(e) => std::result::Result::Err(
format!("Unable to convert header: {:?} to string: {}",
hdr_value, e))
}
}
}
impl InlineResponse201 {
/// Helper function to allow us to convert this model to an XML string.
/// Will panic if serialisation fails.
#[allow(dead_code)]
pub(crate) fn to_xml(&self) -> String {
serde_xml_rs::to_string(&self).expect("impossible to fail to serialize")
}
}
/// Test a model containing an anyOf that starts with a number
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
@@ -1265,6 +1251,130 @@ impl Model12345AnyOfObjectAnyOf {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultigetGet201Response {
#[serde(rename = "foo")]
#[serde(skip_serializing_if="Option::is_none")]
pub foo: Option<String>,
}
impl MultigetGet201Response {
pub fn new() -> MultigetGet201Response {
MultigetGet201Response {
foo: None,
}
}
}
/// Converts the MultigetGet201Response 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 MultigetGet201Response {
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 MultigetGet201Response value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for MultigetGet201Response {
type Err = String;
fn from_str(s: &str) -> std::result::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 std::result::Result::Err("Missing value while parsing MultigetGet201Response".to_string())
};
if let Some(key) = key_result {
match key {
"foo" => intermediate_rep.foo.push(<String as std::str::FromStr>::from_str(val).map_err(|x| format!("{}", x))?),
_ => return std::result::Result::Err("Unexpected key while parsing MultigetGet201Response".to_string())
}
}
// Get the next key
key_result = string_iter.next();
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(MultigetGet201Response {
foo: intermediate_rep.foo.into_iter().next(),
})
}
}
// Methods for converting between header::IntoHeaderValue<MultigetGet201Response> and hyper::header::HeaderValue
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<header::IntoHeaderValue<MultigetGet201Response>> for hyper::header::HeaderValue {
type Error = String;
fn try_from(hdr_value: header::IntoHeaderValue<MultigetGet201Response>) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match hyper::header::HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(
format!("Invalid header value for MultigetGet201Response - value: {} is invalid {}",
hdr_value, e))
}
}
}
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<MultigetGet201Response> {
type Error = String;
fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <MultigetGet201Response as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
std::result::Result::Err(err) => std::result::Result::Err(
format!("Unable to convert header value '{}' into MultigetGet201Response - {}",
value, err))
}
},
std::result::Result::Err(e) => std::result::Result::Err(
format!("Unable to convert header: {:?} to string: {}",
hdr_value, e))
}
}
}
impl MultigetGet201Response {
/// 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")
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MyId(i32);
@@ -2221,6 +2331,116 @@ impl Ok {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OneOfGet200Response {
}
impl OneOfGet200Response {
pub fn new() -> OneOfGet200Response {
OneOfGet200Response {
}
}
}
/// Converts the OneOfGet200Response 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 OneOfGet200Response {
fn to_string(&self) -> String {
let mut params: Vec<String> = vec![];
params.join(",").to_string()
}
}
/// Converts Query Parameters representation (style=form, explode=false) to a OneOfGet200Response value
/// as specified in https://swagger.io/docs/specification/serialization/
/// Should be implemented in a serde deserializer
impl std::str::FromStr for OneOfGet200Response {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
#[derive(Default)]
// An intermediate representation of the struct to use for parsing.
struct IntermediateRep {
}
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 std::result::Result::Err("Missing value while parsing OneOfGet200Response".to_string())
};
if let Some(key) = key_result {
match key {
_ => return std::result::Result::Err("Unexpected key while parsing OneOfGet200Response".to_string())
}
}
// Get the next key
key_result = string_iter.next();
}
// Use the intermediate representation to return the struct
std::result::Result::Ok(OneOfGet200Response {
})
}
}
// Methods for converting between header::IntoHeaderValue<OneOfGet200Response> and hyper::header::HeaderValue
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<header::IntoHeaderValue<OneOfGet200Response>> for hyper::header::HeaderValue {
type Error = String;
fn try_from(hdr_value: header::IntoHeaderValue<OneOfGet200Response>) -> std::result::Result<Self, Self::Error> {
let hdr_value = hdr_value.to_string();
match hyper::header::HeaderValue::from_str(&hdr_value) {
std::result::Result::Ok(value) => std::result::Result::Ok(value),
std::result::Result::Err(e) => std::result::Result::Err(
format!("Invalid header value for OneOfGet200Response - value: {} is invalid {}",
hdr_value, e))
}
}
}
#[cfg(any(feature = "client", feature = "server"))]
impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<OneOfGet200Response> {
type Error = String;
fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
match hdr_value.to_str() {
std::result::Result::Ok(value) => {
match <OneOfGet200Response as std::str::FromStr>::from_str(value) {
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
std::result::Result::Err(err) => std::result::Result::Err(
format!("Unable to convert header value '{}' into OneOfGet200Response - {}",
value, err))
}
},
std::result::Result::Err(e) => std::result::Result::Err(
format!("Unable to convert header: {:?} to string: {}",
hdr_value, e))
}
}
}
impl OneOfGet200Response {
/// 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")
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OptionalObjectHeader(i32);