-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
OpenAPI 3.1 supports Body for DELETE method #1432
Comments
According to the OpenAPI 3.x specification, the request body is explicitly supported for POST, PUT, and PATCH methods, but not for GET, DELETE, or HEAD. This limitation isn’t just a constraint of OpenAPI—it’s based on the HTTP standards outlined in various RFCs, particularly RFC 7231. While HTTP itself does not prohibit sending a body in GET or DELETE requests, RFC 7231 (which defines the semantics and content of HTTP methods) makes no provision for how servers should interpret or handle a body for these methods. As a result, behavior is inconsistent across different implementations, and many server frameworks either ignore or outright reject bodies for GET and DELETE requests. The HTTP RFCs suggest that GET should retrieve resources, and DELETE should remove resources. Neither of these actions typically requires a body to define the action being performed, hence the lack of a formal specification supporting it. For example:
For DELETE, the common expectation is that the resource to be deleted is identified by the URL alone, without needing additional data in the body. Although some server implementations might permit bodies with DELETE requests, this is not standardized or recommended in the RFCs, leading to potential interoperability issues. Thus, OpenAPI adheres to these guidelines to maintain compatibility across different servers and implementations, ensuring that request bodies are used only with methods where they are clearly defined by HTTP standards. For more information, you can refer to the official OpenAPI documentation: |
From what I've seen, one should avoid using a Body for a DELETE. However, I have a requirement where the delete calls need a few more parameters than I want to put in the URL. For that very reason, probably OpenAPI allows it in their latest standard. Thus it's hindering in my case for Pode to not allow it |
You can pass the body content as a JSON/YAML/XML header. |
Do you have a link that says Delete body is supported openapi? |
https://spec.openapis.org/oas/v3.1.0.html#operation-object under Field Name requestBody |
Add -AllowNonStandardBody Parameter to Enable Request Bodies for Non-Standard HTTP Methods (Address #1432)
Describe the Bug
OpenAPI 3.1 supports Body for DELETE method, if condition in OpenApi.ps1 doesn't allow it:
Pode/src/Public/OpenApi.ps1
Line 814 in f8c51b7
Steps To Reproduce
Steps to reproduce the behavior:
Expected Behavior
Should work, especially if Enable-PodeOpenApi -OpenApiVersion is defined as "3.1.0"
The text was updated successfully, but these errors were encountered: