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

feat: Change optional Open API query parameters to allow `None #40

Merged
merged 5 commits into from Jan 28, 2021

Conversation

forest-benchling
Copy link

@forest-benchling forest-benchling commented Jan 27, 2021

Fixes openapi-generators#285.
Upstream: https://github.com/triaxtec/openapi-python-client/pull/297/files

Instead of methods like

def sync_detailed(
    *,
    client: Client,
    size: Union[Unset, int] = UNSET,
) -> Response[Thing]:

we will now generate

def sync_detailed(
    *,
    client: Client,
    size: Union[Unset, None, int] = None,
) -> Response[Thing]:

and treat None the same as Unset.

This is a bit different from the original proposal in the linked issue, but if you scroll down you can see that it's what was agreed upon in the end IIUC (though I wasn't sure if we agreed on what the default value should be). In addition, it has the benefit of preserving back-compat.

As part of this issue, I also tried to collapse nested Optional and Union types, so that what was formerly Union[Unset, Optional[int]] or Optional[Union[Unset, int]] is now Union[Unset, None, int].

@forest-benchling forest-benchling merged commit 55e16f3 into main-v.0.7.3 Jan 28, 2021
@forest-benchling forest-benchling deleted the forest-optional branch January 28, 2021 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants