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

3

4

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

Turanian answered 2/5, 2022 at 7:51 Comment(1)
I had similar issue and accepted answer to this question pointed me in the right direction: #62527754Etalon
R
1

You can use the below approach

Before

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

After

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

Reflect answered 5/9, 2022 at 10:32 Comment(2)
Where is the example about "allowMultiple=true"?United
It was about true only, corrected the answer.Reflect
S
0

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.") 
})
Stultify answered 27/7, 2022 at 17:16 Comment(0)
C
0

You need to use the array param as the example below:

@Parameter(array=@ArraySchema(schema = @Schema())) 
Coadjutrix answered 19/6, 2023 at 19:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.