docusaurus-theme-openapi-docs 4.1.0 → 4.3.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.
Files changed (56) hide show
  1. package/lib/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +0 -12
  2. package/lib/theme/ApiExplorer/Authorization/index.js +3 -0
  3. package/lib/theme/ApiExplorer/Body/index.js +11 -2
  4. package/lib/theme/ApiExplorer/CodeSnippets/index.js +2 -1
  5. package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +50 -0
  6. package/lib/theme/ApiItem/Layout/index.js +6 -2
  7. package/lib/theme/ApiItem/index.js +15 -4
  8. package/lib/theme/ApiTabs/_ApiTabs.scss +0 -1
  9. package/lib/theme/ArrayBrackets/index.d.ts +3 -0
  10. package/lib/theme/ArrayBrackets/index.js +50 -0
  11. package/lib/theme/Markdown/Details/_Details.scss +5 -2
  12. package/lib/theme/Markdown/index.js +160 -18
  13. package/lib/theme/ParamsDetails/index.d.ts +6 -0
  14. package/lib/theme/ParamsDetails/index.js +134 -0
  15. package/lib/theme/ParamsItem/index.d.ts +1 -0
  16. package/lib/theme/ParamsItem/index.js +11 -48
  17. package/lib/theme/RequestSchema/index.d.ts +15 -0
  18. package/lib/theme/RequestSchema/index.js +243 -0
  19. package/lib/theme/ResponseExamples/index.d.ts +18 -0
  20. package/lib/theme/ResponseExamples/index.js +194 -0
  21. package/lib/theme/ResponseHeaders/index.d.ts +13 -0
  22. package/lib/theme/ResponseHeaders/index.js +39 -0
  23. package/lib/theme/ResponseSchema/index.d.ts +15 -0
  24. package/lib/theme/ResponseSchema/index.js +208 -0
  25. package/lib/theme/Schema/index.d.ts +8 -0
  26. package/lib/theme/Schema/index.js +887 -0
  27. package/lib/theme/SchemaItem/index.d.ts +8 -8
  28. package/lib/theme/SchemaItem/index.js +11 -41
  29. package/lib/theme/SkeletonLoader/index.d.ts +6 -0
  30. package/lib/theme/SkeletonLoader/index.js +20 -0
  31. package/lib/theme/StatusCodes/index.d.ts +9 -0
  32. package/lib/theme/StatusCodes/index.js +81 -0
  33. package/lib/theme/styles.scss +56 -9
  34. package/package.json +13 -8
  35. package/src/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +0 -12
  36. package/src/theme/ApiExplorer/Authorization/index.tsx +3 -0
  37. package/src/theme/ApiExplorer/Body/index.tsx +3 -2
  38. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +2 -1
  39. package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +50 -0
  40. package/src/theme/ApiItem/Layout/index.tsx +5 -2
  41. package/src/theme/ApiItem/index.tsx +14 -2
  42. package/src/theme/ApiTabs/_ApiTabs.scss +0 -1
  43. package/src/theme/ArrayBrackets/index.tsx +37 -0
  44. package/src/theme/Markdown/Details/_Details.scss +5 -2
  45. package/src/theme/Markdown/index.js +160 -18
  46. package/src/theme/ParamsDetails/index.tsx +88 -0
  47. package/src/theme/ParamsItem/index.tsx +9 -36
  48. package/src/theme/RequestSchema/index.tsx +164 -0
  49. package/src/theme/ResponseExamples/index.tsx +192 -0
  50. package/src/theme/ResponseHeaders/index.tsx +49 -0
  51. package/src/theme/ResponseSchema/index.tsx +151 -0
  52. package/src/theme/Schema/index.tsx +935 -0
  53. package/src/theme/SchemaItem/index.tsx +21 -43
  54. package/src/theme/SkeletonLoader/index.tsx +18 -0
  55. package/src/theme/StatusCodes/index.tsx +72 -0
  56. package/src/theme/styles.scss +56 -9
@@ -8,13 +8,6 @@ the background in custom CSS file due bug https://github.com/facebook/docusaurus
8
8
  --docusaurus-highlighted-code-line-bg: rgb(100 100 100);
9
9
  }
10
10
 
11
- .theme-code-block-highlighted-line {
12
- background-color: var(--docusaurus-highlighted-code-line-bg);
13
- display: block;
14
- margin: 0 calc(-1 * var(--ifm-pre-padding));
15
- padding: 0 var(--ifm-pre-padding);
16
- }
17
-
18
11
  .openapi-explorer__code-block-code-line {
19
12
  display: table-row;
20
13
  counter-increment: line-count;
@@ -36,11 +29,6 @@ the background in custom CSS file due bug https://github.com/facebook/docusaurus
36
29
  opacity: 0.4;
37
30
  }
38
31
 
39
- :global(.theme-code-block-highlighted-line)
40
- .openapi-explorer__code-block-code-line-number::before {
41
- opacity: 0.8;
42
- }
43
-
44
32
  .openapi-explorer__code-block-code-line-number {
45
33
  padding-right: var(--ifm-pre-padding);
46
34
  }
@@ -53,6 +53,7 @@ function Authorization() {
53
53
  { label: "Bearer Token", key: a.key + "-bearer" },
54
54
  react_1.default.createElement(FormTextInput_1.default, {
55
55
  placeholder: "Bearer Token",
56
+ password: true,
56
57
  value: data[a.key].token ?? "",
57
58
  onChange: (e) => {
58
59
  const value = e.target.value;
@@ -73,6 +74,7 @@ function Authorization() {
73
74
  { label: "Bearer Token", key: a.key + "-oauth2" },
74
75
  react_1.default.createElement(FormTextInput_1.default, {
75
76
  placeholder: "Bearer Token",
77
+ password: true,
76
78
  value: data[a.key].token ?? "",
77
79
  onChange: (e) => {
78
80
  const value = e.target.value;
@@ -136,6 +138,7 @@ function Authorization() {
136
138
  { label: `${a.key}`, key: a.key + "-apikey" },
137
139
  react_1.default.createElement(FormTextInput_1.default, {
138
140
  placeholder: `${a.key}`,
141
+ password: true,
139
142
  value: data[a.key].apiKey ?? "",
140
143
  onChange: (e) => {
141
144
  const value = e.target.value;
@@ -23,6 +23,7 @@ const FormTextInput_1 = __importDefault(
23
23
  );
24
24
  const LiveEditor_1 = __importDefault(require("@theme/ApiExplorer/LiveEditor"));
25
25
  const hooks_1 = require("@theme/ApiItem/hooks");
26
+ const Markdown_1 = __importDefault(require("@theme/Markdown"));
26
27
  const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
27
28
  const TabItem_1 = __importDefault(require("@theme/TabItem"));
28
29
  const xml_formatter_1 = __importDefault(require("xml-formatter"));
@@ -297,7 +298,11 @@ function Body({
297
298
  TabItem_1.default,
298
299
  { label: "Example", value: "example" },
299
300
  example.summary &&
300
- react_1.default.createElement("div", null, example.summary),
301
+ react_1.default.createElement(
302
+ Markdown_1.default,
303
+ null,
304
+ example.summary
305
+ ),
301
306
  exampleBody &&
302
307
  react_1.default.createElement(
303
308
  LiveEditor_1.default,
@@ -339,7 +344,11 @@ function Body({
339
344
  key: example.label,
340
345
  },
341
346
  example.summary &&
342
- react_1.default.createElement("div", null, example.summary),
347
+ react_1.default.createElement(
348
+ Markdown_1.default,
349
+ null,
350
+ example.summary
351
+ ),
343
352
  example.body &&
344
353
  react_1.default.createElement(
345
354
  LiveEditor_1.default,
@@ -224,7 +224,7 @@ function CodeSnippets({ postman, codeSamples }) {
224
224
  ]);
225
225
  // no dependencies was intentionlly set for this particular hook. it's safe as long as if conditions are set
226
226
  (0, react_1.useEffect)(function onSelectedVariantUpdate() {
227
- if (selectedVariant && selectedVariant !== language.variant) {
227
+ if (selectedVariant && selectedVariant !== language?.variant) {
228
228
  const postmanRequest = (0, buildPostmanRequest_1.default)(postman, {
229
229
  queryParams,
230
230
  pathParams,
@@ -254,6 +254,7 @@ function CodeSnippets({ postman, codeSamples }) {
254
254
  // eslint-disable-next-line react-hooks/exhaustive-deps
255
255
  (0, react_1.useEffect)(function onSelectedSampleUpdate() {
256
256
  if (
257
+ language &&
257
258
  language.samples &&
258
259
  language.samplesSources &&
259
260
  selectedSample &&
@@ -436,6 +436,56 @@ body[class="ReactModal__Body--open"] {
436
436
  }
437
437
  }
438
438
 
439
+ .openapi-tabs__code-item--http {
440
+ color: var(--ifm-color-gray-500);
441
+ display: flex;
442
+ align-items: center;
443
+ justify-content: center;
444
+ position: relative;
445
+
446
+ &::after {
447
+ content: "";
448
+ display: inline-block;
449
+ width: 32px; /* Explicitly setting width to 32 pixels */
450
+ height: 32px; /* Explicitly setting height to 32 pixels */
451
+ background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIyTDggMTZMMTIgMTBNMjAgMjJMMjQgMTZMIDIwIDEwIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=");
452
+ background-size: contain;
453
+ background-repeat: no-repeat;
454
+ background-position: center; /* Center the SVG */
455
+ margin-top: 0.5rem;
456
+ }
457
+
458
+ &.active {
459
+ box-shadow: 0 0 0 3px var(--opeanpi-code-tab-shadow-color-http);
460
+ border-color: var(--openapi-code-tab-border-color-http);
461
+ }
462
+ }
463
+
464
+ .openapi-tabs__code-item--shell {
465
+ color: var(--ifm-color-gray-500);
466
+ display: flex;
467
+ align-items: center;
468
+ justify-content: center;
469
+ position: relative;
470
+
471
+ &::after {
472
+ content: "";
473
+ display: inline-block;
474
+ width: 32px; /* Explicitly setting width to 32 pixels */
475
+ height: 32px; /* Explicitly setting height to 32 pixels */
476
+ background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIyTDggMTZMMTIgMTBNMjAgMjJMMjQgMTZMIDIwIDEwIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=");
477
+ background-size: contain;
478
+ background-repeat: no-repeat;
479
+ background-position: center; /* Center the SVG */
480
+ margin-top: 0.5rem;
481
+ }
482
+
483
+ &.active {
484
+ box-shadow: 0 0 0 3px var(--opeanpi-code-tab-shadow-color-shell);
485
+ border-color: var(--openapi-code-tab-border-color-shell);
486
+ }
487
+ }
488
+
439
489
  @media only screen and (min-width: 768px) and (max-width: 996px) {
440
490
  .openapi-tabs__code-list {
441
491
  justify-content: space-around;
@@ -53,6 +53,7 @@ function DocItemLayout({ children }) {
53
53
  const { metadata } = (0, client_1.useDoc)();
54
54
  const { frontMatter } = (0, client_1.useDoc)();
55
55
  const api = frontMatter.api;
56
+ const schema = frontMatter.schema;
56
57
  return react_1.default.createElement(
57
58
  "div",
58
59
  { className: "row" },
@@ -86,7 +87,7 @@ function DocItemLayout({ children }) {
86
87
  {
87
88
  className: (0, clsx_1.default)(
88
89
  "col",
89
- api ? "col--7" : "col--12"
90
+ api || schema ? "col--7" : "col--12"
90
91
  ),
91
92
  },
92
93
  react_1.default.createElement(Footer_1.default, null)
@@ -99,7 +100,10 @@ function DocItemLayout({ children }) {
99
100
  react_1.default.createElement(
100
101
  "div",
101
102
  {
102
- className: (0, clsx_1.default)("col", api ? "col--7" : "col--12"),
103
+ className: (0, clsx_1.default)(
104
+ "col",
105
+ api || schema ? "col--7" : "col--12"
106
+ ),
103
107
  },
104
108
  react_1.default.createElement(Paginator_1.default, null)
105
109
  )
@@ -26,7 +26,9 @@ const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
26
26
  const slice_1 = require("@theme/ApiExplorer/Authorization/slice");
27
27
  const persistanceMiddleware_1 = require("@theme/ApiExplorer/persistanceMiddleware");
28
28
  const Layout_1 = __importDefault(require("@theme/ApiItem/Layout"));
29
+ const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
29
30
  const Metadata_1 = __importDefault(require("@theme/DocItem/Metadata"));
31
+ const SkeletonLoader_1 = __importDefault(require("@theme/SkeletonLoader"));
30
32
  const clsx_1 = __importDefault(require("clsx"));
31
33
  const react_redux_1 = require("react-redux");
32
34
  const store_1 = require("./store");
@@ -42,6 +44,7 @@ function ApiItem(props) {
42
44
  const { info_path: infoPath } = frontMatter;
43
45
  let { api } = frontMatter;
44
46
  const { schema } = frontMatter;
47
+ const { sample } = frontMatter;
45
48
  // decompress and parse
46
49
  if (api) {
47
50
  try {
@@ -149,9 +152,8 @@ function ApiItem(props) {
149
152
  BrowserOnly_1.default,
150
153
  {
151
154
  fallback: react_1.default.createElement(
152
- "div",
153
- null,
154
- "Loading..."
155
+ SkeletonLoader_1.default,
156
+ { size: "lg" }
155
157
  ),
156
158
  },
157
159
  () => {
@@ -183,8 +185,17 @@ function ApiItem(props) {
183
185
  { className: (0, clsx_1.default)("row", "theme-api-markdown") },
184
186
  react_1.default.createElement(
185
187
  "div",
186
- { className: "col col--12" },
188
+ { className: "col col--7 openapi-left-panel__container schema" },
187
189
  react_1.default.createElement(MDXComponent, null)
190
+ ),
191
+ react_1.default.createElement(
192
+ "div",
193
+ { className: "col col--5 openapi-right-panel__container" },
194
+ react_1.default.createElement(
195
+ CodeBlock_1.default,
196
+ { language: "json", title: `${frontMatter.title}` },
197
+ JSON.stringify(sample, null, 2)
198
+ )
188
199
  )
189
200
  )
190
201
  )
@@ -6,7 +6,6 @@
6
6
  * ========================================================================== */
7
7
  .openapi-tabs__container {
8
8
  margin-left: -1px;
9
- margin-bottom: var(--ifm-leading);
10
9
  }
11
10
 
12
11
  .openapi-tabs__response-header {
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ export declare const OpeningArrayBracket: () => React.JSX.Element;
3
+ export declare const ClosingArrayBracket: () => React.JSX.Element;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ var __importDefault =
9
+ (this && this.__importDefault) ||
10
+ function (mod) {
11
+ return mod && mod.__esModule ? mod : { default: mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.ClosingArrayBracket = exports.OpeningArrayBracket = void 0;
15
+ const react_1 = __importDefault(require("react"));
16
+ const OpeningArrayBracket = () =>
17
+ react_1.default.createElement(
18
+ "li",
19
+ null,
20
+ react_1.default.createElement(
21
+ "div",
22
+ {
23
+ style: {
24
+ fontSize: "var(--ifm-code-font-size)",
25
+ opacity: 0.6,
26
+ marginLeft: "-.5rem",
27
+ paddingBottom: ".5rem",
28
+ },
29
+ },
30
+ "Array ["
31
+ )
32
+ );
33
+ exports.OpeningArrayBracket = OpeningArrayBracket;
34
+ const ClosingArrayBracket = () =>
35
+ react_1.default.createElement(
36
+ "li",
37
+ null,
38
+ react_1.default.createElement(
39
+ "div",
40
+ {
41
+ style: {
42
+ fontSize: "var(--ifm-code-font-size)",
43
+ opacity: 0.6,
44
+ marginLeft: "-.5rem",
45
+ },
46
+ },
47
+ "]"
48
+ )
49
+ );
50
+ exports.ClosingArrayBracket = ClosingArrayBracket;
@@ -23,10 +23,13 @@
23
23
 
24
24
  /* Top-Level Details Caret Styling */
25
25
  .openapi-left-panel__container > .openapi-markdown__details > summary::before,
26
- .openapi-markdown__details.mime > summary::before,
27
- .openapi-markdown__details.response > summary::before {
26
+ .openapi-markdown__details.mime > summary::before {
28
27
  top: 0.1rem;
29
28
  }
29
+
30
+ .openapi-markdown__details.response > summary::before {
31
+ top: 0.25rem; /* TODO: figure out why this is necessary */
32
+ }
30
33
  /* End of Top-Level Details Caret Styling */
31
34
 
32
35
  .openapi-markdown__details {
@@ -7,30 +7,172 @@
7
7
 
8
8
  import React from "react";
9
9
 
10
+ import Admonition from "@theme/Admonition";
10
11
  import CodeBlock from "@theme/CodeBlock";
11
12
  import ReactMarkdown from "react-markdown";
12
13
  import rehypeRaw from "rehype-raw";
14
+ import remarkGfm from "remark-gfm";
15
+
16
+ function remarkAdmonition() {
17
+ return (tree) => {
18
+ const openingTagRegex = /^:::(\w+)(?:\[(.*?)\])?\s*$/;
19
+ const closingTagRegex = /^:::\s*$/;
20
+ const textOnlyAdmonition = /^:::(\w+)(?:\[(.*?)\])?\s*([\s\S]*?)\s*:::$/;
21
+
22
+ const nodes = [];
23
+ let bufferedChildren = [];
24
+
25
+ let insideAdmonition = false;
26
+ let type = null;
27
+ let title = null;
28
+
29
+ tree.children.forEach((node) => {
30
+ if (
31
+ node.type === "paragraph" &&
32
+ node.children.length === 1 &&
33
+ node.children[0].type === "text"
34
+ ) {
35
+ const text = node.children[0].value.trim();
36
+ const openingMatch = text.match(openingTagRegex);
37
+ const closingMatch = text.match(closingTagRegex);
38
+ const textOnlyAdmonitionMatch = text.match(textOnlyAdmonition);
39
+
40
+ if (textOnlyAdmonitionMatch) {
41
+ const type = textOnlyAdmonitionMatch[1];
42
+ const title = textOnlyAdmonitionMatch[2]
43
+ ? textOnlyAdmonitionMatch[2]?.trim()
44
+ : undefined;
45
+ const content = textOnlyAdmonitionMatch[3];
46
+
47
+ const admonitionNode = {
48
+ type: "admonition",
49
+ data: {
50
+ hName: "Admonition", // Tells ReactMarkdown to replace the node with Admonition component
51
+ hProperties: {
52
+ type, // Passed as a prop to the Admonition component
53
+ title,
54
+ },
55
+ },
56
+ children: [
57
+ {
58
+ type: "text",
59
+ value: content?.trim(), // Trim leading/trailing whitespace
60
+ },
61
+ ],
62
+ };
63
+ nodes.push(admonitionNode);
64
+ return;
65
+ }
66
+
67
+ if (openingMatch) {
68
+ type = openingMatch[1];
69
+ title = openingMatch[2] || type;
70
+ insideAdmonition = true;
71
+ return;
72
+ }
73
+
74
+ if (closingMatch && insideAdmonition) {
75
+ nodes.push({
76
+ type: "admonition",
77
+ data: {
78
+ hName: "Admonition",
79
+ hProperties: { type: type, title: title },
80
+ },
81
+ children: bufferedChildren,
82
+ });
83
+ bufferedChildren = [];
84
+ insideAdmonition = false;
85
+ type = null;
86
+ title = null;
87
+ return;
88
+ }
89
+ }
90
+
91
+ if (insideAdmonition) {
92
+ bufferedChildren.push(node);
93
+ } else {
94
+ nodes.push(node);
95
+ }
96
+ });
97
+
98
+ if (bufferedChildren.length > 0 && type) {
99
+ nodes.push({
100
+ type: "admonition",
101
+ data: {
102
+ hName: "Admonition",
103
+ hProperties: { type: type, title: title },
104
+ },
105
+ children: bufferedChildren,
106
+ });
107
+ }
108
+ tree.children = nodes;
109
+ };
110
+ }
111
+
112
+ function convertAstToHtmlStr(ast) {
113
+ if (!ast || !Array.isArray(ast)) {
114
+ return "";
115
+ }
116
+
117
+ const convertNode = (node) => {
118
+ switch (node.type) {
119
+ case "text":
120
+ return node.value;
121
+ case "element":
122
+ const { tagName, properties, children } = node;
123
+
124
+ // Convert attributes to a string
125
+ const attrs = properties
126
+ ? Object.entries(properties)
127
+ .map(([key, value]) => `${key}="${value}"`)
128
+ .join(" ")
129
+ : "";
130
+
131
+ // Convert children to HTML
132
+ const childrenHtml = children ? children.map(convertNode).join("") : "";
133
+
134
+ return `<${tagName} ${attrs}>${childrenHtml}</${tagName}>`;
135
+ default:
136
+ return "";
137
+ }
138
+ };
139
+
140
+ return ast.map(convertNode).join("");
141
+ }
13
142
 
14
143
  function Markdown({ children }) {
15
144
  return (
16
- <div>
17
- <ReactMarkdown
18
- children={children}
19
- rehypePlugins={[rehypeRaw]}
20
- components={{
21
- pre: "div",
22
- code({ node, inline, className, children, ...props }) {
23
- const match = /language-(\w+)/.exec(className || "");
24
- if (inline) return <code>{children}</code>;
25
- return !inline && match ? (
26
- <CodeBlock className={className}>{children}</CodeBlock>
27
- ) : (
28
- <CodeBlock>{children}</CodeBlock>
29
- );
30
- },
31
- }}
32
- />
33
- </div>
145
+ <ReactMarkdown
146
+ rehypePlugins={[rehypeRaw]}
147
+ remarkPlugins={[remarkGfm, remarkAdmonition]}
148
+ components={{
149
+ pre: (props) => <div {...props} />,
150
+ code({ node, inline, className, children, ...props }) {
151
+ const match = /language-(\w+)/.exec(className || "");
152
+ return match ? (
153
+ <CodeBlock className={className} language={match[1]} {...props}>
154
+ {children}
155
+ </CodeBlock>
156
+ ) : (
157
+ <code className={className} {...props}>
158
+ {children}
159
+ </code>
160
+ );
161
+ },
162
+ admonition: ({ node, ...props }) => {
163
+ const type = node.data?.hProperties?.type || "note";
164
+ const title = node.data?.hProperties?.title || type;
165
+ const content = convertAstToHtmlStr(node.children);
166
+ return (
167
+ <Admonition type={type} title={title} {...props}>
168
+ <div dangerouslySetInnerHTML={{ __html: content }} />
169
+ </Admonition>
170
+ );
171
+ },
172
+ }}
173
+ >
174
+ {children}
175
+ </ReactMarkdown>
34
176
  );
35
177
  }
36
178
 
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ interface Props {
3
+ parameters: any[];
4
+ }
5
+ declare const ParamsDetails: React.FC<Props>;
6
+ export default ParamsDetails;
@@ -0,0 +1,134 @@
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 (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null)
46
+ for (var k in mod)
47
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
48
+ __createBinding(result, mod, k);
49
+ __setModuleDefault(result, mod);
50
+ return result;
51
+ };
52
+ var __importDefault =
53
+ (this && this.__importDefault) ||
54
+ function (mod) {
55
+ return mod && mod.__esModule ? mod : { default: mod };
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ const react_1 = __importStar(require("react"));
59
+ const BrowserOnly_1 = __importDefault(require("@docusaurus/BrowserOnly"));
60
+ const Details_1 = __importDefault(require("@theme/Details"));
61
+ const ParamsItem_1 = __importDefault(require("@theme/ParamsItem"));
62
+ const SkeletonLoader_1 = __importDefault(require("@theme/SkeletonLoader"));
63
+ const ParamsDetailsComponent = ({ parameters }) => {
64
+ const types = ["path", "query", "header", "cookie"];
65
+ return react_1.default.createElement(
66
+ react_1.default.Fragment,
67
+ null,
68
+ types.map((type) => {
69
+ const params = parameters?.filter((param) => param?.in === type);
70
+ if (!params || params.length === 0) {
71
+ return null;
72
+ }
73
+ const summaryElement = react_1.default.createElement(
74
+ "summary",
75
+ null,
76
+ react_1.default.createElement(
77
+ "h3",
78
+ { className: "openapi-markdown__details-summary-header-params" },
79
+ `${type.charAt(0).toUpperCase() + type.slice(1)} Parameters`
80
+ )
81
+ );
82
+ return react_1.default.createElement(
83
+ Details_1.default,
84
+ {
85
+ key: type,
86
+ className: "openapi-markdown__details",
87
+ style: { marginBottom: "1rem" },
88
+ "data-collapsed": false,
89
+ open: true,
90
+ summary: summaryElement,
91
+ },
92
+ react_1.default.createElement(
93
+ "ul",
94
+ null,
95
+ params.map((param, index) =>
96
+ react_1.default.createElement(ParamsItem_1.default, {
97
+ key: index,
98
+ className: "paramsItem",
99
+ param: {
100
+ ...param,
101
+ enumDescriptions: Object.entries(
102
+ param?.schema?.["x-enumDescriptions"] ??
103
+ param?.schema?.items?.["x-enumDescriptions"] ??
104
+ {}
105
+ ),
106
+ },
107
+ })
108
+ )
109
+ )
110
+ );
111
+ })
112
+ );
113
+ };
114
+ const ParamsDetails = (props) => {
115
+ return react_1.default.createElement(
116
+ BrowserOnly_1.default,
117
+ {
118
+ fallback: react_1.default.createElement(SkeletonLoader_1.default, {
119
+ size: "sm",
120
+ }),
121
+ },
122
+ () => {
123
+ const LazyComponent = react_1.default.lazy(() =>
124
+ Promise.resolve({ default: ParamsDetailsComponent })
125
+ );
126
+ return react_1.default.createElement(
127
+ react_1.Suspense,
128
+ { fallback: null },
129
+ react_1.default.createElement(LazyComponent, { ...props })
130
+ );
131
+ }
132
+ );
133
+ };
134
+ exports.default = ParamsDetails;
@@ -9,6 +9,7 @@ export interface ExampleObject {
9
9
  externalValue?: string;
10
10
  }
11
11
  export interface Props {
12
+ className: string;
12
13
  param: {
13
14
  description: string;
14
15
  example: any;