[PR #4312] [MERGED] feat(api-docs): enhance API documentation with missing endpoints, search, collapse, syntax highlighting, body examples, error responses, and route sync test #5650

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4312
Author: @abdalrahmanx9
Created: 5/12/2026
Status: ✅ Merged
Merged: 5/12/2026
Merged by: @MHSanaei

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


📝 Commits (6)

  • 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)
  • 8e30a23 feat(api-docs): add request body examples, error responses, WebSocket message types, and subscription response headers
  • 34ea51f fix(api-docs): use ClipboardManager.copyText instead of copy to fix API token copy button
  • 26246ee fix

📊 Changes

6 files changed (+859 additions, -28 deletions)

View changed files

📝 frontend/src/pages/api-docs/ApiDocsPage.vue (+104 -5)
➕ frontend/src/pages/api-docs/CodeBlock.vue (+152 -0)
📝 frontend/src/pages/api-docs/EndpointRow.vue (+18 -8)
📝 frontend/src/pages/api-docs/EndpointSection.vue (+98 -7)
📝 frontend/src/pages/api-docs/endpoints.js (+327 -8)
➕ web/controller/api_docs_test.go (+160 -0)

📄 Description

Summary

Enhance the in-panel API documentation page (/panel/api-docs) with complete endpoint coverage, visual improvements, request/response examples, 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 with 4 message type descriptions

Accuracy fixes:

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

Request body examples: Added to 6 previously undocumented POST endpoints (updateGeofile, xraylogs, importDB, getNewEchCert, node update/:id, node test)

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

Error response examples: Added error shapes to key endpoints (login, inbound add, server stop/restart)

HTTP status codes: Documented in the page header (200, 401, 403, 404, 500)

Subscription headers table: Added 8 response headers with descriptions (Subscription-Userinfo, Profile-Title, Support-Url, 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) with light/dark theme
  • Hover-reveal copy button at top-right of every code block
  • Error responses shown in red-labeled blocks

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/4312 **Author:** [@abdalrahmanx9](https://github.com/abdalrahmanx9) **Created:** 5/12/2026 **Status:** ✅ Merged **Merged:** 5/12/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/api-docs-enhancements` --- ### 📝 Commits (6) - [`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) - [`8e30a23`](https://github.com/MHSanaei/3x-ui/commit/8e30a23a5f0b0b8014cebe0eb93cc20da24bf54a) feat(api-docs): add request body examples, error responses, WebSocket message types, and subscription response headers - [`34ea51f`](https://github.com/MHSanaei/3x-ui/commit/34ea51f7b468e9988767b038bc6eb899414bda94) fix(api-docs): use ClipboardManager.copyText instead of copy to fix API token copy button - [`26246ee`](https://github.com/MHSanaei/3x-ui/commit/26246ee810f92b6ea7bb5663a374192f783c3d3b) fix ### 📊 Changes **6 files changed** (+859 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/pages/api-docs/ApiDocsPage.vue` (+104 -5) ➕ `frontend/src/pages/api-docs/CodeBlock.vue` (+152 -0) 📝 `frontend/src/pages/api-docs/EndpointRow.vue` (+18 -8) 📝 `frontend/src/pages/api-docs/EndpointSection.vue` (+98 -7) 📝 `frontend/src/pages/api-docs/endpoints.js` (+327 -8) ➕ `web/controller/api_docs_test.go` (+160 -0) </details> ### 📄 Description ## Summary Enhance the in-panel API documentation page (`/panel/api-docs`) with complete endpoint coverage, visual improvements, request/response examples, 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 with 4 message type descriptions **Accuracy fixes**: - Corrected history metric keys (`netUp`/`netDown` not `netIn`/`netOut`, added `load5`/`load15`, node metrics limited to `cpu`/`mem`) - Updated `getNewVlessEnc` description to reflect actual response shape **Request body examples**: Added to 6 previously undocumented POST endpoints (`updateGeofile`, `xraylogs`, `importDB`, `getNewEchCert`, node `update/:id`, node `test`) **Response schemas**: Added example responses to 15+ key endpoints (inbound list, server status, traffic, logs, cert generators, etc.) **Error response examples**: Added error shapes to key endpoints (login, inbound add, server stop/restart) **HTTP status codes**: Documented in the page header (`200`, `401`, `403`, `404`, `500`) **Subscription headers table**: Added 8 response headers with descriptions (`Subscription-Userinfo`, `Profile-Title`, `Support-Url`, 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) with light/dark theme - Hover-reveal copy button at top-right of every code block - Error responses shown in red-labeled blocks **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:24 +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#5650
No description provided.