【发布时间】:2021-03-24 13:24:51
【问题描述】:
我对 Swagger 自动生成的模型架构有疑问。我有一个 List<String> 类型的集合字段,我想将其序列化为纯字符串,并且为此我有单独的序列化程序。杰克逊的工作做得很好,但模式生成器做得不好。尽管明确设置了属性dataType,但它将字段的类型解析为对象:
public class FilialDetails {
@ApiModelProperty(dataType = "string", example = "10000101010")
@JsonInclude(JsonInclude.Include.NON_NULL)
// custom serializer treats collection as subset of known, pre-populated list
// and serializes it as series of 0 and 1
@JsonSerialize(using = ServicesSerializer.class)
private List<String> services;
}
生成的属性定义(摘录):
"properties": {
"services": {
"type": "object",
"example": 10000101010
}
}
我在架构定义中需要string,而不是object,这怎么可能?我在我的项目中使用io.springfox:springfox-boot-starter:3.0.0。
【问题讨论】: