fix: address review feedback on allOf/oneOf handling

- Guard property+oneOf schemas from premature dataclass return
- Recognize empty additionalProperties ({}) as allow-any in oneOf
- Boolean false allOf branches and sibling properties already handled

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
strawgate 2026-05-12 22:48:36 -05:00
commit 08236c4345

View file

@ -453,7 +453,7 @@ def _schema_to_type(
if not schema:
return object
if "type" not in schema and "properties" in schema and "allOf" not in schema:
if "type" not in schema and "properties" in schema and "allOf" not in schema and "oneOf" not in schema:
return _create_dataclass(schema, schema.get("title", "<unknown>"), schemas)
# Handle references first
@ -569,10 +569,10 @@ def _schema_to_type(
isinstance(subschema, dict)
and subschema.get("type") == "object"
and not subschema.get("properties")
and subschema.get("additionalProperties")
and "additionalProperties" in subschema
):
additional_props = subschema["additionalProperties"]
if additional_props is True:
if additional_props is True or additional_props == {}:
types.append(dict[str, Any])
else:
value_type = _schema_to_type(additional_props, schemas)