-
-
Notifications
You must be signed in to change notification settings - Fork 61
Adds default, and various properties related to minimum and maximum #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
9f9930b
7f7a270
8cbb469
48be538
23c61f4
7271248
6efec71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,13 +158,67 @@ pub struct Operation { | |
| pub schemes: Option<Vec<String>>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub tags: Option<Vec<String>>, | ||
| #[serde(rename = "operationId")] | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub operation_id: Option<String>, | ||
| pub responses: BTreeMap<String, Response>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub parameters: Option<Vec<ParameterOrRef>>, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] | ||
| #[serde(untagged)] | ||
| pub enum PropertyDefault { | ||
| Integer(i32), | ||
| Boolean(bool), | ||
| String(String), | ||
| } | ||
|
|
||
| impl From<i32> for PropertyDefault { | ||
| fn from(item: i32) -> Self { | ||
| PropertyDefault::Integer(item) | ||
| } | ||
| } | ||
|
|
||
| impl From<bool> for PropertyDefault { | ||
| fn from(item: bool) -> Self { | ||
| PropertyDefault::Boolean(item) | ||
| } | ||
| } | ||
|
|
||
| impl From<String> for PropertyDefault { | ||
| fn from(item: String) -> Self { | ||
| PropertyDefault::String(item) | ||
| } | ||
| } | ||
|
|
||
| impl From<PropertyDefault> for i32 { | ||
| fn from(item: PropertyDefault) -> Self { | ||
| match item { | ||
| PropertyDefault::Integer(item) => item, | ||
| _ => 1, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<PropertyDefault> for bool { | ||
| fn from(item: PropertyDefault) -> Self { | ||
| match item { | ||
| PropertyDefault::Boolean(item) => item, | ||
| _ => true, | ||
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<PropertyDefault> for String { | ||
| fn from(item: PropertyDefault) -> Self { | ||
| match item { | ||
| PropertyDefault::String(item) => item, | ||
| _ => "".to_string(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub struct Parameter { | ||
|
|
@@ -184,6 +238,16 @@ pub struct Parameter { | |
| pub format: Option<String>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub description: Option<String>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| //#[serde(deserialize_with = "deserialize_default_param")] | ||
| pub default: Option<PropertyDefault>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub minimum: Option<i32>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub maximum: Option<i32>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| #[serde(rename = "enum")] | ||
| pub enum_values: Option<Vec<String>>, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)] | ||
|
|
@@ -223,17 +287,40 @@ pub enum ParameterOrRef { | |
| /// of use. GitHub Flavored Markdown is allowed. | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| description: Option<String>, | ||
| /// The default value of this parameter. | ||
| /// Deser from String because it can be any type. | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| //#[serde(deserialize_with = "deserialize_default_param")] | ||
| default: Option<PropertyDefault>, | ||
| /// The minimum valid value for this parameter. | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| minimum: Option<i32>, | ||
| /// When set to true the value of the minimum property is not part of the range | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| exclusiveMinimum: Option<bool>, | ||
| /// The maximum valid value for this parameter. | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| maximum: Option<i32>, | ||
| /// When set to true the value of the maximum property is not part of the range | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| exclusiveMaximum: Option<bool>, | ||
| /// The maximum number of characters of a String | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| maxLength: Option<i32>, | ||
| /// The minimum number of characters of a String | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| minLength: Option<i32>, | ||
| /// The maximum number of items of an array | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| maxItems: Option<i32>, | ||
| /// The minimmum number of items of an array | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| minItems: Option<i32>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| #[serde(rename = "enum")] | ||
| enum_values: Option<Vec<String>>, | ||
| // collectionFormat: ??? | ||
| // default: ??? | ||
| // maximum ? | ||
| // exclusiveMaximum ?? | ||
| // minimum ?? | ||
| // exclusiveMinimum ?? | ||
| // maxLength ?? | ||
| // minLength ?? | ||
| // pattern ?? | ||
| // maxItems ?? | ||
| // minItems ?? | ||
| // enum ?? | ||
| // multipleOf ?? | ||
| // allowEmptyValue ( for query / body params ) | ||
|
|
@@ -243,6 +330,7 @@ pub enum ParameterOrRef { | |
| ref_path: String, | ||
| }, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] | ||
| #[serde(tag = "type")] | ||
| pub enum Security { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason for these two. Newer is better I'd hope