Duplicate schema resoponse attribute in swagger ui

73 Views Asked by At

My model looks like this:

@AllArgsConstructor
@Data
@NoArgsConstructor
@Schema(description = "Contains list of strings")
public class MyResponse {

    @Schema(requiredMode = RequiredMode.REQUIRED, description = "List of my sample strings")
    @JsonProperty(required = true)
    @NotNull
    private List<String> myMessages;
}

Now, when I see my swagger ui, it looks like this:

enter image description here

Why is it printing myMessages twice? Shouldn't it just print once? I am using springdoc openapi ui 1.7.0

1

There are 1 best solutions below

0
On

You can configure the description only for Array by using @ArraySchema annotation. Here is a simple example:

@ArraySchema(arraySchema = @Schema(description = "This is a list"))
List<String> items = new HashSet<>();

You can find the same question in this springdoc issue. https://github.com/springdoc/springdoc-openapi/issues/330