FrontEndDev-org / openapi-axios

OpenAPI Specification ➡️ TypeScript
MIT License
5 stars 0 forks source link

执行报错:Cannot read property 'get' of undefined #238

Closed StreakingMan closed 1 year ago

StreakingMan commented 1 year ago

参照示例配置,在空项目中运行报错。

node: v14.21.3 npm: 6.14.18 package manager: npm

openapi.config.cjs

// openapi.config.cjs
const { defineConfig } = require('openapi-axios');

module.exports = defineConfig({
    openAPIs: [
        {
            // 将会生成 src/apis/swagger/petStore3.ts 文件
            name: 'swagger/petStore3',
            // 可以是一个 URL 链接或者本地路径,或者一个 OPENAPI3 文档对象
            document: 'https://petstore3.swagger.io/api/v3/openapi.json',
        },
    ],
});

package.json

{
  "name": "empty-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^1.4.0",
    "openapi-axios": "^0.15.1",
    "typescript": "^5.1.3"
  }
}

output

Cannot read property 'get' of undefined