Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions crates/forge_app/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ fn normalize_gemini_schema_subset_keywords(map: &mut serde_json::Map<String, ser
"definitions",
"deprecated",
"examples",
"propertyNames",
"title",
"unevaluatedItems",
"unevaluatedProperties",
Expand Down Expand Up @@ -610,8 +611,8 @@ fn normalize_gemini_schema_subset_keywords(map: &mut serde_json::Map<String, ser
/// The `required` array is filtered to only include fields present in
/// `properties`.
/// - **Unsupported JSON Schema metadata and references are rejected**:
/// `$schema`, `$defs`, `$ref`, `title`, and `additionalProperties` are
/// removed.
/// `$schema`, `$defs`, `$ref`, `title`, `additionalProperties`, and
/// `propertyNames` are removed.
/// - **Exclusive bounds are rejected**: `exclusiveMinimum` and
/// `exclusiveMaximum` are converted to `minimum` and `maximum` when the
/// inclusive bound is not already present.
Expand Down Expand Up @@ -1684,6 +1685,40 @@ mod tests {
);
}

#[test]
fn test_gemini_removes_property_names() {
let mut schema = json!({
"type": "object",
"properties": {
"pages": {
"type": "array",
"items": {
"type": "object",
"properties": {
"metadata": {
"type": "object",
"propertyNames": {
"pattern": "^[a-z]+$"
}
}
}
}
},
"config": {
"type": "object",
"propertyNames": {
"pattern": "^[a-z]+$"
}
}
}
});

sanitize_gemini_schema(&mut schema);

let api_request_json = serde_json::to_string(&schema).unwrap();
assert!(!api_request_json.contains("propertyNames"));
}

#[test]
fn test_gemini_converts_integer_enum_to_string() {
let mut schema = json!({
Expand Down