Skip to content

Commit d73091e

Browse files
committed
Merge branch 'coutin-feat/support-array-annotation-in-query-param'
2 parents 80f265a + c145c7e commit d73091e

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/GenericParameterService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@
5454
import org.springframework.core.io.Resource;
5555
import org.springframework.web.multipart.MultipartFile;
5656

57+
import static java.util.Objects.isNull;
58+
5759
/**
5860
* The type Generic parameter builder.
59-
* @author bnasslahsen
61+
* @author bnasslahsen, coutin
6062
*/
6163
@SuppressWarnings("rawtypes")
6264
public class GenericParameterService {
@@ -397,9 +399,10 @@ private void setParameterStyle(Parameter parameter, io.swagger.v3.oas.annotation
397399
*/
398400
private boolean isExplodable(io.swagger.v3.oas.annotations.Parameter p) {
399401
io.swagger.v3.oas.annotations.media.Schema schema = p.schema();
402+
io.swagger.v3.oas.annotations.media.ArraySchema arraySchema = p.array();
400403
boolean explode = true;
401404
Class<?> implementation = schema.implementation();
402-
if (implementation == Void.class && !schema.type().equals("object") && !schema.type().equals("array")) {
405+
if (implementation == Void.class && !schema.type().equals("object") && !schema.type().equals("array") && isNull(arraySchema)) {
403406
explode = false;
404407
}
405408
return explode;

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app1/ItemController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import javax.validation.constraints.Size;
2929

3030
import io.swagger.v3.oas.annotations.Parameter;
31+
import io.swagger.v3.oas.annotations.enums.Explode;
3132
import io.swagger.v3.oas.annotations.enums.ParameterIn;
33+
import io.swagger.v3.oas.annotations.media.ArraySchema;
3234
import io.swagger.v3.oas.annotations.media.Schema;
3335
import io.swagger.v3.oas.annotations.tags.Tag;
3436

@@ -47,7 +49,8 @@ public class ItemController {
4749
@GetMapping("/items")
4850
public List<ItemDTO> showItems(@RequestParam("cusID") @Size(min = 4, max = 6) final String customerID,
4951
@Size(min = 4, max = 6) int toto,
50-
@Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate) {
52+
@Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate,
53+
@Parameter(name = "filterIds", in = ParameterIn.QUERY, array = @ArraySchema(schema = @Schema(type = "string")), explode = Explode.FALSE) @RequestParam(required = false) List<String> filterIds) {
5154
return new ArrayList<ItemDTO>();
5255
}
5356

springdoc-openapi-webmvc-core/src/test/resources/results/app1.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,18 @@
230230
"format": "date-time",
231231
"example": "1970-01-01T00:00:00.000Z"
232232
}
233+
},
234+
{
235+
"name": "filterIds",
236+
"in": "query",
237+
"required": false,
238+
"explode": false,
239+
"schema": {
240+
"type": "array",
241+
"items": {
242+
"type": "string"
243+
}
244+
}
233245
}
234246
],
235247
"responses": {

0 commit comments

Comments
 (0)