elements
elements copied to clipboard
TryIt doesn't send request body for DELETE requests
Context
When making an api request with method DELETE which has some body, the body is not sent. This seems to be intentional as per these lines: https://github.com/stoplightio/elements/blob/b20ba4422985ff35617171ec72103719fe3aa2b6/packages/elements-core/src/components/TryIt/build-request.ts#L66
Current Behavior
As explained above
Expected Behavior
Request body should be sent for DELETE requests. It's worth noting that DELETE requests with request body is NOT against the specs. There might be many legacy apis that developers are documenting, which may have a DELEET endpoint with request body. Open Api Spec also supports DELETE requests with body. https://spec.openapis.org/oas/v3.1.0#version-3-1-0
![Screenshot 2022-09-05 at 15 22 20](https://user-images.githubusercontent.com/26996372/188470506-a978775c-cc9b-4a3d-9795-bd560cd76801.png)
Related issues on OAS: https://github.com/OAI/OpenAPI-Specification/issues/1801, https://github.com/OAI/OpenAPI-Specification/pull/2117
Steps to Reproduce
- Use try-it widget to make a DELETE request with request body. Note how in the screenshot below, it is documented that the endpoint accepts some body, but "Request Sample" does not reflect the same
![Screenshot 2022-09-05 at 15 23 51](https://user-images.githubusercontent.com/26996372/188470779-2fd8f858-36e5-48d2-9c97-75e7c8e865c8.png)
Environment
- Version used:
- Environment name and version (e.g. Chrome 39, node.js 5.4):
- Operating System and version (desktop or mobile):
- Link to your environment/workspace/project:
We can potentially create a rule in Spectral to warn users but support it in the docs.
@mnaumanali94 I agree, thats a good way to split it. When there is a SHOULD that means people could. Spectral can help make things better, and Elements should show whatever it understands regardless of opinion. IMO. :D
Any updates on this?