docusaurus-theme-openapi-docs 1.4.7 → 1.5.1
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/MethodEndpoint/index.js +2 -0
- package/lib/theme/ApiDemoPanel/Request/index.js +6 -7
- package/lib/theme/ApiItem/index.js +14 -5
- package/lib/theme/SchemaItem/index.js +8 -2
- package/lib/theme/SchemaItem/styles.module.css +9 -0
- package/lib/theme/styles.css +1 -0
- package/lib-next/theme/ApiDemoPanel/MethodEndpoint/index.js +2 -0
- package/lib-next/theme/ApiDemoPanel/Request/index.js +4 -7
- package/lib-next/theme/ApiItem/index.js +11 -7
- package/lib-next/theme/SchemaItem/index.js +8 -2
- package/lib-next/theme/SchemaItem/styles.module.css +9 -0
- package/lib-next/theme/styles.css +1 -0
- package/package.json +3 -3
- package/src/theme/ApiDemoPanel/MethodEndpoint/index.tsx +2 -0
- package/src/theme/ApiDemoPanel/Request/index.tsx +4 -8
- package/src/theme/ApiItem/index.tsx +12 -7
- package/src/theme/SchemaItem/index.js +8 -2
- package/src/theme/SchemaItem/styles.module.css +9 -0
- package/src/theme/styles.css +1 -0
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _internal = require("@docusaurus/theme-common/internal");
|
|
9
9
|
var _postmanCollection = _interopRequireDefault(require("@paloaltonetworks/postman-collection"));
|
|
10
10
|
var _Accept = _interopRequireDefault(require("@theme/ApiDemoPanel/Accept"));
|
|
11
11
|
var _Authorization = _interopRequireDefault(require("@theme/ApiDemoPanel/Authorization"));
|
|
@@ -28,12 +28,11 @@ function Request({
|
|
|
28
28
|
}) {
|
|
29
29
|
var _item$parameters;
|
|
30
30
|
const response = (0, _hooks.useTypedSelector)(state => state.response.value);
|
|
31
|
-
const {
|
|
32
|
-
siteConfig
|
|
33
|
-
} = (0, _useDocusaurusContext.default)();
|
|
34
|
-
const themeConfig = siteConfig.themeConfig;
|
|
35
|
-
const options = themeConfig.api;
|
|
36
31
|
const postman = new _postmanCollection.default.Request(item.postman);
|
|
32
|
+
const metadata = (0, _internal.useDoc)();
|
|
33
|
+
const {
|
|
34
|
+
proxy
|
|
35
|
+
} = metadata.frontMatter;
|
|
37
36
|
const params = {
|
|
38
37
|
path: [],
|
|
39
38
|
query: [],
|
|
@@ -50,7 +49,7 @@ function Request({
|
|
|
50
49
|
<summary>
|
|
51
50
|
<div className={`details__request-summary`}>
|
|
52
51
|
<h4>Request</h4>
|
|
53
|
-
{item.servers && <_Execute.default postman={postman} proxy={
|
|
52
|
+
{item.servers && <_Execute.default postman={postman} proxy={proxy} />}
|
|
54
53
|
</div>
|
|
55
54
|
</summary>
|
|
56
55
|
<div className={_stylesModule.default.optionsPanel}>
|
|
@@ -51,6 +51,9 @@ function ApiItem(props) {
|
|
|
51
51
|
const options = themeConfig.api;
|
|
52
52
|
const isBrowser = (0, _useIsBrowser.default)();
|
|
53
53
|
|
|
54
|
+
// Regex for 2XX status
|
|
55
|
+
const statusRegex = new RegExp("(20[0-9]|2[1-9][0-9])");
|
|
56
|
+
|
|
54
57
|
// Define store2
|
|
55
58
|
let store2 = {};
|
|
56
59
|
const persistanceMiddleware = (0, _persistanceMiddleware.createPersistanceMiddleware)(options);
|
|
@@ -62,11 +65,17 @@ function ApiItem(props) {
|
|
|
62
65
|
|
|
63
66
|
// Init store for CSR to hydrate components
|
|
64
67
|
if (isBrowser) {
|
|
65
|
-
var _api$
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
var _api$requestBody$cont, _api$requestBody, _api$servers, _api$parameters, _window, _ref;
|
|
69
|
+
// Create list of only 2XX response content types to create request samples from
|
|
70
|
+
let acceptArray = [];
|
|
71
|
+
for (const [code, content] of Object.entries((_api$responses = api === null || api === void 0 ? void 0 : api.responses) !== null && _api$responses !== void 0 ? _api$responses : [])) {
|
|
72
|
+
var _api$responses;
|
|
73
|
+
if (statusRegex.test(code)) {
|
|
74
|
+
var _content$content;
|
|
75
|
+
acceptArray.push(Object.keys((_content$content = content.content) !== null && _content$content !== void 0 ? _content$content : {}));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
acceptArray = acceptArray.flat();
|
|
70
79
|
const content = (_api$requestBody$cont = api === null || api === void 0 ? void 0 : (_api$requestBody = api.requestBody) === null || _api$requestBody === void 0 ? void 0 : _api$requestBody.content) !== null && _api$requestBody$cont !== void 0 ? _api$requestBody$cont : {};
|
|
71
80
|
const contentTypeArray = Object.keys(content);
|
|
72
81
|
const servers = (_api$servers = api === null || api === void 0 ? void 0 : api.servers) !== null && _api$servers !== void 0 ? _api$servers : [];
|
|
@@ -23,6 +23,7 @@ function SchemaItem({
|
|
|
23
23
|
name,
|
|
24
24
|
qualifierMessage,
|
|
25
25
|
required,
|
|
26
|
+
deprecated,
|
|
26
27
|
schemaDescription,
|
|
27
28
|
schemaName,
|
|
28
29
|
defaultValue,
|
|
@@ -32,6 +33,10 @@ function SchemaItem({
|
|
|
32
33
|
() => <strong className={styles.required}> required</strong>
|
|
33
34
|
);
|
|
34
35
|
|
|
36
|
+
const renderDeprecated = guard(deprecated, () => (
|
|
37
|
+
<strong className={styles.deprecated}> deprecated</strong>
|
|
38
|
+
));
|
|
39
|
+
|
|
35
40
|
const renderSchemaDescription = guard(schemaDescription, (description) => (
|
|
36
41
|
<div>
|
|
37
42
|
<ReactMarkdown
|
|
@@ -73,9 +78,10 @@ function SchemaItem({
|
|
|
73
78
|
|
|
74
79
|
const schemaContent = (
|
|
75
80
|
<div>
|
|
76
|
-
<strong>{name}</strong>
|
|
81
|
+
<strong className={deprecated && styles.strikethrough}>{name}</strong>
|
|
77
82
|
<span className={styles.schemaName}> {schemaName}</span>
|
|
78
|
-
{renderRequired}
|
|
83
|
+
{!deprecated && renderRequired}
|
|
84
|
+
{renderDeprecated}
|
|
79
85
|
{renderQualifierMessage}
|
|
80
86
|
{renderDefaultValue}
|
|
81
87
|
{renderSchemaDescription}
|
package/lib/theme/styles.css
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
|
-
import
|
|
9
|
+
import { useDoc } from "@docusaurus/theme-common/internal";
|
|
10
10
|
import sdk from "@paloaltonetworks/postman-collection";
|
|
11
11
|
import Accept from "@theme/ApiDemoPanel/Accept";
|
|
12
12
|
import Authorization from "@theme/ApiDemoPanel/Authorization";
|
|
@@ -18,10 +18,9 @@ import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
|
18
18
|
import styles from "./styles.module.css";
|
|
19
19
|
function Request({ item }) {
|
|
20
20
|
const response = useTypedSelector((state) => state.response.value);
|
|
21
|
-
const { siteConfig } = useDocusaurusContext();
|
|
22
|
-
const themeConfig = siteConfig.themeConfig;
|
|
23
|
-
const options = themeConfig.api;
|
|
24
21
|
const postman = new sdk.Request(item.postman);
|
|
22
|
+
const metadata = useDoc();
|
|
23
|
+
const { proxy } = metadata.frontMatter;
|
|
25
24
|
const params = {
|
|
26
25
|
path: [],
|
|
27
26
|
query: [],
|
|
@@ -39,9 +38,7 @@ function Request({ item }) {
|
|
|
39
38
|
<summary>
|
|
40
39
|
<div className={`details__request-summary`}>
|
|
41
40
|
<h4>Request</h4>
|
|
42
|
-
{item.servers &&
|
|
43
|
-
<Execute postman={postman} proxy={options?.proxy} />
|
|
44
|
-
)}
|
|
41
|
+
{item.servers && <Execute postman={postman} proxy={proxy} />}
|
|
45
42
|
</div>
|
|
46
43
|
</summary>
|
|
47
44
|
<div className={styles.optionsPanel}>
|
|
@@ -34,6 +34,9 @@ export default function ApiItem(props) {
|
|
|
34
34
|
const options = themeConfig.api;
|
|
35
35
|
const isBrowser = useIsBrowser();
|
|
36
36
|
|
|
37
|
+
// Regex for 2XX status
|
|
38
|
+
const statusRegex = new RegExp("(20[0-9]|2[1-9][0-9])");
|
|
39
|
+
|
|
37
40
|
// Define store2
|
|
38
41
|
let store2 = {};
|
|
39
42
|
const persistanceMiddleware = createPersistanceMiddleware(options);
|
|
@@ -45,13 +48,14 @@ export default function ApiItem(props) {
|
|
|
45
48
|
|
|
46
49
|
// Init store for CSR to hydrate components
|
|
47
50
|
if (isBrowser) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
// Create list of only 2XX response content types to create request samples from
|
|
52
|
+
let acceptArray = [];
|
|
53
|
+
for (const [code, content] of Object.entries(api?.responses ?? [])) {
|
|
54
|
+
if (statusRegex.test(code)) {
|
|
55
|
+
acceptArray.push(Object.keys(content.content ?? {}));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
acceptArray = acceptArray.flat();
|
|
55
59
|
const content = api?.requestBody?.content ?? {};
|
|
56
60
|
const contentTypeArray = Object.keys(content);
|
|
57
61
|
const servers = api?.servers ?? [];
|
|
@@ -23,6 +23,7 @@ function SchemaItem({
|
|
|
23
23
|
name,
|
|
24
24
|
qualifierMessage,
|
|
25
25
|
required,
|
|
26
|
+
deprecated,
|
|
26
27
|
schemaDescription,
|
|
27
28
|
schemaName,
|
|
28
29
|
defaultValue,
|
|
@@ -32,6 +33,10 @@ function SchemaItem({
|
|
|
32
33
|
() => <strong className={styles.required}> required</strong>
|
|
33
34
|
);
|
|
34
35
|
|
|
36
|
+
const renderDeprecated = guard(deprecated, () => (
|
|
37
|
+
<strong className={styles.deprecated}> deprecated</strong>
|
|
38
|
+
));
|
|
39
|
+
|
|
35
40
|
const renderSchemaDescription = guard(schemaDescription, (description) => (
|
|
36
41
|
<div>
|
|
37
42
|
<ReactMarkdown
|
|
@@ -73,9 +78,10 @@ function SchemaItem({
|
|
|
73
78
|
|
|
74
79
|
const schemaContent = (
|
|
75
80
|
<div>
|
|
76
|
-
<strong>{name}</strong>
|
|
81
|
+
<strong className={deprecated && styles.strikethrough}>{name}</strong>
|
|
77
82
|
<span className={styles.schemaName}> {schemaName}</span>
|
|
78
|
-
{renderRequired}
|
|
83
|
+
{!deprecated && renderRequired}
|
|
84
|
+
{renderDeprecated}
|
|
79
85
|
{renderQualifierMessage}
|
|
80
86
|
{renderDefaultValue}
|
|
81
87
|
{renderSchemaDescription}
|
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": "1.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -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": "^1.
|
|
54
|
+
"docusaurus-plugin-openapi-docs": "^1.5.1",
|
|
55
55
|
"file-saver": "^2.0.5",
|
|
56
56
|
"immer": "^9.0.7",
|
|
57
57
|
"lodash": "^4.17.20",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"engines": {
|
|
74
74
|
"node": ">=14"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "11d2c2fdb2bc81048097b05bc65698777d54e456"
|
|
77
77
|
}
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
10
|
+
import { useDoc } from "@docusaurus/theme-common/internal";
|
|
12
11
|
import sdk from "@paloaltonetworks/postman-collection";
|
|
13
12
|
import Accept from "@theme/ApiDemoPanel/Accept";
|
|
14
13
|
import Authorization from "@theme/ApiDemoPanel/Authorization";
|
|
@@ -24,10 +23,9 @@ import styles from "./styles.module.css";
|
|
|
24
23
|
|
|
25
24
|
function Request({ item }: { item: NonNullable<ApiItem> }) {
|
|
26
25
|
const response = useTypedSelector((state: any) => state.response.value);
|
|
27
|
-
const { siteConfig } = useDocusaurusContext();
|
|
28
|
-
const themeConfig = siteConfig.themeConfig as ThemeConfig;
|
|
29
|
-
const options = themeConfig.api as ApiItem;
|
|
30
26
|
const postman = new sdk.Request(item.postman);
|
|
27
|
+
const metadata = useDoc();
|
|
28
|
+
const { proxy } = metadata.frontMatter;
|
|
31
29
|
|
|
32
30
|
const params = {
|
|
33
31
|
path: [] as ParameterObject[],
|
|
@@ -50,9 +48,7 @@ function Request({ item }: { item: NonNullable<ApiItem> }) {
|
|
|
50
48
|
<summary>
|
|
51
49
|
<div className={`details__request-summary`}>
|
|
52
50
|
<h4>Request</h4>
|
|
53
|
-
{item.servers &&
|
|
54
|
-
<Execute postman={postman} proxy={options?.proxy} />
|
|
55
|
-
)}
|
|
51
|
+
{item.servers && <Execute postman={postman} proxy={proxy} />}
|
|
56
52
|
</div>
|
|
57
53
|
</summary>
|
|
58
54
|
<div className={styles.optionsPanel}>
|
|
@@ -53,6 +53,9 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
53
53
|
const options = themeConfig.api;
|
|
54
54
|
const isBrowser = useIsBrowser();
|
|
55
55
|
|
|
56
|
+
// Regex for 2XX status
|
|
57
|
+
const statusRegex = new RegExp("(20[0-9]|2[1-9][0-9])");
|
|
58
|
+
|
|
56
59
|
// Define store2
|
|
57
60
|
let store2: any = {};
|
|
58
61
|
const persistanceMiddleware = createPersistanceMiddleware(options);
|
|
@@ -64,13 +67,15 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
64
67
|
|
|
65
68
|
// Init store for CSR to hydrate components
|
|
66
69
|
if (isBrowser) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
// Create list of only 2XX response content types to create request samples from
|
|
71
|
+
let acceptArray: any = [];
|
|
72
|
+
for (const [code, content] of Object.entries(api?.responses ?? [])) {
|
|
73
|
+
if (statusRegex.test(code)) {
|
|
74
|
+
acceptArray.push(Object.keys(content.content ?? {}));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
acceptArray = acceptArray.flat();
|
|
78
|
+
|
|
74
79
|
const content = api?.requestBody?.content ?? {};
|
|
75
80
|
const contentTypeArray = Object.keys(content);
|
|
76
81
|
const servers = api?.servers ?? [];
|
|
@@ -23,6 +23,7 @@ function SchemaItem({
|
|
|
23
23
|
name,
|
|
24
24
|
qualifierMessage,
|
|
25
25
|
required,
|
|
26
|
+
deprecated,
|
|
26
27
|
schemaDescription,
|
|
27
28
|
schemaName,
|
|
28
29
|
defaultValue,
|
|
@@ -32,6 +33,10 @@ function SchemaItem({
|
|
|
32
33
|
() => <strong className={styles.required}> required</strong>
|
|
33
34
|
);
|
|
34
35
|
|
|
36
|
+
const renderDeprecated = guard(deprecated, () => (
|
|
37
|
+
<strong className={styles.deprecated}> deprecated</strong>
|
|
38
|
+
));
|
|
39
|
+
|
|
35
40
|
const renderSchemaDescription = guard(schemaDescription, (description) => (
|
|
36
41
|
<div>
|
|
37
42
|
<ReactMarkdown
|
|
@@ -73,9 +78,10 @@ function SchemaItem({
|
|
|
73
78
|
|
|
74
79
|
const schemaContent = (
|
|
75
80
|
<div>
|
|
76
|
-
<strong>{name}</strong>
|
|
81
|
+
<strong className={deprecated && styles.strikethrough}>{name}</strong>
|
|
77
82
|
<span className={styles.schemaName}> {schemaName}</span>
|
|
78
|
-
{renderRequired}
|
|
83
|
+
{!deprecated && renderRequired}
|
|
84
|
+
{renderDeprecated}
|
|
79
85
|
{renderQualifierMessage}
|
|
80
86
|
{renderDefaultValue}
|
|
81
87
|
{renderSchemaDescription}
|
package/src/theme/styles.css
CHANGED