簡體   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