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

int64生成的类型为string类型 #131

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

int64生成的类型为string类型 #131

vvv100 opened this issue Dec 5, 2023 · 4 comments

Comments

@vvv100
Copy link

vvv100 commented Dec 5, 2023

使用 openapi生成 Swagger 对应的前端代码时,发现 Long 类型在 Swagger 中被生成为 string 类型的前端代码,比如下面id和userId给生成成了string类型
// 前端生成的代码
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;
};

// swagger
"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"
}
}
},
这个版本
"@umijs/plugin-openapi": "^1.3.3",

@vvv100 vvv100 changed the title int64生成的确实string类型 int64生成的类型为string类型 Dec 5, 2023
@rookie-luochao
Copy link
Contributor

int64不应该被解析成string?

@vvv100
Copy link
Author

vvv100 commented Dec 6, 2023

int64不应该被解析成string?

为了保证精度是应该,但是我记得我以前使用openapi生成代码时long类型是转成number的,这样写dome的时候很方便

@jackeyzhang
Copy link

最近版本貌似忽然变了,让前端大量代码防不胜防,有没有回退或补救措施??

@rookie-luochao
Copy link
Contributor

最近版本貌似忽然变了,让前端大量代码防不胜防,有没有回退或补救措施??

措施一:可以让作者发布1.9.3版本包,参数加上isCamelCase: false

措施二: 你可以自己下载指定的npm包,npm install @umijs/openapi@1.9.1,重新生成代码

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

3 participants