1

我有一个使用 Swagger2 的应用程序。这有一个端点,它具有以下招摇文档:

{
  "MyEndpoint": {
    "type": "object",
    "properties": {
      "resultCount": {
        "type": "integer",
        "format": "int32"
      },
      "results": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/MyResult"
        }
      },
      "title": "MyEndpoint"
    },
    "MyResult": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      },
      "title": "AResult"
    }
  }
}

这会从我整个项目的注释中自动生成。

在运行我的 Dredd 合同测试时,我收到以下错误消息:

error: Error: unknown format "int32" is used in schema at path "#/properties/resultCount"

我的dredd.yml文件指向自动生成的文件,但如果我将其更改为指向手动创建json的文件,该文件与上面显示的文件相同,但resultCount部分如下所示:

"resultCount": {
   "type": "integer"
}

然后我的测试将通过。

我正在使用这样的 springfox 注释生成这个招摇文档:

@ApiModel
public class MyResponse{

    @ApiModelProperty(dataType = "Number")
    private int resultCount;

    @ApiModelProperty(dataType = "MyResult")
    private MyResult aresult;

}

我想要做的是有某种注释,导致 swagger2 在没有"format": "int32"似乎导致测试失败的行的情况下生成文档。

我认为这不是 Dredd 的问题,而是我不知道如何在 Swagger 中表达我想要的问题。任何想法如何解决这个问题?我需要使用某个注释吗?

4

1 回答 1

1

降级到 dredd 12 为我解决了这个问题。看起来 13.x 版本有问题

于 2020-06-23T08:47:01.887 回答