docusaurus-theme-openapi-docs 0.0.0-1084 → 0.0.0-1087

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.
@@ -4,7 +4,10 @@ export interface State {
4
4
  options: string[];
5
5
  }
6
6
  export declare const slice: import("@reduxjs/toolkit").Slice<State, {
7
- setAccept: (state: import("immer").WritableDraft<State>, action: PayloadAction<string>) => void;
7
+ setAccept: (state: {
8
+ value: string;
9
+ options: string[];
10
+ }, action: PayloadAction<string>) => void;
8
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>;
@@ -24,12 +24,154 @@ export interface AuthState {
24
24
  selected?: string;
25
25
  }
26
26
  export declare const slice: import("@reduxjs/toolkit").Slice<AuthState, {
27
- setAuthData: (state: import("immer").WritableDraft<AuthState>, action: PayloadAction<{
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: import("immer").WritableDraft<AuthState>, action: PayloadAction<string>) => void;
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;
33
175
  }, "auth", "auth", import("@reduxjs/toolkit").SliceSelectors<AuthState>>;
34
176
  export declare const setAuthData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
35
177
  scheme: string;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ interface FileArrayFormItemProps {
3
+ id: string;
4
+ description: string | undefined;
5
+ }
6
+ export default function FileArrayFormBodyItem({ id, description, }: FileArrayFormItemProps): React.JSX.Element;
7
+ export {};
@@ -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
+ }
@@ -18,10 +18,6 @@ const FormFileUpload_1 = __importDefault(
18
18
  require("@theme/ApiExplorer/FormFileUpload")
19
19
  );
20
20
  const FormItem_1 = __importDefault(require("@theme/ApiExplorer/FormItem"));
21
- const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
22
- const FormTextInput_1 = __importDefault(
23
- require("@theme/ApiExplorer/FormTextInput")
24
- );
25
21
  const LiveEditor_1 = __importDefault(require("@theme/ApiExplorer/LiveEditor"));
26
22
  const hooks_1 = require("@theme/ApiItem/hooks");
27
23
  const Markdown_1 = __importDefault(require("@theme/Markdown"));
@@ -30,6 +26,7 @@ const TabItem_1 = __importDefault(require("@theme/TabItem"));
30
26
  const translationIds_1 = require("@theme/translationIds");
31
27
  const xml_formatter_1 = __importDefault(require("xml-formatter"));
32
28
  const slice_1 = require("./slice");
29
+ const FormBodyItem_1 = __importDefault(require("./FormBodyItem"));
33
30
  function BodyWrap({
34
31
  requestBodyMetadata,
35
32
  jsonRequestBodyExample,
@@ -118,94 +115,22 @@ function Body({
118
115
  return react_1.default.createElement(
119
116
  FormItem_1.default,
120
117
  { className: "openapi-explorer__form-item-body-container" },
121
- react_1.default.createElement(
122
- "div",
123
- null,
124
- Object.entries(schema.properties ?? {}).map(([key, val]) => {
125
- if (val.format === "binary") {
126
- return react_1.default.createElement(
127
- FormItem_1.default,
128
- {
129
- key: key,
130
- label: key,
131
- required:
132
- Array.isArray(schema.required) &&
133
- schema.required.includes(key),
134
- },
135
- react_1.default.createElement(FormFileUpload_1.default, {
136
- placeholder: val.description || key,
137
- onChange: (file) => {
138
- if (file === undefined) {
139
- dispatch((0, slice_1.clearFormBodyKey)(key));
140
- return;
141
- }
142
- dispatch(
143
- (0, slice_1.setFileFormBody)({
144
- key: key,
145
- value: {
146
- src: `/path/to/${file.name}`,
147
- content: file,
148
- },
149
- })
150
- );
151
- },
152
- })
153
- );
154
- }
155
- if (val.enum) {
156
- return react_1.default.createElement(
157
- FormItem_1.default,
158
- {
159
- key: key,
160
- label: key,
161
- required:
162
- Array.isArray(schema.required) &&
163
- schema.required.includes(key),
164
- },
165
- react_1.default.createElement(FormSelect_1.default, {
166
- options: ["---", ...val.enum],
167
- onChange: (e) => {
168
- const val = e.target.value;
169
- if (val === "---") {
170
- dispatch((0, slice_1.clearFormBodyKey)(key));
171
- } else {
172
- dispatch(
173
- (0, slice_1.setStringFormBody)({
174
- key: key,
175
- value: val,
176
- })
177
- );
178
- }
179
- },
180
- })
181
- );
182
- }
183
- // TODO: support all the other types.
184
- return react_1.default.createElement(
185
- FormItem_1.default,
186
- {
187
- key: key,
188
- label: key,
189
- required:
190
- Array.isArray(schema.required) && schema.required.includes(key),
191
- },
192
- react_1.default.createElement(FormTextInput_1.default, {
193
- paramName: key,
194
- isRequired:
195
- Array.isArray(schema.required) && schema.required.includes(key),
196
- placeholder: val.description || key,
197
- onChange: (e) => {
198
- dispatch(
199
- (0, slice_1.setStringFormBody)({
200
- key: key,
201
- value: e.target.value,
202
- })
203
- );
204
- },
205
- })
206
- );
207
- })
208
- )
118
+ Object.entries(schema.properties ?? {}).map(([key, val]) => {
119
+ return react_1.default.createElement(
120
+ FormItem_1.default,
121
+ {
122
+ key: key,
123
+ label: key,
124
+ required:
125
+ Array.isArray(schema.required) && schema.required.includes(key),
126
+ },
127
+ react_1.default.createElement(FormBodyItem_1.default, {
128
+ schemaObject: val,
129
+ id: key,
130
+ schema: schema,
131
+ })
132
+ );
133
+ })
209
134
  );
210
135
  }
211
136
  let language = "plaintext";
@@ -343,7 +268,11 @@ function Body({
343
268
  },
344
269
  react_1.default.createElement(
345
270
  LiveEditor_1.default,
346
- { action: dispatch, language: language, required: required },
271
+ {
272
+ action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
273
+ language: language,
274
+ required: required,
275
+ },
347
276
  defaultBody
348
277
  )
349
278
  ),
@@ -359,7 +288,11 @@ function Body({
359
288
  exampleBody &&
360
289
  react_1.default.createElement(
361
290
  LiveEditor_1.default,
362
- { action: dispatch, language: language, required: required },
291
+ {
292
+ action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
293
+ language: language,
294
+ required: required,
295
+ },
363
296
  exampleBody
364
297
  )
365
298
  )
@@ -385,7 +318,11 @@ function Body({
385
318
  },
386
319
  react_1.default.createElement(
387
320
  LiveEditor_1.default,
388
- { action: dispatch, language: language, required: required },
321
+ {
322
+ action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
323
+ language: language,
324
+ required: required,
325
+ },
389
326
  defaultBody
390
327
  )
391
328
  ),
@@ -408,7 +345,11 @@ function Body({
408
345
  example.body &&
409
346
  react_1.default.createElement(
410
347
  LiveEditor_1.default,
411
- { action: dispatch, language: language },
348
+ {
349
+ action: (code) =>
350
+ dispatch((0, slice_1.setStringRawBody)(code)),
351
+ language: language,
352
+ },
412
353
  example.body
413
354
  )
414
355
  )
@@ -422,7 +363,11 @@ function Body({
422
363
  null,
423
364
  react_1.default.createElement(
424
365
  LiveEditor_1.default,
425
- { action: dispatch, language: language, required: required },
366
+ {
367
+ action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
368
+ language: language,
369
+ required: required,
370
+ },
426
371
  defaultBody
427
372
  )
428
373
  );