docusaurus-theme-openapi-docs 0.0.0-349 → 0.0.0-350
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/ApiDemoPanel/SecuritySchemes/index.js +21 -3
- package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +5 -1
- package/lib/theme/ApiItem/styles.module.css +4 -0
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +26 -3
- package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +5 -1
- package/lib-next/theme/ApiItem/styles.module.css +4 -0
- package/package.json +6 -6
- package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +26 -3
- package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +5 -1
- package/src/theme/ApiItem/index.tsx +3 -4
- package/src/theme/ApiItem/styles.module.css +4 -0
- package/src/types.ts +0 -100
- package/lib/theme/ApiDemoPanel/Authorization/index.js +0 -174
- package/lib/theme/ApiDemoPanel/Execute/index.js +0 -85
- package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +0 -200
- package/lib-next/theme/ApiDemoPanel/Authorization/index.js +0 -203
- package/lib-next/theme/ApiDemoPanel/Execute/index.js +0 -73
- package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +0 -181
- package/src/theme/ApiDemoPanel/Authorization/index.tsx +0 -211
- package/src/theme/ApiDemoPanel/Execute/index.tsx +0 -87
- package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +0 -182
- package/yarn-error.log +0 -15035
|
@@ -26,9 +26,13 @@ function SecuritySchemes() {
|
|
|
26
26
|
marginBottom: "var(--ifm-table-cell-padding)"
|
|
27
27
|
}}>
|
|
28
28
|
{selectedAuth.map(auth => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const isApiKey = auth.type === "apiKey";
|
|
30
|
+
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
31
|
+
const isClientCredentials = auth.type === "oauth2" && auth.key === "ClientCredentials";
|
|
32
|
+
|
|
33
|
+
if (isApiKey || isBearer) {
|
|
34
|
+
return <_react.default.Fragment key={selected}>
|
|
35
|
+
<b>Authorization: {auth.key}</b>
|
|
32
36
|
<pre style={{
|
|
33
37
|
display: "flex",
|
|
34
38
|
flexDirection: "column",
|
|
@@ -42,6 +46,20 @@ function SecuritySchemes() {
|
|
|
42
46
|
</_react.default.Fragment>;
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
if (isClientCredentials) {
|
|
50
|
+
return <_react.default.Fragment key={selected}>
|
|
51
|
+
<b>Authorization: {auth.key}</b>
|
|
52
|
+
<pre style={{
|
|
53
|
+
display: "flex",
|
|
54
|
+
flexDirection: "column",
|
|
55
|
+
background: "var(--openapi-card-background-color)",
|
|
56
|
+
borderRadius: "var(--openapi-card-border-radius)"
|
|
57
|
+
}}>
|
|
58
|
+
<span>type: {auth.type}</span>
|
|
59
|
+
</pre>
|
|
60
|
+
</_react.default.Fragment>;
|
|
61
|
+
}
|
|
62
|
+
|
|
45
63
|
return null;
|
|
46
64
|
})}
|
|
47
65
|
</div>;
|
|
@@ -269,6 +269,10 @@ function buildPostmanRequest(postman, {
|
|
|
269
269
|
} = auth.data[a.key];
|
|
270
270
|
|
|
271
271
|
if (token === undefined) {
|
|
272
|
+
otherHeaders.push({
|
|
273
|
+
key: "Authorization",
|
|
274
|
+
value: "Bearer <TOKEN>"
|
|
275
|
+
});
|
|
272
276
|
continue;
|
|
273
277
|
}
|
|
274
278
|
|
|
@@ -306,7 +310,7 @@ function buildPostmanRequest(postman, {
|
|
|
306
310
|
if (apikey === undefined) {
|
|
307
311
|
otherHeaders.push({
|
|
308
312
|
key: a.name,
|
|
309
|
-
value: "API_KEY_VALUE"
|
|
313
|
+
value: "<API_KEY_VALUE>"
|
|
310
314
|
});
|
|
311
315
|
continue;
|
|
312
316
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--openapi-required: var(--ifm-color-danger);
|
|
3
|
+
--openapi-code-blue: var(--ifm-color-info);
|
|
4
|
+
--openapi-code-red: var(--ifm-color-danger);
|
|
5
|
+
--openapi-code-orange: var(--ifm-color-warning);
|
|
6
|
+
--openapi-code-green: var(--ifm-color-success);
|
|
3
7
|
}
|
|
4
8
|
|
|
5
9
|
.apiItemContainer article > *:first-child,
|
|
@@ -19,10 +19,15 @@ function SecuritySchemes() {
|
|
|
19
19
|
}}
|
|
20
20
|
>
|
|
21
21
|
{selectedAuth.map((auth) => {
|
|
22
|
-
|
|
22
|
+
const isApiKey = auth.type === "apiKey";
|
|
23
|
+
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
24
|
+
const isClientCredentials =
|
|
25
|
+
auth.type === "oauth2" && auth.key === "ClientCredentials";
|
|
26
|
+
|
|
27
|
+
if (isApiKey || isBearer) {
|
|
23
28
|
return (
|
|
24
|
-
<React.Fragment key={selected
|
|
25
|
-
<b>Authorization: {auth.
|
|
29
|
+
<React.Fragment key={selected}>
|
|
30
|
+
<b>Authorization: {auth.key}</b>
|
|
26
31
|
<pre
|
|
27
32
|
style={{
|
|
28
33
|
display: "flex",
|
|
@@ -39,6 +44,24 @@ function SecuritySchemes() {
|
|
|
39
44
|
);
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
if (isClientCredentials) {
|
|
48
|
+
return (
|
|
49
|
+
<React.Fragment key={selected}>
|
|
50
|
+
<b>Authorization: {auth.key}</b>
|
|
51
|
+
<pre
|
|
52
|
+
style={{
|
|
53
|
+
display: "flex",
|
|
54
|
+
flexDirection: "column",
|
|
55
|
+
background: "var(--openapi-card-background-color)",
|
|
56
|
+
borderRadius: "var(--openapi-card-border-radius)",
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
<span>type: {auth.type}</span>
|
|
60
|
+
</pre>
|
|
61
|
+
</React.Fragment>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
42
65
|
return null;
|
|
43
66
|
})}
|
|
44
67
|
</div>
|
|
@@ -251,6 +251,10 @@ function buildPostmanRequest(
|
|
|
251
251
|
const { token } = auth.data[a.key];
|
|
252
252
|
|
|
253
253
|
if (token === undefined) {
|
|
254
|
+
otherHeaders.push({
|
|
255
|
+
key: "Authorization",
|
|
256
|
+
value: "Bearer <TOKEN>",
|
|
257
|
+
});
|
|
254
258
|
continue;
|
|
255
259
|
}
|
|
256
260
|
|
|
@@ -281,7 +285,7 @@ function buildPostmanRequest(
|
|
|
281
285
|
if (apikey === undefined) {
|
|
282
286
|
otherHeaders.push({
|
|
283
287
|
key: a.name,
|
|
284
|
-
value: "API_KEY_VALUE",
|
|
288
|
+
value: "<API_KEY_VALUE>",
|
|
285
289
|
});
|
|
286
290
|
continue;
|
|
287
291
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--openapi-required: var(--ifm-color-danger);
|
|
3
|
+
--openapi-code-blue: var(--ifm-color-info);
|
|
4
|
+
--openapi-code-red: var(--ifm-color-danger);
|
|
5
|
+
--openapi-code-orange: var(--ifm-color-warning);
|
|
6
|
+
--openapi-code-green: var(--ifm-color-success);
|
|
3
7
|
}
|
|
4
8
|
|
|
5
9
|
.apiItemContainer article > *:first-child,
|
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-350",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"format:lib-next": "prettier --config ../../.prettierrc.json --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
35
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
34
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.18",
|
|
35
|
+
"@docusaurus/types": "2.0.0-beta.18",
|
|
36
36
|
"@types/concurrently": "^6.3.0",
|
|
37
37
|
"@types/crypto-js": "^4.1.0",
|
|
38
38
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"concurrently": "^5.2.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@docusaurus/theme-common": "2.0.0-beta.
|
|
45
|
+
"@docusaurus/theme-common": "2.0.0-beta.18",
|
|
46
46
|
"@mdx-js/react": "^1.6.21",
|
|
47
47
|
"@monaco-editor/react": "^4.3.1",
|
|
48
48
|
"@paloaltonetworks/postman-code-generators": "1.1.5-hotfix.5",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"buffer": "^6.0.3",
|
|
52
52
|
"clsx": "^1.1.1",
|
|
53
53
|
"crypto-js": "^4.1.1",
|
|
54
|
-
"docusaurus-plugin-openapi-docs": "0.0.0-
|
|
54
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-350",
|
|
55
55
|
"immer": "^9.0.7",
|
|
56
56
|
"lodash": "^4.17.20",
|
|
57
57
|
"monaco-editor": "^0.31.1",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=14"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "c66039acf120aeef0024c18d5ca0d842f38b32a6"
|
|
74
74
|
}
|
|
@@ -20,10 +20,15 @@ function SecuritySchemes() {
|
|
|
20
20
|
return (
|
|
21
21
|
<div style={{ marginBottom: "var(--ifm-table-cell-padding)" }}>
|
|
22
22
|
{selectedAuth.map((auth) => {
|
|
23
|
-
|
|
23
|
+
const isApiKey = auth.type === "apiKey";
|
|
24
|
+
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
25
|
+
const isClientCredentials =
|
|
26
|
+
auth.type === "oauth2" && auth.key === "ClientCredentials";
|
|
27
|
+
|
|
28
|
+
if (isApiKey || isBearer) {
|
|
24
29
|
return (
|
|
25
|
-
<React.Fragment key={selected
|
|
26
|
-
<b>Authorization: {auth.
|
|
30
|
+
<React.Fragment key={selected}>
|
|
31
|
+
<b>Authorization: {auth.key}</b>
|
|
27
32
|
<pre
|
|
28
33
|
style={{
|
|
29
34
|
display: "flex",
|
|
@@ -40,6 +45,24 @@ function SecuritySchemes() {
|
|
|
40
45
|
);
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
if (isClientCredentials) {
|
|
49
|
+
return (
|
|
50
|
+
<React.Fragment key={selected}>
|
|
51
|
+
<b>Authorization: {auth.key}</b>
|
|
52
|
+
<pre
|
|
53
|
+
style={{
|
|
54
|
+
display: "flex",
|
|
55
|
+
flexDirection: "column",
|
|
56
|
+
background: "var(--openapi-card-background-color)",
|
|
57
|
+
borderRadius: "var(--openapi-card-border-radius)",
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<span>type: {auth.type}</span>
|
|
61
|
+
</pre>
|
|
62
|
+
</React.Fragment>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
43
66
|
return null;
|
|
44
67
|
})}
|
|
45
68
|
</div>
|
|
@@ -248,6 +248,10 @@ function buildPostmanRequest(
|
|
|
248
248
|
if (a.type === "http" && a.scheme === "bearer") {
|
|
249
249
|
const { token } = auth.data[a.key];
|
|
250
250
|
if (token === undefined) {
|
|
251
|
+
otherHeaders.push({
|
|
252
|
+
key: "Authorization",
|
|
253
|
+
value: "Bearer <TOKEN>",
|
|
254
|
+
});
|
|
251
255
|
continue;
|
|
252
256
|
}
|
|
253
257
|
otherHeaders.push({
|
|
@@ -276,7 +280,7 @@ function buildPostmanRequest(
|
|
|
276
280
|
if (apikey === undefined) {
|
|
277
281
|
otherHeaders.push({
|
|
278
282
|
key: a.name,
|
|
279
|
-
value: "API_KEY_VALUE",
|
|
283
|
+
value: "<API_KEY_VALUE>",
|
|
280
284
|
});
|
|
281
285
|
continue;
|
|
282
286
|
}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
useWindowSize,
|
|
16
16
|
} from "@docusaurus/theme-common";
|
|
17
17
|
import DocBreadcrumbs from "@theme/DocBreadcrumbs";
|
|
18
|
-
import type { Props } from "@theme/DocItem";
|
|
18
|
+
import type { Props, FrontMatter } from "@theme/DocItem";
|
|
19
19
|
import DocItemFooter from "@theme/DocItemFooter";
|
|
20
20
|
import DocPaginator from "@theme/DocPaginator";
|
|
21
21
|
import DocVersionBadge from "@theme/DocVersionBadge";
|
|
@@ -25,9 +25,8 @@ import MDXContent from "@theme/MDXContent";
|
|
|
25
25
|
import TOC from "@theme/TOC";
|
|
26
26
|
import TOCCollapsible from "@theme/TOCCollapsible";
|
|
27
27
|
import clsx from "clsx";
|
|
28
|
-
import type { ApiItem as ApiItemType } from "docusaurus-plugin-openapi-docs/
|
|
28
|
+
import type { ApiItem as ApiItemType } from "docusaurus-plugin-openapi-docs/lib/types";
|
|
29
29
|
|
|
30
|
-
import { DocFrontMatter } from "../../types";
|
|
31
30
|
import styles from "./styles.module.css";
|
|
32
31
|
|
|
33
32
|
let ApiDemoPanel = (_: { item: any }) => <div style={{ marginTop: "3.5em" }} />;
|
|
@@ -35,7 +34,7 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
35
34
|
ApiDemoPanel = require("@theme/ApiDemoPanel").default;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
interface ApiFrontMatter extends
|
|
37
|
+
interface ApiFrontMatter extends FrontMatter {
|
|
39
38
|
readonly api?: ApiItemType;
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--openapi-required: var(--ifm-color-danger);
|
|
3
|
+
--openapi-code-blue: var(--ifm-color-info);
|
|
4
|
+
--openapi-code-red: var(--ifm-color-danger);
|
|
5
|
+
--openapi-code-orange: var(--ifm-color-warning);
|
|
6
|
+
--openapi-code-green: var(--ifm-color-success);
|
|
3
7
|
}
|
|
4
8
|
|
|
5
9
|
.apiItemContainer article > *:first-child,
|
package/src/types.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import type { FrontMatterTag } from "@docusaurus/utils";
|
|
9
8
|
import type { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
|
|
10
9
|
|
|
11
10
|
export interface ThemeConfig {
|
|
@@ -69,102 +68,3 @@ export interface ExternalDocumentationObject {
|
|
|
69
68
|
description?: string;
|
|
70
69
|
url: string;
|
|
71
70
|
}
|
|
72
|
-
|
|
73
|
-
export type DocFrontMatter = {
|
|
74
|
-
/**
|
|
75
|
-
* The last part of the doc ID (will be refactored in the future to be the
|
|
76
|
-
* full ID instead)
|
|
77
|
-
* @see {@link DocMetadata.id}
|
|
78
|
-
*/
|
|
79
|
-
id?: string;
|
|
80
|
-
/**
|
|
81
|
-
* Will override the default title collected from h1 heading.
|
|
82
|
-
* @see {@link DocMetadata.title}
|
|
83
|
-
*/
|
|
84
|
-
title?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Front matter tags, unnormalized.
|
|
87
|
-
* @see {@link DocMetadata.tags}
|
|
88
|
-
*/
|
|
89
|
-
tags?: FrontMatterTag[];
|
|
90
|
-
/**
|
|
91
|
-
* If there isn't a Markdown h1 heading (which, if there is, we don't
|
|
92
|
-
* remove), this front matter will cause the front matter title to not be
|
|
93
|
-
* displayed in the doc page.
|
|
94
|
-
*/
|
|
95
|
-
hide_title?: boolean;
|
|
96
|
-
/** Hide the TOC on the right. */
|
|
97
|
-
hide_table_of_contents?: boolean;
|
|
98
|
-
/** Used in the head meta. */
|
|
99
|
-
keywords?: string[];
|
|
100
|
-
/** Used in the head meta. Should use `assets.image` in priority. */
|
|
101
|
-
image?: string;
|
|
102
|
-
/**
|
|
103
|
-
* Will override the default excerpt.
|
|
104
|
-
* @see {@link DocMetadata.description}
|
|
105
|
-
*/
|
|
106
|
-
description?: string;
|
|
107
|
-
/**
|
|
108
|
-
* Custom slug appended after /<baseUrl>/<routeBasePath>/<versionPath>
|
|
109
|
-
* @see {@link DocMetadata.slug}
|
|
110
|
-
*/
|
|
111
|
-
slug?: string;
|
|
112
|
-
/** Customizes the sidebar label for this doc. Will default to its title. */
|
|
113
|
-
sidebar_label?: string;
|
|
114
|
-
/**
|
|
115
|
-
* Controls the position of a doc inside the generated sidebar slice when
|
|
116
|
-
* using autogenerated sidebar items.
|
|
117
|
-
*
|
|
118
|
-
* @see https://docusaurus.io/docs/sidebar#autogenerated-sidebar-metadata
|
|
119
|
-
*/
|
|
120
|
-
sidebar_position?: number;
|
|
121
|
-
/**
|
|
122
|
-
* Gives the corresponding sidebar label a special class name when using
|
|
123
|
-
* autogenerated sidebars.
|
|
124
|
-
*/
|
|
125
|
-
sidebar_class_name?: string;
|
|
126
|
-
/**
|
|
127
|
-
* Will be propagated to the final sidebars data structure. Useful if you
|
|
128
|
-
* have swizzled sidebar-related code or simply querying doc data through
|
|
129
|
-
* sidebars.
|
|
130
|
-
*/
|
|
131
|
-
sidebar_custom_props?: { [key: string]: unknown };
|
|
132
|
-
/**
|
|
133
|
-
* Changes the sidebar association of the current doc. Use `null` to make
|
|
134
|
-
* the current doc not associated to any sidebar.
|
|
135
|
-
*/
|
|
136
|
-
displayed_sidebar?: string | null;
|
|
137
|
-
/**
|
|
138
|
-
* Customizes the pagination label for this doc. Will default to the sidebar
|
|
139
|
-
* label.
|
|
140
|
-
*/
|
|
141
|
-
pagination_label?: string;
|
|
142
|
-
/** Overrides the default URL computed for this doc. */
|
|
143
|
-
custom_edit_url?: string | null;
|
|
144
|
-
/**
|
|
145
|
-
* Whether number prefix parsing is disabled on this doc.
|
|
146
|
-
* @see https://docusaurus.io/docs/sidebar#using-number-prefixes
|
|
147
|
-
*/
|
|
148
|
-
parse_number_prefixes?: boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Minimum TOC heading level. Must be between 2 and 6 and lower or equal to
|
|
151
|
-
* the max value.
|
|
152
|
-
*/
|
|
153
|
-
toc_min_heading_level?: number;
|
|
154
|
-
/** Maximum TOC heading level. Must be between 2 and 6. */
|
|
155
|
-
toc_max_heading_level?: number;
|
|
156
|
-
/**
|
|
157
|
-
* The ID of the documentation you want the "Next" pagination to link to.
|
|
158
|
-
* Use `null` to disable showing "Next" for this page.
|
|
159
|
-
* @see {@link DocMetadata.next}
|
|
160
|
-
*/
|
|
161
|
-
pagination_next?: string | null;
|
|
162
|
-
/**
|
|
163
|
-
* The ID of the documentation you want the "Previous" pagination to link
|
|
164
|
-
* to. Use `null` to disable showing "Previous" for this page.
|
|
165
|
-
* @see {@link DocMetadata.prev}
|
|
166
|
-
*/
|
|
167
|
-
pagination_prev?: string | null;
|
|
168
|
-
/** Should this doc be excluded from production builds? */
|
|
169
|
-
draft?: boolean;
|
|
170
|
-
};
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _clsx = _interopRequireDefault(require("clsx"));
|
|
11
|
-
|
|
12
|
-
var _FormItem = _interopRequireDefault(require("../FormItem"));
|
|
13
|
-
|
|
14
|
-
var _FormSelect = _interopRequireDefault(require("../FormSelect"));
|
|
15
|
-
|
|
16
|
-
var _FormTextInput = _interopRequireDefault(require("../FormTextInput"));
|
|
17
|
-
|
|
18
|
-
var _hooks = require("../hooks");
|
|
19
|
-
|
|
20
|
-
var _stylesModule = _interopRequireDefault(require("../styles.module.css"));
|
|
21
|
-
|
|
22
|
-
var _slice = require("./slice");
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
30
|
-
/* ============================================================================
|
|
31
|
-
* Copyright (c) Palo Alto Networks
|
|
32
|
-
*
|
|
33
|
-
* This source code is licensed under the MIT license found in the
|
|
34
|
-
* LICENSE file in the root directory of this source tree.
|
|
35
|
-
* ========================================================================== */
|
|
36
|
-
function LockButton({
|
|
37
|
-
mode,
|
|
38
|
-
children,
|
|
39
|
-
style,
|
|
40
|
-
...rest
|
|
41
|
-
}) {
|
|
42
|
-
return <button className={(0, _clsx.default)("button", "button--primary", {
|
|
43
|
-
"button--outline": mode !== "locked"
|
|
44
|
-
})} style={{
|
|
45
|
-
marginLeft: "auto",
|
|
46
|
-
display: "flex",
|
|
47
|
-
alignItems: "center",
|
|
48
|
-
marginBottom: "var(--ifm-spacing-vertical)",
|
|
49
|
-
...style
|
|
50
|
-
}} {...rest}>
|
|
51
|
-
<span>{children}</span>
|
|
52
|
-
|
|
53
|
-
<svg style={{
|
|
54
|
-
marginLeft: "12px",
|
|
55
|
-
width: "18px",
|
|
56
|
-
height: "18px",
|
|
57
|
-
fill: "currentColor"
|
|
58
|
-
}} viewBox="0 0 20 20" id={mode}>
|
|
59
|
-
{mode === "locked" ? <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"></path> : <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>}
|
|
60
|
-
</svg>
|
|
61
|
-
</button>;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function validateData(selectedAuth, data) {
|
|
65
|
-
for (const scheme of selectedAuth) {
|
|
66
|
-
if (data[scheme.key] === undefined) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const hasMissingKeys = Object.values(data[scheme.key]).includes(undefined);
|
|
71
|
-
|
|
72
|
-
if (hasMissingKeys) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function Authorization() {
|
|
81
|
-
const [editing, setEditing] = (0, _react.useState)(false);
|
|
82
|
-
const data = (0, _hooks.useTypedSelector)(state => state.auth.data);
|
|
83
|
-
const options = (0, _hooks.useTypedSelector)(state => state.auth.options);
|
|
84
|
-
const selected = (0, _hooks.useTypedSelector)(state => state.auth.selected);
|
|
85
|
-
const dispatch = (0, _hooks.useTypedDispatch)();
|
|
86
|
-
|
|
87
|
-
if (selected === undefined) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const selectedAuth = options[selected];
|
|
92
|
-
const authenticated = validateData(selectedAuth, data);
|
|
93
|
-
const optionKeys = Object.keys(options);
|
|
94
|
-
|
|
95
|
-
if (editing) {
|
|
96
|
-
return <div className={_stylesModule.default.optionsPanel}>
|
|
97
|
-
{optionKeys.length > 1 && <_FormItem.default label="Security Scheme">
|
|
98
|
-
<_FormSelect.default options={optionKeys} value={selected} onChange={e => {
|
|
99
|
-
dispatch((0, _slice.setSelectedAuth)(e.target.value));
|
|
100
|
-
}} />
|
|
101
|
-
</_FormItem.default>}
|
|
102
|
-
{selectedAuth.map(a => {
|
|
103
|
-
if (a.type === "http" && a.scheme === "bearer") {
|
|
104
|
-
var _data$a$key$token;
|
|
105
|
-
|
|
106
|
-
return <_FormItem.default label="Bearer Token" key={selected + "-bearer"}>
|
|
107
|
-
<_FormTextInput.default placeholder="Bearer Token" value={(_data$a$key$token = data[a.key].token) !== null && _data$a$key$token !== void 0 ? _data$a$key$token : ""} onChange={e => {
|
|
108
|
-
const value = e.target.value.trim();
|
|
109
|
-
dispatch((0, _slice.setAuthData)({
|
|
110
|
-
scheme: a.key,
|
|
111
|
-
key: "token",
|
|
112
|
-
value: value ? value : undefined
|
|
113
|
-
}));
|
|
114
|
-
}} />
|
|
115
|
-
</_FormItem.default>;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (a.type === "http" && a.scheme === "basic") {
|
|
119
|
-
var _data$a$key$username, _data$a$key$password;
|
|
120
|
-
|
|
121
|
-
return <_react.default.Fragment key={selected + "-basic"}>
|
|
122
|
-
<_FormItem.default label="Username">
|
|
123
|
-
<_FormTextInput.default placeholder="Username" value={(_data$a$key$username = data[a.key].username) !== null && _data$a$key$username !== void 0 ? _data$a$key$username : ""} onChange={e => {
|
|
124
|
-
const value = e.target.value.trim();
|
|
125
|
-
dispatch((0, _slice.setAuthData)({
|
|
126
|
-
scheme: a.key,
|
|
127
|
-
key: "username",
|
|
128
|
-
value: value ? value : undefined
|
|
129
|
-
}));
|
|
130
|
-
}} />
|
|
131
|
-
</_FormItem.default>
|
|
132
|
-
<_FormItem.default label="Password">
|
|
133
|
-
<_FormTextInput.default placeholder="Password" password value={(_data$a$key$password = data[a.key].password) !== null && _data$a$key$password !== void 0 ? _data$a$key$password : ""} onChange={e => {
|
|
134
|
-
const value = e.target.value.trim();
|
|
135
|
-
dispatch((0, _slice.setAuthData)({
|
|
136
|
-
scheme: a.key,
|
|
137
|
-
key: "password",
|
|
138
|
-
value: value ? value : undefined
|
|
139
|
-
}));
|
|
140
|
-
}} />
|
|
141
|
-
</_FormItem.default>
|
|
142
|
-
</_react.default.Fragment>;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return null;
|
|
146
|
-
})}
|
|
147
|
-
<LockButton mode="unlocked" style={{
|
|
148
|
-
marginTop: "var(--ifm-spacing-vertical)",
|
|
149
|
-
marginBottom: 0
|
|
150
|
-
}} onClick={() => {
|
|
151
|
-
setEditing(false);
|
|
152
|
-
}}>
|
|
153
|
-
Save
|
|
154
|
-
</LockButton>
|
|
155
|
-
</div>;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (authenticated) {
|
|
159
|
-
return <LockButton mode="locked" onClick={() => {
|
|
160
|
-
setEditing(true);
|
|
161
|
-
}}>
|
|
162
|
-
Authorized
|
|
163
|
-
</LockButton>;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return <LockButton mode="unlocked" onClick={() => {
|
|
167
|
-
setEditing(true);
|
|
168
|
-
}}>
|
|
169
|
-
Authorize
|
|
170
|
-
</LockButton>;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
var _default = Authorization;
|
|
174
|
-
exports.default = _default;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _hooks = require("../hooks");
|
|
11
|
-
|
|
12
|
-
var _slice = require("../Response/slice");
|
|
13
|
-
|
|
14
|
-
var _buildPostmanRequest = _interopRequireDefault(require("./../buildPostmanRequest"));
|
|
15
|
-
|
|
16
|
-
var _makeRequest = _interopRequireDefault(require("./makeRequest"));
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
/* ============================================================================
|
|
21
|
-
* Copyright (c) Palo Alto Networks
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
* ========================================================================== */
|
|
26
|
-
function validateRequest(params) {
|
|
27
|
-
for (let paramList of Object.values(params)) {
|
|
28
|
-
for (let param of paramList) {
|
|
29
|
-
if (param.required && !param.value) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function Execute({
|
|
39
|
-
postman,
|
|
40
|
-
proxy
|
|
41
|
-
}) {
|
|
42
|
-
const pathParams = (0, _hooks.useTypedSelector)(state => state.params.path);
|
|
43
|
-
const queryParams = (0, _hooks.useTypedSelector)(state => state.params.query);
|
|
44
|
-
const cookieParams = (0, _hooks.useTypedSelector)(state => state.params.cookie);
|
|
45
|
-
const headerParams = (0, _hooks.useTypedSelector)(state => state.params.header);
|
|
46
|
-
const contentType = (0, _hooks.useTypedSelector)(state => state.contentType.value);
|
|
47
|
-
const body = (0, _hooks.useTypedSelector)(state => state.body);
|
|
48
|
-
const accept = (0, _hooks.useTypedSelector)(state => state.accept.value);
|
|
49
|
-
const server = (0, _hooks.useTypedSelector)(state => state.server.value);
|
|
50
|
-
const params = (0, _hooks.useTypedSelector)(state => state.params);
|
|
51
|
-
const auth = (0, _hooks.useTypedSelector)(state => state.auth);
|
|
52
|
-
const isValidRequest = validateRequest(params);
|
|
53
|
-
const dispatch = (0, _hooks.useTypedDispatch)();
|
|
54
|
-
const postmanRequest = (0, _buildPostmanRequest.default)(postman, {
|
|
55
|
-
queryParams,
|
|
56
|
-
pathParams,
|
|
57
|
-
cookieParams,
|
|
58
|
-
contentType,
|
|
59
|
-
accept,
|
|
60
|
-
headerParams,
|
|
61
|
-
body,
|
|
62
|
-
server,
|
|
63
|
-
auth
|
|
64
|
-
});
|
|
65
|
-
return <button className="button button--block button--primary" style={{
|
|
66
|
-
height: "48px",
|
|
67
|
-
marginBottom: "var(--ifm-spacing-vertical)"
|
|
68
|
-
}} disabled={!isValidRequest} onClick={async () => {
|
|
69
|
-
dispatch((0, _slice.setResponse)("loading..."));
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const res = await (0, _makeRequest.default)(postmanRequest, proxy, body);
|
|
73
|
-
dispatch((0, _slice.setResponse)(res));
|
|
74
|
-
} catch (e) {
|
|
75
|
-
var _e$message;
|
|
76
|
-
|
|
77
|
-
dispatch((0, _slice.setResponse)((_e$message = e.message) !== null && _e$message !== void 0 ? _e$message : "Error fetching."));
|
|
78
|
-
}
|
|
79
|
-
}}>
|
|
80
|
-
Execute
|
|
81
|
-
</button>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
var _default = Execute;
|
|
85
|
-
exports.default = _default;
|