我想使用 spring 和 swagger 来描述一个查询参数。 ReceiptStatus 是一个枚举。 我期望使用@ArraySchema中的
arrayschema
定义要解析为模式属性的属性 类型
array
显然 name 不用于定义参数名称。
@ArraySchema(arraySchema = @Schema(description = "Status of the receipt", name = "status", example = "paid"))
private List<ReceiptStatus> statuses;
产生名称为 statuses 的数组类型参数
和
@Schema(description = "Status of the receipt", name = "status", example = "paid")
private List<ReceiptStatus> statuses;
产生名称为“status”的字符串类型参数。
有没有办法定义枚举列表并使用自定义参数名称?
您可以尝试使用@ArraySchema的items属性。然后您可以在其 @Schema 实现属性中使用您想要的枚举类型。
@ArraySchema(
arraySchema = @Schema(description = "Status of the receipt", name = "status", example = "paid"),
items = @Schema(implementation = ReceiptStatus.class)
)
private List<ReceiptStatus> statuses;