Search code examples
javarestspring-bootswaggerspringfox

Springfox : Short type is considered as $int32


Language

  • Java / Springboot / Springfox[ 2.9.2]

Description

Hi, i'm using springfox-swagger-ui and springfox-bean-validators How can i tell to swagger that my property is a Short ($int16)

My Pojo

    @ApiModelProperty(required = true, dataType = "java.lang.Short")
    @NotNull
    @JsonProperty("deviceId")
    private Short deviceId;

The result in Swagger

deviceId* | integer($int32)

Expected

deviceId* | $int16

Thanks a lot

Cordially


Solution

  • Unfortunately you can't.

    Swagger specification does not support short (int16) data type.

    Supported data types:

    +-------------+---------+-----------+--------------------------------------------------+
    | Common Name |  type   |  format   |                     Comments                     |
    +-------------+---------+-----------+--------------------------------------------------+
    | integer     | integer | int32     | signed 32 bits                                   |
    | long        | integer | int64     | signed 64 bits                                   |
    | float       | number  | float     |                                                  |
    | double      | number  | double    |                                                  |
    | string      | string  |           |                                                  |
    | byte        | string  | byte      | base64 encoded characters                        |
    | binary      | string  | binary    | any sequence of octets                           |
    | boolean     | boolean |           |                                                  |
    | date        | string  | date      | As defined by full-date - RFC3339                |
    | dateTime    | string  | date-time | As defined by date-time - RFC3339                |
    | password    | string  | password  | Used to hint UIs the input needs to be obscured. |
    +-------------+---------+-----------+--------------------------------------------------+