Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions internal/util/gemini_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ func removeUnsupportedKeywords(jsonStr string) string {
"$schema", "$defs", "definitions", "const", "$ref", "$id", "additionalProperties",
"propertyNames", "patternProperties", // Gemini doesn't support these schema keywords
"enumTitles", "prefill", // Claude/OpenCode schema metadata fields unsupported by Gemini
"deprecated", // JSON Schema keyword not supported by Gemini API

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change correctly adds deprecated to the list of unsupported keywords. To ensure this fix is robust and prevent future regressions, it would be great to add a test case that verifies the deprecated keyword is stripped.

You could add the following test to internal/util/gemini_schema_test.go:

func TestCleanJSONSchemaForGemini_RemovesDeprecatedField(t *testing.T) {
	input := `{
		"type": "object",
		"properties": {
			"old_field": {
				"type": "string",
				"deprecated": true
			}
		}
	}`

	expected := `{
		"type": "object",
		"properties": {
			"old_field": {
				"type": "string"
			}
		}
	}`

	result := CleanJSONSchemaForGemini(input)
	compareJSON(t, expected, result)
}

)

deletePaths := make([]string, 0)
Expand Down
32 changes: 32 additions & 0 deletions internal/util/gemini_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,38 @@ func TestCleanJSONSchemaForGemini_RemovesGeminiUnsupportedMetadataFields(t *test
compareJSON(t, expected, result)
}

func TestCleanJSONSchemaForGemini_RemovesDeprecatedField(t *testing.T) {
input := `{
"type": "object",
"properties": {
"old_field": {
"type": "string",
"deprecated": true
},
"deprecated": {
"type": "string",
"description": "property named deprecated should not be removed"
}
}
}`

expected := `{
"type": "object",
"properties": {
"old_field": {
"type": "string"
},
"deprecated": {
"type": "string",
"description": "property named deprecated should not be removed"
}
}
}`

result := CleanJSONSchemaForGemini(input)
compareJSON(t, expected, result)
}

func TestRemoveExtensionFields(t *testing.T) {
tests := []struct {
name string
Expand Down