mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
ADK changes
PiperOrigin-RevId: 813321782
This commit is contained in:
committed by
Copybara-Service
parent
c51ea0b52e
commit
a239716930
@@ -224,6 +224,64 @@ class TestToGeminiSchema:
|
||||
assert gemini_schema.type == Type.STRING
|
||||
assert not gemini_schema.format
|
||||
|
||||
def test_to_gemini_schema_nested_dict_with_defs_and_ref(self):
|
||||
"""Test that nested dict with $defs and $refs is converted correctly."""
|
||||
openapi_schema = {
|
||||
"$defs": {
|
||||
"DeviceEnum": {
|
||||
"enum": ["GLOBAL", "desktop", "mobile"],
|
||||
"title": "DeviceEnum",
|
||||
"type": "string",
|
||||
},
|
||||
"DomainPayload": {
|
||||
"properties": {
|
||||
"adDomain": {
|
||||
"description": "List of one or many domains.",
|
||||
"items": {"type": "string"},
|
||||
"title": "Addomain",
|
||||
"type": "array",
|
||||
},
|
||||
"device": {
|
||||
"$ref": "#/$defs/DeviceEnum",
|
||||
"default": "GLOBAL",
|
||||
"description": (
|
||||
"Filter by device. All devices are returned by"
|
||||
" default."
|
||||
),
|
||||
},
|
||||
},
|
||||
"required": ["adDomain"],
|
||||
"title": "DomainPayload",
|
||||
"type": "object",
|
||||
},
|
||||
},
|
||||
"properties": {"payload": {"$ref": "#/$defs/DomainPayload"}},
|
||||
"required": ["payload"],
|
||||
"title": "query_domainsArguments",
|
||||
"type": "object",
|
||||
}
|
||||
gemini_schema = _to_gemini_schema(openapi_schema)
|
||||
assert gemini_schema.type == Type.OBJECT
|
||||
assert gemini_schema.properties["payload"].type == Type.OBJECT
|
||||
assert (
|
||||
gemini_schema.properties["payload"].properties["adDomain"].type
|
||||
== Type.ARRAY
|
||||
)
|
||||
assert (
|
||||
gemini_schema.properties["payload"].properties["adDomain"].items.type
|
||||
== Type.STRING
|
||||
)
|
||||
assert (
|
||||
gemini_schema.properties["payload"].properties["device"].type
|
||||
== Type.STRING
|
||||
)
|
||||
assert gemini_schema.properties["payload"].properties["device"].enum == [
|
||||
"GLOBAL",
|
||||
"desktop",
|
||||
"mobile",
|
||||
]
|
||||
assert gemini_schema.properties["payload"].required == ["adDomain"]
|
||||
|
||||
def test_sanitize_integer_formats(self):
|
||||
"""Test that int32 and int64 formats are preserved for integer types"""
|
||||
openapi_schema = {
|
||||
|
||||
Reference in New Issue
Block a user