我对Swagger自动生成的模型模式有问题。我有一个List<String>类型的集合字段,我想将其序列化为普通字符串,并且我有单独的序列化程序。Jackson做得很好,但模式生成器做得不好。它将字段的类型解析为对象,尽管显式设置了属性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。
发布于 2020-12-14 04:13:59
我必须为string指定完全限定的类型名称
@ApiModelProperty(dataType = "java.lang.String", example = "10000101010")
private List<String> services;https://stackoverflow.com/questions/65279977
复制相似问题