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

modle文件缺失 #39

Closed
flames519 opened this issue Oct 15, 2021 · 7 comments
Closed

modle文件缺失 #39

flames519 opened this issue Oct 15, 2021 · 7 comments

Comments

@flames519
Copy link

1.当我单独定义include指定路径时, body和返回体的类型文件生成正常
2.当我include指定多个路径时, 部分路径只生成返回体或者只生成body的modle类型文件

@gogoyqj
Copy link
Owner

gogoyqj commented Oct 15, 2021

1.当我单独定义include指定路径时, body和返回体的类型文件生成正常 2.当我include指定多个路径时, 部分路径只生成返回体或者只生成body的modle类型文件

可以贴一下 swagger 和 配置

@flames519
Copy link
Author

`

  • 企业管理-企业详情,编辑收票地址

  • @summary 编辑企业收票信息

  • @param data: ParamsBodyenterpriseManageDetailSaveReceiptPost

  • @param opt ajax config

  • @returns models.EnterprisemanageUpdateEnterpriseBillInfo
    `

我找到了问题的位置,如果有相同的返回类型, api 目录下会复用, 导致其他接口的类型没有生成, 那如果我只想生成类型文件, 如果获知这种复用关系呢

@flames519
Copy link
Author

由于我使用 --models 命令 只生成ts类型文件, 并通过命名规则获取每个接口的类型, 而这种默认的复用关系让我找不到对应的类型文件

@gogoyqj
Copy link
Owner

gogoyqj commented Oct 18, 2021

`

  • 企业管理-企业详情,编辑收票地址
  • @summary 编辑企业收票信息
  • @param data: ParamsBodyenterpriseManageDetailSaveReceiptPost
  • @param opt ajax config
  • @returns models.EnterprisemanageUpdateEnterpriseBillInfo
    `

我找到了问题的位置,如果有相同的返回类型, api 目录下会复用, 导致其他接口的类型没有生成, 那如果我只想生成类型文件, 如果获知这种复用关系呢

这个需要解析 swagger 了,如果数据结构是复用的,那么相应的 schema $ref 也是会指向同一个 DTO,例如“#/definitions/AbQueryModel”

@flames519
Copy link
Author

flames519 commented Oct 19, 2021

好的, 非常感谢,目前我又发现了一个问题, 就继续在这里写了
这里有同一个接口生成的三个model文件

//  model\CurrencyGoodsSearchSelectGoodsListByCategory.ts
export interface CurrencyGoodsSearchSelectGoodsListByCategory {
    "data"?: Array<models.CurrencyGoodsSearchSelectGoodsListByCategoryData>; 
}

 //  model\CurrencyGoodsSearchSelectGoodsListByCategoryBody.ts
 
export interface CurrencyGoodsSearchSelectGoodsListByCategoryBody {
    "data": Array<models.CurrencyGoodsSearchselectGoodsListByCategoryData>;
}

//  model\CurrencyGoodsSearchSelectGoodsListByCategoryData.ts 

export interface CurrencyGoodsSearchselectGoodsListByCategoryData { }

这时出现了只有一个字母大小写错误的问题 : selectGoods 和 SelectGoods
想请问一下出现这种情况的原因是什么

@flames519
Copy link
Author

{
    "/currencyGoodsSearch/selectGoodsListByCategory": {
        "post": {
            "parameters": [
                {
                    "name": "CurrencyGoodsSearchSelectGoodsListByCategoryBody",
                    "in": "body"
                }
            ],
            "responses": {
                "200": {
                    "description": "successful operation",
                    "title": "CurrencyGoodsSearchSelectGoodsListByCategory"
                }
            }
        }
    }
}

这是配置项,为了方便看,我只保留了name url 和 title

@gogoyqj
Copy link
Owner

gogoyqj commented Feb 15, 2022

CurrencyGoodsSearchSelectGoodsListByCategoryBody

额,我用 4.0.2 版本,没有复现你说的这个问题 @flames519

@gogoyqj gogoyqj closed this as completed Feb 28, 2022
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

2 participants