yapi icon indicating copy to clipboard operation
yapi copied to clipboard

运行的response中long型数据被四舍五入

Open naah69 opened this issue 7 years ago • 4 comments

版本号

1.7.0

什么问题

我们接口使用long型数字作为数据id,但是在使用yapi时,发现针对esponse返回的long型id进行修改,导致数据不一致

正常的id是256935335202652164 yapi却给四舍五入为256935335202652160

postman:

{
            "alarmRuleName": "规则2019-08-26 01:46:16",
            "alarmRuleType": "REALTIME_FILTER",
            "desc": "",
            "id": 256935335202652164,
            "ruleField": "tag[\"total\"]",
            "ruleOperator": ">",
            "ruleThreshold": "5000"
        }

yapi:

{
      "alarmRuleName": "规则2019-08-26 01:46:16",
      "alarmRuleType": "REALTIME_FILTER",
      "desc": "",
      "id": 256935335202652160,
      "ruleField": "tag[\"total\"]",
      "ruleOperator": ">",
      "ruleThreshold": "5000"
    }

如何复现此问题

long型数据都有这个问题

什么浏览器

chrome 76.0.3809.100

什么系统(Linux, Windows, macOS)

macOS

naah69 avatar Aug 26 '19 03:08 naah69

刚才看了下cross-request 貌似cross-request获取就是错误的

naah69 avatar Aug 26 '19 03:08 naah69

cross-request 3.0

naah69 avatar Aug 26 '19 03:08 naah69

你可以看下 前端 JS Number 最大值是 9007199254740992 超过都会补零。所以你直接返回 "id": 256935335202652164, 到真实前端也只能拿到错的 256935335202652160

DevilLeven avatar Sep 03 '19 03:09 DevilLeven

好的 已解决 后端返回string就可以了

naah69 avatar Sep 03 '19 09:09 naah69