docusaurus-theme-openapi-docs 0.0.0-1239 → 0.0.0-1241
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/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +74 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +66 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +65 -1
- package/lib/theme/ApiItem/index.js +4 -1
- package/package.json +3 -3
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +19 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +14 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +11 -1
- package/src/theme/ApiItem/index.tsx +6 -1
|
@@ -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,7 +68,7 @@ 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"));
|
|
@@ -25,8 +81,23 @@ function ParamBooleanFormItem({ param, label, type, required }) {
|
|
|
25
81
|
const {
|
|
26
82
|
control,
|
|
27
83
|
formState: { errors },
|
|
84
|
+
setValue,
|
|
28
85
|
} = (0, react_hook_form_1.useFormContext)();
|
|
29
86
|
const showErrorMessage = errors?.paramBoolean;
|
|
87
|
+
(0, react_1.useEffect)(() => {
|
|
88
|
+
if (param.value === undefined) return;
|
|
89
|
+
const initial =
|
|
90
|
+
typeof param.value === "boolean" ? String(param.value) : param.value;
|
|
91
|
+
if (initial === "true" || initial === "false") {
|
|
92
|
+
setValue("paramBoolean", initial);
|
|
93
|
+
// Boolean defaults arrive in redux as actual booleans; normalize to the
|
|
94
|
+
// string form the rest of the form uses.
|
|
95
|
+
if (typeof param.value === "boolean") {
|
|
96
|
+
dispatch((0, slice_1.setParam)({ ...param, value: initial }));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
|
+
}, []);
|
|
30
101
|
return react_1.default.createElement(
|
|
31
102
|
react_1.default.Fragment,
|
|
32
103
|
null,
|
|
@@ -41,11 +112,12 @@ function ParamBooleanFormItem({ param, label, type, required }) {
|
|
|
41
112
|
: false,
|
|
42
113
|
},
|
|
43
114
|
name: "paramBoolean",
|
|
44
|
-
render: ({ field: { onChange } }) =>
|
|
115
|
+
render: ({ field: { onChange, value } }) =>
|
|
45
116
|
react_1.default.createElement(FormSelect_1.default, {
|
|
46
117
|
label: label,
|
|
47
118
|
type: type,
|
|
48
119
|
required: required,
|
|
120
|
+
value: value ?? "---",
|
|
49
121
|
options: ["---", "true", "false"],
|
|
50
122
|
onChange: (e) => {
|
|
51
123
|
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,7 +68,7 @@ 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"));
|
|
@@ -25,10 +81,17 @@ function ParamSelectFormItem({ param, label, type, required }) {
|
|
|
25
81
|
const {
|
|
26
82
|
control,
|
|
27
83
|
formState: { errors },
|
|
84
|
+
setValue,
|
|
28
85
|
} = (0, react_hook_form_1.useFormContext)();
|
|
29
86
|
const showErrorMessage = errors?.paramSelect;
|
|
30
87
|
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
31
88
|
const options = (0, ParamOptions_1.getSchemaEnum)(param.schema) ?? [];
|
|
89
|
+
(0, react_1.useEffect)(() => {
|
|
90
|
+
if (typeof param.value === "string" && options.includes(param.value)) {
|
|
91
|
+
setValue("paramSelect", param.value);
|
|
92
|
+
}
|
|
93
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
+
}, []);
|
|
32
95
|
return react_1.default.createElement(
|
|
33
96
|
react_1.default.Fragment,
|
|
34
97
|
null,
|
|
@@ -43,11 +106,12 @@ function ParamSelectFormItem({ param, label, type, required }) {
|
|
|
43
106
|
: false,
|
|
44
107
|
},
|
|
45
108
|
name: "paramSelect",
|
|
46
|
-
render: ({ field: { onChange } }) =>
|
|
109
|
+
render: ({ field: { onChange, value } }) =>
|
|
47
110
|
react_1.default.createElement(FormSelect_1.default, {
|
|
48
111
|
label: label,
|
|
49
112
|
type: type,
|
|
50
113
|
required: required,
|
|
114
|
+
value: value ?? "---",
|
|
51
115
|
options: ["---", ...options],
|
|
52
116
|
onChange: (e) => {
|
|
53
117
|
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,
|
|
@@ -100,7 +100,10 @@ function ApiItem(props) {
|
|
|
100
100
|
api?.parameters?.forEach((param) => {
|
|
101
101
|
const paramType = param.in;
|
|
102
102
|
const paramsArray = params[paramType];
|
|
103
|
-
|
|
103
|
+
const defaultValue = param.schema?.default;
|
|
104
|
+
const initialized =
|
|
105
|
+
defaultValue !== undefined ? { ...param, value: defaultValue } : param;
|
|
106
|
+
paramsArray?.push(initialized);
|
|
104
107
|
});
|
|
105
108
|
const auth = (0, slice_1.createAuth)({
|
|
106
109
|
security: api?.security,
|
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": "0.0.0-
|
|
4
|
+
"version": "0.0.0-1241",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/postman-collection": "^3.5.11",
|
|
39
39
|
"@types/react-modal": "^3.16.3",
|
|
40
40
|
"concurrently": "^9.2.0",
|
|
41
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
41
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-1241",
|
|
42
42
|
"docusaurus-plugin-sass": "^0.2.6",
|
|
43
43
|
"eslint-plugin-prettier": "^5.5.1"
|
|
44
44
|
},
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "1034dbe20ed8a19a1a5f6ed91de1e8a31ab14537"
|
|
86
86
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import React from "react";
|
|
8
|
+
import React, { useEffect } from "react";
|
|
9
9
|
|
|
10
10
|
import { translate } from "@docusaurus/Translate";
|
|
11
11
|
import { ErrorMessage } from "@hookform/error-message";
|
|
@@ -33,10 +33,26 @@ export default function ParamBooleanFormItem({
|
|
|
33
33
|
const {
|
|
34
34
|
control,
|
|
35
35
|
formState: { errors },
|
|
36
|
+
setValue,
|
|
36
37
|
} = useFormContext();
|
|
37
38
|
|
|
38
39
|
const showErrorMessage = errors?.paramBoolean;
|
|
39
40
|
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (param.value === undefined) return;
|
|
43
|
+
const initial =
|
|
44
|
+
typeof param.value === "boolean" ? String(param.value) : param.value;
|
|
45
|
+
if (initial === "true" || initial === "false") {
|
|
46
|
+
setValue("paramBoolean", initial);
|
|
47
|
+
// Boolean defaults arrive in redux as actual booleans; normalize to the
|
|
48
|
+
// string form the rest of the form uses.
|
|
49
|
+
if (typeof param.value === "boolean") {
|
|
50
|
+
dispatch(setParam({ ...param, value: initial }));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
40
56
|
return (
|
|
41
57
|
<>
|
|
42
58
|
<Controller
|
|
@@ -50,11 +66,12 @@ export default function ParamBooleanFormItem({
|
|
|
50
66
|
: false,
|
|
51
67
|
}}
|
|
52
68
|
name="paramBoolean"
|
|
53
|
-
render={({ field: { onChange } }) => (
|
|
69
|
+
render={({ field: { onChange, value } }) => (
|
|
54
70
|
<FormSelect
|
|
55
71
|
label={label}
|
|
56
72
|
type={type}
|
|
57
73
|
required={required}
|
|
74
|
+
value={value ?? "---"}
|
|
58
75
|
options={["---", "true", "false"]}
|
|
59
76
|
onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
60
77
|
const val = e.target.value;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import React from "react";
|
|
8
|
+
import React, { useEffect } from "react";
|
|
9
9
|
|
|
10
10
|
import { translate } from "@docusaurus/Translate";
|
|
11
11
|
import { ErrorMessage } from "@hookform/error-message";
|
|
@@ -32,6 +32,7 @@ export default function ParamSelectFormItem({
|
|
|
32
32
|
const {
|
|
33
33
|
control,
|
|
34
34
|
formState: { errors },
|
|
35
|
+
setValue,
|
|
35
36
|
} = useFormContext();
|
|
36
37
|
|
|
37
38
|
const showErrorMessage = errors?.paramSelect;
|
|
@@ -40,6 +41,16 @@ export default function ParamSelectFormItem({
|
|
|
40
41
|
|
|
41
42
|
const options = getSchemaEnum(param.schema) ?? [];
|
|
42
43
|
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (
|
|
46
|
+
typeof param.value === "string" &&
|
|
47
|
+
(options as string[]).includes(param.value)
|
|
48
|
+
) {
|
|
49
|
+
setValue("paramSelect", param.value);
|
|
50
|
+
}
|
|
51
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
43
54
|
return (
|
|
44
55
|
<>
|
|
45
56
|
<Controller
|
|
@@ -53,11 +64,12 @@ export default function ParamSelectFormItem({
|
|
|
53
64
|
: false,
|
|
54
65
|
}}
|
|
55
66
|
name="paramSelect"
|
|
56
|
-
render={({ field: { onChange } }) => (
|
|
67
|
+
render={({ field: { onChange, value } }) => (
|
|
57
68
|
<FormSelect
|
|
58
69
|
label={label}
|
|
59
70
|
type={type}
|
|
60
71
|
required={required}
|
|
72
|
+
value={value ?? "---"}
|
|
61
73
|
options={["---", ...(options as string[])]}
|
|
62
74
|
onChange={(e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
63
75
|
const val = e.target.value;
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import React from "react";
|
|
8
|
+
import React, { useEffect } from "react";
|
|
9
9
|
|
|
10
10
|
import FormTextInput from "@theme/ApiExplorer/FormTextInput";
|
|
11
11
|
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
|
|
12
12
|
import { useTypedDispatch } from "@theme/ApiItem/hooks";
|
|
13
|
+
import { useFormContext } from "react-hook-form";
|
|
13
14
|
|
|
14
15
|
export interface ParamProps {
|
|
15
16
|
param: Param;
|
|
@@ -25,6 +26,15 @@ export default function ParamTextFormItem({
|
|
|
25
26
|
required,
|
|
26
27
|
}: ParamProps) {
|
|
27
28
|
const dispatch = useTypedDispatch();
|
|
29
|
+
const { setValue } = useFormContext();
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (param.value !== undefined && !Array.isArray(param.value)) {
|
|
33
|
+
setValue(param.name, param.value);
|
|
34
|
+
}
|
|
35
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
28
38
|
return (
|
|
29
39
|
<FormTextInput
|
|
30
40
|
label={label}
|
|
@@ -122,7 +122,12 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
122
122
|
(param: { in: "path" | "query" | "header" | "cookie" }) => {
|
|
123
123
|
const paramType = param.in;
|
|
124
124
|
const paramsArray: ParameterObject[] = params[paramType];
|
|
125
|
-
|
|
125
|
+
const defaultValue = (param as any).schema?.default;
|
|
126
|
+
const initialized =
|
|
127
|
+
defaultValue !== undefined
|
|
128
|
+
? ({ ...param, value: defaultValue } as unknown as ParameterObject)
|
|
129
|
+
: (param as ParameterObject);
|
|
130
|
+
paramsArray?.push(initialized);
|
|
126
131
|
}
|
|
127
132
|
);
|
|
128
133
|
const auth = createAuth({
|