[PR #4311] [CLOSED] feat(api-docs): enhance API documentation with missing endpoints, search, collapse, syntax highlighting, and route sync test #5649

Closed
opened 2026-10-31 20:48:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4311
Author: @abdalrahmanx9
Created: 5/12/2026
Status: ❌ Closed

Base: main ← Head: feat/api-docs-enhancements


📝 Commits (5)

  • a141b4f feat(api-docs): enhance API documentation with missing endpoints, search, collapse, and route sync test
  • 14604e0 feat(api-docs): add JSON syntax highlighting and top-right copy button to code blocks
  • 2aeaaa9 fix(api-docs): use distinct colors for JSON syntax highlighting (green strings, amber numbers)
  • 53b0593 fix(graphs): increase y-axis paddingLeft from 32 to 56 to prevent clipped labels
  • 73b2d64 fix(multi-node): scope tag and email unique constraints per node

📊 Changes

11 files changed (+894 additions, -38 deletions)

View changed files

📝 database/db.go (+53 -0)
📝 database/model/model.go (+2 -2)
📝 frontend/src/components/Sparkline.vue (+1 -1)
📝 frontend/src/pages/api-docs/ApiDocsPage.vue (+107 -9)
➕ frontend/src/pages/api-docs/CodeBlock.vue (+152 -0)
📝 frontend/src/pages/api-docs/EndpointRow.vue (+3 -6)
📝 frontend/src/pages/api-docs/EndpointSection.vue (+63 -7)
📝 frontend/src/pages/api-docs/endpoints.js (+236 -6)
➕ web/controller/api_docs_test.go (+265 -0)
📝 web/service/port_conflict.go (+10 -5)
📝 xray/client_traffic.go (+2 -2)

📄 Description

Summary

Enhance the in-panel API documentation page (/panel/api-docs) with complete endpoint coverage, visual improvements, and a CI test to keep docs in sync.

Changes

Complete endpoint coverage (29 previously undocumented routes added):

  • Server API: Added xrayMetricsState, xrayMetricsHistory, xrayObservatory, xrayObservatoryHistory
  • Settings API (new section): All 8 /panel/setting/* routes
  • Xray Settings API (new section): All 9 /panel/xray/* routes
  • Subscription Server (new section): /sub/:subid, /json/:subid, /clash/:subid
  • WebSocket (new section): /ws endpoint

Accuracy fixes:

  • Corrected history metric keys (netUp/netDown not netIn/netOut, load5/load15 missing, node metrics limited to cpu/mem)
  • Updated getNewVlessEnc description to reflect actual response shape

Response schemas: Added example responses to 15+ key endpoints (inbound list, server status, traffic, logs, cert generators, etc.)

UI improvements:

  • Search bar to filter endpoints by path, method, or description
  • Collapsible sections with expand/collapse all controls
  • JSON syntax highlighting (keys in blue, strings in green, numbers in amber, booleans in red, null in purple)
  • Hover-reveal copy button at top-right of every code block (replaces Ant Design inline copy icon)
  • Light and dark theme support

CI / maintainability:

  • New TestAPIRoutesDocumented Go test scans all controller files for route registrations and verifies every route is documented in endpoints.js — run with go test -run TestAPIRoutesDocumented

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/4311 **Author:** [@abdalrahmanx9](https://github.com/abdalrahmanx9) **Created:** 5/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/api-docs-enhancements` --- ### 📝 Commits (5) - [`a141b4f`](https://github.com/MHSanaei/3x-ui/commit/a141b4f4574edd385590a3c3bb0dab08579ffb8b) feat(api-docs): enhance API documentation with missing endpoints, search, collapse, and route sync test - [`14604e0`](https://github.com/MHSanaei/3x-ui/commit/14604e0c5120ace21c85bc3c26306f029b10e411) feat(api-docs): add JSON syntax highlighting and top-right copy button to code blocks - [`2aeaaa9`](https://github.com/MHSanaei/3x-ui/commit/2aeaaa90528e14d5394937110a58482119523301) fix(api-docs): use distinct colors for JSON syntax highlighting (green strings, amber numbers) - [`53b0593`](https://github.com/MHSanaei/3x-ui/commit/53b05931d44d6194088347142d8c806a97876a22) fix(graphs): increase y-axis paddingLeft from 32 to 56 to prevent clipped labels - [`73b2d64`](https://github.com/MHSanaei/3x-ui/commit/73b2d642473972e7552654d633dba21e0e9da7d3) fix(multi-node): scope tag and email unique constraints per node ### 📊 Changes **11 files changed** (+894 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `database/db.go` (+53 -0) 📝 `database/model/model.go` (+2 -2) 📝 `frontend/src/components/Sparkline.vue` (+1 -1) 📝 `frontend/src/pages/api-docs/ApiDocsPage.vue` (+107 -9) ➕ `frontend/src/pages/api-docs/CodeBlock.vue` (+152 -0) 📝 `frontend/src/pages/api-docs/EndpointRow.vue` (+3 -6) 📝 `frontend/src/pages/api-docs/EndpointSection.vue` (+63 -7) 📝 `frontend/src/pages/api-docs/endpoints.js` (+236 -6) ➕ `web/controller/api_docs_test.go` (+265 -0) 📝 `web/service/port_conflict.go` (+10 -5) 📝 `xray/client_traffic.go` (+2 -2) </details> ### 📄 Description ## Summary Enhance the in-panel API documentation page (`/panel/api-docs`) with complete endpoint coverage, visual improvements, and a CI test to keep docs in sync. ## Changes **Complete endpoint coverage** (29 previously undocumented routes added): - **Server API**: Added `xrayMetricsState`, `xrayMetricsHistory`, `xrayObservatory`, `xrayObservatoryHistory` - **Settings API** (new section): All 8 `/panel/setting/*` routes - **Xray Settings API** (new section): All 9 `/panel/xray/*` routes - **Subscription Server** (new section): `/sub/:subid`, `/json/:subid`, `/clash/:subid` - **WebSocket** (new section): `/ws` endpoint **Accuracy fixes**: - Corrected history metric keys (`netUp`/`netDown` not `netIn`/`netOut`, `load5`/`load15` missing, node metrics limited to `cpu`/`mem`) - Updated `getNewVlessEnc` description to reflect actual response shape **Response schemas**: Added example responses to 15+ key endpoints (inbound list, server status, traffic, logs, cert generators, etc.) **UI improvements**: - Search bar to filter endpoints by path, method, or description - Collapsible sections with expand/collapse all controls - JSON syntax highlighting (keys in blue, strings in green, numbers in amber, booleans in red, null in purple) - Hover-reveal copy button at top-right of every code block (replaces Ant Design inline copy icon) - Light and dark theme support **CI / maintainability**: - New `TestAPIRoutesDocumented` Go test scans all controller files for route registrations and verifies every route is documented in `endpoints.js` — run with `go test -run TestAPIRoutesDocumented` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 20:48:23 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5649
No description provided.