Skip to content

Commit abdae8f

Browse files
committed
Support OpenAPI version 3.1.x on input
https://spec.openapis.org/oas/v3.1.1.html#versions is clear that tools SHOULD ignore the patch version.
1 parent 14fff1e commit abdae8f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

crates/aide/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! See the [examples](https://github.com/tamasfe/aide/tree/master/examples)
1212
//! to see how Aide is used with various frameworks.
1313
//!
14-
//! Currently only Open API version `3.1.0` is supported.
14+
//! Currently only Open API version `3.1.x` is supported.
1515
//!
1616
//! Previous releases of aide relied heavily on macros, and the
1717
//! [`linkme`](https://docs.rs/linkme/latest/linkme/) crate for automagic global state.

crates/aide/src/openapi/openapi.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,13 @@ mod serde_version {
112112
pub(super) fn deserialize<'de, D: Deserializer<'de>>(
113113
de: D,
114114
) -> Result<Cow<'static, str>, D::Error> {
115-
<&'de str>::deserialize(de).and_then(|s| match s == "3.1.0" {
116-
true => Ok(Cow::Owned("3.1.0".to_owned())),
117-
false => Err(serde::de::Error::custom("expected 3.1.0")),
115+
// Accept any patch version of 3.1.x.
116+
<&'de str>::deserialize(de).and_then(|s| {
117+
if s.starts_with("3.1.") {
118+
Ok(Cow::Owned("3.1.0".to_owned()))
119+
} else {
120+
Err(serde::de::Error::custom("expected 3.1.x"))
121+
}
118122
})
119123
}
120124
}

0 commit comments

Comments
 (0)