Skip to content

null converts to Any #52

Closed
Closed
@jessemyers-lettuce

Description

@jessemyers-lettuce

OpenAPI type null is converted to Python type Any, most likely here:

    elif schema.type is None or schema.type == "null":
        converted_type = pre_type + "Any" + post_type

In Fast API (probably among other sources), Foo | None is expressed as:

"anyOf": [
      {
        "$ref": "#/components/schemas/Foo"
      },
      {
        "type": "null"
      }
    ]

because of this issue, we end up with a generated type that uses Union[Foo | Any] instead of Union[Foo | None]

If this is intentional, I'd love to understand why so I can create a fix that doesn't break some implicit, non-obvious behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions