Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null converts to Any #52

Closed
jessemyers-lettuce opened this issue Sep 16, 2023 · 2 comments
Closed

null converts to Any #52

jessemyers-lettuce opened this issue Sep 16, 2023 · 2 comments

Comments

@jessemyers-lettuce
Copy link
Contributor

jessemyers-lettuce commented Sep 16, 2023

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.

@jessemyers-lettuce
Copy link
Contributor Author

For my usage, the fix in #53 works.

@MarcoMuellner
Copy link
Owner

Fixed in #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants