docusaurus-plugin-openapi-docs 1.0.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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +194 -0
  3. package/lib/index.d.ts +3 -0
  4. package/lib/index.js +194 -0
  5. package/lib/markdown/createDeprecationNotice.d.ts +6 -0
  6. package/lib/markdown/createDeprecationNotice.js +19 -0
  7. package/lib/markdown/createDescription.d.ts +1 -0
  8. package/lib/markdown/createDescription.js +16 -0
  9. package/lib/markdown/createDetails.d.ts +2 -0
  10. package/lib/markdown/createDetails.js +18 -0
  11. package/lib/markdown/createDetailsSummary.d.ts +2 -0
  12. package/lib/markdown/createDetailsSummary.js +18 -0
  13. package/lib/markdown/createFullWidthTable.d.ts +2 -0
  14. package/lib/markdown/createFullWidthTable.js +18 -0
  15. package/lib/markdown/createParamsDetails.d.ts +7 -0
  16. package/lib/markdown/createParamsDetails.js +44 -0
  17. package/lib/markdown/createParamsTable.d.ts +7 -0
  18. package/lib/markdown/createParamsTable.js +80 -0
  19. package/lib/markdown/createRequestBodyDetails.d.ts +6 -0
  20. package/lib/markdown/createRequestBodyDetails.js +14 -0
  21. package/lib/markdown/createRequestBodyTable.d.ts +6 -0
  22. package/lib/markdown/createRequestBodyTable.js +14 -0
  23. package/lib/markdown/createSchemaDetails.d.ts +14 -0
  24. package/lib/markdown/createSchemaDetails.js +241 -0
  25. package/lib/markdown/createSchemaTable.d.ts +14 -0
  26. package/lib/markdown/createSchemaTable.js +217 -0
  27. package/lib/markdown/createStatusCodes.d.ts +6 -0
  28. package/lib/markdown/createStatusCodes.js +47 -0
  29. package/lib/markdown/createVersionBadge.d.ts +1 -0
  30. package/lib/markdown/createVersionBadge.js +20 -0
  31. package/lib/markdown/index.d.ts +3 -0
  32. package/lib/markdown/index.js +43 -0
  33. package/lib/markdown/schema.d.ts +3 -0
  34. package/lib/markdown/schema.js +100 -0
  35. package/lib/markdown/schema.test.d.ts +1 -0
  36. package/lib/markdown/schema.test.js +171 -0
  37. package/lib/markdown/utils.d.ts +7 -0
  38. package/lib/markdown/utils.js +33 -0
  39. package/lib/openapi/createExample.d.ts +2 -0
  40. package/lib/openapi/createExample.js +113 -0
  41. package/lib/openapi/index.d.ts +1 -0
  42. package/lib/openapi/index.js +12 -0
  43. package/lib/openapi/openapi.d.ts +11 -0
  44. package/lib/openapi/openapi.js +233 -0
  45. package/lib/openapi/openapi.test.d.ts +1 -0
  46. package/lib/openapi/openapi.test.js +33 -0
  47. package/lib/openapi/types.d.ts +331 -0
  48. package/lib/openapi/types.js +8 -0
  49. package/lib/options.d.ts +4 -0
  50. package/lib/options.js +18 -0
  51. package/lib/sidebars/index.d.ts +3 -0
  52. package/lib/sidebars/index.js +89 -0
  53. package/lib/types.d.ts +68 -0
  54. package/lib/types.js +8 -0
  55. package/package.json +58 -0
  56. package/src/index.ts +244 -0
  57. package/src/markdown/createDeprecationNotice.ts +30 -0
  58. package/src/markdown/createDescription.ts +13 -0
  59. package/src/markdown/createDetails.ts +16 -0
  60. package/src/markdown/createDetailsSummary.ts +16 -0
  61. package/src/markdown/createFullWidthTable.ts +16 -0
  62. package/src/markdown/createParamsDetails.ts +53 -0
  63. package/src/markdown/createParamsTable.ts +102 -0
  64. package/src/markdown/createRequestBodyDetails.ts +17 -0
  65. package/src/markdown/createRequestBodyTable.ts +17 -0
  66. package/src/markdown/createSchemaDetails.ts +302 -0
  67. package/src/markdown/createSchemaTable.ts +275 -0
  68. package/src/markdown/createStatusCodes.ts +52 -0
  69. package/src/markdown/createVersionBadge.ts +18 -0
  70. package/src/markdown/index.ts +55 -0
  71. package/src/markdown/schema.test.ts +196 -0
  72. package/src/markdown/schema.ts +115 -0
  73. package/src/markdown/utils.ts +39 -0
  74. package/src/openapi/__fixtures__/examples/openapi.yaml +13 -0
  75. package/src/openapi/__fixtures__/examples/yogurtstore/_category_.json +4 -0
  76. package/src/openapi/__fixtures__/examples/yogurtstore/froyo.yaml +13 -0
  77. package/src/openapi/__fixtures__/examples/yogurtstore/nested/nested.yaml +13 -0
  78. package/src/openapi/createExample.ts +143 -0
  79. package/src/openapi/index.ts +8 -0
  80. package/src/openapi/openapi.test.ts +37 -0
  81. package/src/openapi/openapi.ts +293 -0
  82. package/src/openapi/types.ts +430 -0
  83. package/src/openapi-to-postmanv2.d.ts +10 -0
  84. package/src/options.ts +20 -0
  85. package/src/plugin-content-docs-types.d.ts +42 -0
  86. package/src/plugin-openapi.d.ts +87 -0
  87. package/src/sidebars/index.ts +121 -0
  88. package/src/types.ts +97 -0
  89. package/tsconfig.json +7 -0
package/src/types.ts ADDED
@@ -0,0 +1,97 @@
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
+ // @ts-ignore
9
+ import type { Request } from "@paloaltonetworks/postman-collection";
10
+
11
+ import {
12
+ InfoObject,
13
+ OperationObject,
14
+ SecuritySchemeObject,
15
+ } from "./openapi/types";
16
+
17
+ export type {
18
+ PropSidebarItemCategory,
19
+ SidebarItemLink,
20
+ PropSidebar,
21
+ PropSidebarItem,
22
+ } from "@docusaurus/plugin-content-docs-types";
23
+ export interface PluginOptions {
24
+ id?: string;
25
+ config: {
26
+ [key: string]: APIOptions;
27
+ };
28
+ }
29
+
30
+ export interface APIOptions {
31
+ specPath: string;
32
+ outputDir: string;
33
+ template?: string;
34
+ sidebarOptions?: SidebarOptions;
35
+ }
36
+
37
+ export interface LoadedContent {
38
+ loadedApi: ApiMetadata[];
39
+ // loadedDocs: DocPageMetadata[]; TODO: cleanup
40
+ }
41
+
42
+ export type ApiMetadata = ApiPageMetadata | InfoPageMetadata;
43
+
44
+ export interface ApiMetadataBase {
45
+ sidebar?: string;
46
+ previous?: ApiNavLink;
47
+ next?: ApiNavLink;
48
+ //
49
+ id: string; // TODO legacy versioned id => try to remove
50
+ unversionedId: string; // TODO new unversioned id => try to rename to "id"
51
+ title: string;
52
+ description: string;
53
+ source: string; // @site aliased source => "@site/docs/folder/subFolder/subSubFolder/myDoc.md"
54
+ sourceDirName: string; // relative to the versioned docs folder (can be ".") => "folder/subFolder/subSubFolder"
55
+ slug: string;
56
+ permalink: string;
57
+ sidebarPosition?: number;
58
+ frontMatter: Record<string, unknown>;
59
+ }
60
+
61
+ export interface ApiPageMetadata extends ApiMetadataBase {
62
+ json?: string;
63
+ type: "api";
64
+ api: ApiItem;
65
+ markdown?: string;
66
+ }
67
+
68
+ export interface ApiItem extends OperationObject {
69
+ method: string; // get, post, put, etc...
70
+ path: string; // The endpoint path => "/api/getPets"
71
+ jsonRequestBodyExample: string;
72
+ securitySchemes?: {
73
+ [key: string]: SecuritySchemeObject;
74
+ };
75
+ postman?: Request;
76
+ info: InfoObject;
77
+ }
78
+
79
+ export interface InfoPageMetadata extends ApiMetadataBase {
80
+ type: "info";
81
+ info: ApiInfo;
82
+ markdown?: string;
83
+ }
84
+
85
+ export type ApiInfo = InfoObject;
86
+
87
+ export interface ApiNavLink {
88
+ title: string;
89
+ permalink: string;
90
+ }
91
+
92
+ export interface SidebarOptions {
93
+ groupPathsBy?: string;
94
+ customProps?: { [key: string]: unknown };
95
+ sidebarCollapsible?: boolean;
96
+ sidebarCollapsed?: boolean;
97
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "lib"
5
+ },
6
+ "include": ["src"]
7
+ }