Skip to content

Ignoring @Parameter(required = false) ?  #2827

Closed
@KneupnerTrackunit

Description

@KneupnerTrackunit

Describe the bug

I have this declaration line:

    @Parameter(description = "The number of individual objects that are returned in each page.", in = QUERY, allowEmptyValue = true, required = false, schema = @Schema(defaultValue = "200", requiredMode = Schema.RequiredMode.NOT_REQUIRED, nullable = true, minimum = "1", maximum = "200"))
    @Max(value = 200L)
    @Min(value = 1L)
    private Integer limit = MAX_LIMIT;

and it results in

{
          "allowEmptyValue" : true,
          "description" : "The number of individual objects that are returned in each page.",
          "in" : "query",
          "name" : "limit",
          "required" : true,
          "schema" : {
            "type" : "string",
            "maximum" : 200,
            "minimum" : 1,
          }
}

but it should result in:

{
          "allowEmptyValue" : true,
          "description" : "The number of individual objects that are returned in each page.",
          "in" : "query",
          "name" : "limit",
          "required" : false,
          "schema" : {
            "type" : "string",
            "default" : "200",
            "maximum" : 200,
            "minimum" : 1,
          }
}

(created via springdoc-openapi-maven-plugin).

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? 3.4.0
  • What modules and versions of springdoc-openapi are you using? 2.7.0
  • What is the actual and the expected result using OpenAPI Description (yml or json)? JSON
  • Provide with a sample code (HelloController) or Test that reproduces the problem - will be added within a few hours

Expected behavior

I would like to have no changes to previous version, i.e. return a required = false and add the default = 200 back in.

Screenshots
This is the diff:
image

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions