繁体   English   中英

如何告诉 Swagger 用字符串完全替换集合类型?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM