Skip to content

Delete request with body #545

Closed
Closed

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.

Activity

  1. added
    ✨ enhancement
    on Dec 16, 2021
  2. dbanty commented on Dec 16, 2021

    @dbanty
    Collaborator

    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.

  3. MalteBecker commented on Dec 17, 2021

    @MalteBecker
    ContributorAuthor

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

  4. dbanty commented on Dec 17, 2021

    @dbanty
    Collaborator
  5. MalteBecker commented on Jan 19, 2022

    @MalteBecker
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✨ enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions