用法
首先下载axios
npm install axios
官网:https://github.com/ferdikoomen/openapi-typescript-codegen
首先安装:
npm install openapi-typescript-codegen --save-dev
–input:指定接口文档的路径、url 或字符串内容(必填)
–output:代码生成的目录
–client:生成的代码所需要使用的请求库
openapi --input ./spec.json --output ./generated --client xhr
首先复制接口文档的路径
完整路径:http://localhost:8121/api/v2/api-docs
实例代码
openapi --input http://localhost:8121/api//v2/api-docs --output ./generated --client axios
执行完成后,在