chore(api): 将 OpenAPI 规范文件改为 YAML 格式

- api-spec.json → api-spec.yml(内容相同,YAML 更易读)
- api:fetch 脚本自动转换 JSON→YAML 后删除 json 临时文件

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
tonytech 2026-03-03 11:11:53 +08:00
parent 2a394a4882
commit 076d832a42
5 changed files with 12151 additions and 5 deletions

View File

@ -2,4 +2,5 @@ node_modules/
dist/ dist/
.env.local .env.local
# orval 生成的文件已提交到 git无需忽略 # api-spec.json 是 api:fetch 的中间产物,转成 yml 后删除
api-spec.json

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,9 @@ import { defineConfig } from 'orval'
export default defineConfig({ export default defineConfig({
readingPlatform: { readingPlatform: {
input: { input: {
// 本地开发:使用下载的规范文件(运行 npm run api:fetch 更新) // 本地开发:使用下载的规范文件(运行 npm run api:update 更新)
// 服务器直连时改为:'http://8.148.151.56:3002/v3/api-docs' // 服务器直连时改为:'http://8.148.151.56:3002/v3/api-docs'
target: './api-spec.json', target: './api-spec.yml',
}, },
output: { output: {
// 自动生成到这个目录,不要手动修改这里的文件 // 自动生成到这个目录,不要手动修改这里的文件

View File

@ -8,7 +8,7 @@
"build": "vue-tsc && vite build", "build": "vue-tsc && vite build",
"preview": "vite preview", "preview": "vite preview",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"api:fetch": "curl -s http://8.148.151.56:3002/v3/api-docs -o api-spec.json && echo API spec updated", "api:fetch": "curl -s http://8.148.151.56:3002/v3/api-docs -o api-spec.json && node -e \"const fs=require('fs'),yaml=require('js-yaml'),d=JSON.parse(fs.readFileSync('api-spec.json','utf-8'));fs.writeFileSync('api-spec.yml',yaml.dump(d,{lineWidth:120,noRefs:true}));fs.unlinkSync('api-spec.json');console.log('api-spec.yml updated')\"",
"api:gen": "orval --config orval.config.ts", "api:gen": "orval --config orval.config.ts",
"api:update": "npm run api:fetch && npm run api:gen" "api:update": "npm run api:fetch && npm run api:gen"
}, },