Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [BUG] openapi把swagger的int64类型生成为string类型 #11077

Closed
vvv100 opened this issue Dec 5, 2023 · 4 comments
Closed

🐛 [BUG] openapi把swagger的int64类型生成为string类型 #11077

vvv100 opened this issue Dec 5, 2023 · 4 comments

Comments

@vvv100
Copy link

vvv100 commented Dec 5, 2023

🐛 bug 描述

使用 Ant Design Pro 生成 Swagger 对应的前端代码时,发现 Long 类型在 Swagger 中被生成为 string 类型的前端代码
比如下面id和userId给生成成了string类型

📷 复现步骤 | Recurrence steps

type InterfaceInfoVO = {
createTime?: string;
description?: string;
id?: string;
isDeleted?: number;
method?: string;
name?: string;
requestHeader?: string;
requestParams?: string;
responseHeader?: string;
sdkToken?: string;
status?: number;
totalNum?: number;
updateTime?: string;
url?: string;
userId?: string;
};

"InterfaceInfoVO": {
"title": "InterfaceInfoVO",
"type": "object",
"properties": {
"createTime": {
"type": "string",
"format": "date-time"
},
"description": {
"type": "string"
},
"id": {
"type": "integer",
"format": "int64"
},
"isDeleted": {
"type": "integer",
"format": "int32"
},
"method": {
"type": "string"
},
"name": {
"type": "string"
},
"requestHeader": {
"type": "string"
},
"requestParams": {
"type": "string"
},
"responseHeader": {
"type": "string"
},
"sdkToken": {
"type": "string"
},
"status": {
"type": "integer",
"format": "int32"
},
"totalNum": {
"type": "integer",
"format": "int32"
},
"updateTime": {
"type": "string",
"format": "date-time"
},
"url": {
"type": "string"
},
"userId": {
"type": "integer",
"format": "int64"
}
}
},

@vvv100
Copy link
Author

vvv100 commented Dec 5, 2023

用的ant design pro v6.0.0

@yuyihan666
Copy link

+1

@chenshuai2144
Copy link
Collaborator

这个问题是关于 openAPI 中的数据类型映射的问题。根据你提供的代码和问题描述,你的 InterfaceInfoVO 类型中的 iduserId 字段在 Swagger 中被定义为 integer 类型,并且使用了 format 属性指定了 int64 格式。然而,在生成的前端代码中,这两个字段被生成成了 string 类型。

这个是因为前端是没办法处理 int64 这么大的数字,为了简单处理转化成了 string

@znxnx
Copy link

znxnx commented Jan 19, 2024

你好,请问解决了吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants