Merge ef0cc252cb7ef50c3021c806e5617ec120d3f96a into 935817c66f5d6e64838f419692545f06787e485f

This commit is contained in:
Afloat 2026-10-20 21:45:50 +08:00 committed by GitHub
commit 4419e4436a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,7 +28,7 @@ pub(crate) enum JsonSchema {
#[serde(rename_all = "camelCase")]
#[untagged_deserialize(field = "anyOf")]
AnyOf {
any_of: Vec<JsonSchemaType>,
any_of: Vec<JsonSchema>,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
},
@ -364,3 +364,19 @@ mod tests {
);
}
}
#[cfg(test)]
mod contribution_regression {
use super::*;
#[test]
fn anyof_accepts_references_and_nested_unions() {
let input = serde_json::json!({"type":"object","properties":{"value":{"anyOf":[{"$ref":"#/properties/base"},{"anyOf":[{"type":"string"},{"type":"null"}]}]},"base":{"type":"integer"}}});
let result = normalize_strict_schema(input, true, |e| e.to_string(), "root").unwrap();
assert_eq!(
result["properties"]["value"]["anyOf"][0]["$ref"],
"#/properties/base"
);
assert!(validate_schema(&result).is_ok());
}
}