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

[Web OpenApi] Request with Body not specified in OpenAPI is NOT rejected #2194

Closed
dprincethg opened this issue Jun 3, 2022 · 5 comments
Closed
Labels

Comments

@dprincethg
Copy link

dprincethg commented Jun 3, 2022

Version

v4.3.1 - Vert.x OpenAPI

Context

In OpenAPI, when operation does not contain any "requestBody" description.

"paths" : { "/myPath" : { "post" : { "summary" : "bla bla", "operationId" : "myOperationId", "parameters" : ..., "responses" : ... } } }

A Request WITH a json body (content-type: application/json) is not rejected by the web-api router as expected.

Do you have a reproducer?

NO

Steps to reproduce

cf description

Extra

@dprincethg dprincethg added the bug label Jun 3, 2022
@dprincethg dprincethg changed the title Request with Body not specified in OpenAPI is NOT rejected [Web API] Request with Body not specified in OpenAPI is NOT rejected Jun 3, 2022
@dprincethg dprincethg changed the title [Web API] Request with Body not specified in OpenAPI is NOT rejected [Web OpenApi] Request with Body not specified in OpenAPI is NOT rejected Jun 3, 2022
@ThorodanBrom
Copy link

ThorodanBrom commented Jul 20, 2022

In OpenAPI 3 at least, the request body is optional by default , see here. I think this is why the validation handler does not throw an error. If you explicitly do not want a request body to be sent, try setting required: false in the requestBody section, it might work.

We had a similar issue when the validation handler did not throw an error when a requestBody was defined in the OpenAPI spec, but an empty body was sent. There, setting required: true solved the issue.

Edit: Sorry, this did not work.

@dprincethg
Copy link
Author

Hi @ThorodanBrom

Thanks for your reply.

Indeed, "required" property is not adapted for this issue.

  1. "required: true" means Operation defines a Body and this body is mandated (MUST be present to all requests)
  2. "required: false" means Operation defines a Body BUT this body presence is optional

My issue is different:

  1. OA specifies that operation has not body so request MUST not have a Body (shall not be present).
  2. Unfortunately , Vertx does not reject request with body

David

@dprincethg
Copy link
Author

Hello,

Any news about this issue?

David

@pk-work
Copy link
Contributor

pk-work commented Apr 26, 2024

I think this issue is tracked in eclipse-vertx/vertx-openapi#17, which also makes more sense as Web OpenAPI is deprecated.

Therefore I will close this issue. If I'm wrong please reopen the issue.

@pk-work pk-work closed this as completed Apr 26, 2024
@pk-work
Copy link
Contributor

pk-work commented Apr 26, 2024

Ah just see that this is about the request, not the response. So it is maybe already fixed in the new version of OpenAPI Router.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants