【问题标题】:Int32 Error whilst contract testing with Dredd与 Dredd 进行合同测试时出现 Int32 错误
【发布时间】:2020-04-28 16:05:22
【问题描述】:

我有一个使用 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 注释生成这个 swagger 文档:

@ApiModel
public class MyResponse{

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

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

}

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

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

【问题讨论】:

    标签: swagger swagger-2.0 springfox dredd


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2018-09-21
      • 1970-01-01
      • 2017-04-07
      • 1970-01-01
      • 1970-01-01
      • 2020-07-22
      • 2020-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多