-
Notifications
You must be signed in to change notification settings - Fork 31
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
对整个项目接口生成时,存在部分生成了对应的operationId,但并没有生成对应的models的case;同时也存在大小写异常的case #81
Comments
最小可复现场景"auto-service": "^4.0.9" model丢失casemodel丢失的case在v3中是正常的,只在v2中存在此case,但把无关的删除后,没有重现,暂时忽略吧 大小写异常 casejson2service.jsmodule.exports = {
"url": "./swagger.json",
"swaggerParser": {
"-o": "src/services",
// "-t": "plugins/types-only" // 存在大小写异常、model未生成的case
"-t": "v3/plugins/typescript-tkit-autos" // 只存在大小写异常:与 types-only 是同一个文件异常,但命名规则不太一样
// "-t": "v3/plugins/types-tkit" // 错误信息:Error: ENOENT: no such file or directory json 找不到
},
"guardConfig": {
"mode": "safe"
}
} swagger.json{
"swagger": "2.0",
"info": {
"title": "unknown",
"version": "last",
"description": "unknown"
},
"tags": [
{
"name": "公共分类",
"description": "公共分类"
}
],
"basePath": "",
"schemes": [
"http"
],
"paths": {
"/cungong/audit/auditsubmit": {
"post": {
"tags": [
"公共分类"
],
"summary": "提交",
"description": "",
"consumes": [
"application/json"
],
"parameters": [
{
"name": "CungongAuditAuditsubmitBody",
"in": "body",
"schema": {
"type": "object",
"properties": {
"audit_district": {
"type": "integer",
"description": "id"
},
"is_confirm": {
"type": "integer",
"description": "1:确定"
},
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "主键id"
},
"reason": {
"type": "array",
"items": {
"type": "integer",
"description": "reasonId"
}
},
"status": {
"type": "integer",
"description": "1:选中,2:非选中"
},
"is_test": {
"type": "number",
"description": "0:非测试数据 1:测试数据"
}
},
"required": [
"id",
"reason",
"status",
"is_test"
]
}
}
},
"required": [
"audit_district",
"data",
"is_confirm"
]
}
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "object",
"$schema": "http:https://json-schema.org/draft-04/schema#",
"title": "CungongAuditAuditsubmit",
"properties": {
"errNo": {
"type": "integer"
},
"errstr": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"status": {
"type": "integer",
"description": "提交状态 1:成功,0失败"
},
"msg": {
"type": "string",
"description": "提示"
},
"list": {
"type": "array",
"items": {
"type": "integer",
"description": "审核数据id"
},
"description": "冲突的数据"
}
},
"required": [
"status",
"msg",
"list"
]
}
},
"required": [
"errNo",
"errstr",
"data"
]
}
}
},
"operationId": "cungongAuditAuditsubmitPost"
}
}
}
} |
@gogoyqj request 参数 audit_district
生成的文件中变成了 auditDistrict |
收到,我看看 |
@BruceCham "guardConfig": {
"mode": "strict" // 默认即严格模式
} 问题1:model缺失的问题我这边确实暂也不能复现哈 问题2:大小写异常……这个其实并不算异常,而是之前技术实现上的缺陷,我是在mustache模板里给参数名拼凑了前缀,所以不能保证一定遵循驼峰命名,这个目前没有办法解决,建议配置eslint或者tslint的ignore规则、直接将src/service目录ignore或者exclude 问题3:snake case变成camel casejson2service.js里配置了 因为你的swagger.json openAPI v2,可以不配置-t参数,这样就会使用v2 的jar去生成代码,如此就不会把snake case转换成camel case了; |
@gogoyqj model丢失的问题能复现了,好像是两个接口返回的一样时候,可能会造成另外一个没有生成 json2service.js
swagger.json
|
这看起来像是 v2 jar的bug,我换成v3就可以了,如果只生成类型的话,可以只用v3(我猜测v2可能有一个合并相同类型的逻辑在)
|
@gogoyqj
但还有个问题一直存在:选择 v3/plugins/types-only 时,java generate 没有生成 tmp/*_json下的文件,一直报错,目前v3 types-only无法使用 ... #55 |
@BruceCham 为何我这边尝试是可以的(莫非是因为你snake_case的值多了一个空格?): module.exports = {
"url": "./swagger.json",
"swaggerParser": {
"-o": "src/test",
"-t": "v3/plugins/types-only",
"-DmodelPropertyNaming=snake_case": "",
},
"guardConfig": {
"mode": "strict",
"validUrlReg": /cungong/g
}
} |
No description provided.
The text was updated successfully, but these errors were encountered: