Skip to content

Commit 916f94f

Browse files
Yuerchuclaude
andcommitted
feat: migrate to animate-ui components, add motion preference setting
Replace shadcn dialog and sidebar with animate-ui animated variants (flip animation for dialogs, spring transitions for sidebar). Add a "Motion" toggle in General Settings (System / On / Reduce) backed by MotionConfig so users sensitive to motion can opt out. Also redesign the loading skeleton to match the actual EndpointsView layout. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent eee748b commit 916f94f

35 files changed

Lines changed: 3254 additions & 88 deletions

‎README.md‎

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,60 @@
22

33
A modern, feature-rich OpenAPI documentation viewer and API testing tool. Built with React, TypeScript, Shadcn/ui, and Tailwind CSS.
44

5-
**Live Demo**: [openapi.yxqi.cn](https://openapi.yxqi.cn)
5+
**Live Demo**: [openapi.yxqi.cn](https://openapi.yxqi.cn) | [README 中文版](README.zh-CN.md)
66

77
## Features
88

9+
### API Documentation & Testing
10+
911
- **Schema-driven forms** — Auto-renders inputs based on OpenAPI schema types (text, number, boolean, enum, date picker, file upload, UUID generator)
1012
- **Live API testing** — Send requests directly from the browser with parameter validation, auth headers, and response display
1113
- **JSON editor** — CodeMirror 6 with syntax highlighting, bidirectional sync with schema form
1214
- **Structured schema display** — Three-column table view (Field / Type / Description) with nested object support
13-
- **Data model browser** — Browse all schema definitions with cross-references to endpoints
14-
- **Model ↔ Endpoint linking** — See which models an endpoint uses, and which endpoints reference a model
1515
- **Curl generation** — Auto-generated curl command with one-click copy
1616
- **Token extraction** — Detect token fields in login responses and apply as Bearer auth with one click
17+
- **Request history** — Per-endpoint request history stored in IndexedDB
18+
19+
### Data Models
20+
21+
- **Model browser** — Browse all schema definitions with field details and constraints
22+
- **Model graph** — Interactive relationship graph with focus/depth controls and SVG/PNG/Mermaid export
23+
- **Model ↔ Endpoint linking** — See which models an endpoint uses, and which endpoints reference a model
24+
25+
### Schema Viewer
26+
27+
- **OpenAPI & external schemas** — View schemas from loaded spec or upload standalone JSON/YAML files
28+
- **Field detail inspector** — Constraints, default values, enum options, file upload rules, cross-field rules
29+
- **Category & type filtering** — Filter schemas by category tags and types
30+
31+
### Environment Management
32+
33+
- **Environment profiles** — Create multiple environments (local/dev/test/staging/prod) with independent base URLs and auth configs
34+
- **Auto-seed from spec** — Environments auto-populate from OpenAPI `servers[]` field
35+
- **Per-environment auth** — Each environment stores its own auth type, token, and credentials
36+
- **Quick switching** — Sidebar dropdown switcher (shadcn workspace-switcher pattern) for instant environment switching
37+
- **Cross-environment API status** — Background-fetch specs from all environments to detect endpoint presence; auto-infers lifecycle status (Online / Testing / In Dev / Local Only / Teammate's Work)
38+
- **Status filtering** — Filter endpoints by their cross-environment status
39+
40+
### Diagnostics & Diff
41+
42+
- **API diagnostics** — Detect issues like unresolved $refs, duplicate operationIds, empty schemas, missing descriptions
43+
- **Spec diff** — Compare two OpenAPI specs side-by-side with breaking change detection
44+
45+
### Favorites
46+
47+
- **Star endpoints** — Bookmark frequently used endpoints with a star icon
48+
- **Favorites view** — Dedicated sidebar page to browse all starred endpoints
49+
50+
### General
51+
1752
- **Multiple auth methods** — Bearer, Basic, API Key, OAuth2 Password flow
1853
- **Swagger 2.0 / OpenAPI 3.0 / 3.1 compatible** — Auto-converts Swagger 2.0 specs
19-
- **Dark theme** — OKLCH color system with custom scrollbar styling
20-
- **i18n** — Chinese and English, switchable in sidebar, persisted to localStorage
21-
- **Animations** — Smooth transitions powered by Motion and animate-ui
54+
- **Dark theme** — OKLCH color system with system/light/dark mode
55+
- **i18n** — English, Simplified Chinese, Traditional Chinese, Hong Kong Chinese, Japanese, Korean
56+
- **Share links** — Generate shareable URLs with spec, base URL, and current location
57+
- **Environment variables** — Define `{{variables}}` for use in parameters and request bodies
58+
- **Command palette** — `Cmd+K` / `Ctrl+K` to search endpoints, models, and schemas
2259
- **Progressive rendering** — Handles 500+ endpoints without blocking the UI
2360
- **Single-file output** — Builds to a single `dist/index.html` for easy deployment
2461
- **FastAPI integration** — Python package for drop-in Swagger UI replacement
@@ -41,12 +78,12 @@ Open [http://localhost:5173](http://localhost:5173), paste an OpenAPI spec URL,
4178
| `auth_type` | Set auth type (`bearer`, `basic`, `apikey`) | `&auth_type=bearer` |
4279
| `auth_token` | Set auth token | `&auth_token=xxx` |
4380
| `title` | Override page title | `&title=My%20API` |
44-
| `lang` | Set language (`zh`, `en`) | `&lang=en` |
4581

4682
## Build
4783

4884
```bash
49-
pnpm build # Production build → dist/index.html (single file)
85+
pnpm build # Production build -> dist/index.html (single file)
86+
pnpm test # Run tests
5087
pnpm lint # ESLint
5188
pnpm typecheck # TypeScript type check
5289
```
@@ -66,11 +103,13 @@ setup_docs(app)
66103
## Tech Stack
67104

68105
- **React 19** + **TypeScript 6** + **Vite 8**
69-
- **Shadcn/ui** (new-york style) — 15+ components
106+
- **Shadcn/ui** (Radix Nova style) — 20+ components
70107
- **Tailwind CSS v4** with OKLCH color system
71108
- **CodeMirror 6** — JSON editor
109+
- **TanStack Virtual** — Virtualized lists for large specs
72110
- **Motion** (Framer Motion) + **animate-ui** — Animations
73-
- **react-i18next** — Internationalization
111+
- **idb** — IndexedDB wrapper for persistent storage
112+
- **react-i18next** — Internationalization (6 languages)
74113
- **Sonner** — Toast notifications
75114
- **marked** — Markdown rendering
76115
- **vite-plugin-singlefile** — Single HTML output
@@ -80,18 +119,23 @@ setup_docs(app)
80119
```
81120
src/
82121
├── components/
83-
│ ├── ui/ # Shadcn components
122+
│ ├── ui/ # Shadcn components (20+)
84123
│ ├── animate-ui/ # Animated components (motion-powered)
85-
│ ├── layout/ # AppSidebar, Header, ViewToolbar, SelectionFab
86-
│ ├── endpoints/ # RouteCard, TryTab, DocTab, ResponsePanel, TagFilter
87-
│ ├── models/ # ModelsView, ModelCard
88-
│ ├── schema/ # SchemaTree, SchemaForm
89-
│ └── editor/ # JsonEditor (CodeMirror)
90-
├── hooks/ # useOpenAPI, useAuth, useRequest, useSettings
124+
│ ├── layout/ # AppSidebar, Header, EnvironmentSwitcher, ViewToolbar, SelectionFab
125+
│ ├── endpoints/ # RouteCard, EndpointsView, FavoritesView, TryTab, DocTab, HistoryTab
126+
│ ├── models/ # ModelsView, ModelCard, ModelGraphView
127+
│ ├── schema/ # SchemaViewerView, SchemaTree, SchemaForm, SchemaInput
128+
│ ├── settings/ # SettingsDialog, ConnectionSettings, AuthSettings, StorageSettings
129+
│ ├── tools/ # ProjectToolsView (Diagnostics, Diff)
130+
│ ├── search/ # CommandPalette
131+
│ ├── share/ # ShareDialog
132+
│ └── editor/ # JsonEditor, CodeViewer
133+
├── hooks/ # useOpenAPI, useAuth, useRequest, useSettings, useEnvironments,
134+
│ # useFavorites, useMultiEnvStatus
91135
├── contexts/ # OpenAPIContext, AuthContext
92136
├── lib/
93-
│ └── openapi/ # Pure TS logic (ref resolution, schema processing, v2 conversion)
94-
└── locales/ # zh.ts, en.ts
137+
│ └── openapi/ # Parser, ref resolution, schema processing, route extraction, diff
138+
└── locales/ # en, zh_CN, zh_TW, zh_HK, ja, ko
95139
```
96140

97141
## License

‎README.zh-CN.md‎

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Apilot
2+
3+
现代化的 OpenAPI 文档查看与 API 测试工具。基于 React、TypeScript、Shadcn/ui 和 Tailwind CSS 构建。
4+
5+
**在线体验**:[openapi.yxqi.cn](https://openapi.yxqi.cn) | [English README](README.md)
6+
7+
## 功能特性
8+
9+
### API 文档与测试
10+
11+
- **Schema 驱动表单** — 根据 OpenAPI Schema 类型自动渲染输入控件(文本、数字、布尔、枚举、日期选择器、文件上传、UUID 生成器)
12+
- **在线 API 测试** — 在浏览器中直接发送请求,支持参数校验、认证头和响应展示
13+
- **JSON 编辑器** — CodeMirror 6 语法高亮,与 Schema 表单双向同步
14+
- **结构化 Schema 展示** — 三列表格视图(字段 / 类型 / 描述),支持嵌套对象展开
15+
- **Curl 生成** — 自动生成 curl 命令,一键复制
16+
- **Token 提取** — 检测登录响应中的 token 字段,一键设为 Bearer 认证
17+
- **请求历史** — 每个端点的请求记录,持久化存储在 IndexedDB
18+
19+
### 数据模型
20+
21+
- **模型浏览器** — 浏览所有 Schema 定义,展示字段详情和约束条件
22+
- **模型关系图** — 交互式关系图谱,支持聚焦/深度控制,导出 SVG/PNG/Mermaid
23+
- **模型 ↔ 端点关联** — 查看端点引用的模型,以及引用某个模型的所有端点
24+
25+
### Schema 查看器
26+
27+
- **OpenAPI 和外部 Schema** — 查看已加载 spec 中的 Schema,或上传独立的 JSON/YAML 文件
28+
- **字段详情检查** — 约束条件、默认值、枚举选项、文件上传规则、跨字段规则
29+
- **分类与类型过滤** — 按分类标签和类型筛选 Schema
30+
31+
### 环境管理
32+
33+
- **环境配置** — 创建多个环境(本地/开发/测试/预发布/生产),各自独立的 Base URL 和认证配置
34+
- **从 Spec 自动填充** — 环境列表自动从 OpenAPI `servers[]` 字段生成
35+
- **独立认证** — 每个环境存储自己的认证类型、Token 和凭据
36+
- **快速切换** — 侧边栏下拉选择器,一键切换环境
37+
- **跨环境 API 状态检测** — 后台拉取各环境的 spec,自动检测端点存在性,推断生命周期状态(已上线 / 测试中 / 开发中 / 本地开发 / 他人开发)
38+
- **状态筛选** — 按跨环境状态筛选端点列表
39+
40+
### 诊断与差异对比
41+
42+
- **API 诊断** — 检测未解析的 $ref、重复 operationId、空 Schema、缺失描述等问题
43+
- **Spec 差异对比** — 两个 OpenAPI 规范并排对比,标注破坏性变更
44+
45+
### 收藏
46+
47+
- **星标端点** — 点击星标收藏常用端点
48+
- **收藏页面** — 侧边栏独立页面,集中浏览所有已收藏端点
49+
50+
### 通用
51+
52+
- **多种认证方式** — Bearer、Basic、API Key、OAuth2 密码模式
53+
- **兼容 Swagger 2.0 / OpenAPI 3.0 / 3.1** — 自动转换 Swagger 2.0 规范
54+
- **深色主题** — OKLCH 色彩系统,支持跟随系统/浅色/深色模式
55+
- **多语言** — 英语、简体中文、繁体中文、港式中文、日语、韩语
56+
- **分享链接** — 生成包含 Spec 地址、Base URL 和当前位置的分享链接
57+
- **环境变量** — 定义 `{{变量}}`,在参数和请求体中使用
58+
- **命令面板** — `Cmd+K` / `Ctrl+K` 快速搜索端点、模型和 Schema
59+
- **渐进渲染** — 500+ 端点不卡顿
60+
- **单文件输出** — 构建为单个 `dist/index.html`,部署简单
61+
- **FastAPI 集成** — Python 包,一行代码替换 FastAPI 内置 Swagger UI
62+
63+
## 快速开始
64+
65+
```bash
66+
pnpm install
67+
pnpm dev
68+
```
69+
70+
打开 [http://localhost:5173](http://localhost:5173),粘贴 OpenAPI Spec URL,点击加载。
71+
72+
## URL 参数
73+
74+
| 参数 | 说明 | 示例 |
75+
|------|------|------|
76+
| `openapi_url` | 自动加载 Spec | `?openapi_url=https://api.example.com/openapi.json` |
77+
| `base_url` | 覆盖服务器地址 | `&base_url=https://api.example.com` |
78+
| `auth_type` | 设置认证类型(`bearer`、`basic`、`apikey`) | `&auth_type=bearer` |
79+
| `auth_token` | 设置认证 Token | `&auth_token=xxx` |
80+
| `title` | 覆盖页面标题 | `&title=My%20API` |
81+
82+
## 构建
83+
84+
```bash
85+
pnpm build # 生产构建 -> dist/index.html(单文件)
86+
pnpm test # 运行测试
87+
pnpm lint # ESLint 检查
88+
pnpm typecheck # TypeScript 类型检查
89+
```
90+
91+
## FastAPI 集成
92+
93+
参见 [openapi-advance-python](https://github.com/Yuerchu/openapi-advance-python),一行代码替换 FastAPI 内置的 Swagger UI:
94+
95+
```python
96+
from fastapi import FastAPI
97+
from openapi_advance import setup_docs
98+
99+
app = FastAPI(docs_url=None)
100+
setup_docs(app)
101+
```
102+
103+
## 技术栈
104+
105+
- **React 19** + **TypeScript 6** + **Vite 8**
106+
- **Shadcn/ui**(Radix Nova 风格)— 20+ 组件
107+
- **Tailwind CSS v4** + OKLCH 色彩系统
108+
- **CodeMirror 6** — JSON 编辑器
109+
- **TanStack Virtual** — 大列表虚拟滚动
110+
- **Motion**(Framer Motion)+ **animate-ui** — 动画
111+
- **idb** — IndexedDB 封装,持久化存储
112+
- **react-i18next** — 国际化(6 种语言)
113+
- **Sonner** — Toast 通知
114+
- **marked** — Markdown 渲染
115+
- **vite-plugin-singlefile** — 单 HTML 文件输出
116+
117+
## 项目结构
118+
119+
```
120+
src/
121+
├── components/
122+
│ ├── ui/ # Shadcn 组件(20+)
123+
│ ├── animate-ui/ # 动画组件(Motion 驱动)
124+
│ ├── layout/ # AppSidebar, Header, EnvironmentSwitcher, ViewToolbar, SelectionFab
125+
│ ├── endpoints/ # RouteCard, EndpointsView, FavoritesView, TryTab, DocTab, HistoryTab
126+
│ ├── models/ # ModelsView, ModelCard, ModelGraphView
127+
│ ├── schema/ # SchemaViewerView, SchemaTree, SchemaForm, SchemaInput
128+
│ ├── settings/ # SettingsDialog, ConnectionSettings, AuthSettings, StorageSettings
129+
│ ├── tools/ # ProjectToolsView(诊断、差异对比)
130+
│ ├── search/ # CommandPalette(命令面板)
131+
│ ├── share/ # ShareDialog(分享对话框)
132+
│ └── editor/ # JsonEditor, CodeViewer
133+
├── hooks/ # useOpenAPI, useAuth, useRequest, useSettings, useEnvironments,
134+
│ # useFavorites, useMultiEnvStatus
135+
├── contexts/ # OpenAPIContext, AuthContext
136+
├── lib/
137+
│ └── openapi/ # 解析器、$ref 解析、Schema 处理、路由提取、差异对比
138+
└── locales/ # en, zh_CN, zh_TW, zh_HK, ja, ko
139+
```
140+
141+
## 许可证
142+
143+
MIT

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "apilot",
33
"private": true,
4-
"version": "0.2.2",
4+
"version": "0.3.0",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
@@ -28,6 +28,7 @@
2828
"@codemirror/view": "^6.41.0",
2929
"@dagrejs/dagre": "^3.0.0",
3030
"@faker-js/faker": "^10.4.0",
31+
"@floating-ui/react": "^0.27.19",
3132
"@hookform/resolvers": "^5.2.2",
3233
"@readme/openapi-parser": "^6.0.1",
3334
"@redocly/openapi-core": "^2.28.0",

‎pnpm-lock.yaml‎

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)