Skip to content

Parameter is now required after upgrading to springdoc-openapi 2.8.10 #3066

@brunopereira7

Description

@brunopereira7

Describe the bug

I'm using springdoc-openapi in my Kotlin project. I've tried to upgrade from version 2.8.6 to 2.8.10, but I've noticed a change in the generated api-docs.

In version 2.8.6, the following parameters were generated as optional (required: false):

  • filters.brand
  • filters.service
  • filters.productGroup

However, in version 2.8.10, these parameters are now generated as required (required: true).

Is it still related to #2978 ? I can have a workaround and explicitly force it as optional, but I would like to understand if it is a bug or why we have this change of behavior.

To Reproduce
Steps to reproduce the behavior:

  • spring-boot version: 3.5.3
  • spring-doc-openapi-webflux: 2.8.10

Code Snippet:

data class BaseSearchParameters(
    val filters: Filters = Filters()
)

@ParameterObject
data class Filters(
    @field:Parameter(
        description = "Description .",
        explode = FALSE,
        array = ArraySchema(schema = Schema(type = "string"))
    )
    var brand: Set<String> = emptySet(),

    @field:Parameter(
        description = "Description ..",
        explode = FALSE,
        array = ArraySchema(schema = Schema(type = "string"))
    )
    var service: Set<String> = emptySet(),

    @field:Parameter(
        description = "Description ...",
        explode = FALSE,
        array = ArraySchema(schema = Schema(type = "string"))
    )
    var productGroup: Set<String> = emptySet(),
)

This code is generating with version 2.8.10:

...
{
    "name": "filters.brand",
    "in": "query",
    "description": "Description .",
    "required": true,
    "explode": false,
    "schema": {
        "type": "array",
        "items": {
            "type": "string"
        }
    }
},
{
    "name": "filters.service",
    "in": "query",
    "description": "Description ..",
    "required": true,
    "explode": false,
    "schema": {
        "type": "array",
        "items": {
            "type": "string"
        }
    }
},
{
    "name": "filters.productGroup",
    "in": "query",
    "description": "Description ...",
    "required": true,
    "explode": false,
    "schema": {
        "type": "array",
        "items": {
            "type": "string"
        }
    }
}
...

Expected behavior

Should we expect the same behavior of 2.8.6 version?

...
{
    "name": "filters.brand",
    "in": "query",
    "description": "Description .",
    "required": false,
    "explode": false,
    "schema": {
        "type": "array",
        "items": {
            "type": "string"
        }
    }
},
{
    "name": "filters.service",
    "in": "query",
    "description": "Description ..",
    "required": false,
    "explode": false,
    "schema": {
        "type": "array",
        "items": {
            "type": "string"
        }
    }
},
{
    "name": "filters.productGroup",
    "in": "query",
    "description": "Description ...",
    "required": false,
    "explode": false,
    "schema": {
        "type": "array",
        "items": {
            "type": "string"
        }
    }
}
...

Thank you for your time and support.

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