Profile name
Profile name

Reputation: 193

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

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

Upvotes: 4

Views: 4300

Answers (3)

Bruce_Wayne
Bruce_Wayne

Reputation: 1614

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"))

Upvotes: 1

Fábio Almeida
Fábio Almeida

Reputation: 296

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

@Parameter(array=@ArraySchema(schema = @Schema())) 

Upvotes: 0

Stan
Stan

Reputation: 1308

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.") 
})

Upvotes: 0

Related Questions