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

@Size on collections query parameter is generating openapi maximum/minimum to the contained type #2393

Closed
CharlyRien opened this issue Sep 28, 2023 · 1 comment

Comments

@CharlyRien
Copy link

Describe the bug
After upgrading from springdoc 2.1.0 to springdoc 2.2.0, a new behavior is occurring that is breaking our openapi doc generated.
If you are using Jakarta Collections validator on controller query parameters (for example @SiZe in my case) the minItems and maxItems are added to the openapi doc generated as expected but it is also adding now the maximum/minimum (with the same number as minItems and maxItems) to the type of the items contained in the collection.

To Reproduce
Steps to reproduce the behavior:
Use @SiZe on Set for example for a query parameter in your controller methods

  • What version of spring-boot you are using?
    spring-boot 3.1.2
  • What modules and versions of springdoc-openapi are you using?
    springdoc-openapi-starter-common-2.2.0.jar
    springdoc-openapi-starter-webflux-api-2.2.0.jar
  • What is the actual and the expected result using OpenAPI Description (yml or json)?
    actual:
      parameters:
      - in: query
        name: article_ids
        required: false
        schema:
          type: array
          items:
            type: integer
            format: int64
            maximum: 50
            minimum: 1
          maxItems: 50
          minItems: 1
          uniqueItems: true

expected:

      parameters:
      - in: query
        name: article_ids
        required: false
        schema:
          type: array
          items:
            type: integer
            format: int64
          maxItems: 50
          minItems: 1
          uniqueItems: true
  • Provide with a sample code (HelloController) or Test that reproduces the problem
@RestController
@RequestMapping(value = ["/api/product-discovery/product-cards"], produces = [MediaType.APPLICATION_JSON_VALUE])
@Validated
class Controller{
    @GetMapping(params = ["article_ids"])
    @Operation(description = "", tags = ["product-cards"])
    fun getProductCardsByArticleIds(
        @RequestParam(name = "article_ids", required = false) @Size(min = 1, max = 50) articleIds: Set<Long>
    ) = ResponseEntity.ok()
}

Expected behavior
@SiZe should only affect the number of items in the collection not the size of the type contained in the collection

      parameters:
      - in: query
        name: article_ids
        required: false
        schema:
          type: array
          items:
            type: integer
            format: int64
          maxItems: 50
          minItems: 1
          uniqueItems: true

Screenshots

Additional context
We are using Kotlin

@CharlyRien
Copy link
Author

I found the issue inside the swagger-core project: swagger-api/swagger-core#4462
We can close this issue since there is nothing we can do in this project I believe.

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