Skip to content

Boolean headers improperly handeled by _get_kwargs #552

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

Closed
John98Zakaria opened this issue Dec 20, 2021 · 0 comments · Fixed by #566
Closed

Boolean headers improperly handeled by _get_kwargs #552

John98Zakaria opened this issue Dec 20, 2021 · 0 comments · Fixed by #566
Labels
🐞bug Something isn't working

Comments

@John98Zakaria
Copy link
Contributor

Describe the bug
Httpx expects headers to be of the following type

HeaderTypes = Union[
    "Headers",
    Dict[str, str],
    Dict[bytes, bytes],
    Sequence[Tuple[str, str]],
    Sequence[Tuple[bytes, bytes]],
]

However _get_kwargs doesn't properly convert the boolean to a string/byte representaion in order for httpx to safely consume them.
Instead they are passed as is.
Resuling in an AttributeError: 'bool' object has no attribute 'encode'
To Reproduce
1- Generate the python client from the openapi spec.
2- Invoke this simple request

import fast_api_client.api.default.echo_model_failing_bool_post as data_provider
from fast_api_client import Client
from fast_api_client.models import SomeModel

client = Client("http://localhost:8000")

r = data_provider.sync(json_body=SomeModel("adsa", 4, True), client=client, boolean_header=True)
print(r)

Expected behavior
A sucessfull resposone.

OpenAPI Spec File
boolean_openapi_header.txt

Desktop (please complete the following information):

  • OS: [e.g. macOS 10.15.1]
  • Python Version: 3.9.7
  • openapi-python-client version 0.10.8
@John98Zakaria John98Zakaria added the 🐞bug Something isn't working label Dec 20, 2021
dbanty added a commit that referenced this issue Jan 18, 2022
Closes #552.

BREAKING CHANGE: Header values will be explicitly transformed or omitted instead of blindly passed to httpx as-is.

Co-authored-by: John Sorial <[email protected]>
Co-authored-by: dbanty <[email protected]>
dbanty added a commit that referenced this issue Jan 18, 2022
Closes #552.

BREAKING CHANGE: Header values will be explicitly transformed or omitted instead of blindly passed to httpx as-is.

Co-authored-by: John Sorial <[email protected]>
Co-authored-by: dbanty <[email protected]>
dbanty added a commit that referenced this issue Jan 18, 2022
Closes #552.

BREAKING CHANGE: Header values will be explicitly transformed or omitted instead of blindly passed to httpx as-is.

Co-authored-by: John Sorial <[email protected]>
Co-authored-by: dbanty <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞bug Something isn't working
Projects
None yet
1 participant