1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
use crate::*;
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct SchemaData {
#[serde(default, skip_serializing_if = "is_false")]
pub nullable: bool,
#[serde(default, skip_serializing_if = "is_false")]
pub read_only: bool,
#[serde(default, skip_serializing_if = "is_false")]
pub write_only: bool,
#[serde(default, skip_serializing_if = "is_false")]
pub deprecated: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub external_docs: Option<ExternalDocumentation>,
#[serde(skip_serializing_if = "Option::is_none")]
pub example: Option<serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub discriminator: Option<Discriminator>,
#[serde(skip_serializing_if = "Option::is_none")]
pub default: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Schema {
#[serde(flatten)]
pub schema_data: SchemaData,
#[serde(flatten)]
pub schema_kind: SchemaKind,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum SchemaKind {
Type(Type),
OneOf {
#[serde(rename = "oneOf")]
one_of: Vec<ReferenceOr<Schema>>,
},
AllOf {
#[serde(rename = "allOf")]
all_of: Vec<ReferenceOr<Schema>>,
},
AnyOf {
#[serde(rename = "anyOf")]
any_of: Vec<ReferenceOr<Schema>>,
},
Any(AnySchema),
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum Type {
String(StringType),
Number(NumberType),
Integer(IntegerType),
Object(ObjectType),
Array(ArrayType),
Boolean {},
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum AdditionalProperties {
Any(bool),
Schema(Box<ReferenceOr<Schema>>),
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct AnySchema {
#[serde(skip_serializing_if = "Option::is_none")]
pub pattern: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub multiple_of: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub exclusive_minimum: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub exclusive_maximum: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub maximum: Option<f64>,
#[serde(default, skip_serializing_if = "IndexMap::is_empty")]
pub properties: IndexMap<String, ReferenceOr<Box<Schema>>>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub required: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub additional_properties: Option<AdditionalProperties>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_properties: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_properties: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
pub items: Option<ReferenceOr<Box<Schema>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_items: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_items: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unique_items: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct StringType {
#[serde(default, skip_serializing_if = "VariantOrUnknownOrEmpty::is_empty")]
pub format: VariantOrUnknownOrEmpty<StringFormat>,
#[serde(skip_serializing_if = "Option::is_none")]
pub pattern: Option<String>,
#[serde(rename = "enum", default, skip_serializing_if = "Vec::is_empty")]
pub enumeration: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_length: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_length: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct NumberType {
#[serde(default, skip_serializing_if = "VariantOrUnknownOrEmpty::is_empty")]
pub format: VariantOrUnknownOrEmpty<NumberFormat>,
#[serde(skip_serializing_if = "Option::is_none")]
pub multiple_of: Option<f64>,
#[serde(default, skip_serializing_if = "is_false")]
pub exclusive_minimum: bool,
#[serde(default, skip_serializing_if = "is_false")]
pub exclusive_maximum: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub maximum: Option<f64>,
#[serde(rename = "enum", default, skip_serializing_if = "Vec::is_empty")]
pub enumeration: Vec<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct IntegerType {
#[serde(default, skip_serializing_if = "VariantOrUnknownOrEmpty::is_empty")]
pub format: VariantOrUnknownOrEmpty<IntegerFormat>,
#[serde(skip_serializing_if = "Option::is_none")]
pub multiple_of: Option<i64>,
#[serde(default, skip_serializing_if = "is_false")]
pub exclusive_minimum: bool,
#[serde(default, skip_serializing_if = "is_false")]
pub exclusive_maximum: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub maximum: Option<i64>,
#[serde(rename = "enum", default, skip_serializing_if = "Vec::is_empty")]
pub enumeration: Vec<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ObjectType {
#[serde(default, skip_serializing_if = "IndexMap::is_empty")]
pub properties: IndexMap<String, ReferenceOr<Box<Schema>>>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub required: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub additional_properties: Option<AdditionalProperties>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_properties: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_properties: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ArrayType {
pub items: ReferenceOr<Box<Schema>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_items: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_items: Option<usize>,
#[serde(default, skip_serializing_if = "is_false")]
pub unique_items: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum NumberFormat {
Float,
Double,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum IntegerFormat {
Int32,
Int64,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum StringFormat {
Date,
#[serde(rename = "date-time")]
DateTime,
Password,
Byte,
Binary,
}