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

Don't generate requestBody in DELETE method, which is not allowed in OpenAPI v3.0.3 spec #243

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

dantherussell
Copy link

While testing some generated docs which included a DELETE operation, the Swagger editor gave me the following error:

Semantic error at paths./views/{id}.delete.requestBody
DELETE operations cannot have a requestBody.

When I looked into it, I found out that in v3.0.3 of the OpenAPI Spec (which is what this gem currently generates), a requestBody in a DELETE operation is not allowed, as the HTTP 1.1 specification Section 4.3.1 does not have explicitly defined semantics for request bodies in DELETE.

This has changed in v3.1.0, where for such operations, requestBody is permitted but does not have well-defined semantics and, as per the specification, should be avoided if possible.

The schema_builder was already using a nil requestBody for GET requests, so I have modified it slightly to do the same for DELETE.

@dantherussell
Copy link
Author

dantherussell commented Feb 4, 2025

FYI @exoego that logger issue making the tests fail is something to do with a gem dependancy changing, I can fix it in this PR if you'd like?

@exoego
Copy link
Owner

exoego commented Feb 4, 2025

@dantherussell Nice but can you create a separate PR?

@dantherussell
Copy link
Author

@dantherussell Nice but can you create a separate PR?

Sure - #244

@dantherussell dantherussell force-pushed the fix-semantic-error-for-deletes branch from f6be466 to 1b22e52 Compare February 4, 2025 10:33
Copy link
Owner

@exoego exoego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Will look Hanami issue later

@exoego exoego merged commit ddb4fb2 into exoego:master Feb 4, 2025
6 of 11 checks passed
@exoego exoego added this to the vnext milestone Feb 6, 2025
@exoego exoego added the bug Something isn't working label Feb 6, 2025
@exoego exoego changed the title Fix semantic error caused by requestBody in deletes Don't generate requestBody in DELETE method, which is not allowed in OpenAPI v3.0.3 spec Feb 6, 2025
@exoego
Copy link
Owner

exoego commented Feb 6, 2025

@dantherussell Thanks for the PRs. This was released in https://rubygems.org/gems/rspec-openapi/versions/0.18.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants