springdoc / springdoc-openapi

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
3.29k stars 500 forks source link

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

Closed CharlyRien closed 1 year ago

CharlyRien commented 1 year ago

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

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 commented 1 year ago

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