Skip to content

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

@danilopiazza

Description

@danilopiazza

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions