diff --git a/modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.java b/modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.java index bd19af4b6b..4124acea79 100644 --- a/modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.java +++ b/modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.java @@ -1411,7 +1411,7 @@ public static void setHeaderExplode (Header header, io.swagger.v3.oas.annotation } private static boolean isHeaderExplodable(io.swagger.v3.oas.annotations.headers.Header h, Header header) { - io.swagger.v3.oas.annotations.media.Schema schema = h.schema(); + io.swagger.v3.oas.annotations.media.Schema schema = hasArrayAnnotation(h.array()) ? h.array().schema() : h.schema(); boolean explode = true; if (schema != null) { Class implementation = schema.implementation(); diff --git a/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ParameterProcessor.java b/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ParameterProcessor.java index e49ae8cc1a..5c977bdfed 100644 --- a/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ParameterProcessor.java +++ b/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ParameterProcessor.java @@ -234,7 +234,7 @@ public static void setParameterExplode(Parameter parameter, io.swagger.v3.oas.an } private static boolean isExplodable(io.swagger.v3.oas.annotations.Parameter p, Parameter parameter) { - io.swagger.v3.oas.annotations.media.Schema schema = p.schema(); + io.swagger.v3.oas.annotations.media.Schema schema = AnnotationsUtils.hasArrayAnnotation(p.array()) ? p.array().schema() : p.schema(); boolean explode = true; if ("form".equals(parameter.getIn())){ return true; diff --git a/modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/annotations/operations/AnnotatedOperationMethodTest.java b/modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/annotations/operations/AnnotatedOperationMethodTest.java index b2ed91a39d..f17409fde4 100644 --- a/modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/annotations/operations/AnnotatedOperationMethodTest.java +++ b/modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/annotations/operations/AnnotatedOperationMethodTest.java @@ -582,6 +582,7 @@ public void testOperationWithResponseMultipleHeadersImplementationSchema() { " Rate-Limit-Limit:\n" + " description: The number of allowed requests in the current period\n" + " style: simple\n" + + " explode: true\n" + " schema:\n" + " maxItems: 10\n" + " minItems: 1\n" + diff --git a/modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/annotations/parameters/ParametersTest.java b/modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/annotations/parameters/ParametersTest.java index 1f3d282f45..625dcf67b9 100644 --- a/modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/annotations/parameters/ParametersTest.java +++ b/modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/annotations/parameters/ParametersTest.java @@ -88,6 +88,7 @@ public void testParameters() { " - name: arrayParameter\n" + " in: query\n" + " required: true\n" + + " explode: true\n" + " content:\n" + " application/json:\n" + " schema:\n" + @@ -102,6 +103,7 @@ public void testParameters() { " - name: arrayParameterImplementation\n" + " in: query\n" + " required: true\n" + + " explode: true\n" + " schema:\n" + " maxItems: 10\n" + " minItems: 1\n" + @@ -148,6 +150,7 @@ public void testArraySchemaParameters() { " - name: arrayParameter\n" + " in: query\n" + " required: true\n" + + " explode: true\n" + " schema:\n" + " maxItems: 10\n" + " minItems: 1\n" + @@ -220,6 +223,7 @@ public void testRepeatableParameters() { " - name: arrayParameter\n" + " in: query\n" + " required: true\n" + + " explode: true\n" + " content:\n" + " application/json:\n" + " schema:\n" + @@ -234,6 +238,7 @@ public void testRepeatableParameters() { " - name: arrayParameterImplementation\n" + " in: query\n" + " required: true\n" + + " explode: true\n" + " schema:\n" + " maxItems: 10\n" + " minItems: 1\n" + diff --git a/modules/swagger-jaxrs2/src/test/resources/petstore/FullPetResource.yaml b/modules/swagger-jaxrs2/src/test/resources/petstore/FullPetResource.yaml index 9360aa0882..5312ec646c 100644 --- a/modules/swagger-jaxrs2/src/test/resources/petstore/FullPetResource.yaml +++ b/modules/swagger-jaxrs2/src/test/resources/petstore/FullPetResource.yaml @@ -631,6 +631,7 @@ paths: - name: arrayParameter in: query required: true + explode: true schema: maxItems: 10 minItems: 1 @@ -787,6 +788,7 @@ paths: - name: arrayParameter in: query required: true + explode: true content: application/json: schema: @@ -801,6 +803,7 @@ paths: - name: arrayParameterImplementation in: query required: true + explode: true schema: maxItems: 10 minItems: 1 @@ -868,6 +871,7 @@ paths: - name: arrayParameter in: query required: true + explode: true content: application/json: schema: @@ -882,6 +886,7 @@ paths: - name: arrayParameterImplementation in: query required: true + explode: true schema: maxItems: 10 minItems: 1 diff --git a/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/ArraySchemaResource.yaml b/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/ArraySchemaResource.yaml index 78260504d3..66d9ccc3a9 100644 --- a/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/ArraySchemaResource.yaml +++ b/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/ArraySchemaResource.yaml @@ -10,6 +10,7 @@ paths: - name: arrayParameter in: query required: true + explode: true schema: maxItems: 10 minItems: 1 diff --git a/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/Parameters31Resource.yaml b/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/Parameters31Resource.yaml index 6a6bbc2596..3cb83e1350 100644 --- a/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/Parameters31Resource.yaml +++ b/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/Parameters31Resource.yaml @@ -44,6 +44,7 @@ paths: - name: arrayParameter in: query required: true + explode: true content: application/json: schema: @@ -58,6 +59,7 @@ paths: - name: arrayParameterImplementation in: query required: true + explode: true schema: type: array contains: {} diff --git a/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/ParametersResource.yaml b/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/ParametersResource.yaml index bb61ce726d..c1117da046 100644 --- a/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/ParametersResource.yaml +++ b/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/ParametersResource.yaml @@ -42,6 +42,7 @@ paths: - name: arrayParameter in: query required: true + explode: true content: application/json: schema: @@ -56,6 +57,7 @@ paths: - name: arrayParameterImplementation in: query required: true + explode: true schema: maxItems: 10 minItems: 1 diff --git a/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/RepeatableParametersResource.yaml b/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/RepeatableParametersResource.yaml index a163e8f543..a3d6054874 100644 --- a/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/RepeatableParametersResource.yaml +++ b/modules/swagger-jaxrs2/src/test/resources/petstore/parameters/RepeatableParametersResource.yaml @@ -42,6 +42,7 @@ paths: - name: arrayParameter in: query required: true + explode: true content: application/json: schema: @@ -56,6 +57,7 @@ paths: - name: arrayParameterImplementation in: query required: true + explode: true schema: maxItems: 10 minItems: 1