Skip to content

@ApiResponse.response of primitive types is reported incorrectly #1120

Closed
@tomtit

Description

@tomtit

Swagger version is 1.5.3-M2-SNAPSHOT (branch develop_2.0)
This test resource:

@Api
@Path("xxx")
public class ResourceXXX {

  @GET
  @Path("test")
  @ApiResponses({ @ApiResponse(code = 400, message = "Message for URL", response = URL.class),
      @ApiResponse(code = 401, message = "Message for Long", response = Long.class),
      @ApiResponse(code = 402, message = "Message for String", response = String.class) })
  public Response test() {
    return null;
  }
}

is reported as follows:

{
  "swagger" : "2.0",
  "paths" : {
    "/xxx/test" : {
      "get" : {
        "operationId" : "test",
        "parameters" : [ ],
        "responses" : {
          "400" : {
            "description" : "Message for URL",
            "schema" : {
              "$ref" : "#/definitions/string"
            }
          },
          "401" : {
            "description" : "Message for Long"
          },
          "402" : {
            "description" : "Message for String"
          }
        }
      }
    }
  },
  "definitions" : {
    "string" : {
      "type" : "object",
      "properties" : {
        "protocol" : {
          "type" : "string"
        },
        "host" : {
          "type" : "string"
        },
        "port" : {
          "type" : "integer",
          "format" : "int32"
        },
        "file" : {
          "type" : "string"
        },
        "authority" : {
          "type" : "string"
        },
        "ref" : {
          "type" : "string"
        },
        "path" : {
          "type" : "string"
        },
        "query" : {
          "type" : "string"
        },
        "userInfo" : {
          "type" : "string"
        },
        "defaultPort" : {
          "type" : "integer",
          "format" : "int32"
        },
        "content" : {
          "type" : "object"
        }
      }
    }
  }
}

As you can see URL was reported as composite class of type string, Long and String were not reported at all.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions