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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
export interface Props {
|
|
3
|
-
children
|
|
4
|
-
collapsible
|
|
5
|
-
name
|
|
6
|
-
qualifierMessage
|
|
7
|
-
required
|
|
8
|
-
schemaName
|
|
9
|
-
schema
|
|
10
|
-
discriminator
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
collapsible?: boolean;
|
|
5
|
+
name?: string;
|
|
6
|
+
qualifierMessage?: string | undefined;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
schemaName?: string;
|
|
9
|
+
schema?: any;
|
|
10
|
+
discriminator?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export default function SchemaItem(
|
|
12
|
+
export default function SchemaItem(props: Props): React.JSX.Element;
|
|
@@ -16,25 +16,50 @@ const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
|
|
|
16
16
|
const clsx_1 = __importDefault(require("clsx"));
|
|
17
17
|
const react_markdown_1 = __importDefault(require("react-markdown"));
|
|
18
18
|
const rehype_raw_1 = __importDefault(require("rehype-raw"));
|
|
19
|
+
const remark_gfm_1 = __importDefault(require("remark-gfm"));
|
|
19
20
|
const createDescription_1 = require("../../markdown/createDescription");
|
|
20
21
|
const utils_1 = require("../../markdown/utils");
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const transformEnumDescriptions = (enumDescriptions) => {
|
|
23
|
+
if (enumDescriptions) {
|
|
24
|
+
return Object.entries(enumDescriptions);
|
|
25
|
+
}
|
|
26
|
+
return [];
|
|
27
|
+
};
|
|
28
|
+
const getEnumDescriptionMarkdown = (enumDescriptions) => {
|
|
29
|
+
if (enumDescriptions?.length) {
|
|
30
|
+
return `| Enum Value | Description |
|
|
31
|
+
| ---- | ----- |
|
|
32
|
+
${enumDescriptions
|
|
33
|
+
.map((desc) => {
|
|
34
|
+
return `| ${desc[0]} | ${desc[1]} | `.replaceAll("\n", "<br/>");
|
|
35
|
+
})
|
|
36
|
+
.join("\n")}
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
return "";
|
|
40
|
+
};
|
|
41
|
+
function SchemaItem(props) {
|
|
42
|
+
const {
|
|
43
|
+
children: collapsibleSchemaContent,
|
|
44
|
+
collapsible,
|
|
45
|
+
name,
|
|
46
|
+
qualifierMessage,
|
|
47
|
+
required,
|
|
48
|
+
schemaName,
|
|
49
|
+
schema,
|
|
50
|
+
} = props;
|
|
30
51
|
let deprecated;
|
|
31
52
|
let schemaDescription;
|
|
32
53
|
let defaultValue;
|
|
54
|
+
let example;
|
|
33
55
|
let nullable;
|
|
56
|
+
let enumDescriptions = [];
|
|
34
57
|
if (schema) {
|
|
35
58
|
deprecated = schema.deprecated;
|
|
36
59
|
schemaDescription = schema.description;
|
|
60
|
+
enumDescriptions = transformEnumDescriptions(schema["x-enumDescriptions"]);
|
|
37
61
|
defaultValue = schema.default;
|
|
62
|
+
example = schema.example;
|
|
38
63
|
nullable = schema.nullable;
|
|
39
64
|
}
|
|
40
65
|
const renderRequired = (0, utils_1.guard)(
|
|
@@ -60,6 +85,20 @@ function SchemaItem({
|
|
|
60
85
|
"nullable"
|
|
61
86
|
)
|
|
62
87
|
);
|
|
88
|
+
const renderEnumDescriptions = (0, utils_1.guard)(
|
|
89
|
+
getEnumDescriptionMarkdown(enumDescriptions),
|
|
90
|
+
(value) => {
|
|
91
|
+
return react_1.default.createElement(
|
|
92
|
+
"div",
|
|
93
|
+
{ style: { marginTop: ".5rem" } },
|
|
94
|
+
react_1.default.createElement(react_markdown_1.default, {
|
|
95
|
+
remarkPlugins: [remark_gfm_1.default],
|
|
96
|
+
rehypePlugins: [rehype_raw_1.default],
|
|
97
|
+
children: value,
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
);
|
|
63
102
|
const renderSchemaDescription = (0, utils_1.guard)(
|
|
64
103
|
schemaDescription,
|
|
65
104
|
(description) =>
|
|
@@ -103,15 +142,64 @@ function SchemaItem({
|
|
|
103
142
|
})
|
|
104
143
|
)
|
|
105
144
|
);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
145
|
+
function renderDefaultValue() {
|
|
146
|
+
if (defaultValue !== undefined) {
|
|
147
|
+
if (typeof defaultValue === "string") {
|
|
148
|
+
return react_1.default.createElement(
|
|
149
|
+
"div",
|
|
150
|
+
null,
|
|
151
|
+
react_1.default.createElement("strong", null, "Default value: "),
|
|
152
|
+
react_1.default.createElement(
|
|
153
|
+
"span",
|
|
154
|
+
null,
|
|
155
|
+
react_1.default.createElement("code", null, defaultValue)
|
|
156
|
+
)
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return react_1.default.createElement(
|
|
160
|
+
"div",
|
|
161
|
+
null,
|
|
162
|
+
react_1.default.createElement("strong", null, "Default value: "),
|
|
163
|
+
react_1.default.createElement(
|
|
164
|
+
"span",
|
|
165
|
+
null,
|
|
166
|
+
react_1.default.createElement(
|
|
167
|
+
"code",
|
|
168
|
+
null,
|
|
169
|
+
JSON.stringify(defaultValue)
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
function renderExample() {
|
|
177
|
+
if (example !== undefined) {
|
|
178
|
+
if (typeof example === "string") {
|
|
179
|
+
return react_1.default.createElement(
|
|
180
|
+
"div",
|
|
181
|
+
null,
|
|
182
|
+
react_1.default.createElement("strong", null, "Example: "),
|
|
183
|
+
react_1.default.createElement(
|
|
184
|
+
"span",
|
|
185
|
+
null,
|
|
186
|
+
react_1.default.createElement("code", null, example)
|
|
187
|
+
)
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
return react_1.default.createElement(
|
|
191
|
+
"div",
|
|
192
|
+
null,
|
|
193
|
+
react_1.default.createElement("strong", null, "Example: "),
|
|
194
|
+
react_1.default.createElement(
|
|
195
|
+
"span",
|
|
196
|
+
null,
|
|
197
|
+
react_1.default.createElement("code", null, JSON.stringify(example))
|
|
198
|
+
)
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
115
203
|
const schemaContent = react_1.default.createElement(
|
|
116
204
|
"div",
|
|
117
205
|
null,
|
|
@@ -141,9 +229,11 @@ function SchemaItem({
|
|
|
141
229
|
renderRequired,
|
|
142
230
|
renderDeprecated
|
|
143
231
|
),
|
|
144
|
-
renderQualifierMessage,
|
|
145
|
-
renderDefaultValue,
|
|
146
232
|
renderSchemaDescription,
|
|
233
|
+
renderEnumDescriptions,
|
|
234
|
+
renderQualifierMessage,
|
|
235
|
+
renderDefaultValue(),
|
|
236
|
+
renderExample(),
|
|
147
237
|
collapsibleSchemaContent ?? collapsibleSchemaContent
|
|
148
238
|
);
|
|
149
239
|
return react_1.default.createElement(
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const SkeletonLoader = (props) => {
|
|
16
|
+
return react_1.default.createElement("div", {
|
|
17
|
+
className: `openapi-skeleton ${props.size ?? "md"}`,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
exports.default = SkeletonLoader;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ApiItem } from "docusaurus-plugin-openapi-docs/lib/types";
|
|
3
|
+
interface Props {
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
responses: ApiItem["responses"];
|
|
7
|
+
}
|
|
8
|
+
declare const StatusCodes: React.FC<Props>;
|
|
9
|
+
export default StatusCodes;
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const ApiTabs_1 = __importDefault(require("@theme/ApiTabs"));
|
|
16
|
+
const Details_1 = __importDefault(require("@theme/Details"));
|
|
17
|
+
const ResponseExamples_1 = require("@theme/ResponseExamples");
|
|
18
|
+
const ResponseSchema_1 = __importDefault(require("@theme/ResponseSchema"));
|
|
19
|
+
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
20
|
+
const createDescription_1 = require("docusaurus-plugin-openapi-docs/lib/markdown/createDescription");
|
|
21
|
+
const StatusCodes = ({ label, id, responses }) => {
|
|
22
|
+
if (!responses) return null;
|
|
23
|
+
const codes = Object.keys(responses);
|
|
24
|
+
if (codes.length === 0) return null;
|
|
25
|
+
return react_1.default.createElement(
|
|
26
|
+
ApiTabs_1.default,
|
|
27
|
+
{ label: label, id: id },
|
|
28
|
+
codes.map((code) => {
|
|
29
|
+
const response = responses[code];
|
|
30
|
+
const responseHeaders = response.headers;
|
|
31
|
+
return (
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
react_1.default.createElement(
|
|
34
|
+
TabItem_1.default,
|
|
35
|
+
{ key: code, label: code, value: code },
|
|
36
|
+
react_1.default.createElement(
|
|
37
|
+
"div",
|
|
38
|
+
null,
|
|
39
|
+
response.description &&
|
|
40
|
+
react_1.default.createElement(
|
|
41
|
+
"div",
|
|
42
|
+
{ style: { marginTop: ".5rem", marginBottom: ".5rem" } },
|
|
43
|
+
(0, createDescription_1.createDescription)(response.description)
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
responseHeaders &&
|
|
47
|
+
react_1.default.createElement(
|
|
48
|
+
Details_1.default,
|
|
49
|
+
{
|
|
50
|
+
className: "openapi-markdown__details",
|
|
51
|
+
"data-collapsed": true,
|
|
52
|
+
open: false,
|
|
53
|
+
style: { textAlign: "left", marginBottom: "1rem" },
|
|
54
|
+
summary: react_1.default.createElement(
|
|
55
|
+
"summary",
|
|
56
|
+
null,
|
|
57
|
+
react_1.default.createElement(
|
|
58
|
+
"strong",
|
|
59
|
+
null,
|
|
60
|
+
"Response Headers"
|
|
61
|
+
)
|
|
62
|
+
),
|
|
63
|
+
},
|
|
64
|
+
react_1.default.createElement(
|
|
65
|
+
ResponseExamples_1.ResponseHeaders,
|
|
66
|
+
{ responseHeaders: responseHeaders }
|
|
67
|
+
)
|
|
68
|
+
),
|
|
69
|
+
react_1.default.createElement(ResponseSchema_1.default, {
|
|
70
|
+
title: "Schema",
|
|
71
|
+
body: { content: response.content },
|
|
72
|
+
})
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
exports.default = StatusCodes;
|
package/lib/theme/styles.scss
CHANGED
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
--openapi-explorer-padding-input: 0.5rem;
|
|
82
82
|
--openapi-explorer-border-color: var(--ifm-toc-border-color);
|
|
83
83
|
--openapi-explorer-caret-bg: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px" viewBox="0 0 24 24"><path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path></svg>');
|
|
84
|
+
--openapi-skeleton-background: var(--ifm-color-emphasis-100);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
[data-theme="dark"] {
|
|
@@ -92,16 +93,16 @@
|
|
|
92
93
|
height: 100%;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
@media (min-width: 997px) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
// @media (min-width: 997px) {
|
|
97
|
+
// .docItemCol {
|
|
98
|
+
// max-width: 75% !important;
|
|
99
|
+
// }
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
101
|
+
// /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
|
|
102
|
+
// .tocMobile {
|
|
103
|
+
// display: none;
|
|
104
|
+
// }
|
|
105
|
+
// }
|
|
105
106
|
|
|
106
107
|
/* Begin OpenAPI theme styles */
|
|
107
108
|
// [data-theme="dark"] {
|
|
@@ -160,6 +161,52 @@
|
|
|
160
161
|
border-right: thin solid var(--ifm-toc-border-color);
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
@media (max-width: 997px) {
|
|
165
|
+
.schema {
|
|
166
|
+
margin-bottom: 1rem;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
163
170
|
.openapi-tabs__heading {
|
|
164
171
|
margin-bottom: 1rem;
|
|
165
172
|
}
|
|
173
|
+
|
|
174
|
+
/* Loading Skeleton */
|
|
175
|
+
@keyframes pulsing {
|
|
176
|
+
0% {
|
|
177
|
+
opacity: 1;
|
|
178
|
+
background-color: var(--ifm-color-emphasis-100);
|
|
179
|
+
}
|
|
180
|
+
50% {
|
|
181
|
+
opacity: 0.6;
|
|
182
|
+
background-color: var(--ifm-toc-border-color);
|
|
183
|
+
}
|
|
184
|
+
100% {
|
|
185
|
+
opacity: 1;
|
|
186
|
+
background-color: var(--ifm-color-emphasis-100);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.openapi-skeleton {
|
|
191
|
+
animation: pulsing 2s infinite ease-in-out;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* Loading Skeleton */
|
|
195
|
+
.openapi-skeleton {
|
|
196
|
+
border-radius: var(--ifm-pre-border-radius);
|
|
197
|
+
background-color: var(--openapi-skeleton-background);
|
|
198
|
+
max-width: 100%;
|
|
199
|
+
margin: 1rem auto;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.openapi-skeleton.sm {
|
|
203
|
+
height: 100px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.openapi-skeleton.md {
|
|
207
|
+
height: 350px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.openapi-skeleton.lg {
|
|
211
|
+
height: 96.5%;
|
|
212
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "4.0
|
|
4
|
+
"version": "4.2.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\""
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/types": "^3.0
|
|
31
|
+
"@docusaurus/types": "^3.5.0",
|
|
32
32
|
"@types/crypto-js": "^4.1.0",
|
|
33
33
|
"@types/file-saver": "^2.0.5",
|
|
34
34
|
"@types/lodash": "^4.14.176",
|
|
@@ -36,13 +36,14 @@
|
|
|
36
36
|
"eslint-plugin-prettier": "^5.0.1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@docusaurus/theme-common": "^3.0
|
|
39
|
+
"@docusaurus/theme-common": "^3.5.0",
|
|
40
40
|
"@hookform/error-message": "^2.0.1",
|
|
41
41
|
"@reduxjs/toolkit": "^1.7.1",
|
|
42
|
+
"allof-merge": "^0.6.6",
|
|
42
43
|
"clsx": "^1.1.1",
|
|
43
44
|
"copy-text-to-clipboard": "^3.1.0",
|
|
44
45
|
"crypto-js": "^4.1.1",
|
|
45
|
-
"docusaurus-plugin-openapi-docs": "^4.0
|
|
46
|
+
"docusaurus-plugin-openapi-docs": "^4.2.0",
|
|
46
47
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
47
48
|
"file-saver": "^2.0.5",
|
|
48
49
|
"lodash": "^4.17.20",
|
|
@@ -57,8 +58,9 @@
|
|
|
57
58
|
"react-modal": "^3.15.1",
|
|
58
59
|
"react-redux": "^7.2.0",
|
|
59
60
|
"rehype-raw": "^6.1.1",
|
|
60
|
-
"
|
|
61
|
-
"sass
|
|
61
|
+
"remark-gfm": "3.0.1",
|
|
62
|
+
"sass": "^1.80.4",
|
|
63
|
+
"sass-loader": "^16.0.2",
|
|
62
64
|
"webpack": "^5.61.0",
|
|
63
65
|
"xml-formatter": "^2.6.1"
|
|
64
66
|
},
|
|
@@ -69,5 +71,5 @@
|
|
|
69
71
|
"engines": {
|
|
70
72
|
"node": ">=14"
|
|
71
73
|
},
|
|
72
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "e7295a8aa6f3fab5ccc4f8f9ad0e6c33d785aa16"
|
|
73
75
|
}
|
package/src/markdown/utils.ts
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import { ReactNode } from "react";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** @deprecated use ReactNode from React instead */
|
|
11
|
+
export type Children = ReactNode;
|
|
11
12
|
|
|
12
|
-
export type Props = Record<string, any> & { children?:
|
|
13
|
+
export type Props = Record<string, any> & { children?: ReactNode };
|
|
13
14
|
|
|
14
15
|
export function create(tag: string, props: Props): string {
|
|
15
16
|
const { children, ...rest } = props;
|
|
@@ -24,8 +25,8 @@ export function create(tag: string, props: Props): string {
|
|
|
24
25
|
|
|
25
26
|
export function guard<T>(
|
|
26
27
|
value: T | undefined | string,
|
|
27
|
-
cb: (value: T) =>
|
|
28
|
-
)
|
|
28
|
+
cb: (value: T) => ReactNode
|
|
29
|
+
) {
|
|
29
30
|
if (!!value || value === 0) {
|
|
30
31
|
const children = cb(value as T);
|
|
31
32
|
return render(children);
|
|
@@ -33,11 +34,11 @@ export function guard<T>(
|
|
|
33
34
|
return "";
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
export function render(children:
|
|
37
|
+
export function render(children: ReactNode) {
|
|
37
38
|
if (Array.isArray(children)) {
|
|
38
39
|
return children.filter((c) => c !== undefined).join("");
|
|
39
40
|
}
|
|
40
|
-
return
|
|
41
|
+
return children ?? "";
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export function toString(value: any): string | undefined {
|
|
@@ -27,120 +27,10 @@ import {
|
|
|
27
27
|
getCodeSampleSourceFromLanguage,
|
|
28
28
|
mergeArraysbyLanguage,
|
|
29
29
|
mergeCodeSampleLanguage,
|
|
30
|
+
generateLanguageSet,
|
|
30
31
|
} from "./languages";
|
|
31
32
|
|
|
32
|
-
export const languageSet: Language[] =
|
|
33
|
-
{
|
|
34
|
-
highlight: "bash",
|
|
35
|
-
language: "curl",
|
|
36
|
-
codeSampleLanguage: "Shell",
|
|
37
|
-
logoClass: "bash",
|
|
38
|
-
options: {
|
|
39
|
-
longFormat: false,
|
|
40
|
-
followRedirect: true,
|
|
41
|
-
trimRequestBody: true,
|
|
42
|
-
},
|
|
43
|
-
variant: "cURL",
|
|
44
|
-
variants: ["curl"],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
highlight: "python",
|
|
48
|
-
language: "python",
|
|
49
|
-
codeSampleLanguage: "Python",
|
|
50
|
-
logoClass: "python",
|
|
51
|
-
options: {
|
|
52
|
-
followRedirect: true,
|
|
53
|
-
trimRequestBody: true,
|
|
54
|
-
},
|
|
55
|
-
variant: "requests",
|
|
56
|
-
variants: ["requests", "http.client"],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
highlight: "go",
|
|
60
|
-
language: "go",
|
|
61
|
-
codeSampleLanguage: "Go",
|
|
62
|
-
logoClass: "go",
|
|
63
|
-
options: {
|
|
64
|
-
followRedirect: true,
|
|
65
|
-
trimRequestBody: true,
|
|
66
|
-
},
|
|
67
|
-
variant: "native",
|
|
68
|
-
variants: ["native"],
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
highlight: "javascript",
|
|
72
|
-
language: "nodejs",
|
|
73
|
-
codeSampleLanguage: "JavaScript",
|
|
74
|
-
logoClass: "nodejs",
|
|
75
|
-
options: {
|
|
76
|
-
ES6_enabled: true,
|
|
77
|
-
followRedirect: true,
|
|
78
|
-
trimRequestBody: true,
|
|
79
|
-
},
|
|
80
|
-
variant: "axios",
|
|
81
|
-
variants: ["axios", "native"],
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
highlight: "ruby",
|
|
85
|
-
language: "ruby",
|
|
86
|
-
codeSampleLanguage: "Ruby",
|
|
87
|
-
logoClass: "ruby",
|
|
88
|
-
options: {
|
|
89
|
-
followRedirect: true,
|
|
90
|
-
trimRequestBody: true,
|
|
91
|
-
},
|
|
92
|
-
variant: "Net::HTTP",
|
|
93
|
-
variants: ["net::http"],
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
highlight: "csharp",
|
|
97
|
-
language: "csharp",
|
|
98
|
-
codeSampleLanguage: "C#",
|
|
99
|
-
logoClass: "csharp",
|
|
100
|
-
options: {
|
|
101
|
-
followRedirect: true,
|
|
102
|
-
trimRequestBody: true,
|
|
103
|
-
},
|
|
104
|
-
variant: "RestSharp",
|
|
105
|
-
variants: ["restsharp", "httpclient"],
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
highlight: "php",
|
|
109
|
-
language: "php",
|
|
110
|
-
codeSampleLanguage: "PHP",
|
|
111
|
-
logoClass: "php",
|
|
112
|
-
options: {
|
|
113
|
-
followRedirect: true,
|
|
114
|
-
trimRequestBody: true,
|
|
115
|
-
},
|
|
116
|
-
variant: "cURL",
|
|
117
|
-
variants: ["curl", "guzzle", "pecl_http", "http_request2"],
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
highlight: "java",
|
|
121
|
-
language: "java",
|
|
122
|
-
codeSampleLanguage: "Java",
|
|
123
|
-
logoClass: "java",
|
|
124
|
-
options: {
|
|
125
|
-
followRedirect: true,
|
|
126
|
-
trimRequestBody: true,
|
|
127
|
-
},
|
|
128
|
-
variant: "OkHttp",
|
|
129
|
-
variants: ["okhttp", "unirest"],
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
highlight: "powershell",
|
|
133
|
-
language: "powershell",
|
|
134
|
-
codeSampleLanguage: "PowerShell",
|
|
135
|
-
logoClass: "powershell",
|
|
136
|
-
options: {
|
|
137
|
-
followRedirect: true,
|
|
138
|
-
trimRequestBody: true,
|
|
139
|
-
},
|
|
140
|
-
variant: "RestMethod",
|
|
141
|
-
variants: ["restmethod"],
|
|
142
|
-
},
|
|
143
|
-
];
|
|
33
|
+
export const languageSet: Language[] = generateLanguageSet();
|
|
144
34
|
|
|
145
35
|
export interface Props {
|
|
146
36
|
postman: sdk.Request;
|
|
@@ -290,7 +180,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
290
180
|
]);
|
|
291
181
|
// no dependencies was intentionlly set for this particular hook. it's safe as long as if conditions are set
|
|
292
182
|
useEffect(function onSelectedVariantUpdate() {
|
|
293
|
-
if (selectedVariant && selectedVariant !== language
|
|
183
|
+
if (selectedVariant && selectedVariant !== language?.variant) {
|
|
294
184
|
const postmanRequest = buildPostmanRequest(postman, {
|
|
295
185
|
queryParams,
|
|
296
186
|
pathParams,
|
|
@@ -321,6 +211,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
321
211
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
322
212
|
useEffect(function onSelectedSampleUpdate() {
|
|
323
213
|
if (
|
|
214
|
+
language &&
|
|
324
215
|
language.samples &&
|
|
325
216
|
language.samplesSources &&
|
|
326
217
|
selectedSample &&
|
|
@@ -339,6 +230,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
339
230
|
|
|
340
231
|
return (
|
|
341
232
|
<>
|
|
233
|
+
{/* Outer language tabs */}
|
|
342
234
|
<CodeTabs
|
|
343
235
|
groupId="code-samples"
|
|
344
236
|
action={{
|
|
@@ -347,6 +239,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
347
239
|
setSelectedSample: setSelectedSample,
|
|
348
240
|
}}
|
|
349
241
|
languageSet={mergedLangs}
|
|
242
|
+
defaultValue={defaultLang[0]?.language ?? mergedLangs[0].language}
|
|
350
243
|
lazy
|
|
351
244
|
>
|
|
352
245
|
{mergedLangs.map((lang) => {
|
|
@@ -359,6 +252,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
359
252
|
className: `openapi-tabs__code-item--${lang.logoClass}`,
|
|
360
253
|
}}
|
|
361
254
|
>
|
|
255
|
+
{/* Inner x-codeSamples tabs */}
|
|
362
256
|
{lang.samples && (
|
|
363
257
|
<CodeTabs
|
|
364
258
|
className="openapi-tabs__code-container-inner"
|
|
@@ -400,6 +294,7 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
400
294
|
</CodeTabs>
|
|
401
295
|
)}
|
|
402
296
|
|
|
297
|
+
{/* Inner generated code snippets */}
|
|
403
298
|
<CodeTabs
|
|
404
299
|
className="openapi-tabs__code-container-inner"
|
|
405
300
|
action={{
|