Skip to content

Delete request with body #545

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
MalteBecker opened this issue Dec 16, 2021 · 4 comments
Closed

Delete request with body #545

MalteBecker opened this issue Dec 16, 2021 · 4 comments
Labels
✨ enhancement New feature or improvement

Comments

@MalteBecker
Copy link
Contributor

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.

@MalteBecker MalteBecker added the ✨ enhancement New feature or improvement label Dec 16, 2021
@dbanty
Copy link
Collaborator

dbanty commented Dec 16, 2021

Sounds good to me. IMO a client shouldn't be prescriptive about an Server's API implementation since it's usually not up to the client 😬. Happy to accept a PR that makes this a bit more flexible.

@MalteBecker
Copy link
Contributor Author

Cool :)
Sadly I cannot create branches. Maybe you have to add me as a collaborator?

@dbanty
Copy link
Collaborator

dbanty commented Dec 17, 2021

Generally folks will fork the repo, make changes on their fork, then make a PR back upstream.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

@MalteBecker
Copy link
Contributor Author

Feature committed in #547
Available since version 0.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants