Haych
Haych

Reputation: 942

Int32 Error whilst contract testing with Dredd

I have an application which uses Swagger2. This has an endpoint which has the following swagger documentation:

{
  "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"
    }
  }
}

This automatically generated from annotations throughout my project.

When running my Dredd contract test, I get the following failure with this error message:

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

My dredd.yml file points to the automatically generated file but if I change that to point to manually created json file which is identical to the one shown above except the resultCount part looks like this:

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

Then my test will pass.

I am generating this swagger documentation using springfox annotations like this:

@ApiModel
public class MyResponse{

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

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

}

What I am trying to do is to have some kind of annotation that causes swagger2 to generate the documentation without the "format": "int32" line which seems to be causing the test failure.

I don't think this is a problem with Dredd but a problem with me not knowing how to express what I want in Swagger. Any ideas how to fix this issue? Is there a certain annotation I need to use?

Upvotes: 1

Views: 239

Answers (1)

slim1979
slim1979

Reputation: 28

Downgrade to dredd 12 solved this for me. Looks like 13.x versions have an issue with it

Upvotes: 1

Related Questions