docusaurus-theme-openapi-docs 4.5.0 → 4.6.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 +9 -1
- package/lib/theme/ApiExplorer/Accept/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/Authorization/index.js +50 -9
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +145 -3
- package/lib/theme/ApiExplorer/Authorization/slice.js +3 -1
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +126 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +110 -0
- package/lib/theme/ApiExplorer/Body/index.js +94 -100
- package/lib/theme/ApiExplorer/Body/slice.d.ts +1056 -11
- package/lib/theme/ApiExplorer/Body/slice.js +22 -2
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +37 -26
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +3 -3
- package/lib/theme/ApiExplorer/CodeTabs/index.js +2 -2
- package/lib/theme/ApiExplorer/ContentType/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +6 -1
- package/lib/theme/ApiExplorer/FormItem/index.js +6 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +2 -0
- package/lib/theme/ApiExplorer/FormTextInput/index.js +8 -1
- package/lib/theme/ApiExplorer/LiveEditor/index.js +11 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +15 -5
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +11 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +12 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +11 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.js +11 -1
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +0 -4
- package/lib/theme/ApiExplorer/ParamOptions/slice.js +4 -4
- package/lib/theme/ApiExplorer/Request/index.js +110 -17
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +7 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +94 -24
- package/lib/theme/ApiExplorer/Response/index.js +34 -14
- package/lib/theme/ApiExplorer/Response/slice.d.ts +31 -7
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +208 -69
- package/lib/theme/ApiExplorer/Server/index.js +16 -2
- package/lib/theme/ApiExplorer/Server/slice.d.ts +49 -3
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -57
- package/lib/theme/ApiExplorer/index.js +11 -1
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +19 -0
- package/lib/theme/ApiExplorer/{persistanceMiddleware.js → persistenceMiddleware.js} +16 -9
- package/lib/theme/ApiExplorer/storage-utils.d.ts +2 -2
- package/lib/theme/ApiExplorer/storage-utils.js +3 -3
- package/lib/theme/ApiItem/Layout/index.d.ts +1 -1
- package/lib/theme/ApiItem/hooks.d.ts +9 -9
- package/lib/theme/ApiItem/index.js +12 -8
- package/lib/theme/ApiItem/store.d.ts +55 -43
- package/lib/theme/ApiTabs/index.js +6 -1
- package/lib/theme/Example/_Example.scss +11 -0
- package/lib/theme/Example/index.d.ts +24 -0
- package/lib/theme/Example/index.js +170 -0
- package/lib/theme/ParamsDetails/index.js +9 -1
- package/lib/theme/ParamsItem/index.d.ts +1 -1
- package/lib/theme/ParamsItem/index.js +43 -74
- package/lib/theme/RequestSchema/index.js +18 -4
- package/lib/theme/ResponseExamples/index.js +23 -3
- package/lib/theme/ResponseSchema/index.js +97 -82
- package/lib/theme/Schema/index.js +106 -23
- package/lib/theme/SchemaItem/index.js +64 -36
- package/lib/theme/SchemaTabs/index.js +4 -1
- package/lib/theme/StatusCodes/index.js +11 -2
- package/lib/theme/styles.scss +5 -0
- package/lib/theme/translationIds.d.ts +90 -0
- package/lib/theme/translationIds.js +114 -0
- package/lib/types.d.ts +9 -1
- package/package.json +28 -28
- package/src/markdown/schema.ts +11 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +51 -10
- package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
- package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +77 -0
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +120 -0
- package/src/theme/ApiExplorer/Body/index.tsx +87 -107
- package/src/theme/ApiExplorer/Body/json2xml.d.ts +8 -0
- package/src/theme/ApiExplorer/Body/slice.ts +40 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +43 -29
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +6 -5
- package/src/theme/ApiExplorer/ContentType/index.tsx +1 -1
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +6 -1
- package/src/theme/ApiExplorer/FormItem/index.tsx +8 -1
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +10 -1
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +11 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +16 -6
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +12 -3
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +10 -2
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
- package/src/theme/ApiExplorer/Request/index.tsx +108 -17
- package/src/theme/ApiExplorer/Request/makeRequest.ts +106 -25
- package/src/theme/ApiExplorer/Response/index.tsx +30 -8
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +157 -69
- package/src/theme/ApiExplorer/Server/index.tsx +12 -4
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +47 -63
- package/src/theme/ApiExplorer/index.tsx +10 -1
- package/src/theme/ApiExplorer/{persistanceMiddleware.ts → persistenceMiddleware.ts} +23 -13
- package/src/theme/ApiExplorer/storage-utils.ts +4 -4
- package/src/theme/ApiItem/Layout/index.tsx +1 -1
- package/src/theme/ApiItem/index.tsx +12 -7
- package/src/theme/ApiTabs/index.tsx +6 -1
- package/src/theme/Example/_Example.scss +11 -0
- package/src/theme/Example/index.tsx +168 -0
- package/src/theme/Markdown/index.d.ts +8 -0
- package/src/theme/ParamsDetails/index.tsx +10 -1
- package/src/theme/ParamsItem/index.tsx +38 -54
- package/src/theme/RequestSchema/index.tsx +19 -4
- package/src/theme/ResponseExamples/index.tsx +23 -3
- package/src/theme/ResponseSchema/index.tsx +73 -61
- package/src/theme/Schema/index.tsx +128 -33
- package/src/theme/SchemaItem/index.tsx +51 -33
- package/src/theme/SchemaTabs/index.tsx +4 -1
- package/src/theme/StatusCodes/index.tsx +13 -2
- package/src/theme/styles.scss +5 -0
- package/src/theme/translationIds.ts +111 -0
- package/src/theme-openapi.d.ts +7 -275
- package/src/types.ts +9 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/theme/ApiExplorer/persistanceMiddleware.d.ts +0 -3
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
var _a;
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.setFileArrayFormBody =
|
|
11
|
+
exports.setFileFormBody =
|
|
11
12
|
exports.setStringFormBody =
|
|
12
13
|
exports.clearFormBodyKey =
|
|
13
14
|
exports.setFileRawBody =
|
|
@@ -85,6 +86,24 @@ exports.slice = (0, toolkit_1.createSlice)({
|
|
|
85
86
|
};
|
|
86
87
|
return state;
|
|
87
88
|
},
|
|
89
|
+
setFileArrayFormBody: (state, action) => {
|
|
90
|
+
if (state?.type !== "form") {
|
|
91
|
+
return {
|
|
92
|
+
type: "form",
|
|
93
|
+
content: {
|
|
94
|
+
[action.payload.key]: {
|
|
95
|
+
type: "file[]",
|
|
96
|
+
value: action.payload.value,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
state.content[action.payload.key] = {
|
|
102
|
+
type: "file[]",
|
|
103
|
+
value: action.payload.value,
|
|
104
|
+
};
|
|
105
|
+
return state;
|
|
106
|
+
},
|
|
88
107
|
},
|
|
89
108
|
});
|
|
90
109
|
((_a = exports.slice.actions),
|
|
@@ -93,5 +112,6 @@ exports.slice = (0, toolkit_1.createSlice)({
|
|
|
93
112
|
(exports.setFileRawBody = _a.setFileRawBody),
|
|
94
113
|
(exports.clearFormBodyKey = _a.clearFormBodyKey),
|
|
95
114
|
(exports.setStringFormBody = _a.setStringFormBody),
|
|
96
|
-
(exports.setFileFormBody = _a.setFileFormBody)
|
|
115
|
+
(exports.setFileFormBody = _a.setFileFormBody),
|
|
116
|
+
(exports.setFileArrayFormBody = _a.setFileArrayFormBody));
|
|
97
117
|
exports.default = exports.slice.reducer;
|
|
@@ -5,6 +5,7 @@ export declare const languageSet: Language[];
|
|
|
5
5
|
export interface Props {
|
|
6
6
|
postman: sdk.Request;
|
|
7
7
|
codeSamples: CodeSample[];
|
|
8
|
+
maskCredentials?: boolean;
|
|
8
9
|
}
|
|
9
|
-
declare function CodeSnippets({ postman, codeSamples }: Props): React.JSX.Element | null;
|
|
10
|
+
declare function CodeSnippets({ postman, codeSamples, maskCredentials: propMaskCredentials, }: Props): React.JSX.Element | null;
|
|
10
11
|
export default CodeSnippets;
|
|
@@ -93,7 +93,11 @@ function CodeTab({ children, hidden, className }) {
|
|
|
93
93
|
children
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
|
-
function CodeSnippets({
|
|
96
|
+
function CodeSnippets({
|
|
97
|
+
postman,
|
|
98
|
+
codeSamples,
|
|
99
|
+
maskCredentials: propMaskCredentials,
|
|
100
|
+
}) {
|
|
97
101
|
const { siteConfig } = (0, useDocusaurusContext_1.default)();
|
|
98
102
|
const contentType = (0, hooks_1.useTypedSelector)(
|
|
99
103
|
(state) => state.contentType.value
|
|
@@ -114,29 +118,36 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
114
118
|
(state) => state.params.header
|
|
115
119
|
);
|
|
116
120
|
const auth = (0, hooks_1.useTypedSelector)((state) => state.auth);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
121
|
+
// Check if credential masking is enabled (default: true)
|
|
122
|
+
const maskCredentials = propMaskCredentials ?? true;
|
|
123
|
+
// Clone Auth if maskCredentials is not false
|
|
124
|
+
const cleanedAuth = maskCredentials
|
|
125
|
+
? (() => {
|
|
126
|
+
const clonedAuth = (0, cloneDeep_1.default)(auth);
|
|
127
|
+
let placeholder;
|
|
128
|
+
function cleanCredentials(obj) {
|
|
129
|
+
for (const key in obj) {
|
|
130
|
+
if (typeof obj[key] === "object" && obj[key] !== null) {
|
|
131
|
+
// use name as placeholder if exists
|
|
132
|
+
const comboAuthId = Object.keys(obj).join(" and ");
|
|
133
|
+
const authOptions =
|
|
134
|
+
clonedAuth?.options?.[key] ??
|
|
135
|
+
clonedAuth?.options?.[comboAuthId];
|
|
136
|
+
placeholder = authOptions?.find((opt) => opt.key === key)?.name;
|
|
137
|
+
obj[key] = cleanCredentials(obj[key]);
|
|
138
|
+
} else {
|
|
139
|
+
obj[key] = `<${placeholder ?? key}>`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return obj;
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
...clonedAuth,
|
|
146
|
+
data: cleanCredentials(clonedAuth.data),
|
|
147
|
+
};
|
|
148
|
+
})()
|
|
149
|
+
: auth;
|
|
150
|
+
// Create a Postman request object using cleanedAuth or original auth
|
|
140
151
|
const cleanedPostmanRequest = (0, buildPostmanRequest_1.default)(postman, {
|
|
141
152
|
queryParams,
|
|
142
153
|
pathParams,
|
|
@@ -314,7 +325,7 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
314
325
|
setSelectedSample: setSelectedSample,
|
|
315
326
|
},
|
|
316
327
|
includeSample: true,
|
|
317
|
-
currentLanguage: lang
|
|
328
|
+
currentLanguage: lang,
|
|
318
329
|
defaultValue: selectedSample,
|
|
319
330
|
languageSet: mergedLangs,
|
|
320
331
|
lazy: true,
|
|
@@ -353,7 +364,7 @@ function CodeSnippets({ postman, codeSamples }) {
|
|
|
353
364
|
setSelectedVariant: setSelectedVariant,
|
|
354
365
|
},
|
|
355
366
|
includeVariant: true,
|
|
356
|
-
currentLanguage: lang
|
|
367
|
+
currentLanguage: lang,
|
|
357
368
|
defaultValue: selectedVariant,
|
|
358
369
|
languageSet: mergedLangs,
|
|
359
370
|
lazy: true,
|
|
@@ -197,7 +197,11 @@ body[class="ReactModal__Body--open"] {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
&.active {
|
|
200
|
-
box-shadow: 0 0 0 3px
|
|
200
|
+
box-shadow: 0 0 0 3px
|
|
201
|
+
var(
|
|
202
|
+
--openapi-code-tab-shadow-color-curl,
|
|
203
|
+
var(--openapi-code-tab-shadow-color-bash)
|
|
204
|
+
);
|
|
201
205
|
border-color: var(--ifm-color-danger);
|
|
202
206
|
}
|
|
203
207
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type TabProps } from "@docusaurus/theme-common/internal";
|
|
3
|
-
import { Language } from "
|
|
3
|
+
import { Language } from "../CodeSnippets/code-snippets-types";
|
|
4
4
|
export interface Props {
|
|
5
5
|
action: {
|
|
6
6
|
[key: string]: React.Dispatch<any>;
|
|
7
7
|
};
|
|
8
|
-
currentLanguage
|
|
8
|
+
currentLanguage?: Language;
|
|
9
9
|
languageSet: Language[];
|
|
10
|
-
includeVariant
|
|
10
|
+
includeVariant?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface CodeTabsProps extends Props, TabProps {
|
|
13
13
|
includeSample?: boolean;
|
|
@@ -122,13 +122,13 @@ function TabList({
|
|
|
122
122
|
let newLanguage;
|
|
123
123
|
if (currentLanguage && includeVariant) {
|
|
124
124
|
newLanguage = languageSet.filter(
|
|
125
|
-
(lang) => lang.language === currentLanguage
|
|
125
|
+
(lang) => lang.language === currentLanguage.language
|
|
126
126
|
)[0];
|
|
127
127
|
newLanguage.variant = newTabValue;
|
|
128
128
|
action.setSelectedVariant(newTabValue.toLowerCase());
|
|
129
129
|
} else if (currentLanguage && includeSample) {
|
|
130
130
|
newLanguage = languageSet.filter(
|
|
131
|
-
(lang) => lang.language === currentLanguage
|
|
131
|
+
(lang) => lang.language === currentLanguage.language
|
|
132
132
|
)[0];
|
|
133
133
|
newLanguage.sample = newTabValue;
|
|
134
134
|
action.setSelectedSample(newTabValue);
|
|
@@ -4,8 +4,11 @@ export interface State {
|
|
|
4
4
|
options: string[];
|
|
5
5
|
}
|
|
6
6
|
export declare const slice: import("@reduxjs/toolkit").Slice<State, {
|
|
7
|
-
setContentType: (state:
|
|
8
|
-
|
|
7
|
+
setContentType: (state: {
|
|
8
|
+
value: string;
|
|
9
|
+
options: string[];
|
|
10
|
+
}, action: PayloadAction<string>) => void;
|
|
11
|
+
}, "contentType", "contentType", import("@reduxjs/toolkit").SliceSelectors<State>>;
|
|
9
12
|
export declare const setContentType: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "contentType/setContentType">;
|
|
10
13
|
declare const _default: import("redux").Reducer<State>;
|
|
11
14
|
export default _default;
|
|
@@ -68,9 +68,11 @@ var __importDefault =
|
|
|
68
68
|
};
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
const react_1 = __importStar(require("react"));
|
|
71
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
71
72
|
const FloatingButton_1 = __importDefault(
|
|
72
73
|
require("@theme/ApiExplorer/FloatingButton")
|
|
73
74
|
);
|
|
75
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
74
76
|
const react_magic_dropzone_1 = __importDefault(require("react-magic-dropzone"));
|
|
75
77
|
function RenderPreview({ file }) {
|
|
76
78
|
switch (file.type) {
|
|
@@ -158,7 +160,10 @@ function FormFileUpload({ placeholder, onChange }) {
|
|
|
158
160
|
setAndNotifyFile(undefined);
|
|
159
161
|
},
|
|
160
162
|
},
|
|
161
|
-
|
|
163
|
+
(0, Translate_1.translate)({
|
|
164
|
+
id: translationIds_1.OPENAPI_FORM_FILE_UPLOAD.CLEAR_BUTTON,
|
|
165
|
+
message: "Clear",
|
|
166
|
+
})
|
|
162
167
|
),
|
|
163
168
|
react_1.default.createElement(RenderPreview, { file: file })
|
|
164
169
|
)
|
|
@@ -12,6 +12,8 @@ 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");
|
|
16
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
15
17
|
const clsx_1 = __importDefault(require("clsx"));
|
|
16
18
|
function FormItem({ label, type, required, children, className }) {
|
|
17
19
|
return react_1.default.createElement(
|
|
@@ -36,7 +38,10 @@ function FormItem({ label, type, required, children, className }) {
|
|
|
36
38
|
react_1.default.createElement(
|
|
37
39
|
"span",
|
|
38
40
|
{ className: "openapi-schema__required" },
|
|
39
|
-
|
|
41
|
+
(0, Translate_1.translate)({
|
|
42
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
43
|
+
message: "required",
|
|
44
|
+
})
|
|
40
45
|
),
|
|
41
46
|
react_1.default.createElement("div", null, children)
|
|
42
47
|
);
|
|
@@ -4,6 +4,8 @@ export interface Props {
|
|
|
4
4
|
placeholder?: string;
|
|
5
5
|
password?: boolean;
|
|
6
6
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
7
|
+
paramName?: string;
|
|
8
|
+
isRequired?: boolean;
|
|
7
9
|
}
|
|
8
10
|
declare function FormTextInput({ isRequired, value, placeholder, password, onChange, paramName, }: Props): React.JSX.Element;
|
|
9
11
|
export default FormTextInput;
|
|
@@ -13,7 +13,9 @@ var __importDefault =
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
// @ts-nocheck
|
|
15
15
|
const react_1 = __importDefault(require("react"));
|
|
16
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
16
17
|
const error_message_1 = require("@hookform/error-message");
|
|
18
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
17
19
|
const clsx_1 = __importDefault(require("clsx"));
|
|
18
20
|
const react_hook_form_1 = require("react-hook-form");
|
|
19
21
|
function FormTextInput({
|
|
@@ -36,7 +38,12 @@ function FormTextInput({
|
|
|
36
38
|
paramName
|
|
37
39
|
? react_1.default.createElement("input", {
|
|
38
40
|
...register(paramName, {
|
|
39
|
-
required: isRequired
|
|
41
|
+
required: isRequired
|
|
42
|
+
? (0, Translate_1.translate)({
|
|
43
|
+
id: translationIds_1.OPENAPI_FORM.FIELD_REQUIRED,
|
|
44
|
+
message: "This field is required",
|
|
45
|
+
})
|
|
46
|
+
: false,
|
|
40
47
|
}),
|
|
41
48
|
className: (0, clsx_1.default)("openapi-explorer__form-item-input", {
|
|
42
49
|
error: showErrorMessage,
|
|
@@ -69,9 +69,10 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
const react_1 = __importStar(require("react"));
|
|
71
71
|
const theme_common_1 = require("@docusaurus/theme-common");
|
|
72
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
72
73
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
73
74
|
const error_message_1 = require("@hookform/error-message");
|
|
74
|
-
const
|
|
75
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
75
76
|
const clsx_1 = __importDefault(require("clsx"));
|
|
76
77
|
const react_hook_form_1 = require("react-hook-form");
|
|
77
78
|
const react_live_1 = require("react-live");
|
|
@@ -110,8 +111,8 @@ function App({
|
|
|
110
111
|
const prismTheme = (0, theme_common_1.usePrismTheme)();
|
|
111
112
|
const [code, setCode] = react_1.default.useState(children.replace(/\n$/, ""));
|
|
112
113
|
(0, react_1.useEffect)(() => {
|
|
113
|
-
action(
|
|
114
|
-
}, [
|
|
114
|
+
action(code);
|
|
115
|
+
}, [code]);
|
|
115
116
|
const {
|
|
116
117
|
control,
|
|
117
118
|
formState: { errors },
|
|
@@ -140,7 +141,13 @@ function App({
|
|
|
140
141
|
react_1.default.createElement(react_hook_form_1.Controller, {
|
|
141
142
|
control: control,
|
|
142
143
|
rules: {
|
|
143
|
-
required:
|
|
144
|
+
required:
|
|
145
|
+
isRequired && !code
|
|
146
|
+
? (0, Translate_1.translate)({
|
|
147
|
+
id: translationIds_1.OPENAPI_FORM.FIELD_REQUIRED,
|
|
148
|
+
message: "This field is required",
|
|
149
|
+
})
|
|
150
|
+
: false,
|
|
144
151
|
},
|
|
145
152
|
name: "requestBody",
|
|
146
153
|
render: ({ field: { onChange, name } }) =>
|
|
@@ -69,6 +69,7 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.default = ParamArrayFormItem;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
72
73
|
const error_message_1 = require("@hookform/error-message");
|
|
73
74
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
74
75
|
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
@@ -77,6 +78,7 @@ const FormTextInput_1 = __importDefault(
|
|
|
77
78
|
);
|
|
78
79
|
const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
|
|
79
80
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
81
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
80
82
|
const react_hook_form_1 = require("react-hook-form");
|
|
81
83
|
function ArrayItem({ param, onChange, initialValue }) {
|
|
82
84
|
const [value, setValue] = (0, react_1.useState)(initialValue || "");
|
|
@@ -126,14 +128,15 @@ function ParamArrayFormItem({ param }) {
|
|
|
126
128
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
127
129
|
}, [items]);
|
|
128
130
|
(0, react_1.useEffect)(() => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
const example = param.schema?.example;
|
|
132
|
+
if (Array.isArray(example) && example.length > 0) {
|
|
133
|
+
const examplesWithIds = example.map((item) => ({
|
|
131
134
|
id: (0, toolkit_1.nanoid)(),
|
|
132
135
|
value: item.toString(),
|
|
133
136
|
}));
|
|
134
137
|
setItems(examplesWithIds);
|
|
135
138
|
}
|
|
136
|
-
}, [param.schema
|
|
139
|
+
}, [param.schema?.example]);
|
|
137
140
|
function handleDeleteItem(itemToDelete) {
|
|
138
141
|
return () => {
|
|
139
142
|
const newItems = items.filter((i) => i.id !== itemToDelete.id);
|
|
@@ -157,9 +160,16 @@ function ParamArrayFormItem({ param }) {
|
|
|
157
160
|
null,
|
|
158
161
|
react_1.default.createElement(react_hook_form_1.Controller, {
|
|
159
162
|
control: control,
|
|
160
|
-
rules: {
|
|
163
|
+
rules: {
|
|
164
|
+
required: param.required
|
|
165
|
+
? (0, Translate_1.translate)({
|
|
166
|
+
id: translationIds_1.OPENAPI_FORM.FIELD_REQUIRED,
|
|
167
|
+
message: "This field is required",
|
|
168
|
+
})
|
|
169
|
+
: false,
|
|
170
|
+
},
|
|
161
171
|
name: "paramArray",
|
|
162
|
-
render: ({ field: { onChange
|
|
172
|
+
render: ({ field: { onChange } }) =>
|
|
163
173
|
react_1.default.createElement(
|
|
164
174
|
react_1.default.Fragment,
|
|
165
175
|
null,
|
|
@@ -13,10 +13,12 @@ var __importDefault =
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.default = ParamBooleanFormItem;
|
|
15
15
|
const react_1 = __importDefault(require("react"));
|
|
16
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
16
17
|
const error_message_1 = require("@hookform/error-message");
|
|
17
18
|
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
18
19
|
const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
|
|
19
20
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
21
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
20
22
|
const react_hook_form_1 = require("react-hook-form");
|
|
21
23
|
function ParamBooleanFormItem({ param }) {
|
|
22
24
|
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
@@ -30,11 +32,17 @@ function ParamBooleanFormItem({ param }) {
|
|
|
30
32
|
null,
|
|
31
33
|
react_1.default.createElement(react_hook_form_1.Controller, {
|
|
32
34
|
control: control,
|
|
33
|
-
rules: {
|
|
35
|
+
rules: {
|
|
36
|
+
required: param.required
|
|
37
|
+
? (0, Translate_1.translate)({
|
|
38
|
+
id: translationIds_1.OPENAPI_FORM.FIELD_REQUIRED,
|
|
39
|
+
message: "This field is required",
|
|
40
|
+
})
|
|
41
|
+
: false,
|
|
42
|
+
},
|
|
34
43
|
name: "paramBoolean",
|
|
35
|
-
render: ({ field: { onChange
|
|
44
|
+
render: ({ field: { onChange } }) =>
|
|
36
45
|
react_1.default.createElement(FormSelect_1.default, {
|
|
37
|
-
name: name,
|
|
38
46
|
options: ["---", "true", "false"],
|
|
39
47
|
onChange: (e) => {
|
|
40
48
|
const val = e.target.value;
|
|
@@ -13,12 +13,14 @@ var __importDefault =
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.default = ParamMultiSelectFormItem;
|
|
15
15
|
const react_1 = __importDefault(require("react"));
|
|
16
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
16
17
|
const error_message_1 = require("@hookform/error-message");
|
|
17
18
|
const FormMultiSelect_1 = __importDefault(
|
|
18
19
|
require("@theme/ApiExplorer/FormMultiSelect")
|
|
19
20
|
);
|
|
20
21
|
const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
|
|
21
22
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
23
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
22
24
|
const react_hook_form_1 = require("react-hook-form");
|
|
23
25
|
function ParamMultiSelectFormItem({ param }) {
|
|
24
26
|
const {
|
|
@@ -64,14 +66,20 @@ function ParamMultiSelectFormItem({ param }) {
|
|
|
64
66
|
null,
|
|
65
67
|
react_1.default.createElement(react_hook_form_1.Controller, {
|
|
66
68
|
control: control,
|
|
67
|
-
rules: {
|
|
69
|
+
rules: {
|
|
70
|
+
required: param.required
|
|
71
|
+
? (0, Translate_1.translate)({
|
|
72
|
+
id: translationIds_1.OPENAPI_FORM.FIELD_REQUIRED,
|
|
73
|
+
message: "This field is required",
|
|
74
|
+
})
|
|
75
|
+
: false,
|
|
76
|
+
},
|
|
68
77
|
name: "paramMultiSelect",
|
|
69
|
-
render: ({ field: { onChange
|
|
78
|
+
render: ({ field: { onChange } }) =>
|
|
70
79
|
react_1.default.createElement(FormMultiSelect_1.default, {
|
|
71
80
|
options: options,
|
|
72
|
-
name: name,
|
|
73
81
|
onChange: (e) => handleChange(e, onChange),
|
|
74
|
-
showErrors: showErrorMessage,
|
|
82
|
+
showErrors: !!showErrorMessage,
|
|
75
83
|
}),
|
|
76
84
|
}),
|
|
77
85
|
showErrorMessage &&
|
|
@@ -13,10 +13,12 @@ var __importDefault =
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.default = ParamSelectFormItem;
|
|
15
15
|
const react_1 = __importDefault(require("react"));
|
|
16
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
16
17
|
const error_message_1 = require("@hookform/error-message");
|
|
17
18
|
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
18
19
|
const slice_1 = require("@theme/ApiExplorer/ParamOptions/slice");
|
|
19
20
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
21
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
20
22
|
const react_hook_form_1 = require("react-hook-form");
|
|
21
23
|
function ParamSelectFormItem({ param }) {
|
|
22
24
|
const {
|
|
@@ -31,9 +33,16 @@ function ParamSelectFormItem({ param }) {
|
|
|
31
33
|
null,
|
|
32
34
|
react_1.default.createElement(react_hook_form_1.Controller, {
|
|
33
35
|
control: control,
|
|
34
|
-
rules: {
|
|
36
|
+
rules: {
|
|
37
|
+
required: param.required
|
|
38
|
+
? (0, Translate_1.translate)({
|
|
39
|
+
id: translationIds_1.OPENAPI_FORM.FIELD_REQUIRED,
|
|
40
|
+
message: "This field is required",
|
|
41
|
+
})
|
|
42
|
+
: false,
|
|
43
|
+
},
|
|
35
44
|
name: "paramSelect",
|
|
36
|
-
render: ({ field: { onChange
|
|
45
|
+
render: ({ field: { onChange } }) =>
|
|
37
46
|
react_1.default.createElement(FormSelect_1.default, {
|
|
38
47
|
options: ["---", ...options],
|
|
39
48
|
onChange: (e) => {
|
|
@@ -68,6 +68,7 @@ var __importDefault =
|
|
|
68
68
|
};
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
const react_1 = __importStar(require("react"));
|
|
71
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
71
72
|
const FormItem_1 = __importDefault(require("@theme/ApiExplorer/FormItem"));
|
|
72
73
|
const ParamArrayFormItem_1 = __importDefault(
|
|
73
74
|
require("@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem")
|
|
@@ -85,6 +86,7 @@ const ParamTextFormItem_1 = __importDefault(
|
|
|
85
86
|
require("@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem")
|
|
86
87
|
);
|
|
87
88
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
89
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
88
90
|
function ParamOption({ param }) {
|
|
89
91
|
if (param.schema?.type === "array" && param.schema.items?.enum) {
|
|
90
92
|
return react_1.default.createElement(ParamMultiSelectFormItem_1.default, {
|
|
@@ -201,7 +203,15 @@ function ParamOptions() {
|
|
|
201
203
|
)
|
|
202
204
|
)
|
|
203
205
|
),
|
|
204
|
-
showOptional
|
|
206
|
+
showOptional
|
|
207
|
+
? (0, Translate_1.translate)({
|
|
208
|
+
id: translationIds_1.OPENAPI_PARAM_OPTIONS.HIDE_OPTIONAL,
|
|
209
|
+
message: "Hide optional parameters",
|
|
210
|
+
})
|
|
211
|
+
: (0, Translate_1.translate)({
|
|
212
|
+
id: translationIds_1.OPENAPI_PARAM_OPTIONS.SHOW_OPTIONAL,
|
|
213
|
+
message: "Show optional parameters",
|
|
214
|
+
})
|
|
205
215
|
),
|
|
206
216
|
react_1.default.createElement(
|
|
207
217
|
"div",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
1
|
import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
3
2
|
export type Param = ParameterObject & {
|
|
4
3
|
value?: string[] | string;
|
|
@@ -9,9 +8,6 @@ export interface State {
|
|
|
9
8
|
header: Param[];
|
|
10
9
|
cookie: Param[];
|
|
11
10
|
}
|
|
12
|
-
export declare const slice: import("@reduxjs/toolkit").Slice<State, {
|
|
13
|
-
setParam: (state: import("immer/dist/internal").WritableDraft<State>, action: PayloadAction<Param>) => void;
|
|
14
|
-
}, "params">;
|
|
15
11
|
export declare const setParam: import("@reduxjs/toolkit").ActionCreatorWithPayload<Param, "params/setParam">;
|
|
16
12
|
declare const _default: import("redux").Reducer<State>;
|
|
17
13
|
export default _default;
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.setParam =
|
|
9
|
+
exports.setParam = void 0;
|
|
10
10
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
11
11
|
const initialState = {};
|
|
12
|
-
|
|
12
|
+
const slice = (0, toolkit_1.createSlice)({
|
|
13
13
|
name: "params",
|
|
14
14
|
initialState,
|
|
15
15
|
reducers: {
|
|
@@ -21,5 +21,5 @@ exports.slice = (0, toolkit_1.createSlice)({
|
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
});
|
|
24
|
-
exports.setParam =
|
|
25
|
-
exports.default =
|
|
24
|
+
exports.setParam = slice.actions.setParam;
|
|
25
|
+
exports.default = slice.reducer;
|