Skip to content

Boolean headers improperly handeled by _get_kwargs #552

Closed
@John98Zakaria

Description

@John98Zakaria

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions