swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.39k stars 2.19k forks source link

BUG: Long values displayed incorrectly in json response #2608

Open devmsaleh opened 6 years ago

devmsaleh commented 6 years ago

hi, i am using following dependencies

<dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.7.0</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.7.0</version>
        </dependency>

        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-jersey2-jaxrs</artifactId>
            <version>1.5.17</version>
        </dependency>

when i am making a get request with postman as follows: http://localhost:8081/hai/api/v1/findDonatorOldProjects/100000000000000614

i get the response correctly as follows:

{
    "errorCode": "SUCCESS_CODE",
    "errorCodeDesc": "تمت العملية نجاح",
    "errorCodeValue": 0,
    "response": {
        "data": [
            {
                "id": 100000000000001478,
                "name": "الرغيف الخير - الأردن"
            }
        ]
    }
}

but when i make the request with swagger ui, i get the following response

{
  "errorCode": "SUCCESS_CODE",
  "errorCodeDesc": "تمت العملية نجاح",
  "errorCodeValue": 0,
  "response": {
    "data": [
      {
        "id": 100000000000001470,
        "name": "الرغيف الخير - الأردن"
      }
    ]
  }
}

the long value 100000000000001478 is displayed incorrectly as 100000000000001470

kuza2010 commented 1 year ago

Same problem here! I use springdoc-openapi library (uses swagger-core internally) and faced with this issue. But when I started investigate it the discussion with the maintainer brings me to this issue.

See: https://github.com/springdoc/springdoc-openapi/issues/2174

kuza2010 commented 1 year ago

This is because js has right bound: 2^(53)-1 and java: 2^(63)-1. Seems nothing that we can really do here.