From cc556c720168806baff8beda0f293e1b13817ccd Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 4 Nov 2026 13:05:51 +0000 Subject: [PATCH 1/2] :bug: fix union schema missing allof --- codegen/parser/schemas/union_schema.py | 19 ++++++++++++------- pyproject.toml | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/codegen/parser/schemas/union_schema.py b/codegen/parser/schemas/union_schema.py index 592f0f2808..1419081d5b 100644 --- a/codegen/parser/schemas/union_schema.py +++ b/codegen/parser/schemas/union_schema.py @@ -89,12 +89,13 @@ def build_union_schema( ) types = data.type or (base_schema and base_schema.type) + can_be_object = bool(data.properties or data.allOf) if isinstance(types, list): for type in types: if type not in TYPES_MAP: continue - types = TYPES_MAP[type] - if any(isinstance(shema, types) for shema in schemas): + schema_types = TYPES_MAP[type] + if any(isinstance(schema, schema_types) for schema in schemas): continue if type == "null": schemas.append(build_none_schema(source)) @@ -109,11 +110,15 @@ def build_union_schema( elif type == "array": schemas.append(build_list_schema(source, class_name, base_source)) elif type == "object": - schema = build_model_schema( - source, class_name, base_source, prestore_schema=False - ) - add_schema((source / "union_object").uri, schema) - schemas.append(schema) + can_be_object = True + + # build the object schema finally + if can_be_object: + schema = build_model_schema( + source, class_name, base_source, prestore_schema=False + ) + add_schema((source / "union_object").uri, schema) + schemas.append(schema) if not schemas: return AnySchema( diff --git a/pyproject.toml b/pyproject.toml index 2947215b6f..3992a24c75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -139,6 +139,7 @@ ignore = [ "RUF002", # ambiguous-unicode-character-docstring "RUF003", # ambiguous-unicode-character-comment ] +extend-safe-fixes = ["RUF036"] [tool.ruff.lint.per-file-ignores] "packages/githubkit-schemas-**/**" = ["E501", "PYI016", "TID", "UP007"] From deb598c45dcc23e4eeeea0280c90d177e91dd15a Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 4 Nov 2026 13:10:41 +0000 Subject: [PATCH 2/2] :bug: can not be object when anyof or oneof --- codegen/parser/schemas/union_schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codegen/parser/schemas/union_schema.py b/codegen/parser/schemas/union_schema.py index 1419081d5b..bcfb095030 100644 --- a/codegen/parser/schemas/union_schema.py +++ b/codegen/parser/schemas/union_schema.py @@ -89,7 +89,9 @@ def build_union_schema( ) types = data.type or (base_schema and base_schema.type) - can_be_object = bool(data.properties or data.allOf) + can_be_object = bool(data.properties or data.allOf) and not bool( + data.anyOf or data.oneOf + ) if isinstance(types, list): for type in types: if type not in TYPES_MAP: