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

🧐[问题 | question] 如何使用OpenAPI生成代码呢? #11181

Open
fanhualei opened this issue Mar 12, 2024 · 2 comments
Open

🧐[问题 | question] 如何使用OpenAPI生成代码呢? #11181

fanhualei opened this issue Mar 12, 2024 · 2 comments

Comments

@fanhualei
Copy link

🧐 问题描述 | Problem description

按照官方文档的做了,但是报错。

fatal - AssertionError [ERR_ASSERTION]: Invalid config keys: model, initialState, layout, moment2dayjs, locale, antd, request, access
    at Config.validateConfig (/home/fanhl/08-web/test/pro2024/aifarm/node_modules/@umijs/core/dist/config/config.js:209:31)
    at Config.getConfig (/home/fanhl/08-web/test/pro2024/aifarm/node_modules/@umijs/core/dist/config/config.js:67:12)
    at Service.resolveConfig (/home/fanhl/08-web/test/pro2024/aifarm/node_modules/@umijs/core/dist/service/service.js:352:55)
    at Service.run (/home/fanhl/08-web/test/pro2024/aifarm/node_modules/@umijs/core/dist/service/service.js:276:42)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Service.run2 (/home/fanhl/08-web/test/pro2024/aifarm/node_modules/umi/dist/service/service.js:65:12)
    at async Object.run (/home/fanhl/08-web/test/pro2024/aifarm/node_modules/umi/dist/cli/cli.js:56:7) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

我的openAPI文件如下,是用的apifox到处的文件,是不是文件格式有问题?

{
    "info": {
        "title": "个人项目",
        "description": "",
        "version": "1.0.0"
    },
    "tags": [],
    "paths": {
        "/getStudent": {
            "get": {
                "summary": "得到学生信息",
                "deprecated": false,
                "description": "",
                "tags": [],
                "parameters": [
                    {
                        "name": "studentId",
                        "in": "query",
                        "description": "",
                        "required": false,
                        "type": "number"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "type": "object",
                            "properties": {
                                "success": {
                                    "type": "boolean",
                                    "title": "是否成功"
                                },
                                "data": {
                                    "type": "object",
                                    "properties": {
                                        "sutdentId": {
                                            "type": "number",
                                            "title": "学生编号"
                                        },
                                        "studentName": {
                                            "type": "string",
                                            "title": "姓名"
                                        },
                                        "age": {
                                            "type": "number",
                                            "title": "年龄"
                                        },
                                        "address": {
                                            "type": "string",
                                            "title": "住址"
                                        }
                                    },
                                    "x-apifox-orders": [
                                        "sutdentId",
                                        "studentName",
                                        "age",
                                        "address"
                                    ],
                                    "required": [
                                        "sutdentId",
                                        "studentName",
                                        "age",
                                        "address"
                                    ],
                                    "title": "学生信息",
                                    "x-apifox-ignore-properties": []
                                }
                            },
                            "x-apifox-orders": [
                                "success",
                                "data"
                            ],
                            "required": [
                                "success",
                                "data"
                            ],
                            "x-apifox-ignore-properties": []
                        }
                    }
                },
                "security": [],
                "x-apifox-folder": "",
                "x-apifox-status": "developing",
                "x-run-in-apifox": "https://apifox.com/web/project/4147484/apis/api-154765495-run",
                "produces": [
                    "application/json"
                ]
            }
        }
    },
    "swagger": "2.0",
    "definitions": {},
    "securityDefinitions": {},
    "x-components": {}
}
@Edisonchow119
Copy link

你可以尝试把后端给你的接口文档(json格式)添加到
congig/config.ts下面的路径中, 再运行openapi脚本

openAPI: [{
    schemaPath: '接口文档',
}]

@njflove
Copy link

njflove commented May 13, 2024

有解决办法吗,我也是这个问题,执行umi openapi包上面的错

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