mirror of
https://github.com/deepseek-ai/deepseek-recipe.git
synced 2026-10-28 17:17:08 +08:00
Accept references and nested unions inside strict anyOf schemas
This commit is contained in:
parent
935817c66f
commit
ef0cc252cb
@ -28,7 +28,7 @@ pub(crate) enum JsonSchema {
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
#[untagged_deserialize(field = "anyOf")]
|
#[untagged_deserialize(field = "anyOf")]
|
||||||
AnyOf {
|
AnyOf {
|
||||||
any_of: Vec<JsonSchemaType>,
|
any_of: Vec<JsonSchema>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
description: Option<String>,
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user