docusaurus-theme-openapi-docs 0.0.0-345

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 (194) hide show
  1. package/LICENSE +21 -0
  2. package/babel.config.js +35 -0
  3. package/lib/index.js +48 -0
  4. package/lib/markdown/createDescription.js +20 -0
  5. package/lib/markdown/schema.js +121 -0
  6. package/lib/markdown/utils.js +45 -0
  7. package/lib/postman-code-generators.d.ts +9 -0
  8. package/lib/react-magic-dropzone.d.ts +9 -0
  9. package/lib/theme/ApiDemoPanel/Accept/index.js +41 -0
  10. package/lib/theme/ApiDemoPanel/Accept/slice.js +32 -0
  11. package/lib/theme/ApiDemoPanel/Authorization/auth-types.js +32 -0
  12. package/lib/theme/ApiDemoPanel/Authorization/index.js +174 -0
  13. package/lib/theme/ApiDemoPanel/Authorization/slice.js +137 -0
  14. package/lib/theme/ApiDemoPanel/Body/index.js +185 -0
  15. package/lib/theme/ApiDemoPanel/Body/slice.js +105 -0
  16. package/lib/theme/ApiDemoPanel/ContentType/index.js +41 -0
  17. package/lib/theme/ApiDemoPanel/ContentType/slice.js +32 -0
  18. package/lib/theme/ApiDemoPanel/Curl/index.js +235 -0
  19. package/lib/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
  20. package/lib/theme/ApiDemoPanel/Execute/index.js +85 -0
  21. package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +200 -0
  22. package/lib/theme/ApiDemoPanel/FloatingButton/index.js +32 -0
  23. package/lib/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
  24. package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +96 -0
  25. package/lib/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
  26. package/lib/theme/ApiDemoPanel/FormItem/index.js +35 -0
  27. package/lib/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
  28. package/lib/theme/ApiDemoPanel/FormMultiSelect/index.js +52 -0
  29. package/lib/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
  30. package/lib/theme/ApiDemoPanel/FormSelect/index.js +39 -0
  31. package/lib/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
  32. package/lib/theme/ApiDemoPanel/FormTextInput/index.js +30 -0
  33. package/lib/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
  34. package/lib/theme/ApiDemoPanel/MethodEndpoint/index.js +60 -0
  35. package/lib/theme/ApiDemoPanel/ParamOptions/index.js +248 -0
  36. package/lib/theme/ApiDemoPanel/ParamOptions/slice.js +35 -0
  37. package/lib/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
  38. package/lib/theme/ApiDemoPanel/Response/index.js +75 -0
  39. package/lib/theme/ApiDemoPanel/Response/slice.js +37 -0
  40. package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +51 -0
  41. package/lib/theme/ApiDemoPanel/Server/index.js +109 -0
  42. package/lib/theme/ApiDemoPanel/Server/slice.js +41 -0
  43. package/lib/theme/ApiDemoPanel/Server/styles.module.css +61 -0
  44. package/lib/theme/ApiDemoPanel/VSCode/index.js +252 -0
  45. package/lib/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
  46. package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +328 -0
  47. package/lib/theme/ApiDemoPanel/hooks.js +20 -0
  48. package/lib/theme/ApiDemoPanel/index.js +132 -0
  49. package/lib/theme/ApiDemoPanel/persistanceMiddleware.js +44 -0
  50. package/lib/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
  51. package/lib/theme/ApiDemoPanel/storage-utils.js +47 -0
  52. package/lib/theme/ApiDemoPanel/store.js +48 -0
  53. package/lib/theme/ApiDemoPanel/styles.module.css +44 -0
  54. package/lib/theme/ApiItem/index.js +160 -0
  55. package/lib/theme/ApiItem/styles.module.css +109 -0
  56. package/lib/theme/ApiTabs/index.js +258 -0
  57. package/lib/theme/ApiTabs/styles.module.css +118 -0
  58. package/lib/theme/ParamsItem/index.js +68 -0
  59. package/lib/theme/ParamsItem/styles.module.css +24 -0
  60. package/lib/theme/SchemaItem/index.js +58 -0
  61. package/lib/theme/SchemaItem/styles.module.css +24 -0
  62. package/lib/theme-classic.d.ts +8 -0
  63. package/lib/theme-openapi.d.ts +48 -0
  64. package/lib/theme-translations.d.ts +9 -0
  65. package/lib/types.js +1 -0
  66. package/lib-next/index.js +38 -0
  67. package/lib-next/markdown/createDescription.js +13 -0
  68. package/lib-next/markdown/schema.js +115 -0
  69. package/lib-next/markdown/utils.js +31 -0
  70. package/lib-next/postman-code-generators.d.ts +9 -0
  71. package/lib-next/react-magic-dropzone.d.ts +9 -0
  72. package/lib-next/theme/ApiDemoPanel/Accept/index.js +33 -0
  73. package/lib-next/theme/ApiDemoPanel/Accept/slice.js +19 -0
  74. package/lib-next/theme/ApiDemoPanel/Authorization/auth-types.js +22 -0
  75. package/lib-next/theme/ApiDemoPanel/Authorization/index.js +203 -0
  76. package/lib-next/theme/ApiDemoPanel/Authorization/slice.js +101 -0
  77. package/lib-next/theme/ApiDemoPanel/Body/index.js +210 -0
  78. package/lib-next/theme/ApiDemoPanel/Body/slice.js +89 -0
  79. package/lib-next/theme/ApiDemoPanel/ContentType/index.js +33 -0
  80. package/lib-next/theme/ApiDemoPanel/ContentType/slice.js +19 -0
  81. package/lib-next/theme/ApiDemoPanel/Curl/index.js +262 -0
  82. package/lib-next/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
  83. package/lib-next/theme/ApiDemoPanel/Execute/index.js +73 -0
  84. package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +181 -0
  85. package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +19 -0
  86. package/lib-next/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
  87. package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +112 -0
  88. package/lib-next/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
  89. package/lib-next/theme/ApiDemoPanel/FormItem/index.js +29 -0
  90. package/lib-next/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
  91. package/lib-next/theme/ApiDemoPanel/FormMultiSelect/index.js +49 -0
  92. package/lib-next/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
  93. package/lib-next/theme/ApiDemoPanel/FormSelect/index.js +28 -0
  94. package/lib-next/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
  95. package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +23 -0
  96. package/lib-next/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
  97. package/lib-next/theme/ApiDemoPanel/MethodEndpoint/index.js +53 -0
  98. package/lib-next/theme/ApiDemoPanel/ParamOptions/index.js +284 -0
  99. package/lib-next/theme/ApiDemoPanel/ParamOptions/slice.js +22 -0
  100. package/lib-next/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
  101. package/lib-next/theme/ApiDemoPanel/Response/index.js +65 -0
  102. package/lib-next/theme/ApiDemoPanel/Response/slice.js +22 -0
  103. package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +48 -0
  104. package/lib-next/theme/ApiDemoPanel/Server/index.js +114 -0
  105. package/lib-next/theme/ApiDemoPanel/Server/slice.js +25 -0
  106. package/lib-next/theme/ApiDemoPanel/Server/styles.module.css +61 -0
  107. package/lib-next/theme/ApiDemoPanel/VSCode/index.js +265 -0
  108. package/lib-next/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
  109. package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +309 -0
  110. package/lib-next/theme/ApiDemoPanel/hooks.js +9 -0
  111. package/lib-next/theme/ApiDemoPanel/index.js +108 -0
  112. package/lib-next/theme/ApiDemoPanel/persistanceMiddleware.js +38 -0
  113. package/lib-next/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
  114. package/lib-next/theme/ApiDemoPanel/storage-utils.js +35 -0
  115. package/lib-next/theme/ApiDemoPanel/store.js +30 -0
  116. package/lib-next/theme/ApiDemoPanel/styles.module.css +44 -0
  117. package/lib-next/theme/ApiItem/index.js +171 -0
  118. package/lib-next/theme/ApiItem/styles.module.css +109 -0
  119. package/lib-next/theme/ApiTabs/index.js +258 -0
  120. package/lib-next/theme/ApiTabs/styles.module.css +118 -0
  121. package/lib-next/theme/ParamsItem/index.js +68 -0
  122. package/lib-next/theme/ParamsItem/styles.module.css +24 -0
  123. package/lib-next/theme/SchemaItem/index.js +58 -0
  124. package/lib-next/theme/SchemaItem/styles.module.css +24 -0
  125. package/lib-next/theme-classic.d.ts +8 -0
  126. package/lib-next/theme-openapi.d.ts +48 -0
  127. package/lib-next/theme-translations.d.ts +9 -0
  128. package/lib-next/types.js +1 -0
  129. package/package.json +74 -0
  130. package/src/index.ts +42 -0
  131. package/src/markdown/createDescription.ts +13 -0
  132. package/src/markdown/schema.ts +115 -0
  133. package/src/markdown/utils.ts +39 -0
  134. package/src/postman-code-generators.d.ts +9 -0
  135. package/src/react-magic-dropzone.d.ts +9 -0
  136. package/src/theme/ApiDemoPanel/Accept/index.tsx +35 -0
  137. package/src/theme/ApiDemoPanel/Accept/slice.ts +29 -0
  138. package/src/theme/ApiDemoPanel/Authorization/auth-types.ts +26 -0
  139. package/src/theme/ApiDemoPanel/Authorization/index.tsx +211 -0
  140. package/src/theme/ApiDemoPanel/Authorization/slice.ts +145 -0
  141. package/src/theme/ApiDemoPanel/Body/index.tsx +218 -0
  142. package/src/theme/ApiDemoPanel/Body/slice.ts +133 -0
  143. package/src/theme/ApiDemoPanel/ContentType/index.tsx +35 -0
  144. package/src/theme/ApiDemoPanel/ContentType/slice.ts +29 -0
  145. package/src/theme/ApiDemoPanel/Curl/index.tsx +278 -0
  146. package/src/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
  147. package/src/theme/ApiDemoPanel/Execute/index.tsx +87 -0
  148. package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +182 -0
  149. package/src/theme/ApiDemoPanel/FloatingButton/index.tsx +27 -0
  150. package/src/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
  151. package/src/theme/ApiDemoPanel/FormFileUpload/index.tsx +115 -0
  152. package/src/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
  153. package/src/theme/ApiDemoPanel/FormItem/index.tsx +28 -0
  154. package/src/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
  155. package/src/theme/ApiDemoPanel/FormMultiSelect/index.tsx +54 -0
  156. package/src/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
  157. package/src/theme/ApiDemoPanel/FormSelect/index.tsx +36 -0
  158. package/src/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
  159. package/src/theme/ApiDemoPanel/FormTextInput/index.tsx +32 -0
  160. package/src/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
  161. package/src/theme/ApiDemoPanel/MethodEndpoint/index.tsx +55 -0
  162. package/src/theme/ApiDemoPanel/ParamOptions/index.tsx +316 -0
  163. package/src/theme/ApiDemoPanel/ParamOptions/slice.ts +37 -0
  164. package/src/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
  165. package/src/theme/ApiDemoPanel/Response/index.tsx +66 -0
  166. package/src/theme/ApiDemoPanel/Response/slice.ts +31 -0
  167. package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +49 -0
  168. package/src/theme/ApiDemoPanel/Server/index.tsx +103 -0
  169. package/src/theme/ApiDemoPanel/Server/slice.ts +40 -0
  170. package/src/theme/ApiDemoPanel/Server/styles.module.css +61 -0
  171. package/src/theme/ApiDemoPanel/VSCode/index.tsx +205 -0
  172. package/src/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
  173. package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +305 -0
  174. package/src/theme/ApiDemoPanel/hooks.ts +13 -0
  175. package/src/theme/ApiDemoPanel/index.tsx +117 -0
  176. package/src/theme/ApiDemoPanel/persistanceMiddleware.ts +46 -0
  177. package/src/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
  178. package/src/theme/ApiDemoPanel/storage-utils.ts +39 -0
  179. package/src/theme/ApiDemoPanel/store.ts +41 -0
  180. package/src/theme/ApiDemoPanel/styles.module.css +44 -0
  181. package/src/theme/ApiItem/index.tsx +171 -0
  182. package/src/theme/ApiItem/styles.module.css +109 -0
  183. package/src/theme/ApiTabs/index.js +258 -0
  184. package/src/theme/ApiTabs/styles.module.css +118 -0
  185. package/src/theme/ParamsItem/index.js +68 -0
  186. package/src/theme/ParamsItem/styles.module.css +24 -0
  187. package/src/theme/SchemaItem/index.js +58 -0
  188. package/src/theme/SchemaItem/styles.module.css +24 -0
  189. package/src/theme-classic.d.ts +8 -0
  190. package/src/theme-openapi.d.ts +48 -0
  191. package/src/theme-translations.d.ts +9 -0
  192. package/src/types.ts +70 -0
  193. package/tsconfig.json +10 -0
  194. package/yarn-error.log +15035 -0
@@ -0,0 +1,68 @@
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 ReactMarkdown from "react-markdown";
11
+
12
+ import { createDescription } from "../../markdown/createDescription";
13
+ import { getQualifierMessage, getSchemaName } from "../../markdown/schema";
14
+ import { guard } from "../../markdown/utils";
15
+ import styles from "./styles.module.css";
16
+
17
+ function ParamsItem({
18
+ param: { description, example, examples, name, required, schema },
19
+ }) {
20
+ const renderSchemaName = guard(schema, (schema) => (
21
+ <span className={styles.schemaName}> {getSchemaName(schema)}</span>
22
+ ));
23
+
24
+ const renderSchemaRequired = guard(required, () => (
25
+ <strong className={styles.paramsRequired}> required</strong>
26
+ ));
27
+
28
+ const renderSchema = guard(getQualifierMessage(schema), (message) => (
29
+ <div>
30
+ <ReactMarkdown children={createDescription(message)} />
31
+ </div>
32
+ ));
33
+
34
+ const renderDescription = guard(description, (description) => (
35
+ <div>
36
+ <ReactMarkdown children={createDescription(description)} />
37
+ </div>
38
+ ));
39
+
40
+ const renderExample = guard(example, (example) => (
41
+ <div>{`Example: ${example}`}</div>
42
+ ));
43
+
44
+ const renderExamples = guard(examples, (examples) => {
45
+ const exampleEntries = Object.entries(examples);
46
+ return (
47
+ <>
48
+ {exampleEntries.map(([k, v]) => (
49
+ <div>{`Example (${k}): ${v.value}`}</div>
50
+ ))}
51
+ </>
52
+ );
53
+ });
54
+
55
+ return (
56
+ <li className={styles.paramsItem}>
57
+ <strong>{name}</strong>
58
+ {renderSchemaName}
59
+ {renderSchemaRequired}
60
+ {renderSchema}
61
+ {renderDescription}
62
+ {renderExample}
63
+ {renderExamples}
64
+ </li>
65
+ );
66
+ }
67
+
68
+ export default ParamsItem;
@@ -0,0 +1,24 @@
1
+ .paramsItem {
2
+ margin: 0 0 0 1rem !important;
3
+ position: relative;
4
+ padding-left: 1rem;
5
+ border-left: thin solid var(--ifm-color-gray-500) !important;
6
+ margin-top: unset !important;
7
+ }
8
+
9
+ .paramsItem:hover {
10
+ background-color: var(--ifm-menu-color-background-active);
11
+ }
12
+
13
+ .paramsItem:focus {
14
+ background-color: var(--ifm-menu-color-background-active);
15
+ }
16
+
17
+ .schemaName {
18
+ opacity: 0.6;
19
+ }
20
+
21
+ .paramsRequired {
22
+ font-size: var(--ifm-code-font-size);
23
+ color: var(--openapi-required);
24
+ }
@@ -0,0 +1,58 @@
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 ReactMarkdown from "react-markdown";
11
+
12
+ import { createDescription } from "../../markdown/createDescription";
13
+ import { guard } from "../../markdown/utils";
14
+ import styles from "./styles.module.css";
15
+
16
+ function SchemaItem({
17
+ children: collapsibleSchemaContent,
18
+ collapsible,
19
+ name,
20
+ qualifierMessage,
21
+ required,
22
+ schemaDescription,
23
+ schemaName,
24
+ }) {
25
+ const renderRequired = guard(required, () => (
26
+ <strong className={styles.required}> required</strong>
27
+ ));
28
+
29
+ const renderSchemaDescription = guard(schemaDescription, (description) => (
30
+ <div className={styles.schemaDescription}>
31
+ <ReactMarkdown children={createDescription(description)} />
32
+ </div>
33
+ ));
34
+
35
+ const renderQualifierMessage = guard(qualifierMessage, (message) => (
36
+ <div className={styles.schemaQualifierMessage}>
37
+ <ReactMarkdown children={createDescription(message)} />
38
+ </div>
39
+ ));
40
+
41
+ const schemaContent = (
42
+ <div>
43
+ <strong>{name}</strong>
44
+ <span className={styles.schemaName}> {schemaName}</span>
45
+ {renderRequired}
46
+ {renderQualifierMessage}
47
+ {renderSchemaDescription}
48
+ </div>
49
+ );
50
+
51
+ return (
52
+ <li className={styles.schemaItem}>
53
+ {collapsible ? collapsibleSchemaContent : schemaContent}
54
+ </li>
55
+ );
56
+ }
57
+
58
+ export default SchemaItem;
@@ -0,0 +1,24 @@
1
+ .schemaItem {
2
+ list-style: none;
3
+ position: relative;
4
+ margin: 0 !important;
5
+ padding: 5px 0 5px 1rem;
6
+ border-left: thin solid var(--ifm-color-gray-500) !important;
7
+ }
8
+
9
+ .schemaItem:hover {
10
+ background-color: var(--ifm-menu-color-background-active);
11
+ }
12
+
13
+ .schemaItem:focus {
14
+ background-color: var(--ifm-menu-color-background-active);
15
+ }
16
+
17
+ .schemaName {
18
+ opacity: 0.6;
19
+ }
20
+
21
+ .required {
22
+ font-size: var(--ifm-code-font-size);
23
+ color: var(--openapi-required);
24
+ }
@@ -0,0 +1,8 @@
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
+ /// <reference types="@docusaurus/theme-classic" />
@@ -0,0 +1,48 @@
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
+ /// <reference types="docusaurus-plugin-openapi-docs" />
9
+
10
+ declare module "@docusaurus/plugin-content-docs-types" {
11
+ // Makes all properties visible when hovering over the type
12
+ type Expand<T extends Record<string, unknown>> = { [P in keyof T]: T[P] };
13
+
14
+ export type SidebarItemBase = {
15
+ className?: string;
16
+ customProps?: Record<string, unknown>;
17
+ };
18
+
19
+ export type SidebarItemLink = SidebarItemBase & {
20
+ type: "link";
21
+ href: string;
22
+ label: string;
23
+ docId: string;
24
+ };
25
+
26
+ type SidebarItemCategoryBase = SidebarItemBase & {
27
+ type: "category";
28
+ label: string;
29
+ collapsed: boolean;
30
+ collapsible: boolean;
31
+ };
32
+
33
+ export type PropSidebarItemCategory = Expand<
34
+ SidebarItemCategoryBase & {
35
+ items: PropSidebarItem[];
36
+ }
37
+ >;
38
+
39
+ export type PropSidebarItem = SidebarItemLink | PropSidebarItemCategory;
40
+ export type PropSidebar = PropSidebarItem[];
41
+ export type PropSidebars = {
42
+ [sidebarId: string]: PropSidebar;
43
+ };
44
+ }
45
+
46
+ declare module "docusaurus-theme-openapi-docs" {
47
+ export type ThemeConfig = Partial<import("./types").ThemeConfig>;
48
+ }
@@ -0,0 +1,9 @@
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
+ // TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
9
+ declare module "@docusaurus/theme-translations";
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "docusaurus-theme-openapi-docs",
3
+ "description": "OpenAPI theme for Docusaurus.",
4
+ "version": "0.0.0-345",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "openapi",
8
+ "documentation",
9
+ "docusaurus",
10
+ "websites",
11
+ "theme"
12
+ ],
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs.git",
19
+ "directory": "packages/docusaurus-theme-openapi-docs"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues"
23
+ },
24
+ "types": "src/theme-openapi.d.ts",
25
+ "main": "lib/index.js",
26
+ "scripts": {
27
+ "build": "tsc --noEmit && yarn babel:lib && yarn babel:lib-next && yarn format:lib-next",
28
+ "watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\"",
29
+ "babel:lib": "cross-env BABEL_ENV=lib babel src -d lib --extensions \".tsx,.ts\" --ignore \"**/*.d.ts\" --copy-files",
30
+ "babel:lib-next": "cross-env BABEL_ENV=lib-next babel src -d lib-next --extensions \".tsx,.ts\" --ignore \"**/*.d.ts\" --copy-files",
31
+ "format:lib-next": "prettier --config ../../.prettierrc.json --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
32
+ },
33
+ "devDependencies": {
34
+ "@docusaurus/module-type-aliases": "2.0.0-beta.18",
35
+ "@docusaurus/types": "2.0.0-beta.18",
36
+ "@types/concurrently": "^6.3.0",
37
+ "@types/crypto-js": "^4.1.0",
38
+ "@types/fs-extra": "^9.0.13",
39
+ "@types/lodash": "^4.14.176",
40
+ "@types/mdx-js__react": "^1.5.4",
41
+ "@types/rtlcss": "^3.1.1",
42
+ "concurrently": "^5.2.0"
43
+ },
44
+ "dependencies": {
45
+ "@docusaurus/theme-common": "2.0.0-beta.18",
46
+ "@mdx-js/react": "^1.6.21",
47
+ "@monaco-editor/react": "^4.3.1",
48
+ "@paloaltonetworks/postman-code-generators": "1.1.5-hotfix.5",
49
+ "@paloaltonetworks/postman-collection": "^4.1.0",
50
+ "@reduxjs/toolkit": "^1.7.1",
51
+ "buffer": "^6.0.3",
52
+ "clsx": "^1.1.1",
53
+ "crypto-js": "^4.1.1",
54
+ "docusaurus-plugin-openapi-docs": "0.0.0-345",
55
+ "immer": "^9.0.7",
56
+ "lodash": "^4.17.20",
57
+ "monaco-editor": "^0.31.1",
58
+ "prism-react-renderer": "^1.2.1",
59
+ "process": "^0.11.10",
60
+ "react-magic-dropzone": "^1.0.1",
61
+ "react-markdown": "^8.0.1",
62
+ "react-redux": "^7.2.0",
63
+ "redux-devtools-extension": "^2.13.8",
64
+ "webpack": "^5.61.0"
65
+ },
66
+ "peerDependencies": {
67
+ "react": "^16.8.4 || ^17.0.0",
68
+ "react-dom": "^16.8.4 || ^17.0.0"
69
+ },
70
+ "engines": {
71
+ "node": ">=14"
72
+ },
73
+ "gitHead": "3c372c894fcdf0e84cbbc0e8e5e4e8e3d770fbb4"
74
+ }
package/src/index.ts ADDED
@@ -0,0 +1,42 @@
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 path from "path";
9
+
10
+ import type { Plugin } from "@docusaurus/types";
11
+ import { ProvidePlugin } from "webpack";
12
+
13
+ export default function docusaurusThemeOpenAPI(): Plugin<void> {
14
+ return {
15
+ name: "docusaurus-theme-openapi",
16
+
17
+ getThemePath() {
18
+ return path.join(__dirname, "..", "lib-next", "theme");
19
+ },
20
+
21
+ getTypeScriptThemePath() {
22
+ return path.resolve(__dirname, "..", "src", "theme");
23
+ },
24
+
25
+ configureWebpack() {
26
+ return {
27
+ plugins: [
28
+ new ProvidePlugin({
29
+ Buffer: [require.resolve("buffer/"), "Buffer"],
30
+ process: require.resolve("process/browser"),
31
+ }),
32
+ ],
33
+ resolve: {
34
+ fallback: {
35
+ buffer: require.resolve("buffer/"),
36
+ process: require.resolve("process/browser"),
37
+ },
38
+ },
39
+ };
40
+ },
41
+ };
42
+ }
@@ -0,0 +1,13 @@
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
+ export function createDescription(description: string | undefined) {
9
+ if (!description) {
10
+ return "";
11
+ }
12
+ return `\n\n${description}\n\n`;
13
+ }
@@ -0,0 +1,115 @@
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 { SchemaObject } from "../types";
9
+
10
+ function prettyName(schema: SchemaObject, circular?: boolean) {
11
+ if (schema.$ref) {
12
+ return schema.$ref.replace("#/components/schemas/", "") + circular
13
+ ? " (circular)"
14
+ : "";
15
+ }
16
+
17
+ if (schema.format) {
18
+ return schema.format;
19
+ }
20
+
21
+ if (schema.allOf) {
22
+ return "object";
23
+ }
24
+
25
+ if (schema.type === "object") {
26
+ return schema.xml?.name ?? schema.type;
27
+ }
28
+
29
+ return schema.title ?? schema.type;
30
+ }
31
+
32
+ export function getSchemaName(
33
+ schema: SchemaObject,
34
+ circular?: boolean
35
+ ): string {
36
+ if (schema.items) {
37
+ return prettyName(schema.items, circular) + "[]";
38
+ }
39
+
40
+ return prettyName(schema, circular) ?? "";
41
+ }
42
+
43
+ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
44
+ // TODO:
45
+ // - maxItems
46
+ // - minItems
47
+ // - uniqueItems
48
+ // - maxProperties
49
+ // - minProperties
50
+ // - multipleOf
51
+ if (!schema) {
52
+ return undefined;
53
+ }
54
+
55
+ if (schema.items) {
56
+ return getQualifierMessage(schema.items);
57
+ }
58
+
59
+ let message = "**Possible values:** ";
60
+
61
+ let qualifierGroups = [];
62
+
63
+ if (schema.minLength || schema.maxLength) {
64
+ let lengthQualifier = "";
65
+ if (schema.minLength) {
66
+ lengthQualifier += `${schema.minLength} ≤ `;
67
+ }
68
+ lengthQualifier += "length";
69
+ if (schema.maxLength) {
70
+ lengthQualifier += ` ≤ ${schema.maxLength}`;
71
+ }
72
+ qualifierGroups.push(lengthQualifier);
73
+ }
74
+
75
+ if (
76
+ schema.minimum ||
77
+ schema.maximum ||
78
+ typeof schema.exclusiveMinimum === "number" ||
79
+ typeof schema.exclusiveMaximum === "number"
80
+ ) {
81
+ let minmaxQualifier = "";
82
+ if (typeof schema.exclusiveMinimum === "number") {
83
+ minmaxQualifier += `${schema.exclusiveMinimum} < `;
84
+ } else if (schema.minimum && !schema.exclusiveMinimum) {
85
+ minmaxQualifier += `${schema.minimum} ≤ `;
86
+ } else if (schema.minimum && schema.exclusiveMinimum === true) {
87
+ minmaxQualifier += `${schema.minimum} < `;
88
+ }
89
+ minmaxQualifier += "value";
90
+ if (typeof schema.exclusiveMaximum === "number") {
91
+ minmaxQualifier += ` < ${schema.exclusiveMaximum}`;
92
+ } else if (schema.maximum && !schema.exclusiveMaximum) {
93
+ minmaxQualifier += ` ≤ ${schema.maximum}`;
94
+ } else if (schema.maximum && schema.exclusiveMaximum === true) {
95
+ minmaxQualifier += ` < ${schema.maximum}`;
96
+ }
97
+ qualifierGroups.push(minmaxQualifier);
98
+ }
99
+
100
+ if (schema.pattern) {
101
+ qualifierGroups.push(
102
+ `Value must match regular expression \`${schema.pattern}\``
103
+ );
104
+ }
105
+
106
+ if (schema.enum) {
107
+ qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
108
+ }
109
+
110
+ if (qualifierGroups.length === 0) {
111
+ return undefined;
112
+ }
113
+
114
+ return message + qualifierGroups.join(", ");
115
+ }
@@ -0,0 +1,39 @@
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
+ export type Children = string | undefined | (string | undefined)[];
9
+
10
+ export type Props = Record<string, any> & { children?: Children };
11
+
12
+ export function create(tag: string, props: Props): string {
13
+ const { children, ...rest } = props;
14
+
15
+ let propString = "";
16
+ for (const [key, value] of Object.entries(rest)) {
17
+ propString += ` ${key}={${JSON.stringify(value)}}`;
18
+ }
19
+
20
+ return `<${tag}${propString}>${render(children)}</${tag}>`;
21
+ }
22
+
23
+ export function guard<T>(
24
+ value: T | undefined,
25
+ cb: (value: T) => Children
26
+ ): string {
27
+ if (value) {
28
+ const children = cb(value);
29
+ return render(children);
30
+ }
31
+ return "";
32
+ }
33
+
34
+ export function render(children: Children): string {
35
+ if (Array.isArray(children)) {
36
+ return children.filter((c) => c !== undefined).join("");
37
+ }
38
+ return children ?? "";
39
+ }
@@ -0,0 +1,9 @@
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
+ // TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
9
+ declare module "@paloaltonetworks/postman-code-generators";
@@ -0,0 +1,9 @@
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
+ // TODO: Remove this when https://github.com/facebook/docusaurus/issues/6087 is resolved.
9
+ declare module "react-magic-dropzone";
@@ -0,0 +1,35 @@
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 { useTypedDispatch, useTypedSelector } from "../hooks";
11
+ import FormItem from "./../FormItem";
12
+ import FormSelect from "./../FormSelect";
13
+ import { setAccept } from "./slice";
14
+
15
+ function Accept() {
16
+ const value = useTypedSelector((state) => state.accept.value);
17
+ const options = useTypedSelector((state) => state.accept.options);
18
+ const dispatch = useTypedDispatch();
19
+
20
+ if (options.length <= 1) {
21
+ return null;
22
+ }
23
+
24
+ return (
25
+ <FormItem label="Accept">
26
+ <FormSelect
27
+ value={value}
28
+ options={options}
29
+ onChange={(e) => dispatch(setAccept(e.target.value))}
30
+ />
31
+ </FormItem>
32
+ );
33
+ }
34
+
35
+ export default Accept;
@@ -0,0 +1,29 @@
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 { createSlice, PayloadAction } from "@reduxjs/toolkit";
9
+
10
+ export interface State {
11
+ value: string;
12
+ options: string[];
13
+ }
14
+
15
+ const initialState: State = {} as any;
16
+
17
+ export const slice = createSlice({
18
+ name: "accept",
19
+ initialState,
20
+ reducers: {
21
+ setAccept: (state, action: PayloadAction<string>) => {
22
+ state.value = action.payload;
23
+ },
24
+ },
25
+ });
26
+
27
+ export const { setAccept } = slice.actions;
28
+
29
+ export default slice.reducer;
@@ -0,0 +1,26 @@
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
+ export function getAuthDataKeys(security: { [key: string]: any }) {
9
+ // Bearer Auth
10
+ if (security.type === "http" && security.scheme === "bearer") {
11
+ return ["token"];
12
+ }
13
+
14
+ // Basic Auth
15
+ if (security.type === "http" && security.scheme === "basic") {
16
+ return ["username", "password"];
17
+ }
18
+
19
+ // API Auth
20
+ if (security.type === "apiKey") {
21
+ return ["apiKey"];
22
+ }
23
+
24
+ // none
25
+ return [];
26
+ }