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
@@ -7,25 +7,21 @@
7
7
 
8
8
  import React, { ReactNode } from "react";
9
9
 
10
- import CodeBlock from "@theme/CodeBlock";
10
+ import Markdown from "@theme/Markdown";
11
11
  import clsx from "clsx";
12
- import ReactMarkdown from "react-markdown";
13
- import rehypeRaw from "rehype-raw";
14
- import remarkGfm from "remark-gfm";
15
12
 
16
- import { createDescription } from "../../markdown/createDescription";
17
13
  import { guard } from "../../markdown/utils";
18
14
 
19
15
  export interface Props {
20
- children: ReactNode;
21
- collapsible: boolean;
22
- name: string;
23
- qualifierMessage: string | undefined;
24
- required: boolean;
25
- schemaName: string;
16
+ children?: ReactNode;
17
+ collapsible?: boolean;
18
+ name?: string;
19
+ qualifierMessage?: string | undefined;
20
+ required?: boolean;
21
+ schemaName?: string;
26
22
  // TODO should probably be typed
27
- schema: any;
28
- discriminator: boolean;
23
+ schema?: any;
24
+ discriminator?: boolean;
29
25
  }
30
26
 
31
27
  const transformEnumDescriptions = (
@@ -96,43 +92,23 @@ export default function SchemaItem(props: Props) {
96
92
  getEnumDescriptionMarkdown(enumDescriptions),
97
93
  (value) => {
98
94
  return (
99
- <ReactMarkdown
100
- remarkPlugins={[remarkGfm]}
101
- rehypePlugins={[rehypeRaw]}
102
- children={value}
103
- />
95
+ <div style={{ marginTop: ".5rem" }}>
96
+ <Markdown>{value}</Markdown>
97
+ </div>
104
98
  );
105
99
  }
106
100
  );
107
101
 
108
102
  const renderSchemaDescription = guard(schemaDescription, (description) => (
109
- <div>
110
- <ReactMarkdown
111
- children={createDescription(description)}
112
- components={{
113
- pre: "div",
114
- code({ node, inline, className, children, ...props }) {
115
- const match = /language-(\w+)/.exec(className || "");
116
- if (inline) return <code>{children}</code>;
117
- return !inline && match ? (
118
- <CodeBlock className={className}>{children}</CodeBlock>
119
- ) : (
120
- <CodeBlock>{children}</CodeBlock>
121
- );
122
- },
123
- }}
124
- rehypePlugins={[rehypeRaw]}
125
- />
126
- </div>
103
+ <>
104
+ <Markdown>{description}</Markdown>
105
+ </>
127
106
  ));
128
107
 
129
108
  const renderQualifierMessage = guard(qualifierMessage, (message) => (
130
- <div>
131
- <ReactMarkdown
132
- children={createDescription(message)}
133
- rehypePlugins={[rehypeRaw]}
134
- />
135
- </div>
109
+ <>
110
+ <Markdown>{message}</Markdown>
111
+ </>
136
112
  ));
137
113
 
138
114
  function renderDefaultValue() {
@@ -193,7 +169,9 @@ export default function SchemaItem(props: Props) {
193
169
  >
194
170
  {name}
195
171
  </strong>
196
- <span className="openapi-schema__name"> {schemaName}</span>
172
+ <span className="openapi-schema__name">
173
+ {Array.isArray(schemaName) ? schemaName.join(" | ") : schemaName}
174
+ </span>
197
175
  {(nullable || required || deprecated) && (
198
176
  <span className="openapi-schema__divider"></span>
199
177
  )}
@@ -0,0 +1,18 @@
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
+ interface Props {
11
+ size?: "sm" | "md" | "lg";
12
+ }
13
+
14
+ const SkeletonLoader: React.FC<Props> = (props) => {
15
+ return <div className={`openapi-skeleton ${props.size ?? "md"}`}></div>;
16
+ };
17
+
18
+ export default SkeletonLoader;
@@ -0,0 +1,72 @@
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 ApiTabs from "@theme/ApiTabs";
11
+ import Details from "@theme/Details";
12
+ import Markdown from "@theme/Markdown";
13
+ import ResponseHeaders from "@theme/ResponseHeaders";
14
+ import ResponseSchema from "@theme/ResponseSchema";
15
+ import TabItem from "@theme/TabItem";
16
+ import { ApiItem } from "docusaurus-plugin-openapi-docs/lib/types";
17
+
18
+ interface Props {
19
+ id?: string;
20
+ label?: string;
21
+ responses: ApiItem["responses"];
22
+ }
23
+
24
+ const StatusCodes: React.FC<Props> = ({ label, id, responses }: any) => {
25
+ if (!responses) return null;
26
+
27
+ const codes = Object.keys(responses);
28
+ if (codes.length === 0) return null;
29
+
30
+ return (
31
+ <ApiTabs label={label} id={id}>
32
+ {codes.map((code) => {
33
+ const response = responses[code];
34
+ const responseHeaders = response.headers;
35
+
36
+ return (
37
+ // @ts-ignore
38
+ <TabItem key={code} label={code} value={code}>
39
+ <div>
40
+ {response.description && (
41
+ <div style={{ marginTop: ".5rem", marginBottom: ".5rem" }}>
42
+ <Markdown>{response.description}</Markdown>
43
+ </div>
44
+ )}
45
+ </div>
46
+ {responseHeaders && (
47
+ <Details
48
+ className="openapi-markdown__details"
49
+ data-collapsed={true}
50
+ open={false}
51
+ style={{ textAlign: "left", marginBottom: "1rem" }}
52
+ summary={
53
+ <summary>
54
+ <strong>Response Headers</strong>
55
+ </summary>
56
+ }
57
+ >
58
+ <ResponseHeaders responseHeaders={responseHeaders} />
59
+ </Details>
60
+ )}
61
+ <ResponseSchema
62
+ title="Schema"
63
+ body={{ content: response.content }}
64
+ />
65
+ </TabItem>
66
+ );
67
+ })}
68
+ </ApiTabs>
69
+ );
70
+ };
71
+
72
+ export default StatusCodes;
@@ -81,6 +81,7 @@
81
81
  --openapi-explorer-padding-input: 0.5rem;
82
82
  --openapi-explorer-border-color: var(--ifm-toc-border-color);
83
83
  --openapi-explorer-caret-bg: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px" viewBox="0 0 24 24"><path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path></svg>');
84
+ --openapi-skeleton-background: var(--ifm-color-emphasis-100);
84
85
  }
85
86
 
86
87
  [data-theme="dark"] {
@@ -92,16 +93,16 @@
92
93
  height: 100%;
93
94
  }
94
95
 
95
- @media (min-width: 997px) {
96
- .docItemCol {
97
- max-width: 75% !important;
98
- }
96
+ // @media (min-width: 997px) {
97
+ // .docItemCol {
98
+ // max-width: 75% !important;
99
+ // }
99
100
 
100
- /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
101
- .tocMobile {
102
- display: none;
103
- }
104
- }
101
+ // /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
102
+ // .tocMobile {
103
+ // display: none;
104
+ // }
105
+ // }
105
106
 
106
107
  /* Begin OpenAPI theme styles */
107
108
  // [data-theme="dark"] {
@@ -160,6 +161,52 @@
160
161
  border-right: thin solid var(--ifm-toc-border-color);
161
162
  }
162
163
 
164
+ @media (max-width: 997px) {
165
+ .schema {
166
+ margin-bottom: 1rem;
167
+ }
168
+ }
169
+
163
170
  .openapi-tabs__heading {
164
171
  margin-bottom: 1rem;
165
172
  }
173
+
174
+ /* Loading Skeleton */
175
+ @keyframes pulsing {
176
+ 0% {
177
+ opacity: 1;
178
+ background-color: var(--ifm-color-emphasis-100);
179
+ }
180
+ 50% {
181
+ opacity: 0.6;
182
+ background-color: var(--ifm-toc-border-color);
183
+ }
184
+ 100% {
185
+ opacity: 1;
186
+ background-color: var(--ifm-color-emphasis-100);
187
+ }
188
+ }
189
+
190
+ .openapi-skeleton {
191
+ animation: pulsing 2s infinite ease-in-out;
192
+ }
193
+
194
+ /* Loading Skeleton */
195
+ .openapi-skeleton {
196
+ border-radius: var(--ifm-pre-border-radius);
197
+ background-color: var(--openapi-skeleton-background);
198
+ max-width: 100%;
199
+ margin: 1rem auto;
200
+ }
201
+
202
+ .openapi-skeleton.sm {
203
+ height: 100px;
204
+ }
205
+
206
+ .openapi-skeleton.md {
207
+ height: 350px;
208
+ }
209
+
210
+ .openapi-skeleton.lg {
211
+ height: 96.5%;
212
+ }