[英]How to tell Swagger to replace collection type entirely with string?
我遇到了由 Swagger 自动生成的 model 架构的问题。 我有一个List<String>
类型的集合字段,我想将其序列化为纯字符串,并且为此我有单独的序列化程序。 Jackson 做得很好,但不是模式生成器。 尽管明确设置了属性dataType
,但它将字段类型解析为 object :
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
。
我必须为string
指定完全限定的类型名称
@ApiModelProperty(dataType = "java.lang.String", example = "10000101010")
private List<String> services;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.