docusaurus-theme-openapi-docs 5.0.2 → 5.1.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/schema.js +38 -15
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +86 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +4 -2
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +9 -6
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +9 -10
- package/lib/theme/ApiExplorer/Body/index.js +4 -5
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +96 -61
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +12 -1
- package/lib/theme/ApiExplorer/CodeSnippets/languages.test.d.ts +1 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.test.js +102 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.js +6 -5
- package/lib/theme/ApiExplorer/Export/index.js +9 -2
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +1 -2
- package/lib/theme/ApiExplorer/FormLabel/index.js +1 -2
- package/lib/theme/ApiExplorer/FormTextInput/index.js +1 -2
- package/lib/theme/ApiExplorer/LiveEditor/index.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +5 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +75 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +67 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +65 -1
- package/lib/theme/ApiExplorer/ParamOptions/index.js +2 -3
- package/lib/theme/ApiExplorer/Request/index.js +17 -18
- package/lib/theme/ApiExplorer/Response/index.js +54 -12
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +57 -50
- package/lib/theme/ApiExplorer/Server/index.js +2 -3
- package/lib/theme/ApiItem/index.js +59 -33
- package/lib/theme/ApiTabs/index.d.ts +1 -1
- package/lib/theme/ApiTabs/index.js +7 -7
- package/lib/theme/DiscriminatorTabs/index.d.ts +1 -1
- package/lib/theme/DiscriminatorTabs/index.js +6 -5
- package/lib/theme/Example/index.js +3 -4
- package/lib/theme/MimeTabs/index.d.ts +1 -1
- package/lib/theme/MimeTabs/index.js +6 -5
- package/lib/theme/OperationTabs/index.d.ts +1 -1
- package/lib/theme/OperationTabs/index.js +6 -5
- package/lib/theme/ParamsDetails/index.js +1 -2
- package/lib/theme/ParamsItem/index.js +7 -8
- package/lib/theme/RequestSchema/index.js +57 -57
- package/lib/theme/ResponseExamples/index.js +3 -4
- package/lib/theme/ResponseSchema/index.js +26 -24
- package/lib/theme/Schema/index.js +148 -27
- package/lib/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/lib/theme/SchemaExpansion/context.d.ts +24 -0
- package/lib/theme/SchemaExpansion/context.js +187 -0
- package/lib/theme/SchemaExpansion/index.d.ts +4 -0
- package/lib/theme/SchemaExpansion/index.js +314 -0
- package/lib/theme/SchemaItem/index.js +9 -10
- package/lib/theme/SchemaTabs/index.d.ts +1 -1
- package/lib/theme/SchemaTabs/index.js +6 -5
- package/lib/theme/StatusCodes/index.js +2 -4
- package/lib/theme/TabItem/index.d.ts +5 -0
- package/lib/theme/TabItem/index.js +51 -0
- package/lib/theme/TabItem/styles.module.css +3 -0
- package/lib/theme/Tabs/index.d.ts +5 -0
- package/lib/theme/Tabs/index.js +148 -0
- package/lib/theme/Tabs/styles.module.css +7 -0
- package/lib/theme/styles.scss +1 -0
- package/lib/theme/translationIds.d.ts +1 -93
- package/lib/theme/translationIds.js +0 -109
- package/lib/theme/utils/codeBlockUtils.d.ts +28 -0
- package/lib/theme/utils/codeBlockUtils.js +223 -0
- package/lib/theme/utils/reactUtils.d.ts +1 -0
- package/lib/theme/utils/reactUtils.js +23 -0
- package/lib/theme/utils/scrollUtils.d.ts +7 -0
- package/lib/theme/utils/scrollUtils.js +175 -0
- package/lib/theme/utils/tabsUtils.d.ts +47 -0
- package/lib/theme/utils/tabsUtils.js +299 -0
- package/lib/theme/utils/useCodeWordWrap.d.ts +8 -0
- package/lib/theme/utils/useCodeWordWrap.js +84 -0
- package/lib/theme/utils/useMutationObserver.d.ts +3 -0
- package/lib/theme/utils/useMutationObserver.js +34 -0
- package/package.json +4 -4
- package/src/markdown/schema.test.ts +102 -0
- package/src/markdown/schema.ts +42 -15
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/index.tsx +2 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +8 -7
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/index.tsx +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/index.tsx +1 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +9 -10
- package/src/theme/ApiExplorer/Body/index.tsx +7 -5
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +103 -59
- package/src/theme/ApiExplorer/CodeSnippets/languages.test.ts +109 -0
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +13 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +5 -5
- package/src/theme/ApiExplorer/Export/index.tsx +6 -2
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +1 -2
- package/src/theme/ApiExplorer/FormLabel/index.tsx +1 -2
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +1 -2
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +5 -3
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +20 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +15 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +11 -1
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +2 -3
- package/src/theme/ApiExplorer/Request/index.tsx +23 -18
- package/src/theme/ApiExplorer/Response/index.tsx +63 -9
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +60 -52
- package/src/theme/ApiExplorer/Server/index.tsx +8 -3
- package/src/theme/ApiItem/index.tsx +43 -21
- package/src/theme/ApiTabs/index.tsx +8 -8
- package/src/theme/DiscriminatorTabs/index.tsx +6 -5
- package/src/theme/Example/index.tsx +3 -4
- package/src/theme/MimeTabs/index.tsx +9 -8
- package/src/theme/OperationTabs/index.tsx +5 -4
- package/src/theme/ParamsDetails/index.tsx +1 -2
- package/src/theme/ParamsItem/index.tsx +13 -8
- package/src/theme/RequestSchema/index.tsx +38 -40
- package/src/theme/ResponseExamples/index.tsx +3 -4
- package/src/theme/ResponseSchema/index.tsx +16 -17
- package/src/theme/Schema/index.tsx +156 -27
- package/src/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/src/theme/SchemaExpansion/context.tsx +154 -0
- package/src/theme/SchemaExpansion/index.tsx +236 -0
- package/src/theme/SchemaItem/index.tsx +18 -10
- package/src/theme/SchemaTabs/index.tsx +6 -5
- package/src/theme/StatusCodes/index.tsx +2 -3
- package/src/theme/TabItem/index.tsx +61 -0
- package/src/theme/TabItem/styles.module.css +3 -0
- package/src/theme/Tabs/index.tsx +164 -0
- package/src/theme/Tabs/styles.module.css +7 -0
- package/src/theme/styles.scss +1 -0
- package/src/theme/translationIds.ts +37 -106
- package/src/theme/utils/codeBlockUtils.ts +296 -0
- package/src/theme/utils/reactUtils.ts +22 -0
- package/src/theme/utils/scrollUtils.tsx +153 -0
- package/src/theme/utils/tabsUtils.tsx +329 -0
- package/src/theme/utils/useCodeWordWrap.ts +110 -0
- package/src/theme/utils/useMutationObserver.ts +43 -0
- package/src/theme-classic.d.ts +0 -96
- package/src/types.d.ts +27 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const languages_1 = require("./languages");
|
|
10
|
+
const baseLang = (language, codeSampleLanguage) => ({
|
|
11
|
+
highlight: language,
|
|
12
|
+
language,
|
|
13
|
+
codeSampleLanguage,
|
|
14
|
+
logoClass: language,
|
|
15
|
+
variant: "http",
|
|
16
|
+
variants: ["http"],
|
|
17
|
+
});
|
|
18
|
+
describe("mergeCodeSampleLanguage", () => {
|
|
19
|
+
it("returns the language unchanged when no codeSamples target it", () => {
|
|
20
|
+
const langs = [baseLang("python", "Python")];
|
|
21
|
+
const result = (0, languages_1.mergeCodeSampleLanguage)(langs, []);
|
|
22
|
+
expect(result[0]).toEqual(langs[0]);
|
|
23
|
+
expect(result[0].samples).toBeUndefined();
|
|
24
|
+
});
|
|
25
|
+
it("attaches a single sample with no label using an indexed id", () => {
|
|
26
|
+
const samples = [{ lang: "Python", source: "print('hi')" }];
|
|
27
|
+
const [py] = (0, languages_1.mergeCodeSampleLanguage)(
|
|
28
|
+
[baseLang("python", "Python")],
|
|
29
|
+
samples
|
|
30
|
+
);
|
|
31
|
+
expect(py.samples).toEqual(["Python-0"]);
|
|
32
|
+
expect(py.samplesLabels).toEqual(["Python"]);
|
|
33
|
+
expect(py.samplesSources).toEqual(["print('hi')"]);
|
|
34
|
+
expect(py.sample).toBe("Python-0");
|
|
35
|
+
});
|
|
36
|
+
it("attaches a single sample with a label using lang-label id", () => {
|
|
37
|
+
const samples = [{ lang: "PHP", label: "Custom", source: "<?php" }];
|
|
38
|
+
const [php] = (0, languages_1.mergeCodeSampleLanguage)(
|
|
39
|
+
[baseLang("php", "PHP")],
|
|
40
|
+
samples
|
|
41
|
+
);
|
|
42
|
+
expect(php.samples).toEqual(["PHP-Custom"]);
|
|
43
|
+
expect(php.samplesLabels).toEqual(["Custom"]);
|
|
44
|
+
});
|
|
45
|
+
it("produces unique ids for multiple samples sharing a lang with distinct labels (#1204)", () => {
|
|
46
|
+
const samples = [
|
|
47
|
+
{ lang: "Python", label: "KeyPair Auth", source: "a" },
|
|
48
|
+
{ lang: "Python", label: "Basic Auth", source: "b" },
|
|
49
|
+
{ lang: "Python", label: "OAuth", source: "c" },
|
|
50
|
+
];
|
|
51
|
+
const [py] = (0, languages_1.mergeCodeSampleLanguage)(
|
|
52
|
+
[baseLang("python", "Python")],
|
|
53
|
+
samples
|
|
54
|
+
);
|
|
55
|
+
expect(py.samples).toEqual([
|
|
56
|
+
"Python-KeyPair Auth",
|
|
57
|
+
"Python-Basic Auth",
|
|
58
|
+
"Python-OAuth",
|
|
59
|
+
]);
|
|
60
|
+
expect(new Set(py.samples).size).toBe(3);
|
|
61
|
+
expect(py.samplesLabels).toEqual(["KeyPair Auth", "Basic Auth", "OAuth"]);
|
|
62
|
+
expect(py.samplesSources).toEqual(["a", "b", "c"]);
|
|
63
|
+
});
|
|
64
|
+
it("produces unique indexed ids for multiple samples sharing a lang without labels", () => {
|
|
65
|
+
const samples = [
|
|
66
|
+
{ lang: "PowerShell", source: "x" },
|
|
67
|
+
{ lang: "PowerShell", source: "y" },
|
|
68
|
+
];
|
|
69
|
+
const [ps] = (0, languages_1.mergeCodeSampleLanguage)(
|
|
70
|
+
[baseLang("powershell", "PowerShell")],
|
|
71
|
+
samples
|
|
72
|
+
);
|
|
73
|
+
expect(ps.samples).toEqual(["PowerShell-0", "PowerShell-1"]);
|
|
74
|
+
expect(new Set(ps.samples).size).toBe(2);
|
|
75
|
+
expect(ps.samplesLabels).toEqual(["PowerShell", "PowerShell"]);
|
|
76
|
+
});
|
|
77
|
+
it("defensively suffixes ids when lang+label collides", () => {
|
|
78
|
+
const samples = [
|
|
79
|
+
{ lang: "Java", label: "Auth", source: "a" },
|
|
80
|
+
{ lang: "Java", label: "Auth", source: "b" },
|
|
81
|
+
];
|
|
82
|
+
const [java] = (0, languages_1.mergeCodeSampleLanguage)(
|
|
83
|
+
[baseLang("java", "Java")],
|
|
84
|
+
samples
|
|
85
|
+
);
|
|
86
|
+
expect(java.samples).toEqual(["Java-Auth", "Java-Auth-1"]);
|
|
87
|
+
expect(new Set(java.samples).size).toBe(2);
|
|
88
|
+
expect(java.samplesLabels).toEqual(["Auth", "Auth"]);
|
|
89
|
+
});
|
|
90
|
+
it("filters codeSamples by codeSampleLanguage and leaves other languages alone", () => {
|
|
91
|
+
const samples = [
|
|
92
|
+
{ lang: "Python", label: "A", source: "a" },
|
|
93
|
+
{ lang: "Java", label: "B", source: "b" },
|
|
94
|
+
];
|
|
95
|
+
const result = (0, languages_1.mergeCodeSampleLanguage)(
|
|
96
|
+
[baseLang("python", "Python"), baseLang("php", "PHP")],
|
|
97
|
+
samples
|
|
98
|
+
);
|
|
99
|
+
expect(result[0].samples).toEqual(["Python-A"]);
|
|
100
|
+
expect(result[1].samples).toBeUndefined();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -69,9 +69,10 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.default = CodeTabs;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
73
72
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
73
|
const clsx_1 = __importDefault(require("clsx"));
|
|
74
|
+
const scrollUtils_1 = require("@theme/utils/scrollUtils");
|
|
75
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
75
76
|
function TabList({
|
|
76
77
|
action,
|
|
77
78
|
currentLanguage,
|
|
@@ -87,7 +88,7 @@ function TabList({
|
|
|
87
88
|
const tabRefs = (0, react_1.useRef)([]);
|
|
88
89
|
const tabsScrollContainerRef = (0, react_1.useRef)(null);
|
|
89
90
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
90
|
-
|
|
91
|
+
scrollUtils_1.useScrollPositionBlocker)();
|
|
91
92
|
(0, react_1.useEffect)(() => {
|
|
92
93
|
const activeTab = tabRefs.current.find(
|
|
93
94
|
(tab) => tab?.getAttribute("aria-selected") === "true"
|
|
@@ -235,10 +236,10 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
235
236
|
);
|
|
236
237
|
}
|
|
237
238
|
function TabsComponent(props) {
|
|
238
|
-
const tabs = (0,
|
|
239
|
+
const tabs = (0, tabsUtils_1.useTabsContextValue)(props);
|
|
239
240
|
const { className } = props;
|
|
240
241
|
return react_1.default.createElement(
|
|
241
|
-
|
|
242
|
+
tabsUtils_1.TabsProvider,
|
|
242
243
|
{ value: tabs },
|
|
243
244
|
react_1.default.createElement(
|
|
244
245
|
"div",
|
|
@@ -265,6 +266,6 @@ function CodeTabs(props) {
|
|
|
265
266
|
key: String(isBrowser),
|
|
266
267
|
...props,
|
|
267
268
|
},
|
|
268
|
-
(0,
|
|
269
|
+
(0, tabsUtils_1.sanitizeTabsChildren)(props.children)
|
|
269
270
|
);
|
|
270
271
|
}
|
|
@@ -12,6 +12,7 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
15
16
|
const file_saver_1 = __importDefault(require("file-saver"));
|
|
16
17
|
const saveFile = (url) => {
|
|
17
18
|
let fileName;
|
|
@@ -30,7 +31,10 @@ function Export({ url, proxy }) {
|
|
|
30
31
|
react_1.default.createElement(
|
|
31
32
|
"button",
|
|
32
33
|
{ className: "export-button button button--sm button--secondary" },
|
|
33
|
-
|
|
34
|
+
(0, Translate_1.translate)({
|
|
35
|
+
id: "theme.openapi.export.button",
|
|
36
|
+
message: "Export",
|
|
37
|
+
})
|
|
34
38
|
),
|
|
35
39
|
react_1.default.createElement(
|
|
36
40
|
"ul",
|
|
@@ -48,7 +52,10 @@ function Export({ url, proxy }) {
|
|
|
48
52
|
className: "dropdown__link",
|
|
49
53
|
href: `${url}`,
|
|
50
54
|
},
|
|
51
|
-
|
|
55
|
+
(0, Translate_1.translate)({
|
|
56
|
+
id: "theme.openapi.export.openapiSpec",
|
|
57
|
+
message: "OpenAPI Spec",
|
|
58
|
+
})
|
|
52
59
|
)
|
|
53
60
|
)
|
|
54
61
|
)
|
|
@@ -72,7 +72,6 @@ const Translate_1 = require("@docusaurus/Translate");
|
|
|
72
72
|
const FloatingButton_1 = __importDefault(
|
|
73
73
|
require("@theme/ApiExplorer/FloatingButton")
|
|
74
74
|
);
|
|
75
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
76
75
|
const react_magic_dropzone_1 = __importDefault(require("react-magic-dropzone"));
|
|
77
76
|
function RenderPreview({ file }) {
|
|
78
77
|
switch (file.type) {
|
|
@@ -161,7 +160,7 @@ function FormFileUpload({ placeholder, onChange }) {
|
|
|
161
160
|
},
|
|
162
161
|
},
|
|
163
162
|
(0, Translate_1.translate)({
|
|
164
|
-
id:
|
|
163
|
+
id: "theme.openapi.formFileUpload.clearButton",
|
|
165
164
|
message: "Clear",
|
|
166
165
|
})
|
|
167
166
|
),
|
|
@@ -13,7 +13,6 @@ var __importDefault =
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
15
|
const Translate_1 = require("@docusaurus/Translate");
|
|
16
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
17
16
|
function FormLabel({ htmlFor, label, type, required }) {
|
|
18
17
|
return react_1.default.createElement(
|
|
19
18
|
react_1.default.Fragment,
|
|
@@ -41,7 +40,7 @@ function FormLabel({ htmlFor, label, type, required }) {
|
|
|
41
40
|
"span",
|
|
42
41
|
{ className: "openapi-schema__required" },
|
|
43
42
|
(0, Translate_1.translate)({
|
|
44
|
-
id:
|
|
43
|
+
id: "theme.openapi.schemaItem.required",
|
|
45
44
|
message: "required",
|
|
46
45
|
})
|
|
47
46
|
)
|
|
@@ -72,7 +72,6 @@ const react_1 = __importStar(require("react"));
|
|
|
72
72
|
const Translate_1 = require("@docusaurus/Translate");
|
|
73
73
|
const error_message_1 = require("@hookform/error-message");
|
|
74
74
|
const FormLabel_1 = __importDefault(require("@theme/ApiExplorer/FormLabel"));
|
|
75
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
76
75
|
const clsx_1 = __importDefault(require("clsx"));
|
|
77
76
|
const react_hook_form_1 = require("react-hook-form");
|
|
78
77
|
function FormTextInput({
|
|
@@ -108,7 +107,7 @@ function FormTextInput({
|
|
|
108
107
|
...register(paramName, {
|
|
109
108
|
required: isRequired
|
|
110
109
|
? (0, Translate_1.translate)({
|
|
111
|
-
id:
|
|
110
|
+
id: "theme.openapi.form.fieldRequired",
|
|
112
111
|
message: "This field is required",
|
|
113
112
|
})
|
|
114
113
|
: false,
|
|
@@ -72,7 +72,6 @@ const theme_common_1 = require("@docusaurus/theme-common");
|
|
|
72
72
|
const Translate_1 = require("@docusaurus/Translate");
|
|
73
73
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
74
|
const error_message_1 = require("@hookform/error-message");
|
|
75
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
76
75
|
const clsx_1 = __importDefault(require("clsx"));
|
|
77
76
|
const react_hook_form_1 = require("react-hook-form");
|
|
78
77
|
const react_live_1 = require("react-live");
|
|
@@ -144,7 +143,7 @@ function App({
|
|
|
144
143
|
required:
|
|
145
144
|
isRequired && !code
|
|
146
145
|
? (0, Translate_1.translate)({
|
|
147
|
-
id:
|
|
146
|
+
id: "theme.openapi.form.fieldRequired",
|
|
148
147
|
message: "This field is required",
|
|
149
148
|
})
|
|
150
149
|
: false,
|
|
@@ -79,7 +79,6 @@ const FormTextInput_1 = __importDefault(
|
|
|
79
79
|
);
|
|
80
80
|
const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
|
|
81
81
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
82
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
83
82
|
const react_hook_form_1 = require("react-hook-form");
|
|
84
83
|
function ArrayItem({ param, onChange, initialValue }) {
|
|
85
84
|
const [value, setValue] = (0, react_1.useState)(initialValue || "");
|
|
@@ -171,7 +170,7 @@ function ParamArrayFormItem({ param, label, type, required }) {
|
|
|
171
170
|
rules: {
|
|
172
171
|
required: param.required
|
|
173
172
|
? (0, Translate_1.translate)({
|
|
174
|
-
id:
|
|
173
|
+
id: "theme.openapi.form.fieldRequired",
|
|
175
174
|
message: "This field is required",
|
|
176
175
|
})
|
|
177
176
|
: false,
|
|
@@ -219,7 +218,10 @@ function ParamArrayFormItem({ param, label, type, required }) {
|
|
|
219
218
|
react_1.default.createElement(
|
|
220
219
|
"button",
|
|
221
220
|
{ className: "openapi-explorer__thin-btn", onClick: handleAddItem },
|
|
222
|
-
|
|
221
|
+
(0, Translate_1.translate)({
|
|
222
|
+
id: "theme.openapi.paramArray.addItem",
|
|
223
|
+
message: "Add item",
|
|
224
|
+
})
|
|
223
225
|
)
|
|
224
226
|
),
|
|
225
227
|
}),
|
|
@@ -5,6 +5,62 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
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 () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
8
64
|
var __importDefault =
|
|
9
65
|
(this && this.__importDefault) ||
|
|
10
66
|
function (mod) {
|
|
@@ -12,21 +68,35 @@ var __importDefault =
|
|
|
12
68
|
};
|
|
13
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
70
|
exports.default = ParamBooleanFormItem;
|
|
15
|
-
const react_1 =
|
|
71
|
+
const react_1 = __importStar(require("react"));
|
|
16
72
|
const Translate_1 = require("@docusaurus/Translate");
|
|
17
73
|
const error_message_1 = require("@hookform/error-message");
|
|
18
74
|
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
19
75
|
const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
|
|
20
76
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
21
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
22
77
|
const react_hook_form_1 = require("react-hook-form");
|
|
23
78
|
function ParamBooleanFormItem({ param, label, type, required }) {
|
|
24
79
|
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
25
80
|
const {
|
|
26
81
|
control,
|
|
27
82
|
formState: { errors },
|
|
83
|
+
setValue,
|
|
28
84
|
} = (0, react_hook_form_1.useFormContext)();
|
|
29
85
|
const showErrorMessage = errors?.paramBoolean;
|
|
86
|
+
(0, react_1.useEffect)(() => {
|
|
87
|
+
if (param.value === undefined) return;
|
|
88
|
+
const initial =
|
|
89
|
+
typeof param.value === "boolean" ? String(param.value) : param.value;
|
|
90
|
+
if (initial === "true" || initial === "false") {
|
|
91
|
+
setValue("paramBoolean", initial);
|
|
92
|
+
// Boolean defaults arrive in redux as actual booleans; normalize to the
|
|
93
|
+
// string form the rest of the form uses.
|
|
94
|
+
if (typeof param.value === "boolean") {
|
|
95
|
+
dispatch((0, slice_1.setParam)({ ...param, value: initial }));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
99
|
+
}, []);
|
|
30
100
|
return react_1.default.createElement(
|
|
31
101
|
react_1.default.Fragment,
|
|
32
102
|
null,
|
|
@@ -35,17 +105,18 @@ function ParamBooleanFormItem({ param, label, type, required }) {
|
|
|
35
105
|
rules: {
|
|
36
106
|
required: param.required
|
|
37
107
|
? (0, Translate_1.translate)({
|
|
38
|
-
id:
|
|
108
|
+
id: "theme.openapi.form.fieldRequired",
|
|
39
109
|
message: "This field is required",
|
|
40
110
|
})
|
|
41
111
|
: false,
|
|
42
112
|
},
|
|
43
113
|
name: "paramBoolean",
|
|
44
|
-
render: ({ field: { onChange } }) =>
|
|
114
|
+
render: ({ field: { onChange, value } }) =>
|
|
45
115
|
react_1.default.createElement(FormSelect_1.default, {
|
|
46
116
|
label: label,
|
|
47
117
|
type: type,
|
|
48
118
|
required: required,
|
|
119
|
+
value: value ?? "---",
|
|
49
120
|
options: ["---", "true", "false"],
|
|
50
121
|
onChange: (e) => {
|
|
51
122
|
const val = e.target.value;
|
|
@@ -21,7 +21,6 @@ const FormMultiSelect_1 = __importDefault(
|
|
|
21
21
|
const ParamOptions_1 = require("@theme/ApiExplorer/ParamOptions");
|
|
22
22
|
const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
|
|
23
23
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
24
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
25
24
|
const react_hook_form_1 = require("react-hook-form");
|
|
26
25
|
function ParamMultiSelectFormItem({ param, label, type, required }) {
|
|
27
26
|
const {
|
|
@@ -70,7 +69,7 @@ function ParamMultiSelectFormItem({ param, label, type, required }) {
|
|
|
70
69
|
rules: {
|
|
71
70
|
required: param.required
|
|
72
71
|
? (0, Translate_1.translate)({
|
|
73
|
-
id:
|
|
72
|
+
id: "theme.openapi.form.fieldRequired",
|
|
74
73
|
message: "This field is required",
|
|
75
74
|
})
|
|
76
75
|
: false,
|
|
@@ -5,6 +5,62 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
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 () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
8
64
|
var __importDefault =
|
|
9
65
|
(this && this.__importDefault) ||
|
|
10
66
|
function (mod) {
|
|
@@ -12,23 +68,29 @@ var __importDefault =
|
|
|
12
68
|
};
|
|
13
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
70
|
exports.default = ParamSelectFormItem;
|
|
15
|
-
const react_1 =
|
|
71
|
+
const react_1 = __importStar(require("react"));
|
|
16
72
|
const Translate_1 = require("@docusaurus/Translate");
|
|
17
73
|
const error_message_1 = require("@hookform/error-message");
|
|
18
74
|
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
19
75
|
const ParamOptions_1 = require("@theme/ApiExplorer/ParamOptions");
|
|
20
76
|
const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
|
|
21
77
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
22
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
23
78
|
const react_hook_form_1 = require("react-hook-form");
|
|
24
79
|
function ParamSelectFormItem({ param, label, type, required }) {
|
|
25
80
|
const {
|
|
26
81
|
control,
|
|
27
82
|
formState: { errors },
|
|
83
|
+
setValue,
|
|
28
84
|
} = (0, react_hook_form_1.useFormContext)();
|
|
29
85
|
const showErrorMessage = errors?.paramSelect;
|
|
30
86
|
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
31
87
|
const options = (0, ParamOptions_1.getSchemaEnum)(param.schema) ?? [];
|
|
88
|
+
(0, react_1.useEffect)(() => {
|
|
89
|
+
if (typeof param.value === "string" && options.includes(param.value)) {
|
|
90
|
+
setValue("paramSelect", param.value);
|
|
91
|
+
}
|
|
92
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
|
+
}, []);
|
|
32
94
|
return react_1.default.createElement(
|
|
33
95
|
react_1.default.Fragment,
|
|
34
96
|
null,
|
|
@@ -37,17 +99,18 @@ function ParamSelectFormItem({ param, label, type, required }) {
|
|
|
37
99
|
rules: {
|
|
38
100
|
required: param.required
|
|
39
101
|
? (0, Translate_1.translate)({
|
|
40
|
-
id:
|
|
102
|
+
id: "theme.openapi.form.fieldRequired",
|
|
41
103
|
message: "This field is required",
|
|
42
104
|
})
|
|
43
105
|
: false,
|
|
44
106
|
},
|
|
45
107
|
name: "paramSelect",
|
|
46
|
-
render: ({ field: { onChange } }) =>
|
|
108
|
+
render: ({ field: { onChange, value } }) =>
|
|
47
109
|
react_1.default.createElement(FormSelect_1.default, {
|
|
48
110
|
label: label,
|
|
49
111
|
type: type,
|
|
50
112
|
required: required,
|
|
113
|
+
value: value ?? "---",
|
|
51
114
|
options: ["---", ...options],
|
|
52
115
|
onChange: (e) => {
|
|
53
116
|
const val = e.target.value;
|
|
@@ -5,6 +5,62 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
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 () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
8
64
|
var __importDefault =
|
|
9
65
|
(this && this.__importDefault) ||
|
|
10
66
|
function (mod) {
|
|
@@ -12,14 +68,22 @@ var __importDefault =
|
|
|
12
68
|
};
|
|
13
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
70
|
exports.default = ParamTextFormItem;
|
|
15
|
-
const react_1 =
|
|
71
|
+
const react_1 = __importStar(require("react"));
|
|
16
72
|
const FormTextInput_1 = __importDefault(
|
|
17
73
|
require("@theme/ApiExplorer/FormTextInput")
|
|
18
74
|
);
|
|
19
75
|
const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
|
|
20
76
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
77
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
21
78
|
function ParamTextFormItem({ param, label, type, required }) {
|
|
22
79
|
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
80
|
+
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
81
|
+
(0, react_1.useEffect)(() => {
|
|
82
|
+
if (param.value !== undefined && !Array.isArray(param.value)) {
|
|
83
|
+
setValue(param.name, param.value);
|
|
84
|
+
}
|
|
85
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
|
+
}, []);
|
|
23
87
|
return react_1.default.createElement(FormTextInput_1.default, {
|
|
24
88
|
label: label,
|
|
25
89
|
type: type,
|
|
@@ -87,7 +87,6 @@ const ParamTextFormItem_1 = __importDefault(
|
|
|
87
87
|
require("@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem")
|
|
88
88
|
);
|
|
89
89
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
90
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
91
90
|
/**
|
|
92
91
|
* Extracts enum values from a schema, including when wrapped in allOf.
|
|
93
92
|
* This handles cases where an enum is referenced via allOf for composition.
|
|
@@ -254,11 +253,11 @@ function ParamOptions() {
|
|
|
254
253
|
),
|
|
255
254
|
showOptional
|
|
256
255
|
? (0, Translate_1.translate)({
|
|
257
|
-
id:
|
|
256
|
+
id: "theme.openapi.paramOptions.hideOptional",
|
|
258
257
|
message: "Hide optional parameters",
|
|
259
258
|
})
|
|
260
259
|
: (0, Translate_1.translate)({
|
|
261
|
-
id:
|
|
260
|
+
id: "theme.openapi.paramOptions.showOptional",
|
|
262
261
|
message: "Show optional parameters",
|
|
263
262
|
})
|
|
264
263
|
),
|