-
Notifications
You must be signed in to change notification settings - Fork 39
Required nullable fields generate non-nullable types #135
Copy link
Copy link
Open
Description
Using openapi-python-generator 2.1.2 with OpenAPI 3.1, a required property declared like this:
description:
type:
- string
- 'null'is generated as str rather than Optional[str] / str | None.
Current behavior:
- required + nullable field -> non-nullable Python type
- non-required + nullable field -> nullable Python type
This is a bug because required only means the field must be present in the payload. It does not mean the value cannot be null. For a required nullable schema, the generated Python type should still accept None; otherwise the generated Pydantic models reject valid API responses containing null.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels