@umami/shiso 1.13.0 → 1.14.0
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/bin/shiso.mjs +0 -0
- package/dist/chunks/App.js +110 -110
- package/dist/chunks/architectureDiagram-5GKGNRK7.js +1 -1
- package/dist/chunks/chunk-GMAD6QVW.js +1 -1
- package/dist/chunks/cose-bilkent-JH36ORCC.js +1 -1
- package/dist/chunks/dist.js +1 -1
- package/dist/chunks/docs.js +200 -280
- package/dist/chunks/ganttDiagram-EL5Y4UJY.js +1 -1
- package/dist/chunks/src.js +1 -1
- package/dist/components.js +2 -2
- package/dist/entry-client.js +1 -1
- package/dist/entry-server.js +2 -2
- package/package.json +1 -1
- package/scripts/lib/openapi.mjs +24 -13
- package/src/components/OpenApiOperation.tsx +41 -62
- package/src/components/docs/Param.tsx +6 -0
- package/src/components/docs/PropertiesTable.tsx +52 -36
- package/src/components/docs/index.ts +2 -3
- package/src/components/docs/styles.ts +0 -8
- package/src/lib/openapi.ts +17 -1
- package/types/components.d.ts +4 -14
- package/src/components/docs/ParamField.tsx +0 -57
- package/src/components/docs/ResponseField.tsx +0 -48
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ar as __commonJSMin, jr as __toESM } from "./docs.js";
|
|
2
2
|
import { n as __name } from "./chunk-Y2CYZVJY.js";
|
|
3
3
|
import { a as nogamma, c as Rgb, d as define_default, f as extend, g as require_dayjs_min, i as hue, m as log, p as select_default, s as Color, u as rgbConvert } from "./src.js";
|
|
4
4
|
import { H as setAccDescription, K as setDiagramTitle, U as setAccTitle, a as clear, c as configureSvgSize, s as common_default, v as getAccDescription, w as getDiagramTitle, x as getConfig2, y as getAccTitle } from "./chunk-DU6HZSFF.js";
|
package/dist/chunks/src.js
CHANGED
package/dist/components.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as Column, Bt as Callout, C as Tooltip, Ct as Icon, Et as Expandable, Gt as Tip, Ht as Danger, It as Changelog, Jt as Button, Kt as Warning, Lt as Update, Mt as CodeGroup, Qt as AccordionGroup, Rt as Card, S as TreeFolder, St as Link, Ut as Info, Vt as Check, Wt as Note, Yt as Badge, Zt as Accordion, _ as FileTree, _t as Param, b as Tree, bn as mermaidSource, bt as usePanelContent, dt as Tiles, ft as Tab, gt as PropertiesTable, ht as Steps, jt as Columns, mt as Step, n as ZoomableImage, pt as Tabs, qt as WarningBanner, ut as Tile, v as FileTreeFile, vt as Panel, wt as Frame, x as TreeFile, xt as useSetPanelContent, y as FileTreeFolder, yn as Mermaid, yt as PanelProvider, zt as CardGroup } from "./chunks/docs.js";
|
|
2
2
|
|
|
3
|
-
export { Accordion, AccordionGroup, Badge, Button, Callout, Card, CardGroup, Changelog, Check, CodeGroup, Column, Columns, Danger, Expandable, FileTree, FileTreeFile, FileTreeFolder, Frame, Icon, Info, Link, Mermaid, Note, Panel, PanelProvider, Param,
|
|
3
|
+
export { Accordion, AccordionGroup, Badge, Button, Callout, Card, CardGroup, Changelog, Check, CodeGroup, Column, Columns, Danger, Expandable, FileTree, FileTreeFile, FileTreeFolder, Frame, Icon, Info, Link, Mermaid, Note, Panel, PanelProvider, Param, PropertiesTable, Step, Steps, Tab, Tabs, Tile, Tiles, Tip, Tooltip, Tree, TreeFile, TreeFolder, Update, Warning, WarningBanner, ZoomableImage, mermaidSource, usePanelContent, useSetPanelContent };
|
package/dist/entry-client.js
CHANGED
package/dist/entry-server.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cr as Router, Dr as createPath, Or as parsePath, kr as ABSOLUTE_URL_REGEX } from "./chunks/docs.js";
|
|
2
2
|
import { a as docsSite, c as getSeo, d as standalonePages, f as getDocModule, g as toAbsoluteUrl, h as BASE_URL, i as docsHomeUrl, l as siteConfig, m as getScopeForPage, n as buildHead, o as getLocaleByPathname, p as getLastModified, r as renderHeadToString, s as getRedirects, t as App, u as siteName } from "./chunks/App.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { renderToString } from "react-dom/server";
|
|
6
6
|
|
|
7
|
-
//#region ../../node_modules/.pnpm/react-router@8.3.0_react-
|
|
7
|
+
//#region ../../node_modules/.pnpm/react-router@8.3.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/react-router/dist/production/lib/dom/server.js
|
|
8
8
|
/**
|
|
9
9
|
* react-router v8.3.0
|
|
10
10
|
*
|
package/package.json
CHANGED
package/scripts/lib/openapi.mjs
CHANGED
|
@@ -588,13 +588,26 @@ export function hasOperationParameters(operation) {
|
|
|
588
588
|
);
|
|
589
589
|
}
|
|
590
590
|
|
|
591
|
+
function operationParameterSections(operation) {
|
|
592
|
+
return [
|
|
593
|
+
{ location: 'header', heading: 'Headers', id: 'headers' },
|
|
594
|
+
{ location: 'path', heading: 'Path parameters', id: 'path-parameters' },
|
|
595
|
+
{ location: 'query', heading: 'Query parameters', id: 'query-parameters' },
|
|
596
|
+
{ location: 'cookie', heading: 'Cookie parameters', id: 'cookie-parameters' },
|
|
597
|
+
].filter(
|
|
598
|
+
({ location }) =>
|
|
599
|
+
operation.parameters[location].length > 0 ||
|
|
600
|
+
(location === 'header' && operation.security.length > 0),
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
|
|
591
604
|
/**
|
|
592
605
|
* Anchor ids for the generated sections, in render order. Mirrors
|
|
593
606
|
* operationSections in src/lib/openapi.ts (asserted by tests/openapi.test.mjs).
|
|
594
607
|
*/
|
|
595
608
|
export function operationAnchors(operation) {
|
|
596
609
|
return [
|
|
597
|
-
...(
|
|
610
|
+
...operationParameterSections(operation).map(section => section.id),
|
|
598
611
|
...(operation.requestBody ? ['request-body'] : []),
|
|
599
612
|
...(operation.responses.length ? ['responses'] : []),
|
|
600
613
|
...(operation.samples.length ? ['code-samples'] : []),
|
|
@@ -617,13 +630,6 @@ export function normalizeOperationKey(value) {
|
|
|
617
630
|
|
|
618
631
|
/** Search-index sections for an operation, matching operationAnchors ids. */
|
|
619
632
|
export function operationSearchSections(operation) {
|
|
620
|
-
const allParameters = [
|
|
621
|
-
...operation.parameters.path,
|
|
622
|
-
...operation.parameters.query,
|
|
623
|
-
...operation.parameters.header,
|
|
624
|
-
...operation.parameters.cookie,
|
|
625
|
-
];
|
|
626
|
-
|
|
627
633
|
return [
|
|
628
634
|
{
|
|
629
635
|
heading: undefined,
|
|
@@ -632,11 +638,16 @@ export function operationSearchSections(operation) {
|
|
|
632
638
|
.filter(Boolean)
|
|
633
639
|
.join(' '),
|
|
634
640
|
},
|
|
635
|
-
{
|
|
636
|
-
heading
|
|
637
|
-
id
|
|
638
|
-
text:
|
|
639
|
-
|
|
641
|
+
...operationParameterSections(operation).map(({ location, heading, id }) => ({
|
|
642
|
+
heading,
|
|
643
|
+
id,
|
|
644
|
+
text: [
|
|
645
|
+
...operation.parameters[location].map(schemaText),
|
|
646
|
+
...(location === 'header' && operation.security.length > 0
|
|
647
|
+
? ['Authorization Authentication credentials']
|
|
648
|
+
: []),
|
|
649
|
+
].join(' '),
|
|
650
|
+
})),
|
|
640
651
|
{
|
|
641
652
|
heading: 'Request body',
|
|
642
653
|
id: 'request-body',
|
|
@@ -2,16 +2,10 @@ import { CodeBlock } from '@/components/CodeBlock';
|
|
|
2
2
|
import { Badge } from '@/components/docs/Badge';
|
|
3
3
|
import { CodeGroup } from '@/components/docs/CodeGroup';
|
|
4
4
|
import { Expandable } from '@/components/docs/Expandable';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { styles } from '@/components/docs/styles';
|
|
8
|
-
import { operationSections, statusColor } from '@/lib/openapi';
|
|
5
|
+
import { PropertiesTable } from '@/components/docs/PropertiesTable';
|
|
6
|
+
import { operationParameterSections, operationSections, statusColor } from '@/lib/openapi';
|
|
9
7
|
import type { NormalizedOperation, SchemaNode } from '@/lib/types';
|
|
10
8
|
|
|
11
|
-
type ParamLocation = 'path' | 'query' | 'header' | 'cookie';
|
|
12
|
-
|
|
13
|
-
const PARAM_LOCATIONS: ParamLocation[] = ['path', 'query', 'header', 'cookie'];
|
|
14
|
-
|
|
15
9
|
function FieldChildren({ node }: { node: SchemaNode }) {
|
|
16
10
|
return (
|
|
17
11
|
<>
|
|
@@ -29,44 +23,35 @@ function FieldChildren({ node }: { node: SchemaNode }) {
|
|
|
29
23
|
)}
|
|
30
24
|
{node.children && node.children.length > 0 && (
|
|
31
25
|
<Expandable title="properties">
|
|
32
|
-
{node.children
|
|
33
|
-
<SchemaField key={child.name || child.type} node={child} />
|
|
34
|
-
))}
|
|
26
|
+
<SchemaTable nodes={node.children} />
|
|
35
27
|
</Expandable>
|
|
36
28
|
)}
|
|
37
29
|
</>
|
|
38
30
|
);
|
|
39
31
|
}
|
|
40
32
|
|
|
41
|
-
function
|
|
42
|
-
const hasDetails = Boolean(node.description || node.enum?.length || node.children?.length);
|
|
43
|
-
|
|
33
|
+
function SchemaTable({ nodes }: { nodes: SchemaNode[] }) {
|
|
44
34
|
return (
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
<PropertiesTable>
|
|
36
|
+
{nodes.map(node => (
|
|
37
|
+
<PropertiesTable.Row
|
|
38
|
+
key={node.name || node.type}
|
|
39
|
+
name={node.name || node.type}
|
|
40
|
+
type={node.type}
|
|
41
|
+
required={node.required}
|
|
42
|
+
deprecated={node.deprecated}
|
|
43
|
+
default={node.default}
|
|
44
|
+
>
|
|
45
|
+
<FieldChildren node={node} />
|
|
46
|
+
</PropertiesTable.Row>
|
|
47
|
+
))}
|
|
48
|
+
</PropertiesTable>
|
|
54
49
|
);
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
/** Renders a schema tree: a root object's properties, or the node itself. */
|
|
58
53
|
function SchemaFields({ node }: { node: SchemaNode }) {
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<>
|
|
62
|
-
{node.children.map(child => (
|
|
63
|
-
<SchemaField key={child.name || child.type} node={child} />
|
|
64
|
-
))}
|
|
65
|
-
</>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return <SchemaField node={node} />;
|
|
54
|
+
return <SchemaTable nodes={!node.name && node.children?.length ? node.children : [node]} />;
|
|
70
55
|
}
|
|
71
56
|
|
|
72
57
|
function HighlightedCode({
|
|
@@ -110,35 +95,33 @@ export interface OpenApiOperationProps {
|
|
|
110
95
|
/** The generated reference for one API operation, rendered under the page body. */
|
|
111
96
|
export function OpenApiOperation({ operation }: OpenApiOperationProps) {
|
|
112
97
|
const sections = new Map(operationSections(operation).map(entry => [entry.name, entry.id]));
|
|
113
|
-
const showParameters = sections.has('Parameters');
|
|
114
98
|
|
|
115
99
|
return (
|
|
116
100
|
<div className="docs-markdown">
|
|
117
|
-
{
|
|
118
|
-
<section>
|
|
119
|
-
<h2 id={sections.get(
|
|
120
|
-
<
|
|
121
|
-
{operation.security.length > 0 && (
|
|
122
|
-
<
|
|
101
|
+
{operationParameterSections(operation).map(({ location, name }) => (
|
|
102
|
+
<section key={location}>
|
|
103
|
+
<h2 id={sections.get(name)}>{name}</h2>
|
|
104
|
+
<PropertiesTable>
|
|
105
|
+
{location === 'header' && operation.security.length > 0 && (
|
|
106
|
+
<PropertiesTable.Row name="Authorization" type="string" required>
|
|
123
107
|
Authentication credentials, e.g. <code>Bearer <token></code>.
|
|
124
|
-
</
|
|
125
|
-
)}
|
|
126
|
-
{PARAM_LOCATIONS.map(location =>
|
|
127
|
-
operation.parameters[location].map(parameter => (
|
|
128
|
-
<ParamField
|
|
129
|
-
key={`${location}-${parameter.name}`}
|
|
130
|
-
{...{ [location]: parameter.name }}
|
|
131
|
-
type={parameter.type}
|
|
132
|
-
required={parameter.required}
|
|
133
|
-
>
|
|
134
|
-
<FieldChildren node={{ ...parameter, name: undefined, description: undefined }} />
|
|
135
|
-
{parameter.description}
|
|
136
|
-
</ParamField>
|
|
137
|
-
)),
|
|
108
|
+
</PropertiesTable.Row>
|
|
138
109
|
)}
|
|
139
|
-
|
|
110
|
+
{operation.parameters[location].map(parameter => (
|
|
111
|
+
<PropertiesTable.Row
|
|
112
|
+
key={parameter.name}
|
|
113
|
+
name={parameter.name || parameter.type}
|
|
114
|
+
type={parameter.type}
|
|
115
|
+
required={parameter.required}
|
|
116
|
+
deprecated={parameter.deprecated}
|
|
117
|
+
default={parameter.default}
|
|
118
|
+
>
|
|
119
|
+
<FieldChildren node={parameter} />
|
|
120
|
+
</PropertiesTable.Row>
|
|
121
|
+
))}
|
|
122
|
+
</PropertiesTable>
|
|
140
123
|
</section>
|
|
141
|
-
)}
|
|
124
|
+
))}
|
|
142
125
|
{operation.requestBody && (
|
|
143
126
|
<section>
|
|
144
127
|
<h2 id={sections.get('Request body')}>Request body</h2>
|
|
@@ -166,11 +149,7 @@ export function OpenApiOperation({ operation }: OpenApiOperationProps) {
|
|
|
166
149
|
<span className="text-muted-foreground text-sm">{response.description}</span>
|
|
167
150
|
)}
|
|
168
151
|
</div>
|
|
169
|
-
{response.schema &&
|
|
170
|
-
<div className={styles.fieldGroup}>
|
|
171
|
-
<SchemaFields node={response.schema} />
|
|
172
|
-
</div>
|
|
173
|
-
)}
|
|
152
|
+
{response.schema && <SchemaFields node={response.schema} />}
|
|
174
153
|
{response.example && (
|
|
175
154
|
<HighlightedCode
|
|
176
155
|
language="json"
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import { Badge } from './Badge';
|
|
3
|
-
import type { ResponseFieldProps } from './ResponseField';
|
|
4
3
|
import { decodeHtmlEntities, toElementArray } from './utils';
|
|
5
4
|
|
|
5
|
+
type FieldValue = string | number | boolean | null | undefined;
|
|
6
|
+
|
|
7
|
+
export interface PropertiesTableRowProps {
|
|
8
|
+
name: string;
|
|
9
|
+
type?: FieldValue;
|
|
10
|
+
default?: FieldValue;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
deprecated?: boolean;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
export interface PropertiesTableProps {
|
|
7
17
|
children?: ReactNode;
|
|
8
18
|
}
|
|
9
19
|
|
|
10
|
-
function displayValue(value:
|
|
20
|
+
function displayValue(value: PropertiesTableRowProps['type']): string | undefined {
|
|
11
21
|
if (typeof value === 'string') {
|
|
12
22
|
return decodeHtmlEntities(value);
|
|
13
23
|
}
|
|
@@ -16,7 +26,7 @@ function displayValue(value: ResponseFieldProps['type']): string | undefined {
|
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
export function PropertiesTable({ children }: PropertiesTableProps) {
|
|
19
|
-
const rows = toElementArray<
|
|
29
|
+
const rows = toElementArray<PropertiesTableRowProps>(children);
|
|
20
30
|
|
|
21
31
|
if (!rows.length) {
|
|
22
32
|
return null;
|
|
@@ -29,43 +39,49 @@ export function PropertiesTable({ children }: PropertiesTableProps) {
|
|
|
29
39
|
<table className="m-0 min-w-[40rem] table-fixed">
|
|
30
40
|
<thead>
|
|
31
41
|
<tr>
|
|
32
|
-
<th className="w-
|
|
33
|
-
<th className="w-
|
|
42
|
+
<th className="w-[30%]">Name</th>
|
|
43
|
+
<th className="w-[15%]">Type</th>
|
|
34
44
|
<th>Description</th>
|
|
35
45
|
</tr>
|
|
36
46
|
</thead>
|
|
37
|
-
<tbody>
|
|
38
|
-
{rows.map(row => {
|
|
39
|
-
const { name, type, required, deprecated, children: description } = row.props;
|
|
40
|
-
const defaultValue = displayValue(row.props.default);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<tr key={row.key ?? name}>
|
|
44
|
-
<td>
|
|
45
|
-
<span className="inline-flex flex-wrap items-center gap-2">
|
|
46
|
-
{name}
|
|
47
|
-
{required ? (
|
|
48
|
-
<Badge size="sm" tone="primary">
|
|
49
|
-
required
|
|
50
|
-
</Badge>
|
|
51
|
-
) : null}
|
|
52
|
-
{deprecated ? <Badge size="sm">deprecated</Badge> : null}
|
|
53
|
-
</span>
|
|
54
|
-
</td>
|
|
55
|
-
<td>{displayValue(type)}</td>
|
|
56
|
-
<td className="[&_p]:m-0">
|
|
57
|
-
{description}
|
|
58
|
-
{defaultValue ? (
|
|
59
|
-
<span className="mt-1 block text-muted-foreground">
|
|
60
|
-
Default: {defaultValue}
|
|
61
|
-
</span>
|
|
62
|
-
) : null}
|
|
63
|
-
</td>
|
|
64
|
-
</tr>
|
|
65
|
-
);
|
|
66
|
-
})}
|
|
67
|
-
</tbody>
|
|
47
|
+
<tbody>{rows}</tbody>
|
|
68
48
|
</table>
|
|
69
49
|
</div>
|
|
70
50
|
);
|
|
71
51
|
}
|
|
52
|
+
|
|
53
|
+
function PropertiesTableRow({
|
|
54
|
+
name,
|
|
55
|
+
type,
|
|
56
|
+
required,
|
|
57
|
+
deprecated,
|
|
58
|
+
default: value,
|
|
59
|
+
children,
|
|
60
|
+
}: PropertiesTableRowProps) {
|
|
61
|
+
const defaultValue = displayValue(value);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<tr>
|
|
65
|
+
<td>
|
|
66
|
+
<span className="inline-flex flex-wrap items-center gap-2">
|
|
67
|
+
{name}
|
|
68
|
+
{required ? (
|
|
69
|
+
<Badge size="sm" tone="primary">
|
|
70
|
+
required
|
|
71
|
+
</Badge>
|
|
72
|
+
) : null}
|
|
73
|
+
{deprecated ? <Badge size="sm">deprecated</Badge> : null}
|
|
74
|
+
</span>
|
|
75
|
+
</td>
|
|
76
|
+
<td>{displayValue(type)}</td>
|
|
77
|
+
<td className="[&_p]:m-0">
|
|
78
|
+
{children}
|
|
79
|
+
{defaultValue ? (
|
|
80
|
+
<span className="mt-1 block text-muted-foreground">Default: {defaultValue}</span>
|
|
81
|
+
) : null}
|
|
82
|
+
</td>
|
|
83
|
+
</tr>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
PropertiesTable.Row = PropertiesTableRow;
|
|
@@ -12,10 +12,9 @@ export * from './Icon';
|
|
|
12
12
|
export * from './Link';
|
|
13
13
|
export * from './Mermaid';
|
|
14
14
|
export * from './Panel';
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './ParamField';
|
|
15
|
+
export * from './Param';
|
|
17
16
|
export * from './PropertiesTable';
|
|
18
|
-
export * from './
|
|
17
|
+
export * from './panel-context';
|
|
19
18
|
export * from './Steps';
|
|
20
19
|
export * from './Tabs';
|
|
21
20
|
export * from './Tiles';
|
|
@@ -67,14 +67,6 @@ export const styles = {
|
|
|
67
67
|
frameCaption:
|
|
68
68
|
'relative mt-3 px-4 pb-1 text-center text-sm leading-5 text-muted-foreground [&_p]:m-0 [&_a]:font-semibold',
|
|
69
69
|
|
|
70
|
-
field: 'my-3',
|
|
71
|
-
fieldGroup:
|
|
72
|
-
'my-4 divide-y divide-border overflow-hidden rounded-lg border border-border text-sm leading-6 [&>[data-slot=field-group-item]]:my-0 [&>[data-slot=field-group-item]]:px-4 [&>[data-slot=field-group-item]]:py-3 [&_[data-slot=field-group-body]]:mt-2 [&_[data-slot=field-group-type]]:text-xs',
|
|
73
|
-
paramField: 'my-3',
|
|
74
|
-
fieldHeader: 'flex flex-wrap items-center gap-2',
|
|
75
|
-
fieldBody: 'mt-3',
|
|
76
|
-
fieldType: 'text-[0.9rem] text-muted-foreground',
|
|
77
|
-
fieldName: 'font-bold text-foreground',
|
|
78
70
|
code: 'rounded-sm bg-[color-mix(in_srgb,currentColor_4%,transparent)] px-[0.35rem] py-[0.1rem] text-sm text-foreground font-mono',
|
|
79
71
|
steps:
|
|
80
72
|
"relative my-4 flex flex-col gap-5 before:absolute before:top-4 before:bottom-4 before:left-4 before:w-px before:-translate-x-1/2 before:bg-border before:content-['']",
|
package/src/lib/openapi.ts
CHANGED
|
@@ -45,6 +45,22 @@ export function hasParameters(operation: NormalizedOperation): boolean {
|
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/** Parameter groups shared by the renderer and table of contents. */
|
|
49
|
+
export function operationParameterSections(operation: NormalizedOperation) {
|
|
50
|
+
const groups = [
|
|
51
|
+
{ location: 'header', name: 'Headers' },
|
|
52
|
+
{ location: 'path', name: 'Path parameters' },
|
|
53
|
+
{ location: 'query', name: 'Query parameters' },
|
|
54
|
+
{ location: 'cookie', name: 'Cookie parameters' },
|
|
55
|
+
] as const;
|
|
56
|
+
|
|
57
|
+
return groups.filter(
|
|
58
|
+
({ location }) =>
|
|
59
|
+
operation.parameters[location].length > 0 ||
|
|
60
|
+
(location === 'header' && operation.security.length > 0),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
48
64
|
/**
|
|
49
65
|
* Section headings for an operation, in render order. The single source of
|
|
50
66
|
* truth for section ids: the component, the table of contents, the content
|
|
@@ -53,7 +69,7 @@ export function hasParameters(operation: NormalizedOperation): boolean {
|
|
|
53
69
|
export function operationSections(operation: NormalizedOperation): TocEntry[] {
|
|
54
70
|
const slugger = createSlugger();
|
|
55
71
|
const names = [
|
|
56
|
-
|
|
72
|
+
...operationParameterSections(operation).map(section => section.name),
|
|
57
73
|
operation.requestBody ? 'Request body' : undefined,
|
|
58
74
|
operation.responses.length ? 'Responses' : undefined,
|
|
59
75
|
operation.samples.length ? 'Code samples' : undefined,
|
package/types/components.d.ts
CHANGED
|
@@ -146,18 +146,6 @@ export interface IconProps {
|
|
|
146
146
|
|
|
147
147
|
export declare function Icon(props: IconProps): ReactElement | null;
|
|
148
148
|
|
|
149
|
-
export interface ParamFieldProps {
|
|
150
|
-
name?: string;
|
|
151
|
-
query?: string;
|
|
152
|
-
path?: string;
|
|
153
|
-
header?: string;
|
|
154
|
-
body?: string;
|
|
155
|
-
type?: string;
|
|
156
|
-
required?: boolean;
|
|
157
|
-
children?: ReactNode;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export declare function ParamField(props: ParamFieldProps): ReactElement;
|
|
161
149
|
export declare function Param(props: ChildrenProps): ReactElement;
|
|
162
150
|
|
|
163
151
|
export interface PropertiesTableProps {
|
|
@@ -168,7 +156,7 @@ export declare function PropertiesTable(props: PropertiesTableProps): ReactEleme
|
|
|
168
156
|
|
|
169
157
|
type FieldValue = string | number | boolean | null | undefined;
|
|
170
158
|
|
|
171
|
-
export interface
|
|
159
|
+
export interface PropertiesTableRowProps {
|
|
172
160
|
name: string;
|
|
173
161
|
type?: FieldValue;
|
|
174
162
|
default?: FieldValue;
|
|
@@ -177,7 +165,9 @@ export interface ResponseFieldProps {
|
|
|
177
165
|
children?: ReactNode;
|
|
178
166
|
}
|
|
179
167
|
|
|
180
|
-
export declare
|
|
168
|
+
export declare namespace PropertiesTable {
|
|
169
|
+
function Row(props: PropertiesTableRowProps): ReactElement;
|
|
170
|
+
}
|
|
181
171
|
|
|
182
172
|
export interface StepProps {
|
|
183
173
|
title?: ReactNode;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { Badge } from './Badge';
|
|
3
|
-
import { styles } from './styles';
|
|
4
|
-
import { decodeHtmlEntities } from './utils';
|
|
5
|
-
|
|
6
|
-
export interface ParamFieldProps {
|
|
7
|
-
name?: string;
|
|
8
|
-
query?: string;
|
|
9
|
-
path?: string;
|
|
10
|
-
header?: string;
|
|
11
|
-
body?: string;
|
|
12
|
-
type?: string;
|
|
13
|
-
required?: boolean;
|
|
14
|
-
children?: ReactNode;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function ParamField({
|
|
18
|
-
name,
|
|
19
|
-
query,
|
|
20
|
-
path,
|
|
21
|
-
header,
|
|
22
|
-
body,
|
|
23
|
-
type,
|
|
24
|
-
required,
|
|
25
|
-
children,
|
|
26
|
-
}: ParamFieldProps) {
|
|
27
|
-
const label = name || query || path || header || body || 'parameter';
|
|
28
|
-
const location = query ? 'query' : path ? 'path' : header ? 'header' : body ? 'body' : undefined;
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className={styles.paramField} data-slot="field-group-item">
|
|
32
|
-
<div className={styles.fieldHeader}>
|
|
33
|
-
<span className={styles.fieldName}>{label}</span>
|
|
34
|
-
{location ? <Badge size="sm">{location}</Badge> : null}
|
|
35
|
-
{type ? (
|
|
36
|
-
<span className={styles.fieldType} data-slot="field-group-type">
|
|
37
|
-
{decodeHtmlEntities(type)}
|
|
38
|
-
</span>
|
|
39
|
-
) : null}
|
|
40
|
-
{required ? (
|
|
41
|
-
<Badge size="sm" tone="primary">
|
|
42
|
-
required
|
|
43
|
-
</Badge>
|
|
44
|
-
) : null}
|
|
45
|
-
</div>
|
|
46
|
-
{children ? (
|
|
47
|
-
<div className={styles.fieldBody} data-slot="field-group-body">
|
|
48
|
-
{children}
|
|
49
|
-
</div>
|
|
50
|
-
) : null}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function Param({ children }: { children?: ReactNode }) {
|
|
56
|
-
return <code className={styles.code}>{children}</code>;
|
|
57
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { Badge } from './Badge';
|
|
3
|
-
import { styles } from './styles';
|
|
4
|
-
import { decodeHtmlEntities } from './utils';
|
|
5
|
-
|
|
6
|
-
type FieldValue = string | number | boolean | null | undefined;
|
|
7
|
-
|
|
8
|
-
export interface ResponseFieldProps {
|
|
9
|
-
name: string;
|
|
10
|
-
type?: FieldValue;
|
|
11
|
-
default?: FieldValue;
|
|
12
|
-
required?: boolean;
|
|
13
|
-
deprecated?: boolean;
|
|
14
|
-
children?: ReactNode;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function ResponseField({ name, type, required, deprecated, children }: ResponseFieldProps) {
|
|
18
|
-
const normalizedType =
|
|
19
|
-
typeof type === 'string'
|
|
20
|
-
? decodeHtmlEntities(type)
|
|
21
|
-
: type === undefined || type === null
|
|
22
|
-
? undefined
|
|
23
|
-
: String(type);
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<div className={styles.field} data-slot="field-group-item">
|
|
27
|
-
<div className={styles.fieldHeader}>
|
|
28
|
-
<span className={styles.fieldName}>{name}</span>
|
|
29
|
-
{normalizedType ? (
|
|
30
|
-
<span className={styles.fieldType} data-slot="field-group-type">
|
|
31
|
-
{normalizedType}
|
|
32
|
-
</span>
|
|
33
|
-
) : null}
|
|
34
|
-
{required ? (
|
|
35
|
-
<Badge size="sm" tone="primary">
|
|
36
|
-
required
|
|
37
|
-
</Badge>
|
|
38
|
-
) : null}
|
|
39
|
-
{deprecated ? <Badge size="sm">deprecated</Badge> : null}
|
|
40
|
-
</div>
|
|
41
|
-
{children ? (
|
|
42
|
-
<div className={styles.fieldBody} data-slot="field-group-body">
|
|
43
|
-
{children}
|
|
44
|
-
</div>
|
|
45
|
-
) : null}
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
}
|