@camunda8/docusaurus-plugin-openapi-docs 4.5.1

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 (170) hide show
  1. package/README.md +386 -0
  2. package/lib/index.d.ts +9 -0
  3. package/lib/index.js +714 -0
  4. package/lib/markdown/createArrayBracket.d.ts +2 -0
  5. package/lib/markdown/createArrayBracket.js +36 -0
  6. package/lib/markdown/createAuthentication.d.ts +2 -0
  7. package/lib/markdown/createAuthentication.js +173 -0
  8. package/lib/markdown/createAuthorization.d.ts +1 -0
  9. package/lib/markdown/createAuthorization.js +15 -0
  10. package/lib/markdown/createCallbackMethodEndpoint.d.ts +1 -0
  11. package/lib/markdown/createCallbackMethodEndpoint.js +20 -0
  12. package/lib/markdown/createCallbacks.d.ts +6 -0
  13. package/lib/markdown/createCallbacks.js +77 -0
  14. package/lib/markdown/createContactInfo.d.ts +2 -0
  15. package/lib/markdown/createContactInfo.js +39 -0
  16. package/lib/markdown/createDeprecationNotice.d.ts +6 -0
  17. package/lib/markdown/createDeprecationNotice.js +20 -0
  18. package/lib/markdown/createDescription.d.ts +1 -0
  19. package/lib/markdown/createDescription.js +13 -0
  20. package/lib/markdown/createDetails.d.ts +2 -0
  21. package/lib/markdown/createDetails.js +17 -0
  22. package/lib/markdown/createDetailsSummary.d.ts +2 -0
  23. package/lib/markdown/createDetailsSummary.js +17 -0
  24. package/lib/markdown/createDownload.d.ts +1 -0
  25. package/lib/markdown/createDownload.js +16 -0
  26. package/lib/markdown/createHeading.d.ts +1 -0
  27. package/lib/markdown/createHeading.js +20 -0
  28. package/lib/markdown/createLicense.d.ts +2 -0
  29. package/lib/markdown/createLicense.js +32 -0
  30. package/lib/markdown/createLogo.d.ts +2 -0
  31. package/lib/markdown/createLogo.js +18 -0
  32. package/lib/markdown/createMethodEndpoint.d.ts +1 -0
  33. package/lib/markdown/createMethodEndpoint.js +20 -0
  34. package/lib/markdown/createParamsDetails.d.ts +6 -0
  35. package/lib/markdown/createParamsDetails.js +18 -0
  36. package/lib/markdown/createRequestBodyDetails.d.ts +13 -0
  37. package/lib/markdown/createRequestBodyDetails.js +13 -0
  38. package/lib/markdown/createRequestHeader.d.ts +1 -0
  39. package/lib/markdown/createRequestHeader.js +23 -0
  40. package/lib/markdown/createRequestSchema.d.ts +14 -0
  41. package/lib/markdown/createRequestSchema.js +20 -0
  42. package/lib/markdown/createResponseSchema.d.ts +14 -0
  43. package/lib/markdown/createResponseSchema.js +20 -0
  44. package/lib/markdown/createSchema.d.ts +9 -0
  45. package/lib/markdown/createSchema.js +668 -0
  46. package/lib/markdown/createSchema.test.d.ts +1 -0
  47. package/lib/markdown/createSchema.test.js +913 -0
  48. package/lib/markdown/createStatusCodes.d.ts +9 -0
  49. package/lib/markdown/createStatusCodes.js +63 -0
  50. package/lib/markdown/createTermsOfService.d.ts +1 -0
  51. package/lib/markdown/createTermsOfService.js +31 -0
  52. package/lib/markdown/createVendorExtensions.d.ts +1 -0
  53. package/lib/markdown/createVendorExtensions.js +24 -0
  54. package/lib/markdown/createVersionBadge.d.ts +1 -0
  55. package/lib/markdown/createVersionBadge.js +19 -0
  56. package/lib/markdown/index.d.ts +5 -0
  57. package/lib/markdown/index.js +93 -0
  58. package/lib/markdown/schema.d.ts +3 -0
  59. package/lib/markdown/schema.js +157 -0
  60. package/lib/markdown/schema.test.d.ts +1 -0
  61. package/lib/markdown/schema.test.js +181 -0
  62. package/lib/markdown/utils.d.ts +20 -0
  63. package/lib/markdown/utils.js +68 -0
  64. package/lib/openapi/createRequestExample.d.ts +2 -0
  65. package/lib/openapi/createRequestExample.js +14 -0
  66. package/lib/openapi/createResponseExample.d.ts +2 -0
  67. package/lib/openapi/createResponseExample.js +14 -0
  68. package/lib/openapi/createSchemaExample.d.ts +7 -0
  69. package/lib/openapi/createSchemaExample.js +231 -0
  70. package/lib/openapi/index.d.ts +1 -0
  71. package/lib/openapi/index.js +12 -0
  72. package/lib/openapi/openapi.d.ts +12 -0
  73. package/lib/openapi/openapi.js +634 -0
  74. package/lib/openapi/openapi.test.d.ts +1 -0
  75. package/lib/openapi/openapi.test.js +33 -0
  76. package/lib/openapi/sdkExamples.d.ts +39 -0
  77. package/lib/openapi/sdkExamples.js +141 -0
  78. package/lib/openapi/types.d.ts +352 -0
  79. package/lib/openapi/types.js +8 -0
  80. package/lib/openapi/utils/loadAndResolveSpec.d.ts +2 -0
  81. package/lib/openapi/utils/loadAndResolveSpec.js +153 -0
  82. package/lib/openapi/utils/services/OpenAPIParser.d.ts +52 -0
  83. package/lib/openapi/utils/services/OpenAPIParser.js +343 -0
  84. package/lib/openapi/utils/services/RedocNormalizedOptions.d.ts +100 -0
  85. package/lib/openapi/utils/services/RedocNormalizedOptions.js +170 -0
  86. package/lib/openapi/utils/types/index.d.ts +2 -0
  87. package/lib/openapi/utils/types/index.js +23 -0
  88. package/lib/openapi/utils/types/open-api.d.ts +305 -0
  89. package/lib/openapi/utils/types/open-api.js +8 -0
  90. package/lib/openapi/utils/types.d.ts +307 -0
  91. package/lib/openapi/utils/types.js +8 -0
  92. package/lib/openapi/utils/utils/JsonPointer.d.ts +51 -0
  93. package/lib/openapi/utils/utils/JsonPointer.js +95 -0
  94. package/lib/openapi/utils/utils/helpers.d.ts +43 -0
  95. package/lib/openapi/utils/utils/helpers.js +230 -0
  96. package/lib/openapi/utils/utils/index.d.ts +3 -0
  97. package/lib/openapi/utils/utils/index.js +25 -0
  98. package/lib/openapi/utils/utils/openapi.d.ts +40 -0
  99. package/lib/openapi/utils/utils/openapi.js +605 -0
  100. package/lib/openapi/webhooks.test.d.ts +1 -0
  101. package/lib/openapi/webhooks.test.js +23 -0
  102. package/lib/options.d.ts +2 -0
  103. package/lib/options.js +70 -0
  104. package/lib/sidebars/index.d.ts +4 -0
  105. package/lib/sidebars/index.js +226 -0
  106. package/lib/sidebars/utils.d.ts +2 -0
  107. package/lib/sidebars/utils.js +30 -0
  108. package/lib/types.d.ts +138 -0
  109. package/lib/types.js +8 -0
  110. package/package.json +68 -0
  111. package/src/index.ts +955 -0
  112. package/src/markdown/__snapshots__/createSchema.test.ts.snap +1605 -0
  113. package/src/markdown/createArrayBracket.ts +35 -0
  114. package/src/markdown/createAuthentication.ts +209 -0
  115. package/src/markdown/createAuthorization.ts +13 -0
  116. package/src/markdown/createCallbackMethodEndpoint.ts +19 -0
  117. package/src/markdown/createCallbacks.ts +101 -0
  118. package/src/markdown/createContactInfo.ts +41 -0
  119. package/src/markdown/createDeprecationNotice.ts +31 -0
  120. package/src/markdown/createDescription.ts +12 -0
  121. package/src/markdown/createDetails.ts +16 -0
  122. package/src/markdown/createDetailsSummary.ts +16 -0
  123. package/src/markdown/createDownload.ts +15 -0
  124. package/src/markdown/createHeading.ts +23 -0
  125. package/src/markdown/createLicense.ts +34 -0
  126. package/src/markdown/createLogo.ts +21 -0
  127. package/src/markdown/createMethodEndpoint.ts +19 -0
  128. package/src/markdown/createParamsDetails.ts +22 -0
  129. package/src/markdown/createRequestBodyDetails.ts +24 -0
  130. package/src/markdown/createRequestHeader.ts +22 -0
  131. package/src/markdown/createRequestSchema.ts +32 -0
  132. package/src/markdown/createResponseSchema.ts +32 -0
  133. package/src/markdown/createSchema.test.ts +1075 -0
  134. package/src/markdown/createSchema.ts +864 -0
  135. package/src/markdown/createStatusCodes.ts +63 -0
  136. package/src/markdown/createTermsOfService.ts +30 -0
  137. package/src/markdown/createVendorExtensions.ts +22 -0
  138. package/src/markdown/createVersionBadge.ts +22 -0
  139. package/src/markdown/index.ts +145 -0
  140. package/src/markdown/schema.test.ts +208 -0
  141. package/src/markdown/schema.ts +188 -0
  142. package/src/markdown/utils.ts +89 -0
  143. package/src/openapi/__fixtures__/examples/openapi.yaml +49 -0
  144. package/src/openapi/__fixtures__/webhook/openapi.yaml +17 -0
  145. package/src/openapi/createRequestExample.ts +13 -0
  146. package/src/openapi/createResponseExample.ts +13 -0
  147. package/src/openapi/createSchemaExample.ts +292 -0
  148. package/src/openapi/index.ts +8 -0
  149. package/src/openapi/openapi.test.ts +40 -0
  150. package/src/openapi/openapi.ts +772 -0
  151. package/src/openapi/sdkExamples.ts +195 -0
  152. package/src/openapi/types.ts +458 -0
  153. package/src/openapi/utils/loadAndResolveSpec.ts +171 -0
  154. package/src/openapi/utils/services/OpenAPIParser.ts +434 -0
  155. package/src/openapi/utils/services/RedocNormalizedOptions.ts +330 -0
  156. package/src/openapi/utils/types/index.ts +10 -0
  157. package/src/openapi/utils/types/open-api.ts +303 -0
  158. package/src/openapi/utils/types.ts +304 -0
  159. package/src/openapi/utils/utils/JsonPointer.ts +99 -0
  160. package/src/openapi/utils/utils/helpers.ts +239 -0
  161. package/src/openapi/utils/utils/index.ts +11 -0
  162. package/src/openapi/utils/utils/openapi.ts +771 -0
  163. package/src/openapi/webhooks.test.ts +30 -0
  164. package/src/openapi-to-postmanv2.d.ts +10 -0
  165. package/src/options.ts +78 -0
  166. package/src/plugin-openapi.d.ts +88 -0
  167. package/src/sidebars/index.ts +322 -0
  168. package/src/sidebars/utils.ts +29 -0
  169. package/src/types.ts +180 -0
  170. package/tsconfig.json +7 -0
package/README.md ADDED
@@ -0,0 +1,386 @@
1
+ <h1 align="center">Docusaurus OpenAPI Doc Generator</h1>
2
+
3
+ <div align="center">
4
+ <img width="200" src="https://user-images.githubusercontent.com/9343811/165975569-1bc29814-884c-4931-83df-860043b625b7.svg" />
5
+ </div>
6
+
7
+ <div align="center">
8
+
9
+ OpenAPI plugin for generating API reference docs in Docusaurus v3.
10
+
11
+ <img src="https://img.shields.io/badge/dynamic/json?style=for-the-badge&logo=meta&color=blueviolet&label=Docusaurus&query=dependencies%5B%22%40docusaurus%2Fcore%22%5D&url=https%3A%2F%2Fraw.githubusercontent.com%2FPaloAltoNetworks%2Fdocusaurus-openapi-docs%2Fmain%2Fdemo%2Fpackage.json" />
12
+ <br/><br/>
13
+
14
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/HEAD/LICENSE) [![npm latest package](https://img.shields.io/npm/v/docusaurus-plugin-openapi-docs/latest.svg)](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [![npm downloads](https://img.shields.io/npm/dm/docusaurus-plugin-openapi-docs.svg)](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [![npm canary package](https://img.shields.io/npm/v/docusaurus-plugin-openapi-docs/canary.svg)](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [![npm beta package](https://img.shields.io/npm/v/docusaurus-plugin-openapi-docs/beta.svg)](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs)
15
+ <br/>
16
+ [![build](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/actions/workflows/validate.yaml/badge.svg)](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/actions/workflows/validate.yaml) [![prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Cypress.io](https://img.shields.io/badge/tested%20with-Cypress-04C38E.svg)](https://www.cypress.io/) [![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/HEAD/CONTRIBUTING.md#pull-requests)
17
+ <br />
18
+
19
+ </div>
20
+
21
+ <p align="center">
22
+
23
+ <img src="https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/assets/9343811/d4e75f15-7daf-48d2-a772-a0c49aa25d26" width="900" />
24
+
25
+ </p>
26
+
27
+ ---
28
+
29
+ ## Overview
30
+
31
+ The `docusaurus-plugin-openapi-docs` package extends the Docusaurus CLI with commands for generating MDX using the OpenAPI specification as the source. The resulting MDX is fully compatible with [plugin-content-docs](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs) and can be used to render beautiful reference API docs when combined with the `docusaurus-theme-openapi-docs` theme.
32
+
33
+ Key Features:
34
+
35
+ - **Compatible:** Works with Swagger 2.0 and OpenAPI 3.x.
36
+ - **Fast:** Convert large OpenAPI specs into MDX docs in seconds. 🔥
37
+ - **Stylish:** Based on the same [Infima styling framework](https://infima.dev/) that powers the Docusaurus UI.
38
+ - **Flexible:** Supports single, multi and _even micro_ OpenAPI specs.
39
+
40
+ ## Compatibility Matrix
41
+
42
+ | Docusaurus OpenAPI Docs | Docusaurus |
43
+ | ----------------------- | --------------- |
44
+ | 4.0.x (current) | `3.5.0 - 3.8.1` |
45
+ | 3.0.x (end-of-support) | `3.0.1 - 3.4.0` |
46
+ | 2.2.3 (legacy) | `2.4.1 - 2.4.3` |
47
+ | 1.7.3 (end-of-support) | `2.0.1 - 2.2.0` |
48
+
49
+ ## Bootstrapping from Template (new Docusaurus site)
50
+
51
+ Run the following to bootstrap a Docusaurus v3 site (classic theme) with `docusaurus-openapi-docs`:
52
+
53
+ ```bash
54
+ npx create-docusaurus@3.8.1 my-website --package-manager yarn
55
+ ```
56
+
57
+ > When prompted to select a template choose `Git repository`.
58
+
59
+ Template Repository URL:
60
+
61
+ ```bash
62
+ https://github.com/PaloAltoNetworks/docusaurus-template-openapi-docs.git
63
+ ```
64
+
65
+ > When asked how the template repo should be cloned choose "copy".
66
+
67
+ ```bash
68
+ cd my-website
69
+ yarn start
70
+ ```
71
+
72
+ If all goes well, you should be greeted by a brand new Docusaurus site that includes API reference docs for the ubiquitous Petstore API!
73
+
74
+ ## Installation (existing Docusaurus site)
75
+
76
+ > Both the plugin and theme are currently designed to pair with a specific Docusaurus release. The Docusaurus badge in the `README.md` and at the top of this page will always reflect the current compatible versions.
77
+
78
+ ### Plugin
79
+
80
+ ```bash
81
+ yarn add docusaurus-plugin-openapi-docs
82
+ ```
83
+
84
+ ### Theme
85
+
86
+ ```bash
87
+ yarn add docusaurus-theme-openapi-docs
88
+ ```
89
+
90
+ ## Configuring `docusaurus.config.ts` (Plugin and theme usage)
91
+
92
+ Here is an example of properly configuring `docusaurus.config.ts` for `docusaurus-plugin-openapi-docs` and `docusaurus-theme-openapi-docs` usage.
93
+
94
+ > Note: Instructions may differ slightly for sites that haven't migrated to typescript.
95
+
96
+ ```typescript
97
+ // docusaurus.config.ts
98
+ // note that parts of the complete config were left out for brevity
99
+ import type * as Preset from "@docusaurus/preset-classic";
100
+ import type { Config } from "@docusaurus/types";
101
+ import type * as Plugin from "@docusaurus/types/src/plugin";
102
+ import type * as OpenApiPlugin from "docusaurus-plugin-openapi-docs";
103
+
104
+ {
105
+ presets: [
106
+ [
107
+ "classic",
108
+ {
109
+ docs: {
110
+ sidebarPath: "./sidebars.ts",
111
+ docItemComponent: "@theme/ApiItem", // Derived from docusaurus-theme-openapi
112
+ },
113
+ theme: {
114
+ customCss: "./src/css/custom.css",
115
+ },
116
+ } satisfies Preset.Options,
117
+ ],
118
+ ],
119
+
120
+ plugins: [
121
+ [
122
+ 'docusaurus-plugin-openapi-docs',
123
+ {
124
+ id: "api", // plugin id
125
+ docsPluginId: "classic", // configured for preset-classic
126
+ config: {
127
+ petstore: {
128
+ specPath: "examples/petstore.yaml",
129
+ outputDir: "docs/petstore",
130
+ maskCredentials: false, // Disable credential masking in code snippets
131
+ sidebarOptions: {
132
+ groupPathsBy: "tag",
133
+ },
134
+ } satisfies OpenApiPlugin.Options,
135
+ }
136
+ },
137
+ ]
138
+ ],
139
+ themes: ["docusaurus-theme-openapi-docs"], // export theme components
140
+ }
141
+ ```
142
+
143
+ > Note: You may optionally configure a dedicated `@docusaurus/plugin-content-docs` instance for use with `docusaurus-theme-openapi-docs` by setting `docItemComponent` to `@theme/ApiItem`.
144
+
145
+ ## Plugin Configuration Options
146
+
147
+ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following options:
148
+
149
+ | Name | Type | Default | Description |
150
+ | -------------- | -------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
151
+ | `id` | `string` | `null` | A unique plugin ID. |
152
+ | `docsPlugin` | `string` | `@docusaurus/plugin-content-docs` | The plugin used to render the OpenAPI docs (ignored if the plugin instance referenced by `docsPluginId` is a `preset`). |
153
+ | `docsPluginId` | `string` | `null` | The plugin ID associated with the `preset` or configured `docsPlugin` instance used to render the OpenAPI docs (e.g. "your-plugin-id", "classic", "default"). |
154
+
155
+ ### config
156
+
157
+ `config` can be configured with the following options:
158
+
159
+ | Name | Type | Default | Description |
160
+ | -------------------- | --------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------- |
161
+ | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
162
+ | `outputDir` | `string` | `null` | Desired output path for generated MDX and sidebar files. |
163
+ | `proxy` | `string` | `null` | _Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. |
164
+ | `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
165
+ | `infoTemplate` | `string` | `null` | _Optional:_ Customize MDX content for **info** pages only. |
166
+ | `tagTemplate` | `string` | `null` | _Optional:_ Customize MDX content for **tag** pages only. |
167
+ | `schemaTemplate` | `string` | `null` | _Optional:_ Customize MDX content for **schema** pages only. |
168
+ | `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading OpenAPI specification. (requires `info` section/doc) |
169
+ | `hideSendButton` | `boolean` | `null` | _Optional:_ If set to `true`, hides the “Send API Request” button in the API demo panel. |
170
+ | `showExtensions` | `boolean` | `null` | _Optional:_ If set to `true`, renders operation‑level vendor‑extensions in descriptions. |
171
+ | `maskCredentials` | `boolean` | `true` | _Optional:_ If set to `false`, disables credential masking in generated code snippets. By default, credentials are masked for security. |
172
+ | `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
173
+ | `version` | `string` | `null` | _Optional:_ Version assigned to a single or micro‑spec API specified in `specPath`. |
174
+ | `label` | `string` | `null` | _Optional:_ Version label used when generating the version‑selector dropdown menu. |
175
+ | `baseUrl` | `string` | `null` | _Optional:_ Base URL for versioned docs in the version‑selector dropdown. |
176
+ | `versions` | `object` | `null` | _Optional:_ Options for versioning configuration. See below for a list of supported options. |
177
+ | `markdownGenerators` | `object` | `null` | _Optional:_ Customize MDX content via generator functions. See below for a list of supported options. |
178
+ | `showSchemas` | `boolean` | `null` | _Optional:_ If set to `true`, generates standalone schema pages and adds them to the sidebar. |
179
+
180
+ ### sidebarOptions
181
+
182
+ `sidebarOptions` can be configured with the following options:
183
+
184
+ | Name | Type | Default | Description |
185
+ | -------------------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
186
+ | `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag` and `tagGroup`. |
187
+ | `categoryLinkSource` | `string` | `null` | Defines what source to use for rendering category link pages when grouping paths by tag. <br/><br/>The supported options are as follows: <br/><br/> `tag`: Sets the category link config type to `generated-index` and uses the tag description as the link config description. <br/><br/>`info`: Sets the category link config type to `doc` and renders the `info` section as the category link (recommended only for multi/micro-spec scenarios). <br/><br/>`none`: Does not create pages for categories, only groups that can be expanded/collapsed. |
188
+ | `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. |
189
+ | `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. |
190
+ | `customProps` | `object` | `null` | Additional props for customizing a sidebar item. |
191
+ | `sidebarGenerators` | `object` | `null` | Optional: Customize sidebar rendering with callback functions. |
192
+
193
+ > You may optionally configure a `sidebarOptions`. In doing so, an individual `sidebar.js` slice with the configured options will be generated within the respective `outputDir`.
194
+ > Use `x-position` vendor extension (or the front matter `position`) on operations to explicitly order sidebar items.
195
+
196
+ `versions` can be configured with the following options:
197
+
198
+ | Name | Type | Default | Description |
199
+ | ------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
200
+ | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or a directory of micro OpenAPI specification files. |
201
+ | `outputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
202
+ | `label` | `string` | `null` | _Optional:_ Version label used when generating the version selector dropdown menu. |
203
+ | `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating the version selector dropdown menu. |
204
+ | `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading the versioned OpenAPI specification. |
205
+
206
+ > All versions will automatically inherit `sidebarOptions` from the parent/base config.
207
+
208
+ ### markdownGenerators
209
+
210
+ `markdownGenerators` can be configured with the following options:
211
+
212
+ | Name | Type | Default | Description |
213
+ | -------------------- | ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
214
+ | `createApiPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for API pages.<br/><br/>**Function type:** `(pageData: ApiPageMetadata) => string` |
215
+ | `createInfoPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for info pages.<br/><br/>**Function type:** `(pageData: InfoPageMetadata) => string` |
216
+ | `createTagPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for tag pages.<br/><br/>**Function type:** `(pageData: TagPageMetadata) => string` |
217
+ | `createSchemaPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for schema pages.<br/><br/>**Function type:** `(pageData: SchemaPageMetadata) => string` |
218
+
219
+ ### sidebarGenerators
220
+
221
+ `sidebarGenerators` can be configured with the following options:
222
+
223
+ | Name | Type | Default | Description |
224
+ | --------------- | ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
225
+ | `createDocItem` | `function` | `null` | Optional: Returns a `SidebarItemDoc` object containing metadata for a sidebar item.<br/><br/>**Function type:** `(item: ApiPageMetadata \| SchemaPageMetadata, context: { sidebarOptions: SidebarOptions; basePath: string }) => SidebarItemDoc` |
226
+
227
+ ## Supported Vendor Extensions
228
+
229
+ The plugin extracts a number of vendor extensions from the OpenAPI spec to enrich the generated docs. The theme renders some of these values as part of the UI.
230
+
231
+ | Extension | Purpose |
232
+ | ------------------------------------------ | --------------------------------------------------------------------- |
233
+ | `x-codeSamples` | Operation level code snippets displayed in the API Explorer. |
234
+ | `x-tagGroups` | Groups tags in the sidebar navigation. |
235
+ | `x-tags` | Assigns tags to schema objects so they appear with tagged operations. |
236
+ | `x-position` | Controls ordering of items in the sidebar. |
237
+ | `x-logo` / `x-dark-logo` | Provides logos for light and dark themes on the intro page. |
238
+ | `x-deprecated-description` | Custom text shown for deprecated operations. |
239
+ | `x-webhooks` | Defines webhook events. |
240
+ | `x-displayName` | Overrides tag display names. |
241
+ | `x-enumDescription` / `x-enumDescriptions` | Documents enum values. |
242
+
243
+ Other ReDoc specific extensions such as `x-circular-ref`, `x-code-samples` (deprecated), `x-examples`, `x-ignoredHeaderParameters`, `x-nullable`, `x-servers`, `x-traitTag`, `x-additionalPropertiesName`, and `x-explicitMappingOnly` are ignored when extracting custom data.
244
+
245
+ ## CLI Usage
246
+
247
+ ```bash
248
+ Usage: docusaurus <command> [options]
249
+
250
+ Options:
251
+ -V, --version output the version number
252
+ -h, --help display help for command
253
+
254
+ Commands:
255
+ build [options] [siteDir] Build website.
256
+ swizzle [options] [themeName] [componentName] [siteDir] Wraps or ejects the original theme files into website folder for customization.
257
+ deploy [options] [siteDir] Deploy website to GitHub pages.
258
+ start [options] [siteDir] Start the development server.
259
+ serve [options] [siteDir] Serve website locally.
260
+ clear [siteDir] Remove build artifacts.
261
+ write-translations [options] [siteDir] Extract required translations of your site.
262
+ write-heading-ids [options] [siteDir] [files...] Generate heading ids in Markdown content.
263
+ docs:version <version> Tag a new docs version
264
+ gen-api-docs [options] <id> Generates OpenAPI docs in MDX file format and sidebar.ts (if enabled).
265
+ gen-api-docs:version [options] <id:version> Generates versioned OpenAPI docs in MDX file format, versions.js and sidebar.ts (if
266
+ enabled).
267
+ clean-api-docs [options] <id> Clears the generated OpenAPI docs MDX files and sidebar.ts (if enabled).
268
+ clean-api-docs:version [options] <id:version> Clears the versioned, generated OpenAPI docs MDX files, versions.json and sidebar.ts
269
+ (if enabled)
270
+ ```
271
+
272
+ ### Generating OpenAPI Docs
273
+
274
+ To generate all OpenAPI docs, run the following command from the root directory of your project:
275
+
276
+ ```bash
277
+ yarn docusaurus gen-api-docs all
278
+ ```
279
+
280
+ > This will generate API docs for all of the OpenAPI specification (OAS) files referenced in your `docusaurus-plugin-openapi-docs` config.
281
+
282
+ You may also generate OpenAPI docs for a single path or OAS by specifying the unique `id`:
283
+
284
+ ```bash
285
+ yarn docusaurus gen-api-docs <id>
286
+ ```
287
+
288
+ Example:
289
+
290
+ ```bash
291
+ yarn docusaurus gen-api-docs petstore
292
+ ```
293
+
294
+ > The example above will only generate API docs relative to `petstore`.
295
+
296
+ If you have multiple versions of the same API, `gen-api-docs` only generates the latest. To generate all versions, use the `--all-versions` flag.
297
+
298
+ Example:
299
+
300
+ ```bash
301
+ yarn docusaurus gen-api-docs all --all-versions
302
+ ```
303
+
304
+ > This will generate API docs for all versions of all the OpenAPI specification (OAS) files referenced in your `docusaurus-plugin-openapi-docs` config.
305
+
306
+ ### Cleaning API Docs
307
+
308
+ To clean/remove all API Docs, run the following command from the root directory of your project:
309
+
310
+ ```bash
311
+ yarn docusaurus clean-api-docs all
312
+ ```
313
+
314
+ You may also remove a particular set of API docs by specifying the unique `id` of your desired spec instance.
315
+
316
+ ```bash
317
+ yarn docusaurus clean-api-docs <id>
318
+ ```
319
+
320
+ Example:
321
+
322
+ ```bash
323
+ yarn docusaurus clean-api-docs petstore
324
+ ```
325
+
326
+ > The example above will remove all API docs relative to `burgers`.
327
+
328
+ If you have multiple versions of the same API, `clean-api-docs` only cleans the latest. To clean all versions, use the `--all-versions` flag.
329
+
330
+ Example:
331
+
332
+ ```bash
333
+ yarn docusaurus clean-api-docs all --all-versions
334
+ ```
335
+
336
+ > This will clean API docs for all versions of all the OpenAPI specification (OAS) files referenced in your `docusaurus-plugin-openapi-docs` config.
337
+
338
+ ### Versioning OpenAPI docs
339
+
340
+ To generate _all_ versioned OpenAPI docs, run the following command from the root directory of your project:
341
+
342
+ ```bash
343
+ yarn docusaurus gen-api-docs:version <id>:all
344
+ ```
345
+
346
+ Example:
347
+
348
+ ```bash
349
+ yarn docusaurus gen-api-docs:version petstore:all
350
+ ```
351
+
352
+ > This will generate API docs for all of the OpenAPI specification (OAS) files referenced in your `versions` config and will also generate a `versions.json` file.
353
+
354
+ > Substitute `all` with a specific version ID to generate or clean a specific version. Generating for `all` or a single version ID will automatically update the `versions.json` file.
355
+
356
+ ## Developer Quick Start
357
+
358
+ > Looking to make a contribution? Make sure to check out our contributing guide.
359
+
360
+ After [forking](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/fork) the main repository, run the following:
361
+
362
+ ```bash
363
+ git clone https://github.com/<your account>/docusaurus-openapi-docs.git
364
+ cd docusaurus-openapi-docs
365
+ yarn
366
+ yarn build-packages
367
+ yarn watch:demo
368
+ ```
369
+
370
+ ## Credits
371
+
372
+ Special thanks to @bourdakos1 (Nick Bourdakos), the author of [docusaurus-openapi](https://github.com/cloud-annotations/docusaurus-openapi), which this project is heavily based on.
373
+
374
+ For more insight into why we decided to completely fork see [#47](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/47)
375
+
376
+ ## Contributors
377
+
378
+ <a href="https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/graphs/contributors">
379
+ <img src="https://contrib.rocks/image?repo=PaloAltoNetworks/docusaurus-openapi-docs" />
380
+ </a>
381
+
382
+ ## Support
383
+
384
+ See [SUPPORT.md](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/SUPPORT.md) for our support agreement and guidelines.
385
+
386
+ If you believe you found a bug or have an idea you'd like to suggest you may [report an issue](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/new/choose) or [start a discussion](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/discussions/new/choose).
package/lib/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { LoadContext, Plugin } from "@docusaurus/types";
2
+ import type { LoadedContent, PluginOptions } from "./types";
3
+ export declare function isURL(str: string): boolean;
4
+ export declare function getDocsPluginConfig(presetsPlugins: any[], plugin: string, pluginId: string): Object | undefined;
5
+ declare function pluginOpenAPIDocs(context: LoadContext, options: PluginOptions): Plugin<LoadedContent>;
6
+ declare namespace pluginOpenAPIDocs {
7
+ var validateOptions: ({ options, validate }: any) => any;
8
+ }
9
+ export default pluginOpenAPIDocs;