mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-05 12:44:22 +00:00
Replaces the hand-rolled API docs UI with industry-standard tooling so
external integrations (Postman, Insomnia, openapi-generator) can
consume the panel API without parsing endpoints.js by hand.
Generator
- frontend/scripts/build-openapi.mjs: walks the existing endpoints.js
(still the single source of truth) and emits an OpenAPI 3.0.3 spec
at frontend/public/openapi.json. Handles Gin :param → {param} path
translation, body / query / path parameter splits, 200 + error
response examples, and Bearer + cookie security schemes
- npm run build now runs gen:api before vite build, so the spec is
always in sync with what's documented
Backend
- web/controller/dist.go exposes ServeOpenAPISpec which streams the
embedded dist/openapi.json with a short Cache-Control. Public
endpoint (no auth) so Postman can fetch it without first logging in
- web/web.go wires GET /panel/api/openapi.json before the auth-gated
/panel/api router
Panel
- ApiDocsPage now renders swagger-ui-react fed by the basePath-aware
openapi.json URL. Dark mode is overridden via CSS targeting the
Swagger UI internals
- CodeBlock / EndpointRow / EndpointSection are gone; the swagger-ui
vendor chunk (134 KB gzipped) only loads on this lazy route, not on
every panel page
- vite.config: vendor-swagger manualChunk keeps the new dep out of
the main vendor bundle
For Postman: import http://<panel>/panel/api/openapi.json. Everything
from /login + /panel/api/* shows up with auth, params, and examples.
52 lines
1.4 KiB
JSON
52 lines
1.4 KiB
JSON
{
|
|
"name": "3x-ui-frontend",
|
|
"private": true,
|
|
"version": "0.1.0",
|
|
"type": "module",
|
|
"description": "3x-ui panel frontend (React 19 + Ant Design 6 + Vite 8).",
|
|
"engines": {
|
|
"node": ">=22.0.0",
|
|
"npm": ">=10.0.0"
|
|
},
|
|
"scripts": {
|
|
"dev": "vite",
|
|
"build": "npm run gen:api && vite build",
|
|
"preview": "vite preview",
|
|
"lint": "eslint src",
|
|
"typecheck": "tsc --noEmit",
|
|
"gen:api": "node scripts/build-openapi.mjs"
|
|
},
|
|
"dependencies": {
|
|
"@ant-design/icons": "^6.2.3",
|
|
"@codemirror/lang-json": "^6.0.2",
|
|
"@codemirror/theme-one-dark": "^6.1.3",
|
|
"@tanstack/react-query": "^5.100.14",
|
|
"@tanstack/react-query-devtools": "^5.100.14",
|
|
"antd": "^6.4.3",
|
|
"axios": "^1.16.1",
|
|
"codemirror": "^6.0.2",
|
|
"dayjs": "^1.11.20",
|
|
"i18next": "^26.2.0",
|
|
"otpauth": "^9.5.1",
|
|
"persian-calendar-suite": "^1.5.5",
|
|
"qs": "^6.15.2",
|
|
"react": "^19.2.6",
|
|
"react-dom": "^19.2.6",
|
|
"react-i18next": "^17.0.8",
|
|
"react-router-dom": "^7.15.1",
|
|
"swagger-ui-react": "^5.32.6"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "^10.0.1",
|
|
"@types/react": "^19.2.15",
|
|
"@types/react-dom": "^19.2.3",
|
|
"@types/swagger-ui-react": "^5.18.0",
|
|
"@vitejs/plugin-react": "^6.0.2",
|
|
"eslint": "^10.4.0",
|
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
"globals": "^17.6.0",
|
|
"typescript": "^6.0.3",
|
|
"typescript-eslint": "^8.59.4",
|
|
"vite": "8.0.13"
|
|
}
|
|
}
|