docusaurus-theme-openapi-docs 4.0.1 → 4.2.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/lib/markdown/utils.d.ts +5 -4
- package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +4 -113
- package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +1 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +30 -6
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +196 -2
- package/lib/theme/ApiExplorer/CodeTabs/index.js +34 -8
- package/lib/theme/ApiExplorer/MethodEndpoint/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/MethodEndpoint/index.js +5 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.js +1 -0
- package/lib/theme/ApiExplorer/Request/_Request.scss +5 -0
- package/lib/theme/ApiExplorer/index.js +6 -0
- package/lib/theme/ApiItem/Layout/index.d.ts +3 -0
- package/lib/theme/ApiItem/Layout/index.js +121 -0
- package/lib/theme/ApiItem/Layout/styles.module.css +17 -0
- package/lib/theme/ApiItem/index.js +16 -5
- package/lib/theme/ApiTabs/_ApiTabs.scss +0 -1
- package/lib/theme/ArrayBrackets/index.d.ts +3 -0
- package/lib/theme/ArrayBrackets/index.js +50 -0
- package/lib/theme/ParamsDetails/index.d.ts +6 -0
- package/lib/theme/ParamsDetails/index.js +134 -0
- package/lib/theme/ParamsItem/index.d.ts +3 -1
- package/lib/theme/ParamsItem/index.js +77 -16
- package/lib/theme/RequestSchema/index.d.ts +15 -0
- package/lib/theme/RequestSchema/index.js +235 -0
- package/lib/theme/ResponseExamples/index.d.ts +48 -0
- package/lib/theme/ResponseExamples/index.js +290 -0
- package/lib/theme/ResponseSchema/index.d.ts +15 -0
- package/lib/theme/ResponseSchema/index.js +206 -0
- package/lib/theme/Schema/index.d.ts +8 -0
- package/lib/theme/Schema/index.js +879 -0
- package/lib/theme/SchemaItem/index.d.ts +9 -9
- package/lib/theme/SchemaItem/index.js +110 -20
- package/lib/theme/SkeletonLoader/index.d.ts +6 -0
- package/lib/theme/SkeletonLoader/index.js +20 -0
- package/lib/theme/StatusCodes/index.d.ts +9 -0
- package/lib/theme/StatusCodes/index.js +78 -0
- package/lib/theme/styles.scss +56 -9
- package/package.json +9 -7
- package/src/markdown/utils.ts +7 -6
- package/src/plugin-content-docs.d.ts +2 -0
- package/src/theme/ApiExplorer/CodeSnippets/code-snippets-types.ts +2 -0
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +8 -113
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +26 -5
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +196 -2
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +40 -9
- package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +7 -3
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +1 -0
- package/src/theme/ApiExplorer/Request/_Request.scss +5 -0
- package/src/theme/ApiExplorer/index.tsx +2 -0
- package/src/theme/ApiItem/Layout/index.tsx +85 -0
- package/src/theme/ApiItem/Layout/styles.module.css +17 -0
- package/src/theme/ApiItem/index.tsx +15 -3
- package/src/theme/ApiTabs/_ApiTabs.scss +0 -1
- package/src/theme/ArrayBrackets/index.tsx +37 -0
- package/src/theme/ParamsDetails/index.tsx +88 -0
- package/src/theme/ParamsItem/index.tsx +80 -17
- package/src/theme/RequestSchema/index.tsx +164 -0
- package/src/theme/ResponseExamples/index.tsx +290 -0
- package/src/theme/ResponseSchema/index.tsx +151 -0
- package/src/theme/Schema/index.tsx +928 -0
- package/src/theme/SchemaItem/index.tsx +116 -25
- package/src/theme/SkeletonLoader/index.tsx +18 -0
- package/src/theme/StatusCodes/index.tsx +72 -0
- package/src/theme/styles.scss +56 -9
- package/src/theme-classic.d.ts +0 -2
- package/src/theme-openapi.d.ts +4 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React, { Suspense } from "react";
|
|
9
|
+
|
|
10
|
+
import BrowserOnly from "@docusaurus/BrowserOnly";
|
|
11
|
+
import Details from "@theme/Details";
|
|
12
|
+
import MimeTabs from "@theme/MimeTabs"; // Assume these components exist
|
|
13
|
+
import {
|
|
14
|
+
ExampleFromSchema,
|
|
15
|
+
ResponseExample,
|
|
16
|
+
ResponseExamples,
|
|
17
|
+
} from "@theme/ResponseExamples";
|
|
18
|
+
import SchemaNode from "@theme/Schema";
|
|
19
|
+
import SchemaTabs from "@theme/SchemaTabs";
|
|
20
|
+
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
21
|
+
import TabItem from "@theme/TabItem";
|
|
22
|
+
import { createDescription } from "docusaurus-plugin-openapi-docs/lib/markdown/createDescription";
|
|
23
|
+
import { MediaTypeObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
|
|
24
|
+
|
|
25
|
+
interface Props {
|
|
26
|
+
style?: React.CSSProperties;
|
|
27
|
+
title: string;
|
|
28
|
+
body: {
|
|
29
|
+
content?: {
|
|
30
|
+
[key: string]: MediaTypeObject;
|
|
31
|
+
};
|
|
32
|
+
description?: string;
|
|
33
|
+
required?: string[] | boolean;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ResponseSchemaComponent: React.FC<Props> = ({
|
|
38
|
+
title,
|
|
39
|
+
body,
|
|
40
|
+
style,
|
|
41
|
+
}): any => {
|
|
42
|
+
if (
|
|
43
|
+
body === undefined ||
|
|
44
|
+
body.content === undefined ||
|
|
45
|
+
Object.keys(body).length === 0 ||
|
|
46
|
+
Object.keys(body.content).length === 0
|
|
47
|
+
) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Get all MIME types, including vendor-specific
|
|
52
|
+
const mimeTypes = Object.keys(body.content);
|
|
53
|
+
if (mimeTypes && mimeTypes.length) {
|
|
54
|
+
return (
|
|
55
|
+
<MimeTabs className="openapi-tabs__mime" schemaType="response">
|
|
56
|
+
{mimeTypes.map((mimeType: any) => {
|
|
57
|
+
const responseExamples = body.content![mimeType].examples;
|
|
58
|
+
const responseExample = body.content![mimeType].example;
|
|
59
|
+
const firstBody: any =
|
|
60
|
+
body.content![mimeType].schema ?? body.content![mimeType];
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
firstBody === undefined &&
|
|
64
|
+
responseExample === undefined &&
|
|
65
|
+
responseExamples === undefined
|
|
66
|
+
) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (firstBody) {
|
|
71
|
+
return (
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
<TabItem key={mimeType} label={mimeType} value={mimeType}>
|
|
74
|
+
<SchemaTabs className="openapi-tabs__schema">
|
|
75
|
+
{/* @ts-ignore */}
|
|
76
|
+
<TabItem key={title} label={title} value={title}>
|
|
77
|
+
<Details
|
|
78
|
+
className="openapi-markdown__details response"
|
|
79
|
+
data-collapsed={false}
|
|
80
|
+
open={true}
|
|
81
|
+
style={style}
|
|
82
|
+
summary={
|
|
83
|
+
<>
|
|
84
|
+
<summary>
|
|
85
|
+
<strong className="openapi-markdown__details-summary-response">
|
|
86
|
+
{title}
|
|
87
|
+
{body.required === true && (
|
|
88
|
+
<span className="openapi-schema__required">
|
|
89
|
+
required
|
|
90
|
+
</span>
|
|
91
|
+
)}
|
|
92
|
+
</strong>
|
|
93
|
+
</summary>
|
|
94
|
+
</>
|
|
95
|
+
}
|
|
96
|
+
>
|
|
97
|
+
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
98
|
+
{body.description && (
|
|
99
|
+
<div
|
|
100
|
+
style={{ marginTop: "1rem", marginBottom: "1rem" }}
|
|
101
|
+
>
|
|
102
|
+
{createDescription(body.description)}
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
<ul style={{ marginLeft: "1rem" }}>
|
|
107
|
+
<SchemaNode schema={firstBody} schemaType="response" />
|
|
108
|
+
</ul>
|
|
109
|
+
</Details>
|
|
110
|
+
</TabItem>
|
|
111
|
+
{firstBody &&
|
|
112
|
+
ExampleFromSchema({
|
|
113
|
+
schema: firstBody,
|
|
114
|
+
mimeType: mimeType,
|
|
115
|
+
})}
|
|
116
|
+
|
|
117
|
+
{responseExamples &&
|
|
118
|
+
ResponseExamples({ responseExamples, mimeType })}
|
|
119
|
+
|
|
120
|
+
{responseExample &&
|
|
121
|
+
ResponseExample({ responseExample, mimeType })}
|
|
122
|
+
</SchemaTabs>
|
|
123
|
+
</TabItem>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
})}
|
|
128
|
+
</MimeTabs>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
return undefined;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const ResponseSchema: React.FC<Props> = (props) => {
|
|
135
|
+
return (
|
|
136
|
+
<BrowserOnly fallback={<SkeletonLoader size="md" />}>
|
|
137
|
+
{() => {
|
|
138
|
+
const LazyComponent = React.lazy(() =>
|
|
139
|
+
Promise.resolve({ default: ResponseSchemaComponent })
|
|
140
|
+
);
|
|
141
|
+
return (
|
|
142
|
+
<Suspense fallback={null}>
|
|
143
|
+
<LazyComponent {...props} />
|
|
144
|
+
</Suspense>
|
|
145
|
+
);
|
|
146
|
+
}}
|
|
147
|
+
</BrowserOnly>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export default ResponseSchema;
|