@alauda/doom 0.15.4 → 0.15.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/logo.svg +1 -1
- package/lib/cli/load-config.js +3 -0
- package/lib/plugins/shiki/rehypePlugin.js +0 -3
- package/lib/runtime/components/OpenAPIPath.js +20 -6
- package/lib/runtime/components/OpenAPIRef.d.ts +5 -0
- package/lib/runtime/components/OpenAPIRef.js +32 -33
- package/lib/runtime/components/Tabs.d.ts +4 -1
- package/lib/runtime/components/Tabs.js +7 -1
- package/lib/runtime/utils.js +4 -1
- package/package.json +1 -1
- package/styles/global.scss +18 -0
- package/styles/overview.module.scss +0 -6
package/assets/logo.svg
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg"
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><title>alauda_Blue</title><g id="de0a135b-885c-4036-939d-50f62fab32b6" data-name="Brand Logo"><path d="M31,16V31H24.41V15.93A8.34,8.34,0,0,0,8.13,13.34L5.65,14.56l2.08,1.73C8,20.39,9.41,27.26,21.44,31H15.92A15,15,0,1,1,31,16Z" fill="#3baee4"/><path d="M14.23,16.63a1.74,1.74,0,1,1-1.73-1.74A1.72,1.72,0,0,1,14.23,16.63Z" fill="#3baee4"/></g></svg>
|
package/lib/cli/load-config.js
CHANGED
|
@@ -7,7 +7,7 @@ import BananaSlug from 'github-slugger';
|
|
|
7
7
|
import { OpenAPIV3 } from 'openapi-types';
|
|
8
8
|
import { Fragment, useMemo, useState } from 'react';
|
|
9
9
|
import { omitRoutePathRefs, resolveRef } from '../utils.js';
|
|
10
|
-
import { OpenAPIRef } from './OpenAPIRef.js';
|
|
10
|
+
import { OpenAPIProperties, OpenAPIProperty, OpenAPIRef } from './OpenAPIRef.js';
|
|
11
11
|
import { HeadingTitle } from './_HeadingTitle.js';
|
|
12
12
|
import { Markdown } from './_Markdown.js';
|
|
13
13
|
import { RefLink } from './_RefLink.js';
|
|
@@ -35,12 +35,26 @@ export const OpenAPIResponses = ({ responses, openapi, }) => {
|
|
|
35
35
|
const responseObj = '$ref' in response
|
|
36
36
|
? resolveRef(openapi, response.$ref)
|
|
37
37
|
: response;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const responseContent = responseObj.content;
|
|
39
|
+
const schema = (responseContent?.['application/json'] ?? responseContent?.['*/*'])?.schema;
|
|
40
|
+
const type = schema && ('$ref' in schema ? schema : schema.type);
|
|
41
|
+
let typeNode;
|
|
42
|
+
let extraNode;
|
|
43
|
+
if (typeof type === 'string') {
|
|
44
|
+
typeNode = _jsx("code", { children: type });
|
|
45
|
+
if (type === 'object' &&
|
|
46
|
+
'properties' in schema &&
|
|
47
|
+
schema.properties) {
|
|
48
|
+
extraNode = (_jsxs("div", { className: "my-4", children: ["Properties:", _jsx(OpenAPIProperties, { properties: schema.properties, openapi: openapi })] }));
|
|
49
|
+
}
|
|
50
|
+
else if (type === 'array' && 'items' in schema && schema.items) {
|
|
51
|
+
extraNode = (_jsxs("div", { className: "my-4", children: ["Items:", _jsx(OpenAPIProperty, { property: schema.items, openapi: openapi })] }));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (type && '$ref' in type) {
|
|
55
|
+
typeNode = _jsx(RefLink, { "$ref": type.$ref });
|
|
42
56
|
}
|
|
43
|
-
return (_jsxs(X.li, { children: [_jsx("code", { children: code }),
|
|
57
|
+
return (_jsxs(X.li, { children: [_jsx("code", { children: code }), typeNode, ": ", responseObj.description, extraNode] }, code));
|
|
44
58
|
}) }));
|
|
45
59
|
};
|
|
46
60
|
const getRefsForPath = (openapi, path, knownRefs) => {
|
|
@@ -10,6 +10,11 @@ export interface OpenAPIRefProps {
|
|
|
10
10
|
openapiPath?: string;
|
|
11
11
|
collectRefs?: boolean;
|
|
12
12
|
}
|
|
13
|
+
export declare const OpenAPIProperty: ({ name, property, openapi, }: {
|
|
14
|
+
name?: string;
|
|
15
|
+
property: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject;
|
|
16
|
+
openapi: OpenAPIV3_1.Document;
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
18
|
export declare const OpenAPIProperties: ({ properties, openapi, }: {
|
|
14
19
|
properties: Record<string, OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject>;
|
|
15
20
|
openapi: OpenAPIV3_1.Document;
|
|
@@ -7,41 +7,40 @@ import { modelName, omitRoutePathRefs, resolveRef } from '../utils.js';
|
|
|
7
7
|
import { HeadingTitle } from './_HeadingTitle.js';
|
|
8
8
|
import { Markdown } from './_Markdown.js';
|
|
9
9
|
import { RefLink } from './_RefLink.js';
|
|
10
|
+
export const OpenAPIProperty = ({ name, property, openapi, }) => {
|
|
11
|
+
const propObj = '$ref' in property ? resolveRef(openapi, property.$ref) : property;
|
|
12
|
+
const type = propObj.type;
|
|
13
|
+
let typeNode;
|
|
14
|
+
if (type === 'array') {
|
|
15
|
+
const { items } = propObj;
|
|
16
|
+
const itemsObj = '$ref' in items ? resolveRef(openapi, items.$ref) : items;
|
|
17
|
+
const itemsType = itemsObj.type;
|
|
18
|
+
typeNode = (_jsxs("code", { children: ["[]", '$ref' in items ? _jsx(RefLink, { "$ref": items.$ref }) : itemsType] }));
|
|
19
|
+
}
|
|
20
|
+
else if (type === 'object') {
|
|
21
|
+
if (typeof propObj.additionalProperties === 'object') {
|
|
22
|
+
const props = propObj.additionalProperties;
|
|
23
|
+
const propsObj = '$ref' in props ? resolveRef(openapi, props.$ref) : props;
|
|
24
|
+
const propsType = propsObj.type;
|
|
25
|
+
typeNode = (_jsxs("code", { children: ["map[string]", typeof propsType === 'string'
|
|
26
|
+
? propsType
|
|
27
|
+
: '$ref' in props && _jsx(RefLink, { "$ref": props.$ref })] }));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
typeNode = _jsx("code", { children: type });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else if (typeof type === 'string') {
|
|
34
|
+
typeNode = _jsx("code", { children: type });
|
|
35
|
+
}
|
|
36
|
+
else if ('$ref' in property) {
|
|
37
|
+
typeNode = _jsx(RefLink, { "$ref": property.$ref });
|
|
38
|
+
}
|
|
39
|
+
return (_jsxs(_Fragment, { children: [name && (_jsxs(_Fragment, { children: [_jsx("code", { children: name }), ":", ' '] })), typeNode, _jsx(Markdown, { children: propObj.description })] }));
|
|
40
|
+
};
|
|
10
41
|
export const OpenAPIProperties = ({ properties, openapi, }) => {
|
|
11
42
|
const [X] = useState(getCustomMDXComponent);
|
|
12
|
-
return (_jsx(X.ul, { children: Object.entries(properties).map(([name,
|
|
13
|
-
const propObj = '$ref' in prop ? resolveRef(openapi, prop.$ref) : prop;
|
|
14
|
-
const type = propObj.type;
|
|
15
|
-
let typeNode;
|
|
16
|
-
if (type === 'array') {
|
|
17
|
-
const { items } = propObj;
|
|
18
|
-
const itemsObj = '$ref' in items ? resolveRef(openapi, items.$ref) : items;
|
|
19
|
-
const itemsType = itemsObj.type;
|
|
20
|
-
typeNode = (_jsxs("code", { children: ["[]", typeof itemsType === 'string'
|
|
21
|
-
? itemsType
|
|
22
|
-
: '$ref' in items && _jsx(RefLink, { "$ref": items.$ref })] }));
|
|
23
|
-
}
|
|
24
|
-
else if (type === 'object') {
|
|
25
|
-
if (typeof propObj.additionalProperties === 'object') {
|
|
26
|
-
const props = propObj.additionalProperties;
|
|
27
|
-
const propsObj = '$ref' in props ? resolveRef(openapi, props.$ref) : props;
|
|
28
|
-
const propsType = propsObj.type;
|
|
29
|
-
typeNode = (_jsxs("code", { children: ["map[string]", typeof propsType === 'string'
|
|
30
|
-
? propsType
|
|
31
|
-
: '$ref' in props && _jsx(RefLink, { "$ref": props.$ref })] }));
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
typeNode = _jsx("code", { children: type });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else if (typeof type === 'string') {
|
|
38
|
-
typeNode = _jsx("code", { children: type });
|
|
39
|
-
}
|
|
40
|
-
else if ('$ref' in prop) {
|
|
41
|
-
typeNode = _jsx(RefLink, { "$ref": prop.$ref });
|
|
42
|
-
}
|
|
43
|
-
return (_jsxs(X.li, { children: [_jsx("code", { children: name }), ": ", typeNode, _jsx(Markdown, { children: propObj.description })] }, index));
|
|
44
|
-
}) }));
|
|
43
|
+
return (_jsx(X.ul, { children: Object.entries(properties).map(([name, property], index) => (_jsx(X.li, { children: _jsx(OpenAPIProperty, { name: name, property: property, openapi: openapi }) }, index))) }));
|
|
45
44
|
};
|
|
46
45
|
const getRefsForSchema = (openapi, schema, knownRefs) => {
|
|
47
46
|
const refSchema = openapi.components?.schemas[schema];
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { Tabs as Tabs_ } from '@rspress/core/theme';
|
|
2
|
+
import { type ForwardRefExoticComponent, type RefAttributes } from 'react';
|
|
3
|
+
export declare const Tabs: ForwardRefExoticComponent<Parameters<typeof Tabs_>[0] & RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export default Tabs;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tabs as Tabs_ } from '@rspress/core/theme';
|
|
3
|
+
import { forwardRef, } from 'react';
|
|
4
|
+
export const Tabs = forwardRef(({ children, ...props }, ref) => {
|
|
5
|
+
return (_jsx("div", { className: "doom-tabs", children: _jsx(Tabs_, { ...props, ref: ref, children: children }) }));
|
|
6
|
+
});
|
|
7
|
+
export default Tabs;
|
package/lib/runtime/utils.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import virtual from 'doom-@api-virtual';
|
|
2
2
|
import { last, upperFirst } from 'es-toolkit';
|
|
3
3
|
import { get } from 'es-toolkit/compat';
|
|
4
|
-
export const modelName = (ref) =>
|
|
4
|
+
export const modelName = (ref) => {
|
|
5
|
+
const lastPart = last(ref.split('.'));
|
|
6
|
+
return upperFirst(lastPart.startsWith('#') ? lastPart.slice(1) : lastPart);
|
|
7
|
+
};
|
|
5
8
|
export const resolveRef = (openapi, ref) => {
|
|
6
9
|
if (!ref.startsWith('#/')) {
|
|
7
10
|
ref = `#/components/schemas/${ref}`;
|
package/package.json
CHANGED
package/styles/global.scss
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use "sass:color";
|
|
2
|
+
|
|
1
3
|
@import url(./shiki.css);
|
|
2
4
|
|
|
3
5
|
th,
|
|
@@ -90,6 +92,22 @@ td {
|
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
|
|
95
|
+
.doom-tabs {
|
|
96
|
+
div.language-mdx {
|
|
97
|
+
margin: 24px 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.language-mdx {
|
|
101
|
+
// https://github.com/web-infra-dev/rspress/blob/bbe6476c8394f9c95a98fd791f0614481f89d878/packages/theme-default/src/styles/code.css#L6
|
|
102
|
+
--rp-code-block-bg: #{color.adjust($color: #f6f8fa, $lightness: -5%)};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.dark .doom-tabs .language-mdx {
|
|
107
|
+
// https://github.com/web-infra-dev/rspress/blob/bbe6476c8394f9c95a98fd791f0614481f89d878/packages/theme-default/src/styles/code.css#L17
|
|
108
|
+
--rp-code-block-bg: #{color.adjust($color: #242424, $lightness: 5%)};
|
|
109
|
+
}
|
|
110
|
+
|
|
93
111
|
@mixin print {
|
|
94
112
|
.rspress {
|
|
95
113
|
&-nav,
|