GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Enum properties with nullable: true don't handle null values · Issue #1405 · openapi-generators/openapi-python-client Open DescriptionDescriptionWhen an OpenAPI schema defines an enum property with OpenAPI Schemaconditionable_type: type: string enum: - AlertField nullable: true Expected BehaviorPer OpenAPI v3.0.3 spec:
The generated code should accept Actual BehaviorThe generated Generated Code (v0.28.2)_conditionable_type = d.pop("conditionable_type", UNSET) conditionable_type: SomeEnumType | Unset # Missing `| None` if isinstance(_conditionable_type, Unset): conditionable_type = UNSET else: # Passes None directly to check function - FAILS conditionable_type = check_some_enum_type(_conditionable_type) Expected Generated CodeShould be similar to how nullable string properties are handled: def _parse_conditionable_type(data: object) -> SomeEnumType | None | Unset: if data is None: return data if isinstance(data, Unset): return data return check_some_enum_type(data) conditionable_type = _parse_conditionable_type(d.pop("conditionable_type", UNSET)) Root CauseThe unchecked_value_list = [value for value in enum if value is not None] It does not check for Related Issues
Both are valid per OpenAPI spec, but only the first case is currently handled. ReproductionMinimal OpenAPI spec: openapi: "3.0.3" info: title: Test version: "1.0" paths: {} components: schemas: TestModel: type: object properties: my_enum: type: string enum: - value1 nullable: true Generate client, then: from my_client.models import TestModel TestModel.from_dict({"my_enum": None}) # Raises TypeError Version
Reacted by Brandon Mills and Jean Beuselinck Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |