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 in GET/DELETE requests in 3.x #1689

Closed
AndrianStoikov opened this issue Apr 19, 2023 · 1 comment · Fixed by #1712
Closed

Body in GET/DELETE requests in 3.x #1689

AndrianStoikov opened this issue Apr 19, 2023 · 1 comment · Fixed by #1712

Comments

@AndrianStoikov
Copy link

Description

Hello,
Since version 2.x connexion does not support body in GET and DELETE requests.

if self.method.upper() in ["PATCH", "POST", "PUT"]:

However, many APIs are designed this way and connexion is being too restrictive to API implementations which causes problems with further library updates.

Expected behaviour

IMHO it is best for the library to be as flexible as possible while at the same time promoting correct API design. But currently, it is too restrictive and blocks the projects that have been developed for years to upgrade to a higher version of connexion.

Even the authors of OpenAPI understand that this change is too restrictive

In OpenAPI 3.1, we decided to go back on this change for the main reason that indeed many APIs are designed this way (this is not to say that we believe it's the right approach).

swagger-api/swagger-ui#2136 (comment)

I think it is best if connexion 3.x also reverts to this behavior in order to be more flexible and allow easier transition for projects.

Actual behaviour

Connexion from version 2.x does not automatically parse body in arguments and breaks all endpoints that currently utilize this functionality. I know about the fix of using connexion.request.json however this requires changes of many APIs especially of old APIs that have been developed for years.

Steps to reproduce

Additional info:

Output of the commands:

  • 3.11
  • 2.14.2
@Ruwann
Copy link
Member

Ruwann commented Apr 21, 2023

Hi @AndrianStoikov , Thanks a lot for the detailed issue report!

Reading the spec and links you provided, I am indeed inclined to agree that it would make sense for connexion to be as liberal as possible and accept body arguments in GET and DELETE operations. I do not immediately see a reason why it would not be possible in connexion. I assume the one place would be the swagger UI that woud not properly support it.

Even in OpenAPI 3.0.3 (as opposed to 3.0.2), it is not actually disallowed but rather discouraged, allowing connexion some liberty to choose what to do with it:

The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the HTTP 1.1 specification RFC7231 has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined semantics and SHOULD be avoided if possible.

EDIT: Seems like I was mistaken, the excerpt above is from OpenAPI 3.1 and not present in 3.0.3 (source)

RobbeSneyders added a commit that referenced this issue Oct 23, 2023
Fixes #1689 

Changes proposed in this pull request:

 - Pass through request body in case of `GET` and `DELETE` requests

---------

Co-authored-by: Robbe Sneyders <robbe.sneyders@gmail.com>
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

Successfully merging a pull request may close this issue.

2 participants