OpenAPI Typescript Codegen 生成请求方法报错 -- 降级

npm 找不到命令

1. 输入 `get-ExecutionPolicy` 显示 Restricted (受限的)

2. 再输入 `Set-ExecutionPolicy -Scope CurrentUser`

       输入 RemoteSigned    给用户赋予权限即可

请求时返回JSON报错

  1. 上方命令向openapi 请求生成时返回 json报错

     {
       stack: 'JSONParserError: Error downloading http://localhost:8121/api/v2/api-docs \n' +
         'fetch is not defined\n' +
         '    at download (E:\\workspace\\CxCSOJ\\cxcsoj-frontend\\node_modules\\@apidevtools\\json-schema-ref-parser\\dist\\lib\\resolvers\\http.js:1
     13:15)',
       code: 'ERESOLVER',
       name: 'ResolverError',
       message: 'Error downloading http://localhost:8121/api/v2/api-docs \n' +
         'fetch is not defined',
       source: 'http://localhost:8121/api/v2/api-docs',
       path: null,
       toJSON: [Function: toJSON],
       footprint: 'null+http://localhost:8121/api/v2/api-docs+ERESOLVER+Error downloading http://localhost:8121/api/v2/api-docs \n' +
         'fetch is not defined',
       toString: [Function: toString]
     }
     ​
  2. 解决方案OpenAPI 生成的客户端有冲突的请求

    OpenAPI Typescript Codegen 版本进行降级到0.25.0

     npm i openapi-typescript-codegen@0.25.0
    
    使用以下命令生成
     npx openapi-typescript-codegen --input http://localhost:8121/api/v2/api-docs --output ./generated --client axios

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值