From d1ea81e3fc30bc4c8892b56bfaea976dbd8e5f27 Mon Sep 17 00:00:00 2001 From: "Adam H. Leventhal" Date: Thu, 14 Aug 2025 14:57:58 -0700 Subject: [PATCH] Allow `not` subschemas Initiailly we didn't handle `not` constructions... mostly because we weren't sure about how they might come up, but also because we didn't have experience knowing how to interpret their meaning. Now they are coming up **and** we understand them well enough to treat them like other subschemas (i.e. "anyOf", "oneOf", "allOf"). --- Cargo.toml | 2 +- src/lib.rs | 4 +++- src/tests/errors.json | 10 +++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1c5bc6a..9bad71d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ categories = ["web-programming::http-server"] heck = "0.4.0" indexmap = "2.0.0" lazy_static = "1.4.0" -openapiv3 = "2.0.0-rc.1" +openapiv3 = "2.0.0" regex = "1.7.3" [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index 30bab8e..3fb5409 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -136,7 +136,9 @@ impl Validator { self.subschemas(spec, subschema.item(&spec.components).unwrap()) }) .collect(), - openapiv3::SchemaKind::Not { .. } => todo!("'not' subschemas aren't handled"), + openapiv3::SchemaKind::Not { not } => { + self.subschemas(spec, not.item(&spec.components).unwrap()) + } openapiv3::SchemaKind::Type(t) => vec![t], openapiv3::SchemaKind::Any(any) if is_permissive(any) => vec![], openapiv3::SchemaKind::Any(any) => todo!("complex 'any' schema not handled {:#?}", any), diff --git a/src/tests/errors.json b/src/tests/errors.json index 79e0594..64a1294 100644 --- a/src/tests/errors.json +++ b/src/tests/errors.json @@ -1802,7 +1802,15 @@ "required": [ "my_uuid" ] + }, + "Marker": { + "not": {}, + "x-rust-type": { + "crate": "my-crate", + "path": "my_crate::types::MyKind", + "version": "1.0.0" + } } } } -} \ No newline at end of file +}