docusaurus-theme-openapi-docs 5.0.1 → 5.1.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 +38 -15
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +86 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +4 -2
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +9 -6
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +9 -10
- package/lib/theme/ApiExplorer/Body/index.js +4 -5
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +96 -61
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +12 -1
- package/lib/theme/ApiExplorer/CodeSnippets/languages.test.d.ts +1 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.test.js +102 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.js +6 -5
- package/lib/theme/ApiExplorer/Export/index.js +9 -2
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +1 -2
- package/lib/theme/ApiExplorer/FormLabel/index.js +1 -2
- package/lib/theme/ApiExplorer/FormTextInput/index.js +1 -2
- package/lib/theme/ApiExplorer/LiveEditor/index.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +5 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +75 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +67 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +65 -1
- package/lib/theme/ApiExplorer/ParamOptions/index.js +2 -3
- package/lib/theme/ApiExplorer/Request/index.js +17 -18
- package/lib/theme/ApiExplorer/Response/index.js +54 -12
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +57 -50
- package/lib/theme/ApiExplorer/Server/index.js +2 -3
- package/lib/theme/ApiItem/index.js +59 -33
- package/lib/theme/ApiTabs/index.d.ts +1 -1
- package/lib/theme/ApiTabs/index.js +7 -7
- package/lib/theme/DiscriminatorTabs/index.d.ts +1 -1
- package/lib/theme/DiscriminatorTabs/index.js +6 -5
- package/lib/theme/Example/index.js +3 -4
- package/lib/theme/MimeTabs/index.d.ts +1 -1
- package/lib/theme/MimeTabs/index.js +6 -5
- package/lib/theme/OperationTabs/index.d.ts +1 -1
- package/lib/theme/OperationTabs/index.js +6 -5
- package/lib/theme/ParamsDetails/index.js +1 -2
- package/lib/theme/ParamsItem/index.js +7 -8
- package/lib/theme/RequestSchema/index.js +57 -57
- package/lib/theme/ResponseExamples/index.js +3 -4
- package/lib/theme/ResponseSchema/index.js +26 -24
- package/lib/theme/Schema/index.js +148 -27
- package/lib/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/lib/theme/SchemaExpansion/context.d.ts +24 -0
- package/lib/theme/SchemaExpansion/context.js +187 -0
- package/lib/theme/SchemaExpansion/index.d.ts +4 -0
- package/lib/theme/SchemaExpansion/index.js +314 -0
- package/lib/theme/SchemaItem/index.js +9 -10
- package/lib/theme/SchemaTabs/index.d.ts +1 -1
- package/lib/theme/SchemaTabs/index.js +6 -5
- package/lib/theme/StatusCodes/index.js +2 -4
- package/lib/theme/TabItem/index.d.ts +5 -0
- package/lib/theme/TabItem/index.js +51 -0
- package/lib/theme/TabItem/styles.module.css +3 -0
- package/lib/theme/Tabs/index.d.ts +5 -0
- package/lib/theme/Tabs/index.js +148 -0
- package/lib/theme/Tabs/styles.module.css +7 -0
- package/lib/theme/styles.scss +1 -0
- package/lib/theme/translationIds.d.ts +1 -93
- package/lib/theme/translationIds.js +0 -109
- package/lib/theme/utils/codeBlockUtils.d.ts +28 -0
- package/lib/theme/utils/codeBlockUtils.js +223 -0
- package/lib/theme/utils/reactUtils.d.ts +1 -0
- package/lib/theme/utils/reactUtils.js +23 -0
- package/lib/theme/utils/scrollUtils.d.ts +7 -0
- package/lib/theme/utils/scrollUtils.js +175 -0
- package/lib/theme/utils/tabsUtils.d.ts +47 -0
- package/lib/theme/utils/tabsUtils.js +299 -0
- package/lib/theme/utils/useCodeWordWrap.d.ts +8 -0
- package/lib/theme/utils/useCodeWordWrap.js +84 -0
- package/lib/theme/utils/useMutationObserver.d.ts +3 -0
- package/lib/theme/utils/useMutationObserver.js +34 -0
- package/package.json +4 -4
- package/src/markdown/schema.test.ts +102 -0
- package/src/markdown/schema.ts +42 -15
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/index.tsx +2 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +8 -7
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/index.tsx +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/index.tsx +1 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +9 -10
- package/src/theme/ApiExplorer/Body/index.tsx +7 -5
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +103 -59
- package/src/theme/ApiExplorer/CodeSnippets/languages.test.ts +109 -0
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +13 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +5 -5
- package/src/theme/ApiExplorer/Export/index.tsx +6 -2
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +1 -2
- package/src/theme/ApiExplorer/FormLabel/index.tsx +1 -2
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +1 -2
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +5 -3
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +20 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +15 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +11 -1
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +2 -3
- package/src/theme/ApiExplorer/Request/index.tsx +23 -18
- package/src/theme/ApiExplorer/Response/index.tsx +63 -9
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +60 -52
- package/src/theme/ApiExplorer/Server/index.tsx +8 -3
- package/src/theme/ApiItem/index.tsx +43 -21
- package/src/theme/ApiTabs/index.tsx +8 -8
- package/src/theme/DiscriminatorTabs/index.tsx +6 -5
- package/src/theme/Example/index.tsx +3 -4
- package/src/theme/MimeTabs/index.tsx +9 -8
- package/src/theme/OperationTabs/index.tsx +5 -4
- package/src/theme/ParamsDetails/index.tsx +1 -2
- package/src/theme/ParamsItem/index.tsx +13 -8
- package/src/theme/RequestSchema/index.tsx +38 -40
- package/src/theme/ResponseExamples/index.tsx +3 -4
- package/src/theme/ResponseSchema/index.tsx +16 -17
- package/src/theme/Schema/index.tsx +156 -27
- package/src/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/src/theme/SchemaExpansion/context.tsx +154 -0
- package/src/theme/SchemaExpansion/index.tsx +236 -0
- package/src/theme/SchemaItem/index.tsx +18 -10
- package/src/theme/SchemaTabs/index.tsx +6 -5
- package/src/theme/StatusCodes/index.tsx +2 -3
- package/src/theme/TabItem/index.tsx +61 -0
- package/src/theme/TabItem/styles.module.css +3 -0
- package/src/theme/Tabs/index.tsx +164 -0
- package/src/theme/Tabs/styles.module.css +7 -0
- package/src/theme/styles.scss +1 -0
- package/src/theme/translationIds.ts +37 -106
- package/src/theme/utils/codeBlockUtils.ts +296 -0
- package/src/theme/utils/reactUtils.ts +22 -0
- package/src/theme/utils/scrollUtils.tsx +153 -0
- package/src/theme/utils/tabsUtils.tsx +329 -0
- package/src/theme/utils/useCodeWordWrap.ts +110 -0
- package/src/theme/utils/useMutationObserver.ts +43 -0
- package/src/theme-classic.d.ts +0 -96
- package/src/types.d.ts +27 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,187 @@
|
|
|
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.SchemaDepthProvider =
|
|
71
|
+
exports.SchemaExpansionProvider =
|
|
72
|
+
exports.SCHEMA_EXPANSION_STORAGE_KEY =
|
|
73
|
+
void 0;
|
|
74
|
+
exports.normalizeLevel = normalizeLevel;
|
|
75
|
+
exports.useSchemaExpansion = useSchemaExpansion;
|
|
76
|
+
exports.useSchemaDepth = useSchemaDepth;
|
|
77
|
+
const react_1 = __importStar(require("react"));
|
|
78
|
+
const useDocusaurusContext_1 = __importDefault(
|
|
79
|
+
require("@docusaurus/useDocusaurusContext")
|
|
80
|
+
);
|
|
81
|
+
exports.SCHEMA_EXPANSION_STORAGE_KEY =
|
|
82
|
+
"docusaurus-openapi-schema-expansion-level";
|
|
83
|
+
const DEFAULT_CONFIG = {
|
|
84
|
+
enabled: false,
|
|
85
|
+
defaultLevel: 0,
|
|
86
|
+
max: 4,
|
|
87
|
+
persist: true,
|
|
88
|
+
};
|
|
89
|
+
const SchemaExpansionContext = (0, react_1.createContext)({
|
|
90
|
+
config: DEFAULT_CONFIG,
|
|
91
|
+
level: 0,
|
|
92
|
+
setLevel: () => {},
|
|
93
|
+
});
|
|
94
|
+
const SchemaDepthContext = (0, react_1.createContext)(0);
|
|
95
|
+
function normalizeLevel(value) {
|
|
96
|
+
if (value === "all") return Infinity;
|
|
97
|
+
if (typeof value === "number" && Number.isFinite(value) && value >= 0) {
|
|
98
|
+
return Math.floor(value);
|
|
99
|
+
}
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
function readConfig(themeConfig) {
|
|
103
|
+
const raw = themeConfig?.api?.schemaExpansion;
|
|
104
|
+
if (!raw) return DEFAULT_CONFIG;
|
|
105
|
+
const enabled = raw.enabled ?? false;
|
|
106
|
+
return {
|
|
107
|
+
enabled,
|
|
108
|
+
defaultLevel: normalizeLevel(raw.default),
|
|
109
|
+
max: typeof raw.max === "number" && raw.max > 0 ? Math.floor(raw.max) : 4,
|
|
110
|
+
// Persistence only matters when the reader can change the level via the
|
|
111
|
+
// UI control. When the control is hidden, fall back to the configured
|
|
112
|
+
// default on every visit so it isn't shadowed by a stale localStorage
|
|
113
|
+
// value from a session where the control used to be enabled.
|
|
114
|
+
persist: enabled ? (raw.persist ?? true) : false,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function readPersistedLevel() {
|
|
118
|
+
if (typeof window === "undefined") return undefined;
|
|
119
|
+
try {
|
|
120
|
+
const stored = window.localStorage.getItem(
|
|
121
|
+
exports.SCHEMA_EXPANSION_STORAGE_KEY
|
|
122
|
+
);
|
|
123
|
+
if (stored === null) return undefined;
|
|
124
|
+
if (stored === "all") return Infinity;
|
|
125
|
+
const parsed = parseInt(stored, 10);
|
|
126
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;
|
|
127
|
+
} catch {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function writePersistedLevel(level) {
|
|
132
|
+
if (typeof window === "undefined") return;
|
|
133
|
+
try {
|
|
134
|
+
const value = level === Infinity ? "all" : String(level);
|
|
135
|
+
window.localStorage.setItem(exports.SCHEMA_EXPANSION_STORAGE_KEY, value);
|
|
136
|
+
} catch {
|
|
137
|
+
// ignore quota / disabled storage
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const SchemaExpansionProvider = ({ children }) => {
|
|
141
|
+
const { siteConfig } = (0, useDocusaurusContext_1.default)();
|
|
142
|
+
const themeConfig = siteConfig.themeConfig;
|
|
143
|
+
const config = (0, react_1.useMemo)(
|
|
144
|
+
() => readConfig(themeConfig),
|
|
145
|
+
[themeConfig]
|
|
146
|
+
);
|
|
147
|
+
const [level, setLevelState] = (0, react_1.useState)(config.defaultLevel);
|
|
148
|
+
(0, react_1.useEffect)(() => {
|
|
149
|
+
if (!config.persist) return;
|
|
150
|
+
const persisted = readPersistedLevel();
|
|
151
|
+
if (persisted !== undefined) {
|
|
152
|
+
setLevelState(persisted);
|
|
153
|
+
}
|
|
154
|
+
}, [config.persist]);
|
|
155
|
+
const setLevel = (0, react_1.useCallback)(
|
|
156
|
+
(next) => {
|
|
157
|
+
setLevelState(next);
|
|
158
|
+
if (config.persist) {
|
|
159
|
+
writePersistedLevel(next);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
[config.persist]
|
|
163
|
+
);
|
|
164
|
+
const value = (0, react_1.useMemo)(
|
|
165
|
+
() => ({ config, level, setLevel }),
|
|
166
|
+
[config, level, setLevel]
|
|
167
|
+
);
|
|
168
|
+
return react_1.default.createElement(
|
|
169
|
+
SchemaExpansionContext.Provider,
|
|
170
|
+
{ value: value },
|
|
171
|
+
children
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
exports.SchemaExpansionProvider = SchemaExpansionProvider;
|
|
175
|
+
const SchemaDepthProvider = ({ depth, children }) =>
|
|
176
|
+
react_1.default.createElement(
|
|
177
|
+
SchemaDepthContext.Provider,
|
|
178
|
+
{ value: depth },
|
|
179
|
+
children
|
|
180
|
+
);
|
|
181
|
+
exports.SchemaDepthProvider = SchemaDepthProvider;
|
|
182
|
+
function useSchemaExpansion() {
|
|
183
|
+
return (0, react_1.useContext)(SchemaExpansionContext);
|
|
184
|
+
}
|
|
185
|
+
function useSchemaDepth() {
|
|
186
|
+
return (0, react_1.useContext)(SchemaDepthContext);
|
|
187
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export { SchemaExpansionProvider, SchemaDepthProvider, useSchemaExpansion, useSchemaDepth, normalizeLevel, SCHEMA_EXPANSION_STORAGE_KEY, } from "./context";
|
|
3
|
+
declare const SchemaExpansionControl: React.FC;
|
|
4
|
+
export default SchemaExpansionControl;
|
|
@@ -0,0 +1,314 @@
|
|
|
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.SCHEMA_EXPANSION_STORAGE_KEY =
|
|
71
|
+
exports.normalizeLevel =
|
|
72
|
+
exports.useSchemaDepth =
|
|
73
|
+
exports.useSchemaExpansion =
|
|
74
|
+
exports.SchemaDepthProvider =
|
|
75
|
+
exports.SchemaExpansionProvider =
|
|
76
|
+
void 0;
|
|
77
|
+
const react_1 = __importStar(require("react"));
|
|
78
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
79
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
80
|
+
const context_1 = require("./context");
|
|
81
|
+
var context_2 = require("./context");
|
|
82
|
+
Object.defineProperty(exports, "SchemaExpansionProvider", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () {
|
|
85
|
+
return context_2.SchemaExpansionProvider;
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "SchemaDepthProvider", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () {
|
|
91
|
+
return context_2.SchemaDepthProvider;
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, "useSchemaExpansion", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () {
|
|
97
|
+
return context_2.useSchemaExpansion;
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, "useSchemaDepth", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () {
|
|
103
|
+
return context_2.useSchemaDepth;
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(exports, "normalizeLevel", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function () {
|
|
109
|
+
return context_2.normalizeLevel;
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, "SCHEMA_EXPANSION_STORAGE_KEY", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () {
|
|
115
|
+
return context_2.SCHEMA_EXPANSION_STORAGE_KEY;
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
const ALL_VALUE = Number.POSITIVE_INFINITY;
|
|
119
|
+
const ExpandIcon = () =>
|
|
120
|
+
react_1.default.createElement(
|
|
121
|
+
"svg",
|
|
122
|
+
{
|
|
123
|
+
"aria-hidden": "true",
|
|
124
|
+
focusable: "false",
|
|
125
|
+
width: "14",
|
|
126
|
+
height: "14",
|
|
127
|
+
viewBox: "0 0 16 16",
|
|
128
|
+
fill: "none",
|
|
129
|
+
stroke: "currentColor",
|
|
130
|
+
strokeWidth: "1.6",
|
|
131
|
+
strokeLinecap: "round",
|
|
132
|
+
strokeLinejoin: "round",
|
|
133
|
+
},
|
|
134
|
+
react_1.default.createElement("polyline", { points: "4 6 8 2 12 6" }),
|
|
135
|
+
react_1.default.createElement("polyline", { points: "4 10 8 14 12 10" })
|
|
136
|
+
);
|
|
137
|
+
const SchemaExpansionControl = () => {
|
|
138
|
+
const { config, level, setLevel } = (0, context_1.useSchemaExpansion)();
|
|
139
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
140
|
+
const [coords, setCoords] = (0, react_1.useState)(null);
|
|
141
|
+
const buttonRef = (0, react_1.useRef)(null);
|
|
142
|
+
const popoverRef = (0, react_1.useRef)(null);
|
|
143
|
+
const optionRefs = (0, react_1.useRef)([]);
|
|
144
|
+
const popoverId = (0, react_1.useId)();
|
|
145
|
+
const options = (0, react_1.useMemo)(() => {
|
|
146
|
+
const numbers = Array.from({ length: config.max + 1 }, (_, i) => i);
|
|
147
|
+
return [...numbers, ALL_VALUE];
|
|
148
|
+
}, [config.max]);
|
|
149
|
+
const activeIndex = (0, react_1.useMemo)(() => {
|
|
150
|
+
const idx = options.indexOf(level);
|
|
151
|
+
return idx >= 0 ? idx : 0;
|
|
152
|
+
}, [options, level]);
|
|
153
|
+
const updatePosition = (0, react_1.useCallback)(() => {
|
|
154
|
+
if (!buttonRef.current || typeof window === "undefined") return;
|
|
155
|
+
const rect = buttonRef.current.getBoundingClientRect();
|
|
156
|
+
setCoords({
|
|
157
|
+
top: rect.bottom + 4,
|
|
158
|
+
right: window.innerWidth - rect.right,
|
|
159
|
+
});
|
|
160
|
+
}, []);
|
|
161
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
162
|
+
if (!open) return;
|
|
163
|
+
updatePosition();
|
|
164
|
+
const handleScroll = () => setOpen(false);
|
|
165
|
+
window.addEventListener("scroll", handleScroll, true);
|
|
166
|
+
window.addEventListener("resize", updatePosition);
|
|
167
|
+
return () => {
|
|
168
|
+
window.removeEventListener("scroll", handleScroll, true);
|
|
169
|
+
window.removeEventListener("resize", updatePosition);
|
|
170
|
+
};
|
|
171
|
+
}, [open, updatePosition]);
|
|
172
|
+
(0, react_1.useEffect)(() => {
|
|
173
|
+
if (!open) return;
|
|
174
|
+
optionRefs.current[activeIndex]?.focus();
|
|
175
|
+
}, [open, activeIndex]);
|
|
176
|
+
(0, react_1.useEffect)(() => {
|
|
177
|
+
if (!open) return;
|
|
178
|
+
const handlePointer = (event) => {
|
|
179
|
+
const target = event.target;
|
|
180
|
+
if (buttonRef.current?.contains(target)) return;
|
|
181
|
+
if (popoverRef.current?.contains(target)) return;
|
|
182
|
+
setOpen(false);
|
|
183
|
+
};
|
|
184
|
+
const handleKey = (event) => {
|
|
185
|
+
if (event.key === "Escape") {
|
|
186
|
+
event.stopPropagation();
|
|
187
|
+
setOpen(false);
|
|
188
|
+
buttonRef.current?.focus();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
document.addEventListener("mousedown", handlePointer);
|
|
192
|
+
document.addEventListener("keydown", handleKey);
|
|
193
|
+
return () => {
|
|
194
|
+
document.removeEventListener("mousedown", handlePointer);
|
|
195
|
+
document.removeEventListener("keydown", handleKey);
|
|
196
|
+
};
|
|
197
|
+
}, [open]);
|
|
198
|
+
const choose = (0, react_1.useCallback)(
|
|
199
|
+
(next) => {
|
|
200
|
+
setLevel(next);
|
|
201
|
+
setOpen(false);
|
|
202
|
+
buttonRef.current?.focus();
|
|
203
|
+
},
|
|
204
|
+
[setLevel]
|
|
205
|
+
);
|
|
206
|
+
const onMenuKeyDown = (event) => {
|
|
207
|
+
if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") return;
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
const current = optionRefs.current.findIndex(
|
|
210
|
+
(el) => el === document.activeElement
|
|
211
|
+
);
|
|
212
|
+
if (current < 0) return;
|
|
213
|
+
const next =
|
|
214
|
+
event.key === "ArrowRight"
|
|
215
|
+
? (current + 1) % options.length
|
|
216
|
+
: (current - 1 + options.length) % options.length;
|
|
217
|
+
optionRefs.current[next]?.focus();
|
|
218
|
+
};
|
|
219
|
+
if (!config.enabled) return null;
|
|
220
|
+
const buttonLabel = (0, Translate_1.translate)({
|
|
221
|
+
id: "theme.openapi.schema.expansion.button",
|
|
222
|
+
message: "Schema expansion depth",
|
|
223
|
+
description: "Aria/title tooltip for the schema expansion icon button",
|
|
224
|
+
});
|
|
225
|
+
const menuLabel = (0, Translate_1.translate)({
|
|
226
|
+
id: "theme.openapi.schema.expansion.menu",
|
|
227
|
+
message: "Schema expansion depth options",
|
|
228
|
+
description: "Accessible label for the expansion options menu",
|
|
229
|
+
});
|
|
230
|
+
const allLabel = (0, Translate_1.translate)({
|
|
231
|
+
id: "theme.openapi.schema.expansion.all",
|
|
232
|
+
message: "All",
|
|
233
|
+
description: "Label for the expand-all option",
|
|
234
|
+
});
|
|
235
|
+
return react_1.default.createElement(
|
|
236
|
+
"span",
|
|
237
|
+
{ className: "openapi-schema-expansion" },
|
|
238
|
+
react_1.default.createElement(
|
|
239
|
+
"button",
|
|
240
|
+
{
|
|
241
|
+
ref: buttonRef,
|
|
242
|
+
type: "button",
|
|
243
|
+
className: "openapi-schema-expansion__trigger",
|
|
244
|
+
"aria-haspopup": "menu",
|
|
245
|
+
"aria-expanded": open,
|
|
246
|
+
"aria-controls": open ? popoverId : undefined,
|
|
247
|
+
"aria-label": buttonLabel,
|
|
248
|
+
title: buttonLabel,
|
|
249
|
+
onClick: (event) => {
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
event.stopPropagation();
|
|
252
|
+
setOpen((prev) => !prev);
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
react_1.default.createElement(ExpandIcon, null)
|
|
256
|
+
),
|
|
257
|
+
open &&
|
|
258
|
+
coords &&
|
|
259
|
+
react_1.default.createElement(
|
|
260
|
+
"div",
|
|
261
|
+
{
|
|
262
|
+
ref: popoverRef,
|
|
263
|
+
id: popoverId,
|
|
264
|
+
role: "menu",
|
|
265
|
+
"aria-label": menuLabel,
|
|
266
|
+
className: "openapi-schema-expansion__popover",
|
|
267
|
+
style: { top: coords.top, right: coords.right },
|
|
268
|
+
onKeyDown: onMenuKeyDown,
|
|
269
|
+
onClick: (event) => {
|
|
270
|
+
event.preventDefault();
|
|
271
|
+
event.stopPropagation();
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
options.map((value, index) => {
|
|
275
|
+
const isAll = value === ALL_VALUE;
|
|
276
|
+
const label = isAll ? allLabel : String(value);
|
|
277
|
+
const optionAriaLabel = isAll
|
|
278
|
+
? allLabel
|
|
279
|
+
: (0, Translate_1.translate)(
|
|
280
|
+
{
|
|
281
|
+
id: "theme.openapi.schema.expansion.depthOption",
|
|
282
|
+
message: "Expand to depth {depth}",
|
|
283
|
+
description: "Accessible label for a depth option",
|
|
284
|
+
},
|
|
285
|
+
{ depth: value }
|
|
286
|
+
);
|
|
287
|
+
const isActive = level === value;
|
|
288
|
+
return react_1.default.createElement(
|
|
289
|
+
"button",
|
|
290
|
+
{
|
|
291
|
+
key: isAll ? "all" : value,
|
|
292
|
+
ref: (el) => {
|
|
293
|
+
optionRefs.current[index] = el;
|
|
294
|
+
},
|
|
295
|
+
type: "button",
|
|
296
|
+
role: "menuitemradio",
|
|
297
|
+
"aria-checked": isActive,
|
|
298
|
+
"aria-label": optionAriaLabel,
|
|
299
|
+
tabIndex: index === activeIndex ? 0 : -1,
|
|
300
|
+
className: (0, clsx_1.default)(
|
|
301
|
+
"openapi-schema-expansion__option",
|
|
302
|
+
{
|
|
303
|
+
"openapi-schema-expansion__option--active": isActive,
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
onClick: () => choose(value),
|
|
307
|
+
},
|
|
308
|
+
label
|
|
309
|
+
);
|
|
310
|
+
})
|
|
311
|
+
)
|
|
312
|
+
);
|
|
313
|
+
};
|
|
314
|
+
exports.default = SchemaExpansionControl;
|
|
@@ -16,7 +16,6 @@ const react_1 = __importDefault(require("react"));
|
|
|
16
16
|
const Translate_1 = require("@docusaurus/Translate");
|
|
17
17
|
const Example_1 = require("@theme/Example");
|
|
18
18
|
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
19
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
20
19
|
const clsx_1 = __importDefault(require("clsx"));
|
|
21
20
|
const schema_1 = require("../../markdown/schema");
|
|
22
21
|
const utils_1 = require("../../markdown/utils");
|
|
@@ -29,11 +28,11 @@ const transformEnumDescriptions = (enumDescriptions) => {
|
|
|
29
28
|
const getEnumDescriptionMarkdown = (enumDescriptions) => {
|
|
30
29
|
if (enumDescriptions?.length) {
|
|
31
30
|
const enumValue = (0, Translate_1.translate)({
|
|
32
|
-
id:
|
|
31
|
+
id: "theme.openapi.schemaItem.enumValue",
|
|
33
32
|
message: "Enum Value",
|
|
34
33
|
});
|
|
35
34
|
const description = (0, Translate_1.translate)({
|
|
36
|
-
id:
|
|
35
|
+
id: "theme.openapi.schemaItem.enumDescription",
|
|
37
36
|
message: "Description",
|
|
38
37
|
});
|
|
39
38
|
return `| ${enumValue} | ${description} |
|
|
@@ -84,7 +83,7 @@ function SchemaItem(props) {
|
|
|
84
83
|
"span",
|
|
85
84
|
{ className: "openapi-schema__required" },
|
|
86
85
|
(0, Translate_1.translate)({
|
|
87
|
-
id:
|
|
86
|
+
id: "theme.openapi.schemaItem.required",
|
|
88
87
|
message: "required",
|
|
89
88
|
})
|
|
90
89
|
)
|
|
@@ -94,7 +93,7 @@ function SchemaItem(props) {
|
|
|
94
93
|
"span",
|
|
95
94
|
{ className: "openapi-schema__deprecated" },
|
|
96
95
|
(0, Translate_1.translate)({
|
|
97
|
-
id:
|
|
96
|
+
id: "theme.openapi.schemaItem.deprecated",
|
|
98
97
|
message: "deprecated",
|
|
99
98
|
})
|
|
100
99
|
)
|
|
@@ -104,7 +103,7 @@ function SchemaItem(props) {
|
|
|
104
103
|
"span",
|
|
105
104
|
{ className: "openapi-schema__nullable" },
|
|
106
105
|
(0, Translate_1.translate)({
|
|
107
|
-
id:
|
|
106
|
+
id: "theme.openapi.schemaItem.nullable",
|
|
108
107
|
message: "nullable",
|
|
109
108
|
})
|
|
110
109
|
)
|
|
@@ -151,7 +150,7 @@ function SchemaItem(props) {
|
|
|
151
150
|
"strong",
|
|
152
151
|
null,
|
|
153
152
|
(0, Translate_1.translate)({
|
|
154
|
-
id:
|
|
153
|
+
id: "theme.openapi.schemaItem.defaultValue",
|
|
155
154
|
message: "Default value:",
|
|
156
155
|
}),
|
|
157
156
|
" "
|
|
@@ -170,7 +169,7 @@ function SchemaItem(props) {
|
|
|
170
169
|
"strong",
|
|
171
170
|
null,
|
|
172
171
|
(0, Translate_1.translate)({
|
|
173
|
-
id:
|
|
172
|
+
id: "theme.openapi.schemaItem.defaultValue",
|
|
174
173
|
message: "Default value:",
|
|
175
174
|
}),
|
|
176
175
|
" "
|
|
@@ -198,7 +197,7 @@ function SchemaItem(props) {
|
|
|
198
197
|
"strong",
|
|
199
198
|
null,
|
|
200
199
|
(0, Translate_1.translate)({
|
|
201
|
-
id:
|
|
200
|
+
id: "theme.openapi.schemaItem.constantValue",
|
|
202
201
|
message: "Constant value:",
|
|
203
202
|
}),
|
|
204
203
|
" "
|
|
@@ -217,7 +216,7 @@ function SchemaItem(props) {
|
|
|
217
216
|
"strong",
|
|
218
217
|
null,
|
|
219
218
|
(0, Translate_1.translate)({
|
|
220
|
-
id:
|
|
219
|
+
id: "theme.openapi.schemaItem.constantValue",
|
|
221
220
|
message: "Constant value:",
|
|
222
221
|
}),
|
|
223
222
|
" "
|
|
@@ -69,10 +69,11 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.default = SchemaTabs;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
73
72
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
73
|
const clsx_1 = __importDefault(require("clsx"));
|
|
75
74
|
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
75
|
+
const scrollUtils_1 = require("@theme/utils/scrollUtils");
|
|
76
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
76
77
|
function TabList({
|
|
77
78
|
className,
|
|
78
79
|
block,
|
|
@@ -83,7 +84,7 @@ function TabList({
|
|
|
83
84
|
}) {
|
|
84
85
|
const tabRefs = [];
|
|
85
86
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
86
|
-
|
|
87
|
+
scrollUtils_1.useScrollPositionBlocker)();
|
|
87
88
|
const handleTabChange = (event) => {
|
|
88
89
|
const newTab = event.currentTarget;
|
|
89
90
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
@@ -237,9 +238,9 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
237
238
|
);
|
|
238
239
|
}
|
|
239
240
|
function TabsComponent(props) {
|
|
240
|
-
const tabs = (0,
|
|
241
|
+
const tabs = (0, tabsUtils_1.useTabsContextValue)(props);
|
|
241
242
|
return react_1.default.createElement(
|
|
242
|
-
|
|
243
|
+
tabsUtils_1.TabsProvider,
|
|
243
244
|
{ value: tabs },
|
|
244
245
|
react_1.default.createElement(
|
|
245
246
|
"div",
|
|
@@ -261,7 +262,7 @@ function SchemaTabs(props) {
|
|
|
261
262
|
}
|
|
262
263
|
let sanitizedChildren;
|
|
263
264
|
try {
|
|
264
|
-
sanitizedChildren = (0,
|
|
265
|
+
sanitizedChildren = (0, tabsUtils_1.sanitizeTabsChildren)(children);
|
|
265
266
|
} catch {
|
|
266
267
|
return null;
|
|
267
268
|
}
|
|
@@ -19,7 +19,6 @@ const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
|
19
19
|
const ResponseHeaders_1 = __importDefault(require("@theme/ResponseHeaders"));
|
|
20
20
|
const ResponseSchema_1 = __importDefault(require("@theme/ResponseSchema"));
|
|
21
21
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
22
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
23
22
|
const StatusCodes = ({ label, id, responses }) => {
|
|
24
23
|
if (!responses) return null;
|
|
25
24
|
const codes = Object.keys(responses);
|
|
@@ -64,8 +63,7 @@ const StatusCodes = ({ label, id, responses }) => {
|
|
|
64
63
|
"strong",
|
|
65
64
|
null,
|
|
66
65
|
(0, Translate_1.translate)({
|
|
67
|
-
id:
|
|
68
|
-
.RESPONSE_HEADERS,
|
|
66
|
+
id: "theme.openapi.statusCodes.responseHeaders",
|
|
69
67
|
message: "Response Headers",
|
|
70
68
|
})
|
|
71
69
|
)
|
|
@@ -77,7 +75,7 @@ const StatusCodes = ({ label, id, responses }) => {
|
|
|
77
75
|
),
|
|
78
76
|
react_1.default.createElement(ResponseSchema_1.default, {
|
|
79
77
|
title: (0, Translate_1.translate)({
|
|
80
|
-
id:
|
|
78
|
+
id: "theme.openapi.statusCodes.schemaTitle",
|
|
81
79
|
message: "Schema",
|
|
82
80
|
}),
|
|
83
81
|
body: { content: response.content },
|