docusaurus-theme-openapi-docs 1.1.2 → 1.1.3
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 +85 -20
- package/lib/theme/ApiItem/Layout/styles.module.css +12 -0
- package/lib/theme/ApiLogo/index.js +29 -0
- package/lib/theme/DiscriminatorTabs/index.js +263 -0
- package/lib/theme/DiscriminatorTabs/styles.module.css +111 -0
- package/lib/theme/ResponseSamples/index.js +27 -0
- package/lib/theme/ResponseSamples/styles.module.css +7 -0
- package/lib/theme/SchemaTabs/styles.module.css +0 -8
- package/lib-next/markdown/schema.js +88 -22
- package/lib-next/theme/ApiItem/Layout/styles.module.css +12 -0
- package/lib-next/theme/ApiLogo/index.js +21 -0
- package/lib-next/theme/DiscriminatorTabs/index.js +263 -0
- package/lib-next/theme/DiscriminatorTabs/styles.module.css +111 -0
- package/lib-next/theme/ResponseSamples/index.js +27 -0
- package/lib-next/theme/ResponseSamples/styles.module.css +7 -0
- package/lib-next/theme/SchemaTabs/styles.module.css +0 -8
- package/package.json +6 -6
- package/src/markdown/schema.ts +86 -20
- package/src/theme/ApiItem/Layout/styles.module.css +12 -0
- package/src/theme/ApiLogo/index.tsx +25 -0
- package/src/theme/DiscriminatorTabs/index.js +263 -0
- package/src/theme/DiscriminatorTabs/styles.module.css +111 -0
- package/src/theme/ResponseSamples/index.js +27 -0
- package/src/theme/ResponseSamples/styles.module.css +7 -0
- package/src/theme/SchemaTabs/styles.module.css +0 -8
|
@@ -5,22 +5,35 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
function prettyName(schema, circular) {
|
|
8
|
-
if (schema.$ref) {
|
|
9
|
-
return schema.$ref.replace("#/components/schemas/", "") + circular
|
|
10
|
-
? " (circular)"
|
|
11
|
-
: "";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
8
|
if (schema.format) {
|
|
15
9
|
return schema.format;
|
|
16
10
|
}
|
|
17
11
|
|
|
18
12
|
if (schema.allOf) {
|
|
13
|
+
if (typeof schema.allOf[0] === "string") {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
if (schema.allOf[0].includes("circular")) {
|
|
16
|
+
return schema.allOf[0];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return "object";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (schema.oneOf) {
|
|
24
|
+
return "object";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (schema.anyOf) {
|
|
19
28
|
return "object";
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
if (schema.type === "object") {
|
|
23
|
-
return schema.xml?.name ?? schema.type;
|
|
32
|
+
return schema.xml?.name ?? schema.type; // return schema.type;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (schema.type === "array") {
|
|
36
|
+
return schema.xml?.name ?? schema.type; // return schema.type;
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
return schema.title ?? schema.type;
|
|
@@ -35,8 +48,6 @@ export function getSchemaName(schema, circular) {
|
|
|
35
48
|
}
|
|
36
49
|
export function getQualifierMessage(schema) {
|
|
37
50
|
// TODO:
|
|
38
|
-
// - maxItems
|
|
39
|
-
// - minItems
|
|
40
51
|
// - uniqueItems
|
|
41
52
|
// - maxProperties
|
|
42
53
|
// - minProperties
|
|
@@ -45,24 +56,52 @@ export function getQualifierMessage(schema) {
|
|
|
45
56
|
return undefined;
|
|
46
57
|
}
|
|
47
58
|
|
|
48
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
schema.items &&
|
|
61
|
+
schema.minItems === undefined &&
|
|
62
|
+
schema.maxItems === undefined
|
|
63
|
+
) {
|
|
49
64
|
return getQualifierMessage(schema.items);
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
let message = "**Possible values:** ";
|
|
53
68
|
let qualifierGroups = [];
|
|
54
69
|
|
|
70
|
+
if (schema.items && schema.items.enum) {
|
|
71
|
+
if (schema.items.enum) {
|
|
72
|
+
qualifierGroups.push(
|
|
73
|
+
`[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
55
78
|
if (schema.minLength || schema.maxLength) {
|
|
56
79
|
let lengthQualifier = "";
|
|
80
|
+
let minLength;
|
|
81
|
+
let maxLength;
|
|
57
82
|
|
|
58
|
-
if (schema.minLength) {
|
|
59
|
-
|
|
83
|
+
if (schema.minLength && schema.minLength > 1) {
|
|
84
|
+
minLength = `\`>= ${schema.minLength} characters\``;
|
|
60
85
|
}
|
|
61
86
|
|
|
62
|
-
|
|
87
|
+
if (schema.minLength && schema.minLength === 1) {
|
|
88
|
+
minLength = `\`non-empty\``;
|
|
89
|
+
}
|
|
63
90
|
|
|
64
91
|
if (schema.maxLength) {
|
|
65
|
-
|
|
92
|
+
maxLength = `\`<= ${schema.maxLength} characters\``;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (minLength && !maxLength) {
|
|
96
|
+
lengthQualifier += minLength;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (maxLength && !minLength) {
|
|
100
|
+
lengthQualifier += maxLength;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (minLength && maxLength) {
|
|
104
|
+
lengthQualifier += `${minLength} and ${maxLength}`;
|
|
66
105
|
}
|
|
67
106
|
|
|
68
107
|
qualifierGroups.push(lengthQualifier);
|
|
@@ -75,23 +114,35 @@ export function getQualifierMessage(schema) {
|
|
|
75
114
|
typeof schema.exclusiveMaximum === "number"
|
|
76
115
|
) {
|
|
77
116
|
let minmaxQualifier = "";
|
|
117
|
+
let minimum;
|
|
118
|
+
let maximum;
|
|
78
119
|
|
|
79
120
|
if (typeof schema.exclusiveMinimum === "number") {
|
|
80
|
-
|
|
121
|
+
minimum = `\`> ${schema.exclusiveMinimum}\``;
|
|
81
122
|
} else if (schema.minimum && !schema.exclusiveMinimum) {
|
|
82
|
-
|
|
123
|
+
minimum = `\`>= ${schema.minimum}\``;
|
|
83
124
|
} else if (schema.minimum && schema.exclusiveMinimum === true) {
|
|
84
|
-
|
|
125
|
+
minimum = `\`> ${schema.minimum}\``;
|
|
85
126
|
}
|
|
86
127
|
|
|
87
|
-
minmaxQualifier += "value";
|
|
88
|
-
|
|
89
128
|
if (typeof schema.exclusiveMaximum === "number") {
|
|
90
|
-
|
|
129
|
+
maximum = `\`< ${schema.exclusiveMaximum}\``;
|
|
91
130
|
} else if (schema.maximum && !schema.exclusiveMaximum) {
|
|
92
|
-
|
|
131
|
+
maximum = `\`<= ${schema.maximum}\``;
|
|
93
132
|
} else if (schema.maximum && schema.exclusiveMaximum === true) {
|
|
94
|
-
|
|
133
|
+
maximum = `\`< ${schema.maximum}\``;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (minimum && !maximum) {
|
|
137
|
+
minmaxQualifier += minimum;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (maximum && !minimum) {
|
|
141
|
+
minmaxQualifier += maximum;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (minimum && maximum) {
|
|
145
|
+
minmaxQualifier += `${minimum} and ${maximum}`;
|
|
95
146
|
}
|
|
96
147
|
|
|
97
148
|
qualifierGroups.push(minmaxQualifier);
|
|
@@ -101,12 +152,27 @@ export function getQualifierMessage(schema) {
|
|
|
101
152
|
qualifierGroups.push(
|
|
102
153
|
`Value must match regular expression \`${schema.pattern}\``
|
|
103
154
|
);
|
|
155
|
+
} // Check if discriminator mapping
|
|
156
|
+
|
|
157
|
+
const discriminator = schema;
|
|
158
|
+
|
|
159
|
+
if (discriminator.mapping) {
|
|
160
|
+
const values = Object.keys(discriminator.mapping);
|
|
161
|
+
qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
|
|
104
162
|
}
|
|
105
163
|
|
|
106
164
|
if (schema.enum) {
|
|
107
165
|
qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
108
166
|
}
|
|
109
167
|
|
|
168
|
+
if (schema.minItems) {
|
|
169
|
+
qualifierGroups.push(`\`>= ${schema.minItems}\``);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (schema.maxItems) {
|
|
173
|
+
qualifierGroups.push(`\`<= ${schema.maxItems}\``);
|
|
174
|
+
}
|
|
175
|
+
|
|
110
176
|
if (qualifierGroups.length === 0) {
|
|
111
177
|
return undefined;
|
|
112
178
|
}
|
|
@@ -126,6 +126,18 @@
|
|
|
126
126
|
border-left: thin solid var(--ifm-color-gray-500) !important;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
:global(.discriminatorItem) {
|
|
130
|
+
list-style: none;
|
|
131
|
+
position: relative;
|
|
132
|
+
margin: 0 !important;
|
|
133
|
+
padding: 5px 0 5px 0 !important;
|
|
134
|
+
border-left: thin solid var(--ifm-color-gray-500) !important;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
:global(.discriminatorTabsContainer) {
|
|
138
|
+
padding-left: 0 !important;
|
|
139
|
+
}
|
|
140
|
+
|
|
129
141
|
:global(.schemaItem:hover) {
|
|
130
142
|
background-color: var(--ifm-menu-color-background-active);
|
|
131
143
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { useColorMode } from "@docusaurus/theme-common";
|
|
9
|
+
export default function ApiLogo(props) {
|
|
10
|
+
const { colorMode } = useColorMode();
|
|
11
|
+
const { logo, darkLogo } = props;
|
|
12
|
+
return logo ? (
|
|
13
|
+
<img
|
|
14
|
+
alt={colorMode === "dark" && darkLogo ? darkLogo.altText : logo.altText}
|
|
15
|
+
src={colorMode === "dark" && darkLogo ? darkLogo.url : logo.url}
|
|
16
|
+
width="250px"
|
|
17
|
+
/>
|
|
18
|
+
) : (
|
|
19
|
+
<div />
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React, {
|
|
9
|
+
Children,
|
|
10
|
+
cloneElement,
|
|
11
|
+
isValidElement,
|
|
12
|
+
useEffect,
|
|
13
|
+
useRef,
|
|
14
|
+
useState,
|
|
15
|
+
} from "react";
|
|
16
|
+
|
|
17
|
+
import { duplicates } from "@docusaurus/theme-common";
|
|
18
|
+
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
19
|
+
import clsx from "clsx";
|
|
20
|
+
|
|
21
|
+
import styles from "./styles.module.css"; // A very rough duck type, but good enough to guard against mistakes while
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
useScrollPositionBlocker,
|
|
25
|
+
useTabGroupChoice,
|
|
26
|
+
} = require("@docusaurus/theme-common/internal");
|
|
27
|
+
|
|
28
|
+
// allowing customization
|
|
29
|
+
|
|
30
|
+
function isTabItem(comp) {
|
|
31
|
+
return typeof comp.props.value !== "undefined";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function DiscriminatorTabsComponent(props) {
|
|
35
|
+
const {
|
|
36
|
+
lazy,
|
|
37
|
+
block,
|
|
38
|
+
defaultValue: defaultValueProp,
|
|
39
|
+
values: valuesProp,
|
|
40
|
+
groupId,
|
|
41
|
+
className,
|
|
42
|
+
} = props;
|
|
43
|
+
const children = Children.map(props.children, (child) => {
|
|
44
|
+
if (isValidElement(child) && isTabItem(child)) {
|
|
45
|
+
return child;
|
|
46
|
+
} // child.type.name will give non-sensical values in prod because of
|
|
47
|
+
// minification, but we assume it won't throw in prod.
|
|
48
|
+
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Docusaurus error: Bad <Tabs> child <${
|
|
51
|
+
// @ts-expect-error: guarding against unexpected cases
|
|
52
|
+
typeof child.type === "string" ? child.type : child.type.name
|
|
53
|
+
}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
const values =
|
|
57
|
+
valuesProp ?? // We only pick keys that we recognize. MDX would inject some keys by default
|
|
58
|
+
children.map(({ props: { value, label, attributes } }) => ({
|
|
59
|
+
value,
|
|
60
|
+
label,
|
|
61
|
+
attributes,
|
|
62
|
+
}));
|
|
63
|
+
const dup = duplicates(values, (a, b) => a.value === b.value);
|
|
64
|
+
|
|
65
|
+
if (dup.length > 0) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`Docusaurus error: Duplicate values "${dup
|
|
68
|
+
.map((a) => a.value)
|
|
69
|
+
.join(", ")}" found in <Tabs>. Every value needs to be unique.`
|
|
70
|
+
);
|
|
71
|
+
} // When defaultValueProp is null, don't show a default tab
|
|
72
|
+
|
|
73
|
+
const defaultValue =
|
|
74
|
+
defaultValueProp === null
|
|
75
|
+
? defaultValueProp
|
|
76
|
+
: defaultValueProp ??
|
|
77
|
+
children.find((child) => child.props.default)?.props.value ??
|
|
78
|
+
children[0]?.props.value;
|
|
79
|
+
|
|
80
|
+
if (defaultValue !== null && !values.some((a) => a.value === defaultValue)) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Docusaurus error: The <Tabs> has a defaultValue "${defaultValue}" but none of its children has the corresponding value. Available values are: ${values
|
|
83
|
+
.map((a) => a.value)
|
|
84
|
+
.join(
|
|
85
|
+
", "
|
|
86
|
+
)}. If you intend to show no default tab, use defaultValue={null} instead.`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const { tabGroupChoices, setTabGroupChoices } = useTabGroupChoice();
|
|
91
|
+
const [selectedValue, setSelectedValue] = useState(defaultValue);
|
|
92
|
+
const tabRefs = [];
|
|
93
|
+
const { blockElementScrollPositionUntilNextRender } =
|
|
94
|
+
useScrollPositionBlocker();
|
|
95
|
+
|
|
96
|
+
if (groupId != null) {
|
|
97
|
+
const relevantTabGroupChoice = tabGroupChoices[groupId];
|
|
98
|
+
|
|
99
|
+
if (
|
|
100
|
+
relevantTabGroupChoice != null &&
|
|
101
|
+
relevantTabGroupChoice !== selectedValue &&
|
|
102
|
+
values.some((value) => value.value === relevantTabGroupChoice)
|
|
103
|
+
) {
|
|
104
|
+
setSelectedValue(relevantTabGroupChoice);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const handleTabChange = (event) => {
|
|
109
|
+
const newTab = event.currentTarget;
|
|
110
|
+
const newTabIndex = tabRefs.indexOf(newTab);
|
|
111
|
+
const newTabValue = values[newTabIndex].value;
|
|
112
|
+
|
|
113
|
+
if (newTabValue !== selectedValue) {
|
|
114
|
+
blockElementScrollPositionUntilNextRender(newTab);
|
|
115
|
+
setSelectedValue(newTabValue);
|
|
116
|
+
|
|
117
|
+
if (groupId != null) {
|
|
118
|
+
setTabGroupChoices(groupId, newTabValue);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const handleKeydown = (event) => {
|
|
124
|
+
let focusElement = null;
|
|
125
|
+
|
|
126
|
+
switch (event.key) {
|
|
127
|
+
case "ArrowRight": {
|
|
128
|
+
const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
|
|
129
|
+
focusElement = tabRefs[nextTab] || tabRefs[0];
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
case "ArrowLeft": {
|
|
134
|
+
const prevTab = tabRefs.indexOf(event.currentTarget) - 1;
|
|
135
|
+
focusElement = tabRefs[prevTab] || tabRefs[tabRefs.length - 1];
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
default:
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
focusElement?.focus();
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const tabItemListContainerRef = useRef(null);
|
|
147
|
+
const [showTabArrows, setShowTabArrows] = useState(false);
|
|
148
|
+
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
const tabOffsetWidth = tabItemListContainerRef.current.offsetWidth;
|
|
151
|
+
const tabScrollWidth = tabItemListContainerRef.current.scrollWidth;
|
|
152
|
+
|
|
153
|
+
if (tabOffsetWidth < tabScrollWidth) {
|
|
154
|
+
setShowTabArrows(true);
|
|
155
|
+
}
|
|
156
|
+
}, []);
|
|
157
|
+
|
|
158
|
+
const handleRightClick = () => {
|
|
159
|
+
tabItemListContainerRef.current.scrollLeft += 90;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const handleLeftClick = () => {
|
|
163
|
+
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div className="tabs__container">
|
|
168
|
+
<div className={styles.discriminatorTabsTopSection}>
|
|
169
|
+
<div className={clsx(styles.discriminatorTabsContainer)}>
|
|
170
|
+
{showTabArrows && (
|
|
171
|
+
<button
|
|
172
|
+
className={clsx(styles.tabArrow, styles.tabArrowLeft)}
|
|
173
|
+
onClick={handleLeftClick}
|
|
174
|
+
/>
|
|
175
|
+
)}
|
|
176
|
+
<ul
|
|
177
|
+
ref={tabItemListContainerRef}
|
|
178
|
+
role="tablist"
|
|
179
|
+
aria-orientation="horizontal"
|
|
180
|
+
className={clsx(
|
|
181
|
+
styles.discriminatorTabsListContainer,
|
|
182
|
+
"tabs",
|
|
183
|
+
{
|
|
184
|
+
"tabs--block": block,
|
|
185
|
+
},
|
|
186
|
+
className
|
|
187
|
+
)}
|
|
188
|
+
>
|
|
189
|
+
{values.map(({ value, label, attributes }) => {
|
|
190
|
+
return (
|
|
191
|
+
<li
|
|
192
|
+
role="tab"
|
|
193
|
+
tabIndex={selectedValue === value ? 0 : -1}
|
|
194
|
+
aria-selected={selectedValue === value}
|
|
195
|
+
key={value}
|
|
196
|
+
ref={(tabControl) => tabRefs.push(tabControl)}
|
|
197
|
+
onKeyDown={handleKeydown}
|
|
198
|
+
onFocus={handleTabChange}
|
|
199
|
+
onClick={handleTabChange}
|
|
200
|
+
{...attributes}
|
|
201
|
+
className={clsx(
|
|
202
|
+
"tabs__item",
|
|
203
|
+
styles.tabItem,
|
|
204
|
+
attributes?.className,
|
|
205
|
+
{
|
|
206
|
+
[styles.discriminatorTabActive]: selectedValue === value,
|
|
207
|
+
}
|
|
208
|
+
)}
|
|
209
|
+
>
|
|
210
|
+
<span className={styles.discriminatorTabLabel}>
|
|
211
|
+
{label ?? value}
|
|
212
|
+
</span>
|
|
213
|
+
</li>
|
|
214
|
+
);
|
|
215
|
+
})}
|
|
216
|
+
</ul>
|
|
217
|
+
{showTabArrows && (
|
|
218
|
+
<button
|
|
219
|
+
className={clsx(styles.tabArrow, styles.tabArrowRight)}
|
|
220
|
+
onClick={handleRightClick}
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
<hr />
|
|
226
|
+
{lazy ? (
|
|
227
|
+
cloneElement(
|
|
228
|
+
children.filter(
|
|
229
|
+
(tabItem) => tabItem.props.value === selectedValue
|
|
230
|
+
)[0],
|
|
231
|
+
{
|
|
232
|
+
className: clsx(
|
|
233
|
+
"margin-vert--md",
|
|
234
|
+
styles.discriminatorTabsContainer
|
|
235
|
+
),
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
) : (
|
|
239
|
+
<div
|
|
240
|
+
className={clsx("margin-vert--md", styles.discriminatorTabsContainer)}
|
|
241
|
+
>
|
|
242
|
+
{children.map((tabItem, i) =>
|
|
243
|
+
cloneElement(tabItem, {
|
|
244
|
+
key: i,
|
|
245
|
+
hidden: tabItem.props.value !== selectedValue,
|
|
246
|
+
})
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
249
|
+
)}
|
|
250
|
+
</div>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export default function DiscriminatorTabs(props) {
|
|
255
|
+
const isBrowser = useIsBrowser();
|
|
256
|
+
return (
|
|
257
|
+
<DiscriminatorTabsComponent // Remount tabs after hydration
|
|
258
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
259
|
+
key={String(isBrowser)}
|
|
260
|
+
{...props}
|
|
261
|
+
/>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
.tabItem {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
height: 1.8rem;
|
|
13
|
+
margin-top: 0 !important;
|
|
14
|
+
margin-right: 0.5rem;
|
|
15
|
+
border: 1px solid var(--openapi-code-dim-dark);
|
|
16
|
+
border-radius: var(--ifm-global-radius);
|
|
17
|
+
color: var(--openapi-code-dim-dark);
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tabItem:hover {
|
|
22
|
+
color: var(--ifm-color-emphasis-500) !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.tabItem:last-child {
|
|
26
|
+
margin-right: 0 !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Open API Schema Tabs */
|
|
30
|
+
.discriminatorTabsTopSection {
|
|
31
|
+
margin-top: 1rem;
|
|
32
|
+
margin-left: 0.9rem;
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: space-between;
|
|
35
|
+
align-items: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.discriminatorTabsTopSection + hr {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.discriminatorTabsContainer {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
max-width: 390px;
|
|
46
|
+
padding-left: 3px;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.discriminatorTabsListContainer {
|
|
51
|
+
padding: 0 0.25rem;
|
|
52
|
+
overflow-y: hidden;
|
|
53
|
+
overflow-x: scroll;
|
|
54
|
+
scroll-behavior: smooth;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.discriminatorTabsListContainer::-webkit-scrollbar {
|
|
58
|
+
display: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.tabItem.discriminatorTabActive {
|
|
62
|
+
border: 1px solid var(--ifm-color-primary);
|
|
63
|
+
color: var(--ifm-color-primary);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.discriminatorTabLabel {
|
|
67
|
+
white-space: nowrap;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.discriminatorTabsContainer {
|
|
71
|
+
max-width: 600px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Tab Arrows */
|
|
75
|
+
.tabArrow {
|
|
76
|
+
content: "";
|
|
77
|
+
height: 1.25rem;
|
|
78
|
+
width: 1.25rem;
|
|
79
|
+
padding: 0 0.75rem;
|
|
80
|
+
border: none;
|
|
81
|
+
min-width: 1.25rem;
|
|
82
|
+
background: var(--ifm-menu-link-sublist-icon) 50% / 2rem 2rem;
|
|
83
|
+
filter: var(--ifm-menu-link-sublist-icon-filter);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.tabArrow:hover {
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.tabArrowLeft {
|
|
91
|
+
transform: rotate(270deg);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.tabArrowRight {
|
|
95
|
+
transform: rotate(90deg);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@media screen and (max-width: 500px) {
|
|
99
|
+
.discriminatorTabsTopSection {
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
align-items: flex-start;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.discriminatorTabsContainer {
|
|
105
|
+
width: 100%;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.tabItem {
|
|
109
|
+
height: 100%;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import CodeBlock from "@theme/CodeBlock";
|
|
11
|
+
|
|
12
|
+
import styles from "./styles.module.css";
|
|
13
|
+
|
|
14
|
+
function ResponseSamples({ responseExample }) {
|
|
15
|
+
return (
|
|
16
|
+
<div className={styles.responseSamplesContainer}>
|
|
17
|
+
<CodeBlock
|
|
18
|
+
language="javascript"
|
|
19
|
+
className={styles.responseSamplesCodeBlock}
|
|
20
|
+
>
|
|
21
|
+
{responseExample}
|
|
22
|
+
</CodeBlock>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default ResponseSamples;
|
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.1.
|
|
4
|
+
"version": "1.1.3",
|
|
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.
|
|
35
|
-
"@docusaurus/types": "2.0.
|
|
34
|
+
"@docusaurus/module-type-aliases": "2.0.1",
|
|
35
|
+
"@docusaurus/types": "2.0.1",
|
|
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.
|
|
45
|
+
"@docusaurus/theme-common": "2.0.1",
|
|
46
46
|
"@mdx-js/react": "^1.6.21",
|
|
47
47
|
"@paloaltonetworks/postman-code-generators": "1.1.5-hotfix.5",
|
|
48
48
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"buffer": "^6.0.3",
|
|
51
51
|
"clsx": "^1.1.1",
|
|
52
52
|
"crypto-js": "^4.1.1",
|
|
53
|
-
"docusaurus-plugin-openapi-docs": "^1.1.
|
|
53
|
+
"docusaurus-plugin-openapi-docs": "^1.1.3",
|
|
54
54
|
"immer": "^9.0.7",
|
|
55
55
|
"lodash": "^4.17.20",
|
|
56
56
|
"process": "^0.11.10",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "4897267289b035aed8155f6001e14c80ba9003a8"
|
|
72
72
|
}
|