[PR #6409] [MERGED] docs(api): align OpenAPI with runtime contracts #6256

Closed
opened 2026-11-02 04:07:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6409
Author: @LineGM
Created: 9/4/2026
Status: ✅ Merged
Merged: 9/4/2026
Merged by: @MHSanaei

Base: main ← Head: docs/openapi-runtime-contracts


📝 Commits (1)

  • d7130d7 docs(api): align OpenAPI with runtime contracts

📊 Changes

20 files changed (+4681 additions, -607 deletions)

View changed files

📝 docs/content/docs/en/reference/api/server.mdx (+8 -12)
📝 docs/content/docs/en/reference/api/subscription-server.mdx (+22 -1)
📝 docs/public/openapi.json (+1557 -234)
📝 frontend/public/openapi.json (+1557 -234)
📝 frontend/scripts/build-openapi.mjs (+32 -16)
📝 frontend/src/generated/examples.ts (+120 -0)
📝 frontend/src/generated/schemas.ts (+382 -0)
📝 frontend/src/generated/types.ts (+82 -0)
📝 frontend/src/generated/zod.ts (+91 -0)
📝 frontend/src/pages/api-docs/ApiDocsPage.css (+23 -0)
📝 frontend/src/pages/api-docs/ApiDocsPage.tsx (+25 -1)
📝 frontend/src/pages/api-docs/endpoints.ts (+147 -50)
➕ frontend/src/pages/api-docs/websocket-events.ts (+325 -0)
➕ frontend/src/test/openapi-runtime-contracts.test.ts (+228 -0)
📝 internal/web/routes_contract_test.go (+1 -1)
📝 internal/web/service/client_paging.go (+30 -30)
📝 internal/web/service/inbound_traffic.go (+5 -5)
📝 internal/web/service/server.go (+32 -18)
📝 internal/xray/traffic.go (+5 -5)
📝 tools/openapigen/main.go (+9 -0)

📄 Description

Summary

  • Align the generated OpenAPI 3.0.3 document with the runtime WebSocket, REST, client-paging, and subscription contracts.
  • Keep WebSocket events as UI cards and an operation extension while exporting only the real GET /ws upgrade path.
  • Generate the affected response schemas and synchronized frontend/docs artifacts from Go types.

Why

The API documentation had drifted from runtime behavior: it exported invalid pseudo WebSocket paths and a ws method, used the wrong envelope/event names, advertised stale REST response shapes, omitted client paging filters/sort keys, and missed registered subscription HEAD routes.

This is documentation/tooling alignment only. It does not change allLinks or other runtime response behavior.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

The new buildSpec() regression test was first run against the old implementation and failed all five contract groups. It now passes.

  • npm test -- src/test/openapi-runtime-contracts.test.ts --project unit
  • npm run format:check
  • npm run lint
  • npm run typecheck
  • npm run build
  • go test -p 1 ./tools/openapigen
  • go test -p 1 ./internal/web/service
  • go test -p 1 ./internal/web/controller
  • go test -p 1 ./internal/xray
  • make gen (run twice; generated diff hash was identical)
  • cd docs && corepack pnpm install --frozen-lockfile
  • cd docs && corepack pnpm gen:api
  • cd docs && corepack pnpm format:check
  • cd docs && corepack pnpm lint
  • cd docs && corepack pnpm typecheck
  • cd docs && corepack pnpm test (106 tests)
  • git diff --check

The full make verify is left to GitHub Actions as requested by the repository workflow.

Screenshots / recordings

WebSocket event cards use the same responsive Ant Design Row / Col / Card layout as the existing panel pages. Long examples scroll inside the code block.

WebSocket event cards

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally. (Full verification is left to GitHub Actions.)
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/6409 **Author:** [@LineGM](https://github.com/LineGM) **Created:** 9/4/2026 **Status:** ✅ Merged **Merged:** 9/4/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `docs/openapi-runtime-contracts` --- ### 📝 Commits (1) - [`d7130d7`](https://github.com/MHSanaei/3x-ui/commit/d7130d7444ecbecb72b619fb7909ed7ef2cac001) docs(api): align OpenAPI with runtime contracts ### 📊 Changes **20 files changed** (+4681 additions, -607 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/reference/api/server.mdx` (+8 -12) 📝 `docs/content/docs/en/reference/api/subscription-server.mdx` (+22 -1) 📝 `docs/public/openapi.json` (+1557 -234) 📝 `frontend/public/openapi.json` (+1557 -234) 📝 `frontend/scripts/build-openapi.mjs` (+32 -16) 📝 `frontend/src/generated/examples.ts` (+120 -0) 📝 `frontend/src/generated/schemas.ts` (+382 -0) 📝 `frontend/src/generated/types.ts` (+82 -0) 📝 `frontend/src/generated/zod.ts` (+91 -0) 📝 `frontend/src/pages/api-docs/ApiDocsPage.css` (+23 -0) 📝 `frontend/src/pages/api-docs/ApiDocsPage.tsx` (+25 -1) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+147 -50) ➕ `frontend/src/pages/api-docs/websocket-events.ts` (+325 -0) ➕ `frontend/src/test/openapi-runtime-contracts.test.ts` (+228 -0) 📝 `internal/web/routes_contract_test.go` (+1 -1) 📝 `internal/web/service/client_paging.go` (+30 -30) 📝 `internal/web/service/inbound_traffic.go` (+5 -5) 📝 `internal/web/service/server.go` (+32 -18) 📝 `internal/xray/traffic.go` (+5 -5) 📝 `tools/openapigen/main.go` (+9 -0) </details> ### 📄 Description ## Summary - Align the generated OpenAPI 3.0.3 document with the runtime WebSocket, REST, client-paging, and subscription contracts. - Keep WebSocket events as UI cards and an operation extension while exporting only the real `GET /ws` upgrade path. - Generate the affected response schemas and synchronized frontend/docs artifacts from Go types. ## Why The API documentation had drifted from runtime behavior: it exported invalid pseudo WebSocket paths and a `ws` method, used the wrong envelope/event names, advertised stale REST response shapes, omitted client paging filters/sort keys, and missed registered subscription `HEAD` routes. This is documentation/tooling alignment only. It does not change `allLinks` or other runtime response behavior. ## Type of change - [ ] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [x] Documentation - [ ] Tests only - [x] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [x] Subscription (share links / Clash / JSON) - [x] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? The new `buildSpec()` regression test was first run against the old implementation and failed all five contract groups. It now passes. - `npm test -- src/test/openapi-runtime-contracts.test.ts --project unit` - `npm run format:check` - `npm run lint` - `npm run typecheck` - `npm run build` - `go test -p 1 ./tools/openapigen` - `go test -p 1 ./internal/web/service` - `go test -p 1 ./internal/web/controller` - `go test -p 1 ./internal/xray` - `make gen` (run twice; generated diff hash was identical) - `cd docs && corepack pnpm install --frozen-lockfile` - `cd docs && corepack pnpm gen:api` - `cd docs && corepack pnpm format:check` - `cd docs && corepack pnpm lint` - `cd docs && corepack pnpm typecheck` - `cd docs && corepack pnpm test` (106 tests) - `git diff --check` The full `make verify` is left to GitHub Actions as requested by the repository workflow. ## Screenshots / recordings WebSocket event cards use the same responsive Ant Design `Row` / `Col` / `Card` layout as the existing panel pages. Long examples scroll inside the code block. ![WebSocket event cards](https://raw.githubusercontent.com/LineGM/3x-ui/pr-assets/openapi-runtime-contracts/screenshots/openapi-runtime-contracts.png?v=21cfcf64) ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. (Full verification is left to GitHub Actions.) - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:26 +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#6256
No description provided.