Skip to content

refactor: unify object-schema conversion through _object_schema_to_type#3884

Merged
jlowin merged 1 commit intomainfrom
refactor/unify-object-schema-to-type-3882
Apr 13, 2026
Merged

refactor: unify object-schema conversion through _object_schema_to_type#3884
jlowin merged 1 commit intomainfrom
refactor/unify-object-schema-to-type-3882

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Apr 13, 2026

#3880 fixed the nested list[dict]Root() bug by adding _object_schema_to_type and wiring it into the recursive _get_from_type_handler. The top-level json_schema_to_type entry point and the anyOf dict-in-union branch continued to carry their own hand-rolled copies of the same four-case object-schema logic. That was the divergence risk that produced the original bug, and leaving two copies around means the next change to object-schema handling has to remember to touch three sites.

This PR collapses all three sites into the existing helper. The top-level branch becomes a single call (passing name through so explicit top-level names still override schema.get("title")), and the anyOf special case is deleted outright — _schema_to_type already routes object subschemas through the helper, so the hand-rolled dict-in-union handling is now redundant. No behavior change, verified by the existing 863-test suite including the 229K real-world schema fuzz (same 279-baseline SchemaError count, zero crashes introduced).

# Before: three near-duplicates of the four-case logic
# After: one helper, called from both entry points

if schema.get("type") == "object":
    return _object_schema_to_type(schema, schemas=schema, name=name)

Closes #3882.

@jlowin jlowin added the enhancement Improvement to existing functionality. For issues and smaller PR improvements. label Apr 13, 2026
@marvin-context-protocol marvin-context-protocol Bot added the openapi Related to OpenAPI integration, parsing, or code generation features. label Apr 13, 2026
@jlowin jlowin merged commit 0a921f5 into main Apr 13, 2026
10 checks passed
@jlowin jlowin deleted the refactor/unify-object-schema-to-type-3882 branch April 13, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement to existing functionality. For issues and smaller PR improvements. openapi Related to OpenAPI integration, parsing, or code generation features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Route top-level and anyOf object-schema logic through _object_schema_to_type

1 participant