mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-11 23:26:07 +00:00
83799d71b0
Stop hand-writing OpenAPI response examples, which kept drifting from the real payloads (clients/traffic missing fields, inbounds/list exposing userId which is json:"-", the fictional inbound-443 tag instead of the real in-<port>-<transport> form).
tools/openapigen now emits frontend/src/generated/examples.ts: a per-struct example instance built from type defaults, validate oneof/min bounds, and example: struct tags, with nested-ref expansion and a cycle guard. build-openapi.mjs composes the {success,obj} envelope from it for any endpoint annotated with responseSchema (+ responseSchemaArray for lists); the hand-written response is dropped for those. Service DTOs InboundOption/ApiTokenView/ProbeResultUI are added to the walker.
#4996: client password regeneration now produces a valid Shadowsocks 2022 PSK (correct base64 length per cipher) when an SS2022 inbound is attached, in both the single and bulk client forms; backend surfaces ssMethod on /inbounds/options so the UI can pick the right length.
Also: Swagger UI persists the Authorization token across reloads (persistAuthorization).
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { ConfigProvider, Layout } from 'antd';
|
|
import SwaggerUI from 'swagger-ui-react';
|
|
import 'swagger-ui-react/swagger-ui.css';
|
|
|
|
import { useTheme } from '@/hooks/useTheme';
|
|
import AppSidebar from '@/layouts/AppSidebar';
|
|
import './ApiDocsPage.css';
|
|
|
|
const basePath = window.X_UI_BASE_PATH || '';
|
|
const openApiUrl = `${basePath}panel/api/openapi.json`;
|
|
|
|
export default function ApiDocsPage() {
|
|
const { isDark, isUltra, antdThemeConfig } = useTheme();
|
|
|
|
const pageClass = useMemo(() => {
|
|
const classes = ['api-docs-page'];
|
|
if (isDark) classes.push('is-dark');
|
|
if (isUltra) classes.push('is-ultra');
|
|
return classes.join(' ');
|
|
}, [isDark, isUltra]);
|
|
|
|
return (
|
|
<ConfigProvider theme={antdThemeConfig}>
|
|
<Layout className={pageClass}>
|
|
<AppSidebar />
|
|
|
|
<Layout className="content-shell">
|
|
<Layout.Content className="content-area">
|
|
<div className="docs-wrapper">
|
|
<SwaggerUI
|
|
url={openApiUrl}
|
|
docExpansion="list"
|
|
deepLinking={false}
|
|
tryItOutEnabled
|
|
persistAuthorization
|
|
/>
|
|
</div>
|
|
</Layout.Content>
|
|
</Layout>
|
|
</Layout>
|
|
</ConfigProvider>
|
|
);
|
|
}
|