diff --git a/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/media/ArraySchema.java b/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/media/ArraySchema.java index 186ade23f7..baabd6ecbe 100644 --- a/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/media/ArraySchema.java +++ b/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/media/ArraySchema.java @@ -39,9 +39,10 @@ * * @since 2.2.12 * + * @deprecated since 2.2.21, use {@link #schema()} instead. Marked for removal in future versions. * @return items */ - + @Deprecated Schema items() default @Schema; /** diff --git a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java index eb6ae9e473..fc86e2184c 100644 --- a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java +++ b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java @@ -2936,11 +2936,17 @@ private void resolveArraySchema(AnnotatedType annotatedType, ArraySchema schema, schema.addPrefixItem(prefixItem); } } + // TODO `ArraySchema.items` is deprecated, when removed, remove this block if (schema.getItems() != null && AnnotationsUtils.hasSchemaAnnotation(resolvedArrayAnnotation.items())) { for (String type : resolvedArrayAnnotation.items().types()) { schema.getItems().addType(type); } } + if (schema.getItems() != null && AnnotationsUtils.hasSchemaAnnotation(resolvedArrayAnnotation.schema())) { + for (String type : resolvedArrayAnnotation.schema().types()) { + schema.getItems().addType(type); + } + } } } } diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/v31/model/AnnotatedArray.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/v31/model/AnnotatedArray.java index 566a98f116..9e49f750d6 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/v31/model/AnnotatedArray.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/v31/model/AnnotatedArray.java @@ -12,7 +12,7 @@ unevaluatedItems = @Schema( types = { "number" } ), - items = @Schema( + schema = @Schema( types = { "string" } ), prefixItems = {