mirror of
https://github.com/deepseek-ai/deepseek-recipe.git
synced 2026-10-28 17:17:08 +08:00
Preserve JSON numeric bounds in strict integer schemas
This commit is contained in:
parent
935817c66f
commit
265ebd5f06
@ -103,19 +103,19 @@ pub(crate) enum JsonSchemaType {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
description: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
r#const: Option<i64>,
|
||||
r#const: Option<serde_json::Number>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
default: Option<i64>,
|
||||
default: Option<serde_json::Number>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
minimum: Option<i64>,
|
||||
minimum: Option<serde_json::Number>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
maximum: Option<i64>,
|
||||
maximum: Option<serde_json::Number>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
exclusive_minimum: Option<i64>,
|
||||
exclusive_minimum: Option<serde_json::Number>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
exclusive_maximum: Option<i64>,
|
||||
exclusive_maximum: Option<serde_json::Number>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
multiple_of: Option<i64>,
|
||||
multiple_of: Option<serde_json::Number>,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
Boolean {
|
||||
@ -364,3 +364,27 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod contribution_regression {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn integer_bounds_can_be_fractional_or_unsigned() {
|
||||
for bounds in [
|
||||
serde_json::json!({"minimum":0.5,"maximum":10.5}),
|
||||
serde_json::json!({"maximum":18446744073709551615u64}),
|
||||
] {
|
||||
let mut property = bounds;
|
||||
property["type"] = serde_json::json!("integer");
|
||||
let result = normalize_strict_schema(
|
||||
serde_json::json!({"type":"object","properties":{"n":property.clone()}}),
|
||||
true,
|
||||
|e| e.to_string(),
|
||||
"root",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(result["properties"]["n"], property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user