4

我在生成带有 swagger 注释的 swagger.json 文件时遇到问题。问题在于生成带有数组的地图。

前任:

我有一个带有字段的@ApiModel:

@JsonProperty
private Map<String, String[]> example;

当它生成时,它看起来像这样:

"example" : {
               "type" : "object",
                "additionalProperties" : {
                "$ref" : "#/definitions/Array"
             }
            }

"Array" : {
            "type" : "object"
        },

当我根据生成的 json 使用 swagger-codegen 创建客户端类时,它解析为:

private Map<String, Array> example = new HashMap<String, Array>();

但是数组不存在。

根据我所见,json 应如下所示:

  "definitions": {
    "example": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    }
  }
}

有没有办法让它工作?

我使用:Dropwizard、Jersey2、Swagger、JAX-RS

4

0 回答 0