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

body type mismatch #963

Open
Leemur89 opened this issue Feb 15, 2024 · 0 comments
Open

body type mismatch #963

Leemur89 opened this issue Feb 15, 2024 · 0 comments

Comments

@Leemur89
Copy link

Describe the bug
In the _get_kwargs generated method, the body is determined as File type (because the format in my swagger definition is binary), but it tries to access its .to_dict attribute (because body_type is considered as data due to the content type application/x-www-form-urlencoded), which does not exist because it is a file

OpenAPI Spec File

"content": {
    "application/x-www-form-urlencoded": {
        "schema": {
            "description": "do stuff",
            "type": "string",
            "format": "binary"
        }
    }
}

Desktop (please complete the following information):

  • OS: macOS 13.3.1
  • Python Version: 3.9.8
  • openapi-python-client version: 0.17.2

Additional context
In the macro, the arguments macro determine the argument type of body based on endpoint.bodies[0].prop.get_type_string(), whereas in the body_to_kwarg macro it determines it based on body.body_type, which is determined by the following:

        if simplified_content_type == "application/x-www-form-urlencoded":
            body_type = BodyType.DATA
        elif simplified_content_type == "multipart/form-data":
            body_type = BodyType.FILES
        elif simplified_content_type == "application/octet-stream":
            body_type = BodyType.CONTENT
        elif simplified_content_type == "application/json" or simplified_content_type.endswith("+json"):
            body_type = BodyType.JSON
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

1 participant