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

Request body without required = true should not have the @NotNull annotation #293

Open
danilopiazza opened this issue Jul 19, 2024 · 1 comment

Comments

@danilopiazza
Copy link

Given a [request body(https://spec.openapis.org/oas/v3.0.3#request-body-object) with "required": false:

   "paths": {
      "/request-body/optional": {
         "post": {
            "requestBody": {
               ...
               "required": false
            },
            ...
         }
      }

when generating JAX-RS code with OpenApi2JaxRs, method parameters representing the request body have the @NotNull annotation, as if they were required:

  @Path("/optional")
  @POST
  @Consumes("application/json")
  void optionalRequestBody(@NotNull Content data);

I believe the @NotNull annotation should only be present when the request body has the "required": true property.

@danilopiazza
Copy link
Author

I don't know whether the code generator should add a @Nullable annotation when required is false (or missing), or no annotation at all.

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

No branches or pull requests

1 participant