docusaurus-theme-openapi-docs 4.1.0 → 4.3.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/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +0 -12
- package/lib/theme/ApiExplorer/Authorization/index.js +3 -0
- package/lib/theme/ApiExplorer/Body/index.js +11 -2
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +2 -1
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +50 -0
- package/lib/theme/ApiItem/Layout/index.js +6 -2
- package/lib/theme/ApiItem/index.js +15 -4
- 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/Markdown/Details/_Details.scss +5 -2
- package/lib/theme/Markdown/index.js +160 -18
- package/lib/theme/ParamsDetails/index.d.ts +6 -0
- package/lib/theme/ParamsDetails/index.js +134 -0
- package/lib/theme/ParamsItem/index.d.ts +1 -0
- package/lib/theme/ParamsItem/index.js +11 -48
- package/lib/theme/RequestSchema/index.d.ts +15 -0
- package/lib/theme/RequestSchema/index.js +243 -0
- package/lib/theme/ResponseExamples/index.d.ts +18 -0
- package/lib/theme/ResponseExamples/index.js +194 -0
- package/lib/theme/ResponseHeaders/index.d.ts +13 -0
- package/lib/theme/ResponseHeaders/index.js +39 -0
- package/lib/theme/ResponseSchema/index.d.ts +15 -0
- package/lib/theme/ResponseSchema/index.js +208 -0
- package/lib/theme/Schema/index.d.ts +8 -0
- package/lib/theme/Schema/index.js +887 -0
- package/lib/theme/SchemaItem/index.d.ts +8 -8
- package/lib/theme/SchemaItem/index.js +11 -41
- 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 +81 -0
- package/lib/theme/styles.scss +56 -9
- package/package.json +13 -8
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +0 -12
- package/src/theme/ApiExplorer/Authorization/index.tsx +3 -0
- package/src/theme/ApiExplorer/Body/index.tsx +3 -2
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +2 -1
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +50 -0
- package/src/theme/ApiItem/Layout/index.tsx +5 -2
- package/src/theme/ApiItem/index.tsx +14 -2
- package/src/theme/ApiTabs/_ApiTabs.scss +0 -1
- package/src/theme/ArrayBrackets/index.tsx +37 -0
- package/src/theme/Markdown/Details/_Details.scss +5 -2
- package/src/theme/Markdown/index.js +160 -18
- package/src/theme/ParamsDetails/index.tsx +88 -0
- package/src/theme/ParamsItem/index.tsx +9 -36
- package/src/theme/RequestSchema/index.tsx +164 -0
- package/src/theme/ResponseExamples/index.tsx +192 -0
- package/src/theme/ResponseHeaders/index.tsx +49 -0
- package/src/theme/ResponseSchema/index.tsx +151 -0
- package/src/theme/Schema/index.tsx +935 -0
- package/src/theme/SchemaItem/index.tsx +21 -43
- package/src/theme/SkeletonLoader/index.tsx +18 -0
- package/src/theme/StatusCodes/index.tsx +72 -0
- package/src/theme/styles.scss +56 -9
|
@@ -12,15 +12,11 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
|
-
const
|
|
15
|
+
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
16
16
|
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
17
17
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
18
18
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
19
19
|
const clsx_1 = __importDefault(require("clsx"));
|
|
20
|
-
const react_markdown_1 = __importDefault(require("react-markdown"));
|
|
21
|
-
const rehype_raw_1 = __importDefault(require("rehype-raw"));
|
|
22
|
-
const remark_gfm_1 = __importDefault(require("remark-gfm"));
|
|
23
|
-
const createDescription_1 = require("../../markdown/createDescription");
|
|
24
20
|
const schema_1 = require("../../markdown/schema");
|
|
25
21
|
const utils_1 = require("../../markdown/utils");
|
|
26
22
|
const getEnumDescriptionMarkdown = (enumDescriptions) => {
|
|
@@ -80,55 +76,22 @@ function ParamsItem({ param, ...rest }) {
|
|
|
80
76
|
"deprecated"
|
|
81
77
|
)
|
|
82
78
|
);
|
|
83
|
-
const
|
|
79
|
+
const renderQualifier = (0, utils_1.guard)(
|
|
84
80
|
(0, schema_1.getQualifierMessage)(schema),
|
|
85
|
-
(
|
|
86
|
-
react_1.default.createElement(
|
|
87
|
-
"div",
|
|
88
|
-
null,
|
|
89
|
-
react_1.default.createElement(react_markdown_1.default, {
|
|
90
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
91
|
-
rehypePlugins: [rehype_raw_1.default],
|
|
92
|
-
})
|
|
93
|
-
)
|
|
81
|
+
(qualifier) =>
|
|
82
|
+
react_1.default.createElement(Markdown_1.default, null, qualifier)
|
|
94
83
|
);
|
|
95
84
|
const renderDescription = (0, utils_1.guard)(description, (description) =>
|
|
96
|
-
react_1.default.createElement(
|
|
97
|
-
"div",
|
|
98
|
-
null,
|
|
99
|
-
react_1.default.createElement(react_markdown_1.default, {
|
|
100
|
-
children: (0, createDescription_1.createDescription)(description),
|
|
101
|
-
components: {
|
|
102
|
-
pre: "div",
|
|
103
|
-
code({ node, inline, className, children, ...props }) {
|
|
104
|
-
const match = /language-(\w+)/.exec(className || "");
|
|
105
|
-
if (inline)
|
|
106
|
-
return react_1.default.createElement("code", null, children);
|
|
107
|
-
return !inline && match
|
|
108
|
-
? react_1.default.createElement(
|
|
109
|
-
CodeBlock_1.default,
|
|
110
|
-
{ className: className },
|
|
111
|
-
children
|
|
112
|
-
)
|
|
113
|
-
: react_1.default.createElement(
|
|
114
|
-
CodeBlock_1.default,
|
|
115
|
-
null,
|
|
116
|
-
children
|
|
117
|
-
);
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
rehypePlugins: [rehype_raw_1.default],
|
|
121
|
-
})
|
|
122
|
-
)
|
|
85
|
+
react_1.default.createElement(Markdown_1.default, null, description)
|
|
123
86
|
);
|
|
124
87
|
const renderEnumDescriptions = (0, utils_1.guard)(
|
|
125
88
|
getEnumDescriptionMarkdown(enumDescriptions),
|
|
126
89
|
(value) => {
|
|
127
|
-
return react_1.default.createElement(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
90
|
+
return react_1.default.createElement(
|
|
91
|
+
"div",
|
|
92
|
+
{ style: { marginTop: ".5rem" } },
|
|
93
|
+
react_1.default.createElement(Markdown_1.default, null, value)
|
|
94
|
+
);
|
|
132
95
|
}
|
|
133
96
|
);
|
|
134
97
|
function renderDefaultValue() {
|
|
@@ -241,7 +204,7 @@ function ParamsItem({ param, ...rest }) {
|
|
|
241
204
|
renderSchemaRequired,
|
|
242
205
|
renderDeprecated
|
|
243
206
|
),
|
|
244
|
-
|
|
207
|
+
renderQualifier,
|
|
245
208
|
renderDescription,
|
|
246
209
|
renderEnumDescriptions,
|
|
247
210
|
renderDefaultValue(),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MediaTypeObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
|
|
3
|
+
interface Props {
|
|
4
|
+
style?: React.CSSProperties;
|
|
5
|
+
title: string;
|
|
6
|
+
body: {
|
|
7
|
+
content?: {
|
|
8
|
+
[key: string]: MediaTypeObject;
|
|
9
|
+
};
|
|
10
|
+
description?: string;
|
|
11
|
+
required?: string[] | boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
declare const RequestSchema: React.FC<Props>;
|
|
15
|
+
export default RequestSchema;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null)
|
|
46
|
+
for (var k in mod)
|
|
47
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
48
|
+
__createBinding(result, mod, k);
|
|
49
|
+
__setModuleDefault(result, mod);
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
var __importDefault =
|
|
53
|
+
(this && this.__importDefault) ||
|
|
54
|
+
function (mod) {
|
|
55
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
56
|
+
};
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
const react_1 = __importStar(require("react"));
|
|
59
|
+
const BrowserOnly_1 = __importDefault(require("@docusaurus/BrowserOnly"));
|
|
60
|
+
const Details_1 = __importDefault(require("@theme/Details"));
|
|
61
|
+
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
62
|
+
const MimeTabs_1 = __importDefault(require("@theme/MimeTabs")); // Assume these components exist
|
|
63
|
+
const Schema_1 = __importDefault(require("@theme/Schema"));
|
|
64
|
+
const SkeletonLoader_1 = __importDefault(require("@theme/SkeletonLoader"));
|
|
65
|
+
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
66
|
+
const RequestSchemaComponent = ({ title, body, style }) => {
|
|
67
|
+
if (
|
|
68
|
+
body === undefined ||
|
|
69
|
+
body.content === undefined ||
|
|
70
|
+
Object.keys(body).length === 0 ||
|
|
71
|
+
Object.keys(body.content).length === 0
|
|
72
|
+
) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const mimeTypes = Object.keys(body.content);
|
|
76
|
+
if (mimeTypes.length > 1) {
|
|
77
|
+
return react_1.default.createElement(
|
|
78
|
+
MimeTabs_1.default,
|
|
79
|
+
{ className: "openapi-tabs__mime", schemaType: "request" },
|
|
80
|
+
mimeTypes.map((mimeType) => {
|
|
81
|
+
const firstBody = body.content[mimeType].schema;
|
|
82
|
+
if (
|
|
83
|
+
firstBody === undefined ||
|
|
84
|
+
(firstBody.properties &&
|
|
85
|
+
Object.keys(firstBody.properties).length === 0)
|
|
86
|
+
) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return (
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
react_1.default.createElement(
|
|
92
|
+
TabItem_1.default,
|
|
93
|
+
{ key: mimeType, label: mimeType, value: mimeType },
|
|
94
|
+
react_1.default.createElement(
|
|
95
|
+
Details_1.default,
|
|
96
|
+
{
|
|
97
|
+
className: "openapi-markdown__details mime",
|
|
98
|
+
"data-collapsed": false,
|
|
99
|
+
open: true,
|
|
100
|
+
style: style,
|
|
101
|
+
summary: react_1.default.createElement(
|
|
102
|
+
react_1.default.Fragment,
|
|
103
|
+
null,
|
|
104
|
+
react_1.default.createElement(
|
|
105
|
+
"summary",
|
|
106
|
+
null,
|
|
107
|
+
react_1.default.createElement(
|
|
108
|
+
"h3",
|
|
109
|
+
{
|
|
110
|
+
className:
|
|
111
|
+
"openapi-markdown__details-summary-header-body",
|
|
112
|
+
},
|
|
113
|
+
title,
|
|
114
|
+
body.required === true &&
|
|
115
|
+
react_1.default.createElement(
|
|
116
|
+
"span",
|
|
117
|
+
{ className: "openapi-schema__required" },
|
|
118
|
+
"required"
|
|
119
|
+
)
|
|
120
|
+
)
|
|
121
|
+
)
|
|
122
|
+
),
|
|
123
|
+
},
|
|
124
|
+
react_1.default.createElement(
|
|
125
|
+
"div",
|
|
126
|
+
{ style: { textAlign: "left", marginLeft: "1rem" } },
|
|
127
|
+
body.description &&
|
|
128
|
+
react_1.default.createElement(
|
|
129
|
+
"div",
|
|
130
|
+
{ style: { marginTop: "1rem", marginBottom: "1rem" } },
|
|
131
|
+
react_1.default.createElement(
|
|
132
|
+
Markdown_1.default,
|
|
133
|
+
null,
|
|
134
|
+
body.description
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
),
|
|
138
|
+
react_1.default.createElement(
|
|
139
|
+
"ul",
|
|
140
|
+
{ style: { marginLeft: "1rem" } },
|
|
141
|
+
react_1.default.createElement(Schema_1.default, {
|
|
142
|
+
schema: firstBody,
|
|
143
|
+
schemaType: "request",
|
|
144
|
+
})
|
|
145
|
+
)
|
|
146
|
+
)
|
|
147
|
+
)
|
|
148
|
+
);
|
|
149
|
+
})
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
const randomFirstKey = mimeTypes[0];
|
|
153
|
+
const firstBody =
|
|
154
|
+
body.content[randomFirstKey].schema ?? body.content[randomFirstKey];
|
|
155
|
+
if (firstBody === undefined) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
return react_1.default.createElement(
|
|
159
|
+
MimeTabs_1.default,
|
|
160
|
+
{ className: "openapi-tabs__mime", schemaType: "request" },
|
|
161
|
+
react_1.default.createElement(
|
|
162
|
+
TabItem_1.default,
|
|
163
|
+
{ label: randomFirstKey, value: `${randomFirstKey}-schema` },
|
|
164
|
+
react_1.default.createElement(
|
|
165
|
+
Details_1.default,
|
|
166
|
+
{
|
|
167
|
+
className: "openapi-markdown__details mime",
|
|
168
|
+
"data-collapsed": false,
|
|
169
|
+
open: true,
|
|
170
|
+
style: style,
|
|
171
|
+
summary: react_1.default.createElement(
|
|
172
|
+
react_1.default.Fragment,
|
|
173
|
+
null,
|
|
174
|
+
react_1.default.createElement(
|
|
175
|
+
"summary",
|
|
176
|
+
null,
|
|
177
|
+
react_1.default.createElement(
|
|
178
|
+
"h3",
|
|
179
|
+
{ className: "openapi-markdown__details-summary-header-body" },
|
|
180
|
+
title,
|
|
181
|
+
firstBody.type === "array" &&
|
|
182
|
+
react_1.default.createElement(
|
|
183
|
+
"span",
|
|
184
|
+
{ style: { opacity: "0.6" } },
|
|
185
|
+
" array"
|
|
186
|
+
),
|
|
187
|
+
body.required &&
|
|
188
|
+
react_1.default.createElement(
|
|
189
|
+
"strong",
|
|
190
|
+
{ className: "openapi-schema__required" },
|
|
191
|
+
"required"
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
)
|
|
195
|
+
),
|
|
196
|
+
},
|
|
197
|
+
react_1.default.createElement(
|
|
198
|
+
"div",
|
|
199
|
+
{ style: { textAlign: "left", marginLeft: "1rem" } },
|
|
200
|
+
body.description &&
|
|
201
|
+
react_1.default.createElement(
|
|
202
|
+
"div",
|
|
203
|
+
{ style: { marginTop: "1rem", marginBottom: "1rem" } },
|
|
204
|
+
react_1.default.createElement(
|
|
205
|
+
Markdown_1.default,
|
|
206
|
+
null,
|
|
207
|
+
body.description
|
|
208
|
+
)
|
|
209
|
+
)
|
|
210
|
+
),
|
|
211
|
+
react_1.default.createElement(
|
|
212
|
+
"ul",
|
|
213
|
+
{ style: { marginLeft: "1rem" } },
|
|
214
|
+
react_1.default.createElement(Schema_1.default, {
|
|
215
|
+
schema: firstBody,
|
|
216
|
+
schemaType: "request",
|
|
217
|
+
})
|
|
218
|
+
)
|
|
219
|
+
)
|
|
220
|
+
)
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
const RequestSchema = (props) => {
|
|
224
|
+
return react_1.default.createElement(
|
|
225
|
+
BrowserOnly_1.default,
|
|
226
|
+
{
|
|
227
|
+
fallback: react_1.default.createElement(SkeletonLoader_1.default, {
|
|
228
|
+
size: "sm",
|
|
229
|
+
}),
|
|
230
|
+
},
|
|
231
|
+
() => {
|
|
232
|
+
const LazyComponent = react_1.default.lazy(() =>
|
|
233
|
+
Promise.resolve({ default: RequestSchemaComponent })
|
|
234
|
+
);
|
|
235
|
+
return react_1.default.createElement(
|
|
236
|
+
react_1.Suspense,
|
|
237
|
+
{ fallback: null },
|
|
238
|
+
react_1.default.createElement(LazyComponent, { ...props })
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
};
|
|
243
|
+
exports.default = RequestSchema;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare function json2xml(o: Record<string, any>, tab: string): string;
|
|
3
|
+
interface ResponseExamplesProps {
|
|
4
|
+
responseExamples: any;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const ResponseExamples: React.FC<ResponseExamplesProps>;
|
|
8
|
+
interface ResponseExampleProps {
|
|
9
|
+
responseExample: any;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const ResponseExample: React.FC<ResponseExampleProps>;
|
|
13
|
+
interface ExampleFromSchemaProps {
|
|
14
|
+
schema: any;
|
|
15
|
+
mimeType: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const ExampleFromSchema: React.FC<ExampleFromSchemaProps>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ExampleFromSchema =
|
|
15
|
+
exports.ResponseExample =
|
|
16
|
+
exports.ResponseExamples =
|
|
17
|
+
exports.json2xml =
|
|
18
|
+
void 0;
|
|
19
|
+
const react_1 = __importDefault(require("react"));
|
|
20
|
+
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
21
|
+
const ResponseSamples_1 = __importDefault(require("@theme/ResponseSamples"));
|
|
22
|
+
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
23
|
+
const createResponseExample_1 = require("docusaurus-plugin-openapi-docs/lib/openapi/createResponseExample");
|
|
24
|
+
const xml_formatter_1 = __importDefault(require("xml-formatter"));
|
|
25
|
+
function json2xml(o, tab) {
|
|
26
|
+
const toXml = (v, name, ind) => {
|
|
27
|
+
let xml = "";
|
|
28
|
+
if (v instanceof Array) {
|
|
29
|
+
for (let i = 0, n = v.length; i < n; i++) {
|
|
30
|
+
xml += ind + toXml(v[i], name, ind + "\t") + "\n";
|
|
31
|
+
}
|
|
32
|
+
} else if (typeof v === "object") {
|
|
33
|
+
let hasChild = false;
|
|
34
|
+
xml += ind + "<" + name;
|
|
35
|
+
for (const m in v) {
|
|
36
|
+
if (m.charAt(0) === "@") {
|
|
37
|
+
xml += " " + m.substr(1) + '="' + v[m].toString() + '"';
|
|
38
|
+
} else {
|
|
39
|
+
hasChild = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
xml += hasChild ? ">" : "/>";
|
|
43
|
+
if (hasChild) {
|
|
44
|
+
for (const m2 in v) {
|
|
45
|
+
if (m2 === "#text") xml += v[m2];
|
|
46
|
+
else if (m2 === "#cdata") xml += "<![CDATA[" + v[m2] + "]]>";
|
|
47
|
+
else if (m2.charAt(0) !== "@") xml += toXml(v[m2], m2, ind + "\t");
|
|
48
|
+
}
|
|
49
|
+
xml +=
|
|
50
|
+
(xml.charAt(xml.length - 1) === "\n" ? ind : "") + "</" + name + ">";
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
xml += ind + "<" + name + ">" + v.toString() + "</" + name + ">";
|
|
54
|
+
}
|
|
55
|
+
return xml;
|
|
56
|
+
};
|
|
57
|
+
let xml = "";
|
|
58
|
+
for (const m3 in o) xml += toXml(o[m3], m3, "");
|
|
59
|
+
return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
|
|
60
|
+
}
|
|
61
|
+
exports.json2xml = json2xml;
|
|
62
|
+
const ResponseExamples = ({ responseExamples, mimeType }) => {
|
|
63
|
+
let language = "shell";
|
|
64
|
+
if (mimeType.endsWith("json")) language = "json";
|
|
65
|
+
if (mimeType.endsWith("xml")) language = "xml";
|
|
66
|
+
// Map response examples to an array of TabItem elements
|
|
67
|
+
const examplesArray = Object.entries(responseExamples).map(
|
|
68
|
+
([exampleName, exampleValue]) => {
|
|
69
|
+
const isObject = typeof exampleValue.value === "object";
|
|
70
|
+
const responseExample = isObject
|
|
71
|
+
? JSON.stringify(exampleValue.value, null, 2)
|
|
72
|
+
: exampleValue.value;
|
|
73
|
+
return (
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
react_1.default.createElement(
|
|
76
|
+
TabItem_1.default,
|
|
77
|
+
{ label: exampleName, value: exampleName, key: exampleName },
|
|
78
|
+
exampleValue.summary &&
|
|
79
|
+
react_1.default.createElement(
|
|
80
|
+
Markdown_1.default,
|
|
81
|
+
{ className: "openapi-example__summary" },
|
|
82
|
+
exampleValue.summary
|
|
83
|
+
),
|
|
84
|
+
react_1.default.createElement(ResponseSamples_1.default, {
|
|
85
|
+
responseExample: responseExample,
|
|
86
|
+
language: language,
|
|
87
|
+
})
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
return examplesArray;
|
|
93
|
+
};
|
|
94
|
+
exports.ResponseExamples = ResponseExamples;
|
|
95
|
+
const ResponseExample = ({ responseExample, mimeType }) => {
|
|
96
|
+
let language = "shell";
|
|
97
|
+
if (mimeType.endsWith("json")) {
|
|
98
|
+
language = "json";
|
|
99
|
+
}
|
|
100
|
+
if (mimeType.endsWith("xml")) {
|
|
101
|
+
language = "xml";
|
|
102
|
+
}
|
|
103
|
+
const isObject = typeof responseExample === "object";
|
|
104
|
+
const exampleContent = isObject
|
|
105
|
+
? JSON.stringify(responseExample, null, 2)
|
|
106
|
+
: responseExample;
|
|
107
|
+
return (
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
react_1.default.createElement(
|
|
110
|
+
TabItem_1.default,
|
|
111
|
+
{ label: "Example", value: "Example" },
|
|
112
|
+
responseExample.summary &&
|
|
113
|
+
react_1.default.createElement(
|
|
114
|
+
Markdown_1.default,
|
|
115
|
+
{ className: "openapi-example__summary" },
|
|
116
|
+
responseExample.summary
|
|
117
|
+
),
|
|
118
|
+
react_1.default.createElement(ResponseSamples_1.default, {
|
|
119
|
+
responseExample: exampleContent,
|
|
120
|
+
language: language,
|
|
121
|
+
})
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
exports.ResponseExample = ResponseExample;
|
|
126
|
+
const ExampleFromSchema = ({ schema, mimeType }) => {
|
|
127
|
+
const responseExample = (0, createResponseExample_1.sampleResponseFromSchema)(
|
|
128
|
+
schema
|
|
129
|
+
);
|
|
130
|
+
if (mimeType.endsWith("xml")) {
|
|
131
|
+
let responseExampleObject;
|
|
132
|
+
try {
|
|
133
|
+
responseExampleObject = JSON.parse(JSON.stringify(responseExample));
|
|
134
|
+
} catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
if (typeof responseExampleObject === "object") {
|
|
138
|
+
let xmlExample;
|
|
139
|
+
try {
|
|
140
|
+
xmlExample = (0, xml_formatter_1.default)(
|
|
141
|
+
json2xml(responseExampleObject, ""),
|
|
142
|
+
{
|
|
143
|
+
indentation: " ",
|
|
144
|
+
lineSeparator: "\n",
|
|
145
|
+
collapseContent: true,
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
} catch {
|
|
149
|
+
const xmlExampleWithRoot = { root: responseExampleObject };
|
|
150
|
+
try {
|
|
151
|
+
xmlExample = (0, xml_formatter_1.default)(
|
|
152
|
+
json2xml(xmlExampleWithRoot, ""),
|
|
153
|
+
{
|
|
154
|
+
indentation: " ",
|
|
155
|
+
lineSeparator: "\n",
|
|
156
|
+
collapseContent: true,
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
} catch {
|
|
160
|
+
xmlExample = json2xml(responseExampleObject, "");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return (
|
|
164
|
+
// @ts-ignore
|
|
165
|
+
react_1.default.createElement(
|
|
166
|
+
TabItem_1.default,
|
|
167
|
+
{ label: "Example (auto)", value: "Example (auto)" },
|
|
168
|
+
react_1.default.createElement(ResponseSamples_1.default, {
|
|
169
|
+
responseExample: xmlExample,
|
|
170
|
+
language: "xml",
|
|
171
|
+
})
|
|
172
|
+
)
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (
|
|
177
|
+
typeof responseExample === "object" ||
|
|
178
|
+
typeof responseExample === "string"
|
|
179
|
+
) {
|
|
180
|
+
return (
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
react_1.default.createElement(
|
|
183
|
+
TabItem_1.default,
|
|
184
|
+
{ label: "Example (auto)", value: "Example (auto)" },
|
|
185
|
+
react_1.default.createElement(ResponseSamples_1.default, {
|
|
186
|
+
responseExample: JSON.stringify(responseExample, null, 2),
|
|
187
|
+
language: "json",
|
|
188
|
+
})
|
|
189
|
+
)
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
};
|
|
194
|
+
exports.ExampleFromSchema = ExampleFromSchema;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ResponseHeadersProps {
|
|
3
|
+
description?: string;
|
|
4
|
+
example?: string;
|
|
5
|
+
schema?: {
|
|
6
|
+
type?: string;
|
|
7
|
+
format?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const ResponseHeaders: React.FC<{
|
|
11
|
+
responseHeaders?: Record<string, ResponseHeadersProps>;
|
|
12
|
+
}>;
|
|
13
|
+
export default ResponseHeaders;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ResponseHeaders = void 0;
|
|
15
|
+
const react_1 = __importDefault(require("react"));
|
|
16
|
+
const SchemaItem_1 = __importDefault(require("@theme/SchemaItem"));
|
|
17
|
+
const schema_1 = require("../../markdown/schema");
|
|
18
|
+
const ResponseHeaders = ({ responseHeaders }) => {
|
|
19
|
+
if (!responseHeaders) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return react_1.default.createElement(
|
|
23
|
+
"ul",
|
|
24
|
+
{ style: { marginLeft: "1rem" } },
|
|
25
|
+
Object.entries(responseHeaders).map(([name, schema]) => {
|
|
26
|
+
return react_1.default.createElement(SchemaItem_1.default, {
|
|
27
|
+
name: name,
|
|
28
|
+
collapsible: false,
|
|
29
|
+
schemaName: (0, schema_1.getSchemaName)(schema),
|
|
30
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
31
|
+
schema: schema,
|
|
32
|
+
discriminator: false,
|
|
33
|
+
children: null,
|
|
34
|
+
});
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
exports.ResponseHeaders = ResponseHeaders;
|
|
39
|
+
exports.default = exports.ResponseHeaders;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MediaTypeObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
|
|
3
|
+
interface Props {
|
|
4
|
+
style?: React.CSSProperties;
|
|
5
|
+
title: string;
|
|
6
|
+
body: {
|
|
7
|
+
content?: {
|
|
8
|
+
[key: string]: MediaTypeObject;
|
|
9
|
+
};
|
|
10
|
+
description?: string;
|
|
11
|
+
required?: string[] | boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
declare const ResponseSchema: React.FC<Props>;
|
|
15
|
+
export default ResponseSchema;
|