Skip to content
Merged
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
5 changes: 5 additions & 0 deletions src/openai/lib/_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def _ensure_strict_json_schema(
for def_name, def_schema in defs.items():
_ensure_strict_json_schema(def_schema, path=(*path, "$defs", def_name))

definitions = json_schema.get("definitions")
if is_dict(definitions):
for definition_name, definition_schema in definitions.items():
_ensure_strict_json_schema(definition_schema, path=(*path, "definitions", definition_name))

return json_schema


Expand Down
2 changes: 2 additions & 0 deletions tests/lib/test_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def test_most_types() -> None:
"type": "object",
"properties": {"column_name": {"title": "Column Name", "type": "string"}},
"required": ["column_name"],
"additionalProperties": False,
},
"Condition": {
"title": "Condition",
Expand All @@ -147,6 +148,7 @@ def test_most_types() -> None:
},
},
"required": ["column", "operator", "value"],
"additionalProperties": False,
},
"OrderBy": {
"title": "OrderBy",
Expand Down