Springfox to OpenAPI Springdocs migration: @ApiImplicitParam(allowMultiple=true) equivalent?

Viewed 307

I'm migrating from springfox to OpenAPI springdocs and I have to replace

@ApiImplicitParam(allowMultiple=true)

@ApiImplicitParam is replaced with @Parameter, but what is the OpenAPI springdoc equivalent to allowMultiple=true?


Reference: https://springdoc.org/migrating-from-springfox.html

2 Answers

You can use the below approach

Before

@ApiImplicitParam(value="Filter by type", allowableValues="typeA,typeB,typeC", allowMultiple=false)

After

@Parameter(description = "Filter by type", schema=@Schema(type="string", allowableValues={"typeA","typeB","typeC"}, defaultValue = "typeA"))

This answer is taken from what @tomjankes put in his comment to the question -> the answer is to add explode=Explode.TRUE. Here's an example piece of code that worked for me:

@Parameters({
    @Parameter(name = "sort", **explode = Explode.TRUE**, schema = @Schema(type = "string"), in = ParameterIn.QUERY, description = "Sort setting in the format of: property(,asc|desc). Default sort order is ascending. Multiple sort settings are supported.") 
})
Related