kindergarten_java/reading-platform-frontend/orval.config.ts
tonytech 2a394a4882 chore(api): 接入 orval 自动生成 API 客户端
- 新增 orval.config.ts:从 OpenAPI spec 自动生成 TypeScript 代码
- 新增 src/api/request.ts:orval mutator,复用现有 axios 实例
- 新增 src/api/generated/:自动生成的 API 函数和类型定义(106个接口,155个类型)
- 新增 api-spec.json:后端 OpenAPI 规范快照
- package.json 新增脚本:api:fetch / api:gen / api:update

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 11:03:56 +08:00

26 lines
736 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'orval'
export default defineConfig({
readingPlatform: {
input: {
// 本地开发:使用下载的规范文件(运行 npm run api:fetch 更新)
// 服务器直连时改为:'http://8.148.151.56:3002/v3/api-docs'
target: './api-spec.json',
},
output: {
// 自动生成到这个目录,不要手动修改这里的文件
target: 'src/api/generated/api.ts',
schemas: 'src/api/generated/model',
client: 'axios',
// 复用项目里已有的 axios 实例(带 token、错误处理
override: {
mutator: {
path: 'src/api/request.ts',
name: 'request',
},
},
prettier: true,
},
},
})