Rust validation handling (#15288)

* Prevent JavaScript regex delimiter

* Validation

* validator dependency

* validation with range

* Switch to garde crate for validation

* Update uuid crate

* Examples

* All rust-server samples

* Added rule handling

* Exchange garde for validator crate (rust)

* Version update in samples

---------

Co-authored-by: Erik Wegner <erik.wegner@regiocom.com>
This commit is contained in:
Erik Wegner 2023-06-16 09:25:27 +02:00 committed by GitHub
parent 0a651e1b0a
commit 389270334a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 319 additions and 105 deletions

View File

@ -334,4 +334,8 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
return toApiName(name);
}
@Override
public String addRegularExpressionDelimiter(String pattern) {
return pattern;
}
}

View File

@ -89,6 +89,7 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
# Crates included if required by the API definition
{{#usesXml}}
@ -103,7 +104,7 @@ mime_0_2 = { package = "mime", version = "0.2.6", optional = true }
multipart = { version = "0.16", default-features = false, optional = true }
{{/apiUsesMultipartFormData}}
{{#apiUsesUuid}}
uuid = {version = "0.8", features = ["serde", "v4"]}
uuid = {version = "1.3.1", features = ["serde", "v4"]}
{{/apiUsesUuid}}
# Common between server and client features

View File

@ -1,5 +1,7 @@
#![allow(unused_qualifications)]
use validator::Validate;
use crate::models;
#[cfg(any(feature = "client", feature = "server"))]
use crate::header;
@ -243,7 +245,7 @@ impl std::str::FromStr for {{{classname}}} {
{{/arrayModelType}}
{{^arrayModelType}}
{{! general struct}}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
{{#xmlName}}
#[serde(rename = "{{{.}}}")]
@ -258,6 +260,44 @@ pub struct {{{classname}}} {
#[serde(serialize_with = "wrap_in_{{{x-item-xml-name}}}")]
{{/x-item-xml-name}}
{{/vendorExtensions}}
{{#hasValidation}}
#[validate(
{{#maxLength}}
{{#minLength}}
length(min = {{minLength}}, max = {{maxLength}}),
{{/minLength}}
{{^minLength}}
length(max = {{maxLength}}),
{{/minLength}}
{{/maxLength}}
{{^maxLength}}
{{#minLength}}
length(min = {{minLength}}),
{{/minLength}}
{{/maxLength}}
{{#pattern}}
{{^isByteArray}}
regex = "RE_{{#lambda.uppercase}}{{{classname}}}_{{{name}}}{{/lambda.uppercase}}",
{{/isByteArray}}
{{#isByteArray}}
custom ="validate_byte_{{#lambda.lowercase}}{{{classname}}}_{{{name}}}{{/lambda.lowercase}}"
{{/isByteArray}}
{{/pattern}}
{{#maximum}}
{{#minimum}}
range(min = {{minimum}}, max = {{maximum}}),
{{/minimum}}
{{^minimum}}
range(max = {{maximum}}),
{{/minimum}}
{{/maximum}}
{{#minimum}}
{{^maximum}}
range(min = {{minimum}}),
{{/maximum}}
{{/minimum}}
)]
{{/hasValidation}}
{{#required}}
pub {{{name}}}: {{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}},
{{/required}}
@ -273,6 +313,31 @@ pub struct {{{classname}}} {
{{/vars}}
}
{{#vars}}
{{#hasValidation}}
{{#pattern}}
{{^isByteArray}}
lazy_static::lazy_static! {
static ref RE_{{#lambda.uppercase}}{{{classname}}}_{{{name}}}{{/lambda.uppercase}}: regex::Regex = regex::Regex::new(r"{{ pattern }}").unwrap();
}
{{/isByteArray}}
{{#isByteArray}}
lazy_static::lazy_static! {
static ref RE_{{#lambda.uppercase}}{{{classname}}}_{{{name}}}{{/lambda.uppercase}}: regex::bytes::Regex = regex::bytes::Regex::new(r"{{ pattern }}").unwrap();
}
fn validate_byte_{{#lambda.lowercase}}{{{classname}}}_{{{name}}}{{/lambda.lowercase}}(
b: &swagger::ByteArray
) -> Result<(), validator::ValidationError> {
if !RE_{{#lambda.uppercase}}{{{classname}}}_{{{name}}}{{/lambda.uppercase}}.is_match(b) {
return Err(validator::ValidationError::new("Character not allowed"));
}
Ok(())
}
{{/isByteArray}}
{{/pattern}}
{{/hasValidation}}
{{/vars}}
impl {{{classname}}} {
#[allow(clippy::new_without_default)]
pub fn new({{#vars}}{{^defaultValue}}{{{name}}}: {{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, {{/defaultValue}}{{/vars}}) -> {{{classname}}} {

View File

@ -670,12 +670,14 @@ components:
id:
type: integer
format: int64
minimum: 0
petId:
type: integer
format: int64
quantity:
type: integer
format: int32
minimum: 0
shipDate:
type: string
format: date-time
@ -714,10 +716,14 @@ components:
format: int64
username:
type: string
maxLength: 90
minLength: 1
pattern: '^[a-z][-a-z0-9]*$'
firstName:
type: string
lastName:
type: string
minLength: 1
email:
type: string
password:
@ -728,6 +734,9 @@ components:
type: integer
format: int32
description: User Status
required:
- username
- lastName
xml:
name: User
Tag:

View File

@ -5,9 +5,9 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | Option<**i64**> | | [optional]
**username** | Option<**String**> | | [optional]
**username** | **String** | |
**first_name** | Option<**String**> | | [optional]
**last_name** | Option<**String**> | | [optional]
**last_name** | **String** | |
**email** | Option<**String**> | | [optional]
**password** | Option<**String**> | | [optional]
**phone** | Option<**String**> | | [optional]

View File

@ -16,12 +16,12 @@
pub struct User {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
#[serde(rename = "username", skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(rename = "username")]
pub username: String,
#[serde(rename = "firstName", skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
#[serde(rename = "lastName", skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
#[serde(rename = "lastName")]
pub last_name: String,
#[serde(rename = "email", skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(rename = "password", skip_serializing_if = "Option::is_none")]
@ -35,12 +35,12 @@ pub struct User {
impl User {
/// A User who is purchasing from the pet store
pub fn new() -> User {
pub fn new(username: String, last_name: String) -> User {
User {
id: None,
username: None,
username,
first_name: None,
last_name: None,
last_name,
email: None,
password: None,
phone: None,

View File

@ -5,9 +5,9 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | Option<**i64**> | | [optional]
**username** | Option<**String**> | | [optional]
**username** | **String** | |
**first_name** | Option<**String**> | | [optional]
**last_name** | Option<**String**> | | [optional]
**last_name** | **String** | |
**email** | Option<**String**> | | [optional]
**password** | Option<**String**> | | [optional]
**phone** | Option<**String**> | | [optional]

View File

@ -16,12 +16,12 @@
pub struct User {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
#[serde(rename = "username", skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(rename = "username")]
pub username: String,
#[serde(rename = "firstName", skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
#[serde(rename = "lastName", skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
#[serde(rename = "lastName")]
pub last_name: String,
#[serde(rename = "email", skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(rename = "password", skip_serializing_if = "Option::is_none")]
@ -35,12 +35,12 @@ pub struct User {
impl User {
/// A User who is purchasing from the pet store
pub fn new() -> User {
pub fn new(username: String, last_name: String) -> User {
User {
id: None,
username: None,
username,
first_name: None,
last_name: None,
last_name,
email: None,
password: None,
phone: None,

View File

@ -5,9 +5,9 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | Option<**i64**> | | [optional]
**username** | Option<**String**> | | [optional]
**username** | **String** | |
**first_name** | Option<**String**> | | [optional]
**last_name** | Option<**String**> | | [optional]
**last_name** | **String** | |
**email** | Option<**String**> | | [optional]
**password** | Option<**String**> | | [optional]
**phone** | Option<**String**> | | [optional]

View File

@ -16,12 +16,12 @@
pub struct User {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
#[serde(rename = "username", skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(rename = "username")]
pub username: String,
#[serde(rename = "firstName", skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
#[serde(rename = "lastName", skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
#[serde(rename = "lastName")]
pub last_name: String,
#[serde(rename = "email", skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(rename = "password", skip_serializing_if = "Option::is_none")]
@ -35,12 +35,12 @@ pub struct User {
impl User {
/// A User who is purchasing from the pet store
pub fn new() -> User {
pub fn new(username: String, last_name: String) -> User {
User {
id: None,
username: None,
username,
first_name: None,
last_name: None,
last_name,
email: None,
password: None,
phone: None,

View File

@ -5,9 +5,9 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | Option<**i64**> | | [optional]
**username** | Option<**String**> | | [optional]
**username** | **String** | |
**first_name** | Option<**String**> | | [optional]
**last_name** | Option<**String**> | | [optional]
**last_name** | **String** | |
**email** | Option<**String**> | | [optional]
**password** | Option<**String**> | | [optional]
**phone** | Option<**String**> | | [optional]

View File

@ -16,12 +16,12 @@
pub struct User {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
#[serde(rename = "username", skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(rename = "username")]
pub username: String,
#[serde(rename = "firstName", skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
#[serde(rename = "lastName", skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
#[serde(rename = "lastName")]
pub last_name: String,
#[serde(rename = "email", skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(rename = "password", skip_serializing_if = "Option::is_none")]
@ -35,12 +35,12 @@ pub struct User {
impl User {
/// A User who is purchasing from the pet store
pub fn new() -> User {
pub fn new(username: String, last_name: String) -> User {
User {
id: None,
username: None,
username,
first_name: None,
last_name: None,
last_name,
email: None,
password: None,
phone: None,

View File

@ -5,9 +5,9 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | Option<**i64**> | | [optional]
**username** | Option<**String**> | | [optional]
**username** | **String** | |
**first_name** | Option<**String**> | | [optional]
**last_name** | Option<**String**> | | [optional]
**last_name** | **String** | |
**email** | Option<**String**> | | [optional]
**password** | Option<**String**> | | [optional]
**phone** | Option<**String**> | | [optional]

View File

@ -16,12 +16,12 @@
pub struct User {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
#[serde(rename = "username", skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(rename = "username")]
pub username: String,
#[serde(rename = "firstName", skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
#[serde(rename = "lastName", skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
#[serde(rename = "lastName")]
pub last_name: String,
#[serde(rename = "email", skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(rename = "password", skip_serializing_if = "Option::is_none")]
@ -35,12 +35,12 @@ pub struct User {
impl User {
/// A User who is purchasing from the pet store
pub fn new() -> User {
pub fn new(username: String, last_name: String) -> User {
User {
id: None,
username: None,
username,
first_name: None,
last_name: None,
last_name,
email: None,
password: None,
phone: None,

View File

@ -42,6 +42,7 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
# Crates included if required by the API definition
mime_0_2 = { package = "mime", version = "0.2.6", optional = true }

View File

@ -1,10 +1,12 @@
#![allow(unused_qualifications)]
use validator::Validate;
use crate::models;
#[cfg(any(feature = "client", feature = "server"))]
use crate::header;
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipartRelatedRequest {
#[serde(rename = "object_field")]
@ -20,6 +22,7 @@ pub struct MultipartRelatedRequest {
}
impl MultipartRelatedRequest {
#[allow(clippy::new_without_default)]
pub fn new(required_binary_field: swagger::ByteArray, ) -> MultipartRelatedRequest {
@ -142,7 +145,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipartRequestObjectField {
#[serde(rename = "field_a")]
@ -154,6 +157,7 @@ pub struct MultipartRequestObjectField {
}
impl MultipartRequestObjectField {
#[allow(clippy::new_without_default)]
pub fn new(field_a: String, ) -> MultipartRequestObjectField {
@ -276,7 +280,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultipleIdenticalMimeTypesPostRequest {
#[serde(rename = "binary1")]
@ -289,6 +293,7 @@ pub struct MultipleIdenticalMimeTypesPostRequest {
}
impl MultipleIdenticalMimeTypesPostRequest {
#[allow(clippy::new_without_default)]
pub fn new() -> MultipleIdenticalMimeTypesPostRequest {

View File

@ -36,6 +36,7 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
# Crates included if required by the API definition

View File

@ -1,10 +1,12 @@
#![allow(unused_qualifications)]
use validator::Validate;
use crate::models;
#[cfg(any(feature = "client", feature = "server"))]
use crate::header;
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OpGetRequest {
#[serde(rename = "property")]
@ -12,6 +14,7 @@ pub struct OpGetRequest {
}
impl OpGetRequest {
#[allow(clippy::new_without_default)]
pub fn new(property: String, ) -> OpGetRequest {

View File

@ -38,12 +38,13 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
# Crates included if required by the API definition
# TODO: this should be updated to point at the official crate once
# https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
uuid = {version = "0.8", features = ["serde", "v4"]}
uuid = {version = "1.3.1", features = ["serde", "v4"]}
# Common between server and client features
hyper = {version = "0.14", features = ["full"], optional = true}

View File

@ -1,5 +1,7 @@
#![allow(unused_qualifications)]
use validator::Validate;
use crate::models;
#[cfg(any(feature = "client", feature = "server"))]
use crate::header;
@ -265,7 +267,7 @@ impl AnotherXmlInner {
}
/// An XML object
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "snake_another_xml_object")]
pub struct AnotherXmlObject {
@ -275,6 +277,7 @@ pub struct AnotherXmlObject {
}
impl AnotherXmlObject {
#[allow(clippy::new_without_default)]
pub fn new() -> AnotherXmlObject {
@ -407,11 +410,12 @@ impl AnotherXmlObject {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AnyOfGet202Response {
}
impl AnyOfGet202Response {
#[allow(clippy::new_without_default)]
pub fn new() -> AnyOfGet202Response {
@ -523,11 +527,12 @@ impl AnyOfGet202Response {
}
/// Test a model containing an anyOf
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AnyOfObject {
}
impl AnyOfObject {
#[allow(clippy::new_without_default)]
pub fn new() -> AnyOfObject {
@ -639,7 +644,7 @@ impl AnyOfObject {
}
/// Test containing an anyOf object
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AnyOfProperty {
#[serde(rename = "requiredAnyOf")]
@ -651,6 +656,7 @@ pub struct AnyOfProperty {
}
impl AnyOfProperty {
#[allow(clippy::new_without_default)]
pub fn new(required_any_of: models::AnyOfObject, ) -> AnyOfProperty {
@ -776,7 +782,7 @@ impl AnyOfProperty {
}
/// An XML object
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "camelDuplicateXmlObject")]
pub struct DuplicateXmlObject {
@ -790,6 +796,7 @@ pub struct DuplicateXmlObject {
}
impl DuplicateXmlObject {
#[allow(clippy::new_without_default)]
pub fn new(inner_array: models::XmlArray, ) -> DuplicateXmlObject {
@ -1083,11 +1090,12 @@ impl Error {
}
/// Test a model containing an anyOf that starts with a number
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Model12345AnyOfObject {
}
impl Model12345AnyOfObject {
#[allow(clippy::new_without_default)]
pub fn new() -> Model12345AnyOfObject {
@ -1198,7 +1206,7 @@ impl Model12345AnyOfObject {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MultigetGet201Response {
#[serde(rename = "foo")]
@ -1207,6 +1215,7 @@ pub struct MultigetGet201Response {
}
impl MultigetGet201Response {
#[allow(clippy::new_without_default)]
pub fn new() -> MultigetGet201Response {
@ -1507,7 +1516,7 @@ impl MyIdList {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct NullableTest {
#[serde(rename = "nullable")]
@ -1539,6 +1548,7 @@ pub struct NullableTest {
}
impl NullableTest {
#[allow(clippy::new_without_default)]
pub fn new(nullable: swagger::Nullable<String>, ) -> NullableTest {
@ -1705,7 +1715,7 @@ impl NullableTest {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectHeader {
#[serde(rename = "requiredObjectHeader")]
@ -1717,6 +1727,7 @@ pub struct ObjectHeader {
}
impl ObjectHeader {
#[allow(clippy::new_without_default)]
pub fn new(required_object_header: bool, ) -> ObjectHeader {
@ -1849,7 +1860,7 @@ impl ObjectHeader {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectParam {
#[serde(rename = "requiredParam")]
@ -1861,6 +1872,7 @@ pub struct ObjectParam {
}
impl ObjectParam {
#[allow(clippy::new_without_default)]
pub fn new(required_param: bool, ) -> ObjectParam {
@ -1993,7 +2005,7 @@ impl ObjectParam {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectUntypedProps {
#[serde(rename = "required_untyped")]
@ -2012,6 +2024,7 @@ pub struct ObjectUntypedProps {
}
impl ObjectUntypedProps {
#[allow(clippy::new_without_default)]
pub fn new(required_untyped: serde_json::Value, required_untyped_nullable: swagger::Nullable<serde_json::Value>, ) -> ObjectUntypedProps {
@ -2149,7 +2162,7 @@ impl ObjectUntypedProps {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectWithArrayOfObjects {
#[serde(rename = "objectArray")]
@ -2158,6 +2171,7 @@ pub struct ObjectWithArrayOfObjects {
}
impl ObjectWithArrayOfObjects {
#[allow(clippy::new_without_default)]
pub fn new() -> ObjectWithArrayOfObjects {
@ -2332,11 +2346,12 @@ impl Ok {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OneOfGet200Response {
}
impl OneOfGet200Response {
#[allow(clippy::new_without_default)]
pub fn new() -> OneOfGet200Response {
@ -2915,7 +2930,7 @@ impl XmlInner {
}
/// An XML object
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "camelXmlObject")]
pub struct XmlObject {
@ -2929,6 +2944,7 @@ pub struct XmlObject {
}
impl XmlObject {
#[allow(clippy::new_without_default)]
pub fn new() -> XmlObject {

View File

@ -36,6 +36,7 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
# Crates included if required by the API definition

View File

@ -1,5 +1,7 @@
#![allow(unused_qualifications)]
use validator::Validate;
use crate::models;
#[cfg(any(feature = "client", feature = "server"))]
use crate::header;

View File

@ -41,6 +41,7 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
# Crates included if required by the API definition
# TODO: this should be updated to point at the official crate once
@ -48,7 +49,7 @@ serde_json = "1.0"
serde-xml-rs = {git = "https://github.com/Metaswitch/serde-xml-rs" , branch = "master"}
mime_0_2 = { package = "mime", version = "0.2.6", optional = true }
multipart = { version = "0.16", default-features = false, optional = true }
uuid = {version = "0.8", features = ["serde", "v4"]}
uuid = {version = "1.3.1", features = ["serde", "v4"]}
# Common between server and client features
hyper = {version = "0.14", features = ["full"], optional = true}

View File

@ -0,0 +1,10 @@
# CatAllOf
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**declawed** | **bool** | | [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,10 @@
# DogAllOf
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**breed** | **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

@ -1,10 +1,12 @@
#![allow(unused_qualifications)]
use validator::Validate;
use crate::models;
#[cfg(any(feature = "client", feature = "server"))]
use crate::header;
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AdditionalPropertiesClass {
#[serde(rename = "map_property")]
@ -17,6 +19,7 @@ pub struct AdditionalPropertiesClass {
}
impl AdditionalPropertiesClass {
#[allow(clippy::new_without_default)]
pub fn new() -> AdditionalPropertiesClass {
@ -140,7 +143,7 @@ impl AdditionalPropertiesClass {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Animal {
#[serde(rename = "className")]
@ -152,6 +155,7 @@ pub struct Animal {
}
impl Animal {
#[allow(clippy::new_without_default)]
pub fn new(class_name: String, ) -> Animal {
@ -422,7 +426,7 @@ impl AnimalFarm {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ApiResponse {
#[serde(rename = "code")]
@ -439,6 +443,7 @@ pub struct ApiResponse {
}
impl ApiResponse {
#[allow(clippy::new_without_default)]
pub fn new() -> ApiResponse {
@ -588,7 +593,7 @@ impl ApiResponse {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ArrayOfArrayOfNumberOnly {
#[serde(rename = "ArrayArrayNumber")]
@ -597,6 +602,7 @@ pub struct ArrayOfArrayOfNumberOnly {
}
impl ArrayOfArrayOfNumberOnly {
#[allow(clippy::new_without_default)]
pub fn new() -> ArrayOfArrayOfNumberOnly {
@ -713,7 +719,7 @@ impl ArrayOfArrayOfNumberOnly {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ArrayOfNumberOnly {
#[serde(rename = "ArrayNumber")]
@ -722,6 +728,7 @@ pub struct ArrayOfNumberOnly {
}
impl ArrayOfNumberOnly {
#[allow(clippy::new_without_default)]
pub fn new() -> ArrayOfNumberOnly {
@ -844,7 +851,7 @@ impl ArrayOfNumberOnly {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ArrayTest {
#[serde(rename = "array_of_string")]
@ -866,6 +873,7 @@ pub struct ArrayTest {
}
impl ArrayTest {
#[allow(clippy::new_without_default)]
pub fn new() -> ArrayTest {
@ -1012,7 +1020,7 @@ impl ArrayTest {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Capitalization {
#[serde(rename = "smallCamel")]
@ -1042,6 +1050,7 @@ pub struct Capitalization {
}
impl Capitalization {
#[allow(clippy::new_without_default)]
pub fn new() -> Capitalization {
@ -1230,7 +1239,7 @@ impl Capitalization {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Cat {
#[serde(rename = "className")]
@ -1246,6 +1255,7 @@ pub struct Cat {
}
impl Cat {
#[allow(clippy::new_without_default)]
pub fn new(class_name: String, ) -> Cat {
@ -1391,7 +1401,7 @@ impl Cat {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Category")]
pub struct Category {
@ -1405,6 +1415,7 @@ pub struct Category {
}
impl Category {
#[allow(clippy::new_without_default)]
pub fn new() -> Category {
@ -1542,7 +1553,7 @@ impl Category {
}
/// Model for testing model with \"_class\" property
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ClassModel {
#[serde(rename = "_class")]
@ -1551,6 +1562,7 @@ pub struct ClassModel {
}
impl ClassModel {
#[allow(clippy::new_without_default)]
pub fn new() -> ClassModel {
@ -1674,7 +1686,7 @@ impl ClassModel {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Client {
#[serde(rename = "client")]
@ -1683,6 +1695,7 @@ pub struct Client {
}
impl Client {
#[allow(clippy::new_without_default)]
pub fn new() -> Client {
@ -1806,7 +1819,7 @@ impl Client {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct Dog {
#[serde(rename = "className")]
@ -1822,6 +1835,7 @@ pub struct Dog {
}
impl Dog {
#[allow(clippy::new_without_default)]
pub fn new(class_name: String, ) -> Dog {
@ -1967,7 +1981,7 @@ impl Dog {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "$special[model.name]")]
pub struct DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket {
@ -1977,6 +1991,7 @@ pub struct DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket {
}
impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket {
#[allow(clippy::new_without_default)]
pub fn new() -> DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket {
@ -2100,7 +2115,7 @@ impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct EnumArrays {
// Note: inline enums are not fully supported by openapi-generator
@ -2120,6 +2135,7 @@ pub struct EnumArrays {
}
impl EnumArrays {
#[allow(clippy::new_without_default)]
pub fn new() -> EnumArrays {
@ -2309,7 +2325,7 @@ impl EnumClass {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct EnumTest {
// Note: inline enums are not fully supported by openapi-generator
@ -2337,6 +2353,7 @@ pub struct EnumTest {
}
impl EnumTest {
#[allow(clippy::new_without_default)]
pub fn new(enum_string_required: String, ) -> EnumTest {
@ -2502,14 +2519,20 @@ impl EnumTest {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct FormatTest {
#[serde(rename = "integer")]
#[validate(
range(min = 10, max = 100),
)]
#[serde(skip_serializing_if="Option::is_none")]
pub integer: Option<u8>,
#[serde(rename = "int32")]
#[validate(
range(min = 20, max = 200),
)]
#[serde(skip_serializing_if="Option::is_none")]
pub int32: Option<u32>,
@ -2518,21 +2541,36 @@ pub struct FormatTest {
pub int64: Option<i64>,
#[serde(rename = "number")]
#[validate(
range(min = 32.1, max = 543.2),
)]
pub number: f64,
#[serde(rename = "float")]
#[validate(
range(min = 54.3, max = 987.6),
)]
#[serde(skip_serializing_if="Option::is_none")]
pub float: Option<f32>,
#[serde(rename = "double")]
#[validate(
range(min = 67.8, max = 123.4),
)]
#[serde(skip_serializing_if="Option::is_none")]
pub double: Option<f64>,
#[serde(rename = "string")]
#[validate(
regex = "RE_FORMATTEST_STRING",
)]
#[serde(skip_serializing_if="Option::is_none")]
pub string: Option<String>,
#[serde(rename = "byte")]
#[validate(
custom ="validate_byte_formattest_byte"
)]
pub byte: swagger::ByteArray,
#[serde(rename = "binary")]
@ -2551,10 +2589,28 @@ pub struct FormatTest {
pub uuid: Option<uuid::Uuid>,
#[serde(rename = "password")]
#[validate(
length(min = 10, max = 64),
)]
pub password: String,
}
lazy_static::lazy_static! {
static ref RE_FORMATTEST_STRING: regex::Regex = regex::Regex::new(r"/[a-z]/i").unwrap();
}
lazy_static::lazy_static! {
static ref RE_FORMATTEST_BYTE: regex::bytes::Regex = regex::bytes::Regex::new(r"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}&#x3D;&#x3D;|[A-Za-z0-9+/]{3}&#x3D;)?$").unwrap();
}
fn validate_byte_formattest_byte(
b: &swagger::ByteArray
) -> Result<(), validator::ValidationError> {
if !RE_FORMATTEST_BYTE.is_match(b) {
return Err(validator::ValidationError::new("Character not allowed"));
}
Ok(())
}
impl FormatTest {
#[allow(clippy::new_without_default)]
pub fn new(number: f64, byte: swagger::ByteArray, date: chrono::DateTime::<chrono::Utc>, password: String, ) -> FormatTest {
@ -2796,7 +2852,7 @@ impl FormatTest {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct HasOnlyReadOnly {
#[serde(rename = "bar")]
@ -2809,6 +2865,7 @@ pub struct HasOnlyReadOnly {
}
impl HasOnlyReadOnly {
#[allow(clippy::new_without_default)]
pub fn new() -> HasOnlyReadOnly {
@ -2945,7 +3002,7 @@ impl HasOnlyReadOnly {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct List {
#[serde(rename = "123-list")]
@ -2954,6 +3011,7 @@ pub struct List {
}
impl List {
#[allow(clippy::new_without_default)]
pub fn new() -> List {
@ -3077,7 +3135,7 @@ impl List {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MapTest {
#[serde(rename = "map_map_of_string")]
@ -3096,6 +3154,7 @@ pub struct MapTest {
}
impl MapTest {
#[allow(clippy::new_without_default)]
pub fn new() -> MapTest {
@ -3226,7 +3285,7 @@ impl MapTest {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct MixedPropertiesAndAdditionalPropertiesClass {
#[serde(rename = "uuid")]
@ -3243,6 +3302,7 @@ pub struct MixedPropertiesAndAdditionalPropertiesClass {
}
impl MixedPropertiesAndAdditionalPropertiesClass {
#[allow(clippy::new_without_default)]
pub fn new() -> MixedPropertiesAndAdditionalPropertiesClass {
@ -3375,7 +3435,7 @@ impl MixedPropertiesAndAdditionalPropertiesClass {
}
/// Model for testing model name starting with number
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Name")]
pub struct Model200Response {
@ -3389,6 +3449,7 @@ pub struct Model200Response {
}
impl Model200Response {
#[allow(clippy::new_without_default)]
pub fn new() -> Model200Response {
@ -3526,7 +3587,7 @@ impl Model200Response {
}
/// Model for testing model name same as property name
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Name")]
pub struct Name {
@ -3547,6 +3608,7 @@ pub struct Name {
}
impl Name {
#[allow(clippy::new_without_default)]
pub fn new(name: i32, ) -> Name {
@ -3705,7 +3767,7 @@ impl Name {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct NumberOnly {
#[serde(rename = "JustNumber")]
@ -3714,6 +3776,7 @@ pub struct NumberOnly {
}
impl NumberOnly {
#[allow(clippy::new_without_default)]
pub fn new() -> NumberOnly {
@ -3837,7 +3900,7 @@ impl NumberOnly {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectContainingObjectWithOnlyAdditionalProperties {
#[serde(rename = "inner")]
@ -3846,6 +3909,7 @@ pub struct ObjectContainingObjectWithOnlyAdditionalProperties {
}
impl ObjectContainingObjectWithOnlyAdditionalProperties {
#[allow(clippy::new_without_default)]
pub fn new() -> ObjectContainingObjectWithOnlyAdditionalProperties {
@ -4022,7 +4086,7 @@ impl ObjectWithOnlyAdditionalProperties {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Order")]
pub struct Order {
@ -4054,6 +4118,7 @@ pub struct Order {
}
impl Order {
#[allow(clippy::new_without_default)]
pub fn new() -> Order {
@ -4275,7 +4340,7 @@ impl OuterBoolean {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct OuterComposite {
#[serde(rename = "my_number")]
@ -4292,6 +4357,7 @@ pub struct OuterComposite {
}
impl OuterComposite {
#[allow(clippy::new_without_default)]
pub fn new() -> OuterComposite {
@ -4580,7 +4646,7 @@ impl OuterString {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Pet")]
pub struct Pet {
@ -4610,6 +4676,7 @@ pub struct Pet {
}
impl Pet {
#[allow(clippy::new_without_default)]
pub fn new(name: String, photo_urls: Vec<String>, ) -> Pet {
@ -4776,7 +4843,7 @@ impl Pet {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ReadOnlyFirst {
#[serde(rename = "bar")]
@ -4789,6 +4856,7 @@ pub struct ReadOnlyFirst {
}
impl ReadOnlyFirst {
#[allow(clippy::new_without_default)]
pub fn new() -> ReadOnlyFirst {
@ -4926,7 +4994,7 @@ impl ReadOnlyFirst {
}
/// Model for testing reserved words
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Return")]
pub struct Return {
@ -4936,6 +5004,7 @@ pub struct Return {
}
impl Return {
#[allow(clippy::new_without_default)]
pub fn new() -> Return {
@ -5059,7 +5128,7 @@ impl Return {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "Tag")]
pub struct Tag {
@ -5073,6 +5142,7 @@ pub struct Tag {
}
impl Tag {
#[allow(clippy::new_without_default)]
pub fn new() -> Tag {
@ -5209,7 +5279,7 @@ impl Tag {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[serde(rename = "User")]
pub struct User {
@ -5248,6 +5318,7 @@ pub struct User {
}
impl User {
#[allow(clippy::new_without_default)]
pub fn new() -> User {

View File

@ -36,6 +36,7 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
# Crates included if required by the API definition

View File

@ -1,5 +1,7 @@
#![allow(unused_qualifications)]
use validator::Validate;
use crate::models;
#[cfg(any(feature = "client", feature = "server"))]
use crate::header;

View File

@ -36,6 +36,7 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
# Crates included if required by the API definition

View File

@ -1,10 +1,12 @@
#![allow(unused_qualifications)]
use validator::Validate;
use crate::models;
#[cfg(any(feature = "client", feature = "server"))]
use crate::header;
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ANullableContainer {
#[serde(rename = "NullableThing")]
@ -18,6 +20,7 @@ pub struct ANullableContainer {
}
impl ANullableContainer {
#[allow(clippy::new_without_default)]
pub fn new(required_nullable_thing: swagger::Nullable<String>, ) -> ANullableContainer {
@ -190,7 +193,7 @@ impl ::std::str::FromStr for AdditionalPropertiesObject {
}
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct AllOfObject {
#[serde(rename = "sampleProperty")]
@ -203,6 +206,7 @@ pub struct AllOfObject {
}
impl AllOfObject {
#[allow(clippy::new_without_default)]
pub fn new() -> AllOfObject {
@ -330,7 +334,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct BaseAllOf {
#[serde(rename = "sampleBaseProperty")]
@ -339,6 +343,7 @@ pub struct BaseAllOf {
}
impl BaseAllOf {
#[allow(clippy::new_without_default)]
pub fn new() -> BaseAllOf {
@ -453,7 +458,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct DummyPutRequest {
#[serde(rename = "id")]
@ -465,6 +470,7 @@ pub struct DummyPutRequest {
}
impl DummyPutRequest {
#[allow(clippy::new_without_default)]
pub fn new(id: String, ) -> DummyPutRequest {
@ -589,7 +595,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal
/// structured response
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct GetYamlResponse {
/// Inner string
@ -599,6 +605,7 @@ pub struct GetYamlResponse {
}
impl GetYamlResponse {
#[allow(clippy::new_without_default)]
pub fn new() -> GetYamlResponse {
@ -714,7 +721,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal
/// An object of objects
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectOfObjects {
#[serde(rename = "inner")]
@ -723,6 +730,7 @@ pub struct ObjectOfObjects {
}
impl ObjectOfObjects {
#[allow(clippy::new_without_default)]
pub fn new() -> ObjectOfObjects {
@ -831,7 +839,7 @@ impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderVal
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
pub struct ObjectOfObjectsInner {
#[serde(rename = "required_thing")]
@ -843,6 +851,7 @@ pub struct ObjectOfObjectsInner {
}
impl ObjectOfObjectsInner {
#[allow(clippy::new_without_default)]
pub fn new(required_thing: String, ) -> ObjectOfObjectsInner {