docusaurus-theme-openapi-docs 4.5.1 → 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 +4 -0
- 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 +5 -0
- 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
package/lib/markdown/schema.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getSchemaName = getSchemaName;
|
|
10
10
|
exports.getQualifierMessage = getQualifierMessage;
|
|
11
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
12
|
+
const translationIds_1 = require("../theme/translationIds");
|
|
11
13
|
function prettyName(schema, circular) {
|
|
12
14
|
if (schema.format) {
|
|
13
15
|
return schema.format;
|
|
@@ -35,6 +37,9 @@ function prettyName(schema, circular) {
|
|
|
35
37
|
return schema.xml?.name ?? schema.type;
|
|
36
38
|
// return schema.type;
|
|
37
39
|
}
|
|
40
|
+
if (Array.isArray(schema.type)) {
|
|
41
|
+
return schema.type.join(" | ");
|
|
42
|
+
}
|
|
38
43
|
return schema.title ?? schema.type;
|
|
39
44
|
}
|
|
40
45
|
function getSchemaName(schema, circular) {
|
|
@@ -57,7 +62,10 @@ function getQualifierMessage(schema) {
|
|
|
57
62
|
schema.maxItems === undefined) {
|
|
58
63
|
return getQualifierMessage(schema.items);
|
|
59
64
|
}
|
|
60
|
-
let message =
|
|
65
|
+
let message = `**${(0, Translate_1.translate)({
|
|
66
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.POSSIBLE_VALUES,
|
|
67
|
+
message: "Possible values:",
|
|
68
|
+
})}** `;
|
|
61
69
|
let qualifierGroups = [];
|
|
62
70
|
if (schema.items && schema.items.enum) {
|
|
63
71
|
if (schema.items.enum) {
|
|
@@ -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
|
-
setAccept: (state:
|
|
8
|
-
|
|
7
|
+
setAccept: (state: {
|
|
8
|
+
value: string;
|
|
9
|
+
options: string[];
|
|
10
|
+
}, action: PayloadAction<string>) => void;
|
|
11
|
+
}, "accept", "accept", import("@reduxjs/toolkit").SliceSelectors<State>>;
|
|
9
12
|
export declare const setAccept: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "accept/setAccept">;
|
|
10
13
|
declare const _default: import("redux").Reducer<State>;
|
|
11
14
|
export default _default;
|
|
@@ -12,12 +12,14 @@ 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 FormItem_1 = __importDefault(require("@theme/ApiExplorer/FormItem"));
|
|
16
17
|
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
17
18
|
const FormTextInput_1 = __importDefault(
|
|
18
19
|
require("@theme/ApiExplorer/FormTextInput")
|
|
19
20
|
);
|
|
20
21
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
22
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
21
23
|
const slice_1 = require("./slice");
|
|
22
24
|
function Authorization() {
|
|
23
25
|
const data = (0, hooks_1.useTypedSelector)((state) => state.auth.data);
|
|
@@ -37,7 +39,12 @@ function Authorization() {
|
|
|
37
39
|
optionKeys.length > 1 &&
|
|
38
40
|
react_1.default.createElement(
|
|
39
41
|
FormItem_1.default,
|
|
40
|
-
{
|
|
42
|
+
{
|
|
43
|
+
label: (0, Translate_1.translate)({
|
|
44
|
+
id: translationIds_1.OPENAPI_AUTH.SECURITY_SCHEME,
|
|
45
|
+
message: "Security Scheme",
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
41
48
|
react_1.default.createElement(FormSelect_1.default, {
|
|
42
49
|
options: optionKeys,
|
|
43
50
|
value: selected,
|
|
@@ -50,9 +57,18 @@ function Authorization() {
|
|
|
50
57
|
if (a.type === "http" && a.scheme === "bearer") {
|
|
51
58
|
return react_1.default.createElement(
|
|
52
59
|
FormItem_1.default,
|
|
53
|
-
{
|
|
60
|
+
{
|
|
61
|
+
label: (0, Translate_1.translate)({
|
|
62
|
+
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
63
|
+
message: "Bearer Token",
|
|
64
|
+
}),
|
|
65
|
+
key: a.key + "-bearer",
|
|
66
|
+
},
|
|
54
67
|
react_1.default.createElement(FormTextInput_1.default, {
|
|
55
|
-
placeholder:
|
|
68
|
+
placeholder: (0, Translate_1.translate)({
|
|
69
|
+
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
70
|
+
message: "Bearer Token",
|
|
71
|
+
}),
|
|
56
72
|
password: true,
|
|
57
73
|
value: data[a.key].token ?? "",
|
|
58
74
|
onChange: (e) => {
|
|
@@ -71,9 +87,18 @@ function Authorization() {
|
|
|
71
87
|
if (a.type === "oauth2") {
|
|
72
88
|
return react_1.default.createElement(
|
|
73
89
|
FormItem_1.default,
|
|
74
|
-
{
|
|
90
|
+
{
|
|
91
|
+
label: (0, Translate_1.translate)({
|
|
92
|
+
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
93
|
+
message: "Bearer Token",
|
|
94
|
+
}),
|
|
95
|
+
key: a.key + "-oauth2",
|
|
96
|
+
},
|
|
75
97
|
react_1.default.createElement(FormTextInput_1.default, {
|
|
76
|
-
placeholder:
|
|
98
|
+
placeholder: (0, Translate_1.translate)({
|
|
99
|
+
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
100
|
+
message: "Bearer Token",
|
|
101
|
+
}),
|
|
77
102
|
password: true,
|
|
78
103
|
value: data[a.key].token ?? "",
|
|
79
104
|
onChange: (e) => {
|
|
@@ -95,9 +120,17 @@ function Authorization() {
|
|
|
95
120
|
{ key: a.key + "-basic" },
|
|
96
121
|
react_1.default.createElement(
|
|
97
122
|
FormItem_1.default,
|
|
98
|
-
{
|
|
123
|
+
{
|
|
124
|
+
label: (0, Translate_1.translate)({
|
|
125
|
+
id: translationIds_1.OPENAPI_AUTH.USERNAME,
|
|
126
|
+
message: "Username",
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
99
129
|
react_1.default.createElement(FormTextInput_1.default, {
|
|
100
|
-
placeholder:
|
|
130
|
+
placeholder: (0, Translate_1.translate)({
|
|
131
|
+
id: translationIds_1.OPENAPI_AUTH.USERNAME,
|
|
132
|
+
message: "Username",
|
|
133
|
+
}),
|
|
101
134
|
value: data[a.key].username ?? "",
|
|
102
135
|
onChange: (e) => {
|
|
103
136
|
const value = e.target.value;
|
|
@@ -113,9 +146,17 @@ function Authorization() {
|
|
|
113
146
|
),
|
|
114
147
|
react_1.default.createElement(
|
|
115
148
|
FormItem_1.default,
|
|
116
|
-
{
|
|
149
|
+
{
|
|
150
|
+
label: (0, Translate_1.translate)({
|
|
151
|
+
id: translationIds_1.OPENAPI_AUTH.PASSWORD,
|
|
152
|
+
message: "Password",
|
|
153
|
+
}),
|
|
154
|
+
},
|
|
117
155
|
react_1.default.createElement(FormTextInput_1.default, {
|
|
118
|
-
placeholder:
|
|
156
|
+
placeholder: (0, Translate_1.translate)({
|
|
157
|
+
id: translationIds_1.OPENAPI_AUTH.PASSWORD,
|
|
158
|
+
message: "Password",
|
|
159
|
+
}),
|
|
119
160
|
password: true,
|
|
120
161
|
value: data[a.key].password ?? "",
|
|
121
162
|
onChange: (e) => {
|
|
@@ -24,13 +24,155 @@ export interface AuthState {
|
|
|
24
24
|
selected?: string;
|
|
25
25
|
}
|
|
26
26
|
export declare const slice: import("@reduxjs/toolkit").Slice<AuthState, {
|
|
27
|
-
setAuthData: (state:
|
|
27
|
+
setAuthData: (state: {
|
|
28
|
+
data: {
|
|
29
|
+
[x: string]: {
|
|
30
|
+
[x: string]: string | undefined;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
options: {
|
|
34
|
+
[x: string]: ({
|
|
35
|
+
key: string;
|
|
36
|
+
scopes: string[];
|
|
37
|
+
type: "apiKey";
|
|
38
|
+
description?: string | undefined;
|
|
39
|
+
name: string;
|
|
40
|
+
in: "query" | "header" | "cookie";
|
|
41
|
+
} | {
|
|
42
|
+
key: string;
|
|
43
|
+
scopes: string[];
|
|
44
|
+
type: "http";
|
|
45
|
+
description?: string | undefined;
|
|
46
|
+
scheme: string;
|
|
47
|
+
bearerFormat?: string | undefined;
|
|
48
|
+
name?: string | undefined;
|
|
49
|
+
in?: string | undefined;
|
|
50
|
+
} | {
|
|
51
|
+
key: string;
|
|
52
|
+
scopes: string[];
|
|
53
|
+
type: "oauth2";
|
|
54
|
+
description?: string | undefined;
|
|
55
|
+
flows: {
|
|
56
|
+
implicit?: {
|
|
57
|
+
authorizationUrl?: string | undefined;
|
|
58
|
+
tokenUrl?: string | undefined;
|
|
59
|
+
refreshUrl?: string | undefined;
|
|
60
|
+
scopes: {
|
|
61
|
+
[x: string]: string;
|
|
62
|
+
};
|
|
63
|
+
} | undefined;
|
|
64
|
+
password?: {
|
|
65
|
+
authorizationUrl?: string | undefined;
|
|
66
|
+
tokenUrl?: string | undefined;
|
|
67
|
+
refreshUrl?: string | undefined;
|
|
68
|
+
scopes: {
|
|
69
|
+
[x: string]: string;
|
|
70
|
+
};
|
|
71
|
+
} | undefined;
|
|
72
|
+
clientCredentials?: {
|
|
73
|
+
authorizationUrl?: string | undefined;
|
|
74
|
+
tokenUrl?: string | undefined;
|
|
75
|
+
refreshUrl?: string | undefined;
|
|
76
|
+
scopes: {
|
|
77
|
+
[x: string]: string;
|
|
78
|
+
};
|
|
79
|
+
} | undefined;
|
|
80
|
+
authorizationCode?: {
|
|
81
|
+
authorizationUrl?: string | undefined;
|
|
82
|
+
tokenUrl?: string | undefined;
|
|
83
|
+
refreshUrl?: string | undefined;
|
|
84
|
+
scopes: {
|
|
85
|
+
[x: string]: string;
|
|
86
|
+
};
|
|
87
|
+
} | undefined;
|
|
88
|
+
};
|
|
89
|
+
} | {
|
|
90
|
+
key: string;
|
|
91
|
+
scopes: string[];
|
|
92
|
+
type: "openIdConnect";
|
|
93
|
+
description?: string | undefined;
|
|
94
|
+
openIdConnectUrl: string;
|
|
95
|
+
})[];
|
|
96
|
+
};
|
|
97
|
+
selected?: string | undefined;
|
|
98
|
+
}, action: PayloadAction<{
|
|
28
99
|
scheme: string;
|
|
29
100
|
key: string;
|
|
30
101
|
value?: string;
|
|
31
102
|
}>) => void;
|
|
32
|
-
setSelectedAuth: (state:
|
|
33
|
-
|
|
103
|
+
setSelectedAuth: (state: {
|
|
104
|
+
data: {
|
|
105
|
+
[x: string]: {
|
|
106
|
+
[x: string]: string | undefined;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
options: {
|
|
110
|
+
[x: string]: ({
|
|
111
|
+
key: string;
|
|
112
|
+
scopes: string[];
|
|
113
|
+
type: "apiKey";
|
|
114
|
+
description?: string | undefined;
|
|
115
|
+
name: string;
|
|
116
|
+
in: "query" | "header" | "cookie";
|
|
117
|
+
} | {
|
|
118
|
+
key: string;
|
|
119
|
+
scopes: string[];
|
|
120
|
+
type: "http";
|
|
121
|
+
description?: string | undefined;
|
|
122
|
+
scheme: string;
|
|
123
|
+
bearerFormat?: string | undefined;
|
|
124
|
+
name?: string | undefined;
|
|
125
|
+
in?: string | undefined;
|
|
126
|
+
} | {
|
|
127
|
+
key: string;
|
|
128
|
+
scopes: string[];
|
|
129
|
+
type: "oauth2";
|
|
130
|
+
description?: string | undefined;
|
|
131
|
+
flows: {
|
|
132
|
+
implicit?: {
|
|
133
|
+
authorizationUrl?: string | undefined;
|
|
134
|
+
tokenUrl?: string | undefined;
|
|
135
|
+
refreshUrl?: string | undefined;
|
|
136
|
+
scopes: {
|
|
137
|
+
[x: string]: string;
|
|
138
|
+
};
|
|
139
|
+
} | undefined;
|
|
140
|
+
password?: {
|
|
141
|
+
authorizationUrl?: string | undefined;
|
|
142
|
+
tokenUrl?: string | undefined;
|
|
143
|
+
refreshUrl?: string | undefined;
|
|
144
|
+
scopes: {
|
|
145
|
+
[x: string]: string;
|
|
146
|
+
};
|
|
147
|
+
} | undefined;
|
|
148
|
+
clientCredentials?: {
|
|
149
|
+
authorizationUrl?: string | undefined;
|
|
150
|
+
tokenUrl?: string | undefined;
|
|
151
|
+
refreshUrl?: string | undefined;
|
|
152
|
+
scopes: {
|
|
153
|
+
[x: string]: string;
|
|
154
|
+
};
|
|
155
|
+
} | undefined;
|
|
156
|
+
authorizationCode?: {
|
|
157
|
+
authorizationUrl?: string | undefined;
|
|
158
|
+
tokenUrl?: string | undefined;
|
|
159
|
+
refreshUrl?: string | undefined;
|
|
160
|
+
scopes: {
|
|
161
|
+
[x: string]: string;
|
|
162
|
+
};
|
|
163
|
+
} | undefined;
|
|
164
|
+
};
|
|
165
|
+
} | {
|
|
166
|
+
key: string;
|
|
167
|
+
scopes: string[];
|
|
168
|
+
type: "openIdConnect";
|
|
169
|
+
description?: string | undefined;
|
|
170
|
+
openIdConnectUrl: string;
|
|
171
|
+
})[];
|
|
172
|
+
};
|
|
173
|
+
selected?: string | undefined;
|
|
174
|
+
}, action: PayloadAction<string>) => void;
|
|
175
|
+
}, "auth", "auth", import("@reduxjs/toolkit").SliceSelectors<AuthState>>;
|
|
34
176
|
export declare const setAuthData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
35
177
|
scheme: string;
|
|
36
178
|
key: string;
|
|
@@ -40,7 +40,9 @@ const auth_types_1 = require("./auth-types");
|
|
|
40
40
|
// BearerAuth -> { token: xxx }
|
|
41
41
|
// BasicAuth -> { username: xxx, password: xxx }
|
|
42
42
|
function createAuth({ security, securitySchemes, options: opts }) {
|
|
43
|
-
const storage = (0, storage_utils_1.createStorage)(
|
|
43
|
+
const storage = (0, storage_utils_1.createStorage)(
|
|
44
|
+
opts?.authPersistence ?? "sessionStorage"
|
|
45
|
+
);
|
|
44
46
|
let data = {};
|
|
45
47
|
let options = {};
|
|
46
48
|
for (const option of security ?? []) {
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
(function () {
|
|
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
|
+
})();
|
|
64
|
+
var __importDefault =
|
|
65
|
+
(this && this.__importDefault) ||
|
|
66
|
+
function (mod) {
|
|
67
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.default = FileArrayFormBodyItem;
|
|
71
|
+
const react_1 = __importStar(require("react"));
|
|
72
|
+
const FormFileUpload_1 = __importDefault(
|
|
73
|
+
require("@theme/ApiExplorer/FormFileUpload")
|
|
74
|
+
);
|
|
75
|
+
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
76
|
+
const slice_1 = require("../slice");
|
|
77
|
+
function FileArrayFormBodyItem({ id, description }) {
|
|
78
|
+
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
79
|
+
const [fileItems, setFileItems] = (0, react_1.useState)(
|
|
80
|
+
new Map([[0, undefined]])
|
|
81
|
+
);
|
|
82
|
+
const handleFileChange = (index, file) => {
|
|
83
|
+
const newItems = new Map(fileItems);
|
|
84
|
+
if (file === undefined) {
|
|
85
|
+
newItems.delete(index);
|
|
86
|
+
setFileItems(newItems);
|
|
87
|
+
dispatch(
|
|
88
|
+
(0, slice_1.setFileArrayFormBody)({
|
|
89
|
+
key: id,
|
|
90
|
+
value: [...newItems.values()].filter((item) => item !== undefined),
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let maxIndex = 0;
|
|
96
|
+
newItems.keys().forEach((item) => {
|
|
97
|
+
maxIndex = item > maxIndex ? item : maxIndex;
|
|
98
|
+
});
|
|
99
|
+
newItems.set(index, {
|
|
100
|
+
src: `/path/to/${file.name}`,
|
|
101
|
+
content: file,
|
|
102
|
+
});
|
|
103
|
+
newItems.set(index + 1, undefined);
|
|
104
|
+
setFileItems(newItems);
|
|
105
|
+
dispatch(
|
|
106
|
+
(0, slice_1.setFileArrayFormBody)({
|
|
107
|
+
key: id,
|
|
108
|
+
value: [...newItems.values()].filter((item) => item !== undefined),
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
return react_1.default.createElement(
|
|
113
|
+
"div",
|
|
114
|
+
null,
|
|
115
|
+
[...fileItems.keys()].map((index) =>
|
|
116
|
+
react_1.default.createElement(
|
|
117
|
+
"div",
|
|
118
|
+
{ key: index },
|
|
119
|
+
react_1.default.createElement(FormFileUpload_1.default, {
|
|
120
|
+
placeholder: description || id,
|
|
121
|
+
onChange: (file) => handleFileChange(index, file),
|
|
122
|
+
})
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SchemaObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
3
|
+
interface FormBodyItemProps {
|
|
4
|
+
schemaObject: SchemaObject;
|
|
5
|
+
id: string;
|
|
6
|
+
schema: SchemaObject;
|
|
7
|
+
}
|
|
8
|
+
export default function FormBodyItem({ schemaObject, id, schema, }: FormBodyItemProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.default = FormBodyItem;
|
|
15
|
+
const react_1 = __importDefault(require("react"));
|
|
16
|
+
const FormFileUpload_1 = __importDefault(
|
|
17
|
+
require("@theme/ApiExplorer/FormFileUpload")
|
|
18
|
+
);
|
|
19
|
+
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
20
|
+
const FormTextInput_1 = __importDefault(
|
|
21
|
+
require("@theme/ApiExplorer/FormTextInput")
|
|
22
|
+
);
|
|
23
|
+
const LiveEditor_1 = __importDefault(require("@theme/ApiExplorer/LiveEditor"));
|
|
24
|
+
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
25
|
+
const slice_1 = require("../slice");
|
|
26
|
+
const FileArrayFormBodyItem_1 = __importDefault(
|
|
27
|
+
require("../FileArrayFormBodyItem")
|
|
28
|
+
);
|
|
29
|
+
function FormBodyItem({ schemaObject, id, schema }) {
|
|
30
|
+
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
31
|
+
if (
|
|
32
|
+
schemaObject.type === "array" &&
|
|
33
|
+
schemaObject.items?.format === "binary"
|
|
34
|
+
) {
|
|
35
|
+
return react_1.default.createElement(FileArrayFormBodyItem_1.default, {
|
|
36
|
+
id: id,
|
|
37
|
+
description: schemaObject.description,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (schemaObject.format === "binary") {
|
|
41
|
+
return react_1.default.createElement(FormFileUpload_1.default, {
|
|
42
|
+
placeholder: schemaObject.description || id,
|
|
43
|
+
onChange: (file) => {
|
|
44
|
+
if (file === undefined) {
|
|
45
|
+
dispatch((0, slice_1.clearFormBodyKey)(id));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
dispatch(
|
|
49
|
+
(0, slice_1.setFileFormBody)({
|
|
50
|
+
key: id,
|
|
51
|
+
value: {
|
|
52
|
+
src: `/path/to/${file.name}`,
|
|
53
|
+
content: file,
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (
|
|
61
|
+
schemaObject.type === "object" &&
|
|
62
|
+
(schemaObject.example || schemaObject.examples)
|
|
63
|
+
) {
|
|
64
|
+
const objectExample = JSON.stringify(
|
|
65
|
+
schemaObject.example ?? schemaObject.examples[0],
|
|
66
|
+
null,
|
|
67
|
+
2
|
|
68
|
+
);
|
|
69
|
+
return react_1.default.createElement(
|
|
70
|
+
LiveEditor_1.default,
|
|
71
|
+
{
|
|
72
|
+
action: (code) =>
|
|
73
|
+
dispatch((0, slice_1.setStringFormBody)({ key: id, value: code })),
|
|
74
|
+
},
|
|
75
|
+
objectExample
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (
|
|
79
|
+
schemaObject.enum &&
|
|
80
|
+
schemaObject.enum.every((value) => typeof value === "string")
|
|
81
|
+
) {
|
|
82
|
+
return react_1.default.createElement(FormSelect_1.default, {
|
|
83
|
+
options: ["---", ...schemaObject.enum],
|
|
84
|
+
onChange: (e) => {
|
|
85
|
+
const val = e.target.value;
|
|
86
|
+
if (val === "---") {
|
|
87
|
+
dispatch((0, slice_1.clearFormBodyKey)(id));
|
|
88
|
+
} else {
|
|
89
|
+
dispatch(
|
|
90
|
+
(0, slice_1.setStringFormBody)({
|
|
91
|
+
key: id,
|
|
92
|
+
value: val,
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
// TODO: support all the other types.
|
|
100
|
+
return react_1.default.createElement(FormTextInput_1.default, {
|
|
101
|
+
paramName: id,
|
|
102
|
+
isRequired: Array.isArray(schema.required) && schema.required.includes(id),
|
|
103
|
+
placeholder: schemaObject.description || id,
|
|
104
|
+
onChange: (e) => {
|
|
105
|
+
dispatch(
|
|
106
|
+
(0, slice_1.setStringFormBody)({ key: id, value: e.target.value })
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|