Skip to content

Delete request with body #545

Closed
Closed
@MalteBecker

Description

@MalteBecker

Is your feature request related to a problem? Please describe.
In our API we handle a lot of items and came to a point where we want to delete a lot of this items at the same time. Our first approach was to call a DELETE on every single ID. This works, but it is very slow.
Then we added a new delete functionality where we have only one DELETE call with a json body with a lot of IDs. I know, that this is not the "normal" way to do it, but it works fine and is not forbidden in openapi I think.

The problem with the openapi-python-client is, that it creates an httpx.delete call. And the httpx library does not allow a body for a DELETE. In the httpx github I found this thread: encode/httpx#1587
So a DELETE with a body is possible if you use httpx.request instead of http.delete.

Describe the solution you'd like
After a short look into the openapi-python-client code I have an easy solution for this problem. I just changed every httpx call into a httpx.request call and added the endpoint.method in the _get_kwargs method.

Here are my changes:
endpoint_module.py.jinja.txt

For me this works pretty good and does not change any other behavior. If nothing speaks against it I would like to PR this change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions