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

V3模板问题 #82

Open
BruceCham opened this issue Feb 4, 2024 · 0 comments
Open

V3模板问题 #82

BruceCham opened this issue Feb 4, 2024 · 0 comments

Comments

@BruceCham
Copy link

BruceCham commented Feb 4, 2024

重新整理了下问题 @gogoyqj

V3中camel命名异常,可通过配置 swaggerParse 解决【已解决】

module.exports = {
  "url": "./swagger.json",
  "swaggerParser": {
    "-o": "src/test",
    "-t": "v3/plugins/types-only",
    // "-DmodelPropertyNaming=snake_case": "",
    "-DmodelPropertyNaming=original": "", // 命名与yapi中的保持一致
  },
  "guardConfig": {
    "mode": "strict",
    "validUrlReg": /cungong/g
  }
}

1. 大小写异常 case 【影响小,可忽略】

在 V2/V3中都存在,必现,特别边缘的场景,暂时通过手工修正

2. V3模板 types-only 与 V2 对比,多余文件和 model 比较多,可优化冗余【待解决的小问题】

3. V3模板 types-tkit,存在 _json 目录未生成,造成报错异常 【待解决,必现】

4. V3模板下,存在 form-data require异常的问题 【应该v3模板的bug】

生成的ts中,require 为 false 的params,也变成了必填项

module.exports = {
  "url": "./swagger.json",
  "swaggerParser": {
    "-DmodelPropertyNaming=original": "",
    "-o": "src/test",
    // "-t": "plugins/types-only" // 存在大小写异常、model未生成的case
    "-t": "v3/plugins/types-only" // 存在大小写异常 required 生成异常
    // "-t": "v3/plugins/typescript-tkit-autos" // 只存在大小写异常
    // "-t": "v3/plugins/types-tkit" // 错误信息:Error: ENOENT: no such file or directory json 找不到
  },
  "guardConfig": {
    "mode": "strict",
    "validUrlReg": /cungong|spamftp/g
  }
}
{
  "swagger": "2.0",
  "info": {
    "title": "unknown",
    "version": "last",
    "description": "unknown"
  },
  "tags": [
    {
      "name": "cungong",
      "description": "cungongDesc"
    }
  ],
  "basePath": "",
  "schemes": [
    "http"
  ],
  "paths": {
    "/cungong/confiltermis/excavateadd": {
      "post": {
        "tags": [
          "cungong"
        ],
        "summary": "任务",
        "description": "",
        "consumes": [
          "multipart/form-data"
        ],
        "parameters": [
          {
            "name": "name",
            "in": "formData",
            "required": true,
            "description": "description",
            "type": "string"
          },
          {
            "name": "command_nos",
            "in": "formData",
            "required": false,
            "description": "description",
            "type": "string"
          },
          {
            "name": "add_type",
            "in": "formData",
            "required": true,
            "description": "description",
            "type": "string"
          },
          {
            "name": "file_url",
            "in": "formData",
            "required": false,
            "description": "description",
            "type": "string"
          },
          {
            "name": "data_status",
            "in": "formData",
            "required": false,
            "description": "description",
            "type": "string"
          },
          {
            "name": "data_rule",
            "in": "formData",
            "required": false,
            "description": "description",
            "type": "string"
          },
          {
            "name": "is_ai",
            "in": "formData",
            "required": false,
            "description": "description",
            "type": "string"
          },
          {
            "name": "start_time",
            "in": "formData",
            "required": false,
            "description": "description",
            "type": "string"
          },
          {
            "name": "end_time",
            "in": "formData",
            "required": false,
            "description": "description",
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "schema": {
              "type": "object",
              "title": "CungongConfiltermisExcavateadd",
              "properties": {
                "errNo": {
                  "type": "number"
                },
                "errstr": {
                  "type": "string"
                }
              },
              "required": [
                "errNo",
                "errstr"
              ]
            }
          }
        },
        "operationId": "cungongConfiltermisExcavateaddPost"
      }
    }
  }
}
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

1 participant