chenshuai2144 / openapi2typescript

一个被大范围使用的小工具
326 stars 141 forks source link

openapi properties属性存在特殊符号导致解析ts格式化失败 #122

Closed lovewinders closed 1 year ago

lovewinders commented 1 year ago

当前使用版本:@umijs/openapi 1.9.1

下面是可复现openapi json的案例:【注意:properties中“Upload[file]”里有中括号特殊符号】

"/user-v2/company-user-import": {
"post": {
"summary": "企业总部人员导入",
"x-apifox-folder": "用户管理",
"x-apifox-status": "developing",
"deprecated": false,
"description": "",
"tags": [
"用户管理"
],
"parameters": [],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"Upload[file]": {
"type": "string",
"example": "file:///Users/dh/Downloads/信息填报人表.xlsx",
"format": "binary"
}
}
}
}
}
},
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {},
"x-apifox-ignore-properties": [],
"x-apifox-orders": []
}
}
}
}
},
"x-run-in-apifox": "https://apifox.com/web/project/3420946/apis/api-119630329-run",
"security": [
{
"bearer": []
}
]
}
},

报错信息如下,个人分析原因是:properties中属性存在“"Upload[file]"这种特殊[]符号导致无法解析成变量,因此报错

image
image

期望能支持属性特殊符号,或至少不要编译ts时文件报错

lovewinders commented 1 year ago

@chenshuai2144 你好,麻烦看下@umijs/openapi无法支持属性特殊符号的问题,谢谢啦

chenshuai2144 commented 1 year ago

这个库全靠社区维护的,我自己很少改东西

如果碰到没解决的bug,绕开一下吧,或者等好心人