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

Ignoring @Parameter(required = false) ? #2827

Open
KneupnerTrackunit opened this issue Dec 19, 2024 · 0 comments
Open

Ignoring @Parameter(required = false) ? #2827

KneupnerTrackunit opened this issue Dec 19, 2024 · 0 comments

Comments

@KneupnerTrackunit
Copy link

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.

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