Skip to content

Commit ae6f22a

Browse files
authored
feat(docs): API Reference — full REST endpoint docs + AI-readable layer (#1257)
Adds the /docs/api API Reference: an openapi.yaml-driven renderer covering the REST endpoints and WebSocket commands with trilingual (en / zh-CN / zh-HK) content, multi-language raw-HTTP request samples, Try-it, search, and machine-readable .md pages plus llms.txt / llms-full.txt entries. Also restores six operations that were lost when generated modules shared a path (order_detail, cancel_order, list_watchlist_groups, delete_watchlist_group, list_topic_replies, list_grid_orders), keeps action verbs in endpoint names so endpoints sharing a resource noun stay distinguishable, and ports the time-condition order (#1289), DelayedNotReported (#1263) and attached-order depth level (#1189) docs into the spec.
1 parent 1678704 commit ae6f22a

97 files changed

Lines changed: 50873 additions & 4379 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3737

3838
old_docs
3939
.superpowers
40+
# superpowers plans/specs are local working artifacts — never version them.
41+
# (astro-migration files already tracked on main stay tracked; gitignore does
42+
# not affect already-tracked files.)
4043
docs/superpowers/*
41-
!docs/superpowers/specs/
42-
!docs/superpowers/specs/**
43-
!docs/superpowers/plans/
44-
!docs/superpowers/plans/**
4544
.claude/worktrees
4645
.worktrees
4746

‎astro.config.ts‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,61 @@ const sitemapLocale = (url: string) =>
2525
const BUILD_FORMAT = process.env['BUILD_FORMAT'] === 'directory' ? 'directory' : 'file'
2626
const ASSETS_DIR = process.env['ASSETS_DIR'] === '_docs' ? '_docs' : 'assets'
2727

28+
// Dev-only reverse proxy for the TryIt debugger. Vite's built-in http-proxy
29+
// returns 502 for these HTTPS upstreams under bun, so forward with fetch (which
30+
// works). `/api-prod` → production gateway.
31+
function apiDevProxy() {
32+
const TARGETS: Record<string, string> = {
33+
'/api-prod': 'https://openapi.longbridge.com',
34+
// Legacy default prefix used by <TryIt> when no baseUrl is passed.
35+
'/api': 'https://openapi.longbridge.com',
36+
}
37+
return {
38+
name: 'lb-api-dev-proxy',
39+
apply: 'serve' as const,
40+
configureServer(server: { middlewares: { use: (fn: (req: any, res: any, next: () => void) => void) => void } }) {
41+
// Dev only: corporate networks MITM these HTTPS upstreams with a cert the
42+
// dev process doesn't trust, so outbound fetch fails. Skip verification —
43+
// this never runs in a production build (apply: 'serve').
44+
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'
45+
server.middlewares.use(async (req: any, res: any, next: () => void) => {
46+
const url: string = req.url ?? ''
47+
const prefix = Object.keys(TARGETS).find((p) => url === p || url.startsWith(p + '/'))
48+
if (!prefix) return next()
49+
const target = TARGETS[prefix]
50+
const path = url.slice(prefix.length) || '/'
51+
try {
52+
const chunks: Buffer[] = []
53+
for await (const c of req) chunks.push(c as Buffer)
54+
const method: string = (req.method ?? 'GET').toUpperCase()
55+
const headers: Record<string, string> = {}
56+
for (const [k, v] of Object.entries(req.headers)) {
57+
if (k === 'host' || k === 'connection' || k === 'content-length') continue
58+
if (typeof v === 'string') headers[k] = v
59+
}
60+
const upstream = await fetch(target + path, {
61+
method,
62+
headers,
63+
body: method === 'GET' || method === 'HEAD' || chunks.length === 0 ? undefined : Buffer.concat(chunks),
64+
})
65+
res.statusCode = upstream.status
66+
upstream.headers.forEach((value: string, key: string) => {
67+
const k = key.toLowerCase()
68+
// Body is already decoded by fetch — don't forward encoding/length.
69+
if (k === 'content-encoding' || k === 'content-length' || k === 'transfer-encoding') return
70+
res.setHeader(key, value)
71+
})
72+
res.end(Buffer.from(await upstream.arrayBuffer()))
73+
} catch (err) {
74+
res.statusCode = 502
75+
res.setHeader('content-type', 'application/json; charset=utf-8')
76+
res.end(JSON.stringify({ code: -1, msg: `dev proxy error: ${err instanceof Error ? err.message : String(err)}`, data: null }))
77+
}
78+
})
79+
},
80+
}
81+
}
82+
2883
export default defineConfig({
2984
site: SITE,
3085
// 产物形态按边缘分轨,默认 'file':
@@ -80,6 +135,11 @@ export default defineConfig({
80135
],
81136
vite: {
82137
plugins: [
138+
// Dev proxy for the API Reference TryIt debugger: one prefix per
139+
// environment so the 生产/测试 toggle can hit either backend without CORS.
140+
// Implemented with fetch (not Vite's http-proxy, which 502s under bun for
141+
// these HTTPS upstreams). Dev only — prod talks to the real domains.
142+
apiDevProxy(),
83143
tailwind(),
84144
// Rename mdx frontmatter `layout:` → `docs_layout:` so astro-mdx
85145
// doesn't try to resolve values like "api-reference" as module

‎bun.lock‎

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

‎docs/en/docs/account/alert/update_alert.mdx‎

Lines changed: 0 additions & 241 deletions
This file was deleted.

‎docs/en/docs/account/overview.mdx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Create and manage price alerts for securities.
2929
|---|---|
3030
| [list_alerts](./alert/list-alerts) | List all active price alerts |
3131
| [create_alert](./alert/create-alert) | Create a new price alert |
32-
| [update_alert](./alert/update-alert) | Update an existing alert |
3332
| [delete_alert](./alert/delete-alert) | Delete a price alert |
3433

3534
## DCAContext

0 commit comments

Comments
 (0)