Skip to content

Commit 362e219

Browse files
committed
Improve OpenAPI 3.2.0 compliance
1 parent ce37ef5 commit 362e219

31 files changed

+2022
-1434
lines changed

core/src/codegen.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ fn generate_enum_body(en: &ParsedEnum) -> String {
195195
code.push_str(&format!(" #[serde(rename = \"{}\")]\n", r));
196196
}
197197

198+
if let Some(aliases) = &variant.aliases {
199+
for alias in aliases {
200+
code.push_str(&format!(" #[serde(alias = \"{}\")]\n", alias));
201+
}
202+
}
203+
198204
if let Some(ty) = &variant.ty {
199205
code.push_str(&format!(" {}({}),\n", variant.name, ty));
200206
} else {
@@ -277,12 +283,14 @@ mod tests {
277283
ty: Some("CatInfo".into()),
278284
description: None,
279285
rename: Some("cat".into()),
286+
aliases: Some(vec!["kitty".into()]),
280287
},
281288
ParsedVariant {
282289
name: "Dog".into(),
283290
ty: Some("DogInfo".into()),
284291
description: None,
285292
rename: Some("dog".into()),
293+
aliases: None,
286294
},
287295
],
288296
};
@@ -291,6 +299,7 @@ mod tests {
291299
assert!(code.contains("pub enum Pet"));
292300
assert!(code.contains("#[serde(tag = \"type\")]"));
293301
assert!(code.contains(" #[serde(rename = \"cat\")]"));
302+
assert!(code.contains(" #[serde(alias = \"kitty\")]"));
294303
assert!(code.contains(" Cat(CatInfo),"));
295304
}
296305

core/src/contract_test_generator.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,15 @@ mod tests {
166166
name: "id".into(),
167167
source: ParamSource::Path,
168168
ty: "Uuid".into(),
169+
style: None,
170+
explode: false,
171+
allow_reserved: false,
169172
}],
170173
request_body: None,
171174
security: vec![],
172175
response_type: None,
173176
kind: RouteKind::Path,
177+
callbacks: vec![],
174178
}];
175179

176180
let strategy = ActixStrategy;
@@ -204,17 +208,24 @@ mod tests {
204208
name: "q".into(),
205209
source: ParamSource::Query,
206210
ty: "String".into(),
211+
style: None,
212+
explode: false,
213+
allow_reserved: false,
207214
},
208215
crate::oas::RouteParam {
209216
name: "page".into(),
210217
source: ParamSource::Query,
211218
ty: "i32".into(),
219+
style: None,
220+
explode: false,
221+
allow_reserved: false,
212222
},
213223
],
214224
request_body: None,
215225
security: vec![],
216226
response_type: None,
217227
kind: RouteKind::Path,
228+
callbacks: vec![],
218229
}];
219230

220231
let strategy = ActixStrategy;
@@ -237,6 +248,7 @@ mod tests {
237248
security: vec![],
238249
response_type: None,
239250
kind: RouteKind::Path,
251+
callbacks: vec![],
240252
}];
241253

242254
let strategy = ActixStrategy;

0 commit comments

Comments
 (0)