docusaurus-plugin-openapi-docs 0.0.0-1000
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.
- package/LICENSE +21 -0
- package/README.md +361 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +709 -0
- package/lib/markdown/createArrayBracket.d.ts +2 -0
- package/lib/markdown/createArrayBracket.js +36 -0
- package/lib/markdown/createAuthentication.d.ts +2 -0
- package/lib/markdown/createAuthentication.js +171 -0
- package/lib/markdown/createAuthorization.d.ts +1 -0
- package/lib/markdown/createAuthorization.js +15 -0
- package/lib/markdown/createCallbackMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createCallbackMethodEndpoint.js +20 -0
- package/lib/markdown/createCallbacks.d.ts +6 -0
- package/lib/markdown/createCallbacks.js +77 -0
- package/lib/markdown/createContactInfo.d.ts +2 -0
- package/lib/markdown/createContactInfo.js +39 -0
- package/lib/markdown/createDeprecationNotice.d.ts +6 -0
- package/lib/markdown/createDeprecationNotice.js +20 -0
- package/lib/markdown/createDescription.d.ts +1 -0
- package/lib/markdown/createDescription.js +13 -0
- package/lib/markdown/createDetails.d.ts +2 -0
- package/lib/markdown/createDetails.js +17 -0
- package/lib/markdown/createDetailsSummary.d.ts +2 -0
- package/lib/markdown/createDetailsSummary.js +17 -0
- package/lib/markdown/createDownload.d.ts +1 -0
- package/lib/markdown/createDownload.js +16 -0
- package/lib/markdown/createHeading.d.ts +1 -0
- package/lib/markdown/createHeading.js +20 -0
- package/lib/markdown/createLicense.d.ts +2 -0
- package/lib/markdown/createLicense.js +32 -0
- package/lib/markdown/createLogo.d.ts +2 -0
- package/lib/markdown/createLogo.js +18 -0
- package/lib/markdown/createMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createMethodEndpoint.js +20 -0
- package/lib/markdown/createParamsDetails.d.ts +6 -0
- package/lib/markdown/createParamsDetails.js +18 -0
- package/lib/markdown/createRequestBodyDetails.d.ts +13 -0
- package/lib/markdown/createRequestBodyDetails.js +13 -0
- package/lib/markdown/createRequestHeader.d.ts +1 -0
- package/lib/markdown/createRequestHeader.js +21 -0
- package/lib/markdown/createRequestSchema.d.ts +14 -0
- package/lib/markdown/createRequestSchema.js +20 -0
- package/lib/markdown/createResponseSchema.d.ts +14 -0
- package/lib/markdown/createResponseSchema.js +20 -0
- package/lib/markdown/createSchema.d.ts +9 -0
- package/lib/markdown/createSchema.js +668 -0
- package/lib/markdown/createSchema.test.d.ts +1 -0
- package/lib/markdown/createSchema.test.js +913 -0
- package/lib/markdown/createStatusCodes.d.ts +9 -0
- package/lib/markdown/createStatusCodes.js +63 -0
- package/lib/markdown/createTermsOfService.d.ts +1 -0
- package/lib/markdown/createTermsOfService.js +31 -0
- package/lib/markdown/createVendorExtensions.d.ts +1 -0
- package/lib/markdown/createVendorExtensions.js +24 -0
- package/lib/markdown/createVersionBadge.d.ts +1 -0
- package/lib/markdown/createVersionBadge.js +19 -0
- package/lib/markdown/index.d.ts +5 -0
- package/lib/markdown/index.js +92 -0
- package/lib/markdown/schema.d.ts +3 -0
- package/lib/markdown/schema.js +154 -0
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +181 -0
- package/lib/markdown/utils.d.ts +20 -0
- package/lib/markdown/utils.js +68 -0
- package/lib/openapi/createRequestExample.d.ts +2 -0
- package/lib/openapi/createRequestExample.js +191 -0
- package/lib/openapi/createResponseExample.d.ts +2 -0
- package/lib/openapi/createResponseExample.js +192 -0
- package/lib/openapi/index.d.ts +1 -0
- package/lib/openapi/index.js +12 -0
- package/lib/openapi/openapi.d.ts +12 -0
- package/lib/openapi/openapi.js +544 -0
- package/lib/openapi/openapi.test.d.ts +1 -0
- package/lib/openapi/openapi.test.js +33 -0
- package/lib/openapi/types.d.ts +354 -0
- package/lib/openapi/types.js +8 -0
- package/lib/openapi/utils/loadAndResolveSpec.d.ts +2 -0
- package/lib/openapi/utils/loadAndResolveSpec.js +153 -0
- package/lib/openapi/utils/services/OpenAPIParser.d.ts +52 -0
- package/lib/openapi/utils/services/OpenAPIParser.js +343 -0
- package/lib/openapi/utils/services/RedocNormalizedOptions.d.ts +100 -0
- package/lib/openapi/utils/services/RedocNormalizedOptions.js +170 -0
- package/lib/openapi/utils/types/index.d.ts +2 -0
- package/lib/openapi/utils/types/index.js +23 -0
- package/lib/openapi/utils/types/open-api.d.ts +305 -0
- package/lib/openapi/utils/types/open-api.js +8 -0
- package/lib/openapi/utils/types.d.ts +306 -0
- package/lib/openapi/utils/types.js +8 -0
- package/lib/openapi/utils/utils/JsonPointer.d.ts +51 -0
- package/lib/openapi/utils/utils/JsonPointer.js +95 -0
- package/lib/openapi/utils/utils/helpers.d.ts +43 -0
- package/lib/openapi/utils/utils/helpers.js +230 -0
- package/lib/openapi/utils/utils/index.d.ts +3 -0
- package/lib/openapi/utils/utils/index.js +25 -0
- package/lib/openapi/utils/utils/openapi.d.ts +40 -0
- package/lib/openapi/utils/utils/openapi.js +605 -0
- package/lib/options.d.ts +2 -0
- package/lib/options.js +69 -0
- package/lib/sidebars/index.d.ts +4 -0
- package/lib/sidebars/index.js +226 -0
- package/lib/sidebars/utils.d.ts +2 -0
- package/lib/sidebars/utils.js +30 -0
- package/lib/types.d.ts +135 -0
- package/lib/types.js +8 -0
- package/package.json +69 -0
- package/src/index.ts +945 -0
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +1605 -0
- package/src/markdown/createArrayBracket.ts +35 -0
- package/src/markdown/createAuthentication.ts +201 -0
- package/src/markdown/createAuthorization.ts +13 -0
- package/src/markdown/createCallbackMethodEndpoint.ts +19 -0
- package/src/markdown/createCallbacks.ts +101 -0
- package/src/markdown/createContactInfo.ts +41 -0
- package/src/markdown/createDeprecationNotice.ts +31 -0
- package/src/markdown/createDescription.ts +12 -0
- package/src/markdown/createDetails.ts +16 -0
- package/src/markdown/createDetailsSummary.ts +16 -0
- package/src/markdown/createDownload.ts +15 -0
- package/src/markdown/createHeading.ts +23 -0
- package/src/markdown/createLicense.ts +34 -0
- package/src/markdown/createLogo.ts +21 -0
- package/src/markdown/createMethodEndpoint.ts +19 -0
- package/src/markdown/createParamsDetails.ts +22 -0
- package/src/markdown/createRequestBodyDetails.ts +24 -0
- package/src/markdown/createRequestHeader.ts +24 -0
- package/src/markdown/createRequestSchema.ts +32 -0
- package/src/markdown/createResponseSchema.ts +32 -0
- package/src/markdown/createSchema.test.ts +1075 -0
- package/src/markdown/createSchema.ts +862 -0
- package/src/markdown/createStatusCodes.ts +63 -0
- package/src/markdown/createTermsOfService.ts +30 -0
- package/src/markdown/createVendorExtensions.ts +22 -0
- package/src/markdown/createVersionBadge.ts +22 -0
- package/src/markdown/index.ts +144 -0
- package/src/markdown/schema.test.ts +208 -0
- package/src/markdown/schema.ts +185 -0
- package/src/markdown/utils.ts +89 -0
- package/src/openapi/__fixtures__/examples/openapi.yaml +49 -0
- package/src/openapi/createRequestExample.ts +235 -0
- package/src/openapi/createResponseExample.ts +238 -0
- package/src/openapi/index.ts +8 -0
- package/src/openapi/openapi.test.ts +40 -0
- package/src/openapi/openapi.ts +697 -0
- package/src/openapi/types.ts +455 -0
- package/src/openapi/utils/loadAndResolveSpec.ts +171 -0
- package/src/openapi/utils/services/OpenAPIParser.ts +434 -0
- package/src/openapi/utils/services/RedocNormalizedOptions.ts +330 -0
- package/src/openapi/utils/types/index.ts +10 -0
- package/src/openapi/utils/types/open-api.ts +303 -0
- package/src/openapi/utils/types.ts +303 -0
- package/src/openapi/utils/utils/JsonPointer.ts +99 -0
- package/src/openapi/utils/utils/helpers.ts +239 -0
- package/src/openapi/utils/utils/index.ts +11 -0
- package/src/openapi/utils/utils/openapi.ts +771 -0
- package/src/openapi-to-postmanv2.d.ts +10 -0
- package/src/options.ts +77 -0
- package/src/plugin-content-docs-types.d.ts +42 -0
- package/src/plugin-openapi.d.ts +87 -0
- package/src/postman-collection.d.ts +10 -0
- package/src/sidebars/index.ts +322 -0
- package/src/sidebars/utils.ts +29 -0
- package/src/types.ts +176 -0
- package/tsconfig.json +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Palo Alto Networks
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
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
|
+
[](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/HEAD/LICENSE) [](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs)
|
|
15
|
+
<br/>
|
|
16
|
+
[](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/actions/workflows/validate.yaml) [](https://github.com/prettier/prettier) [](https://www.cypress.io/) [](https://github.com/facebook/jest) [](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.7.x` |
|
|
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 Docsaurus v3 site (classic theme) with `docusaurus-openapi-docs`:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx create-docusaurus@3.7.0 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
|
+
sidebarOptions: {
|
|
131
|
+
groupPathsBy: "tag",
|
|
132
|
+
},
|
|
133
|
+
} satisfies OpenApiPlugin.Options,
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
]
|
|
137
|
+
],
|
|
138
|
+
themes: ["docusaurus-theme-openapi-docs"], // export theme components
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
> 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`.
|
|
143
|
+
|
|
144
|
+
## Plugin Configuration Options
|
|
145
|
+
|
|
146
|
+
The `docusaurus-plugin-openapi-docs` plugin can be configured with the following options:
|
|
147
|
+
|
|
148
|
+
| Name | Type | Default | Description |
|
|
149
|
+
| -------------- | -------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
150
|
+
| `id` | `string` | `null` | A unique plugin ID. |
|
|
151
|
+
| `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`). |
|
|
152
|
+
| `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"). |
|
|
153
|
+
|
|
154
|
+
### config
|
|
155
|
+
|
|
156
|
+
`config` can be configured with the following options:
|
|
157
|
+
|
|
158
|
+
| Name | Type | Default | Description |
|
|
159
|
+
| -------------------- | --------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
160
|
+
| `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
|
|
161
|
+
| `ouputDir` | `string` | `null` | Desired output path for generated MDX and sidebar files. |
|
|
162
|
+
| `proxy` | `string` | `null` | _Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. |
|
|
163
|
+
| `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
|
|
164
|
+
| `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading OpenAPI specification. (requires `info` section/doc) |
|
|
165
|
+
| `hideSendButton` | `boolean` | `null` | _Optional:_ If set to `true`, hides the "Send API Request" button in API demo panel |
|
|
166
|
+
| `showExtensions` | `boolean` | `null` | _Optional:_ If set to `true`, renders operation-level vendor-extensions in description. |
|
|
167
|
+
| `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
|
|
168
|
+
| `version` | `string` | `null` | _Optional:_ Version assigned to single or micro-spec API specified in `specPath`. |
|
|
169
|
+
| `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
|
|
170
|
+
| `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |
|
|
171
|
+
| `versions` | `object` | `null` | _Optional:_ Set of options for versioning configuration. See below for a list of supported options. |
|
|
172
|
+
| `markdownGenerators` | `object` | `null` | _Optional:_ Customize MDX content with a set of options for specifying markdown generator functions. See below for a list of supported options. |
|
|
173
|
+
| `showSchemas` | `boolean` | `null` | _Optional:_ If set to `true`, generates schema pages and adds them to the sidebar. |
|
|
174
|
+
|
|
175
|
+
### sidebarOptions
|
|
176
|
+
|
|
177
|
+
`sidebarOptions` can be configured with the following options:
|
|
178
|
+
|
|
179
|
+
| Name | Type | Default | Description |
|
|
180
|
+
| -------------------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
181
|
+
| `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag` and `tagGroup`. |
|
|
182
|
+
| `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. |
|
|
183
|
+
| `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. |
|
|
184
|
+
| `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. |
|
|
185
|
+
| `customProps` | `object` | `null` | Additional props for customizing a sidebar item. |
|
|
186
|
+
| `sidebarGenerators` | `object` | `null` | Optional: Customize sidebar rendering with callback functions. |
|
|
187
|
+
|
|
188
|
+
> 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`.
|
|
189
|
+
|
|
190
|
+
`versions` can be configured with the following options:
|
|
191
|
+
|
|
192
|
+
| Name | Type | Default | Description |
|
|
193
|
+
| ---------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
194
|
+
| `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of micro OpenAPI specification files. |
|
|
195
|
+
| `ouputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
|
|
196
|
+
| `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
|
|
197
|
+
| `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |
|
|
198
|
+
|
|
199
|
+
> All versions will automatically inherit `sidebarOptions` from the parent/base config.
|
|
200
|
+
|
|
201
|
+
### markdownGenerators
|
|
202
|
+
|
|
203
|
+
`markdownGenerators` can be configured with the following options:
|
|
204
|
+
|
|
205
|
+
| Name | Type | Default | Description |
|
|
206
|
+
| -------------------- | ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
207
|
+
| `createApiPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for API pages.<br/><br/>**Function type:** `(pageData: ApiPageMetadata) => string` |
|
|
208
|
+
| `createInfoPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for info pages.<br/><br/>**Function type:** `(pageData: InfoPageMetadata) => string` |
|
|
209
|
+
| `createTagPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for tag pages.<br/><br/>**Function type:** `(pageData: TagPageMetadata) => string` |
|
|
210
|
+
| `createSchemaPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for schema pages.<br/><br/>**Function type:** `(pageData: SchemaPageMetadata) => string` |
|
|
211
|
+
|
|
212
|
+
### sidebarGenerators
|
|
213
|
+
|
|
214
|
+
`sidebarGenerators` can be configured with the following options:
|
|
215
|
+
|
|
216
|
+
| Name | Type | Default | Description |
|
|
217
|
+
| --------------- | ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
218
|
+
| `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` |
|
|
219
|
+
|
|
220
|
+
## CLI Usage
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
Usage: docusaurus <command> [options]
|
|
224
|
+
|
|
225
|
+
Options:
|
|
226
|
+
-V, --version output the version number
|
|
227
|
+
-h, --help display help for command
|
|
228
|
+
|
|
229
|
+
Commands:
|
|
230
|
+
build [options] [siteDir] Build website.
|
|
231
|
+
swizzle [options] [themeName] [componentName] [siteDir] Wraps or ejects the original theme files into website folder for customization.
|
|
232
|
+
deploy [options] [siteDir] Deploy website to GitHub pages.
|
|
233
|
+
start [options] [siteDir] Start the development server.
|
|
234
|
+
serve [options] [siteDir] Serve website locally.
|
|
235
|
+
clear [siteDir] Remove build artifacts.
|
|
236
|
+
write-translations [options] [siteDir] Extract required translations of your site.
|
|
237
|
+
write-heading-ids [options] [siteDir] [files...] Generate heading ids in Markdown content.
|
|
238
|
+
docs:version <version> Tag a new docs version
|
|
239
|
+
gen-api-docs [options] <id> Generates OpenAPI docs in MDX file format and sidebar.ts (if enabled).
|
|
240
|
+
gen-api-docs:version [options] <id:version> Generates versioned OpenAPI docs in MDX file format, versions.js and sidebar.ts (if
|
|
241
|
+
enabled).
|
|
242
|
+
clean-api-docs [options] <id> Clears the generated OpenAPI docs MDX files and sidebar.ts (if enabled).
|
|
243
|
+
clean-api-docs:version [options] <id:version> Clears the versioned, generated OpenAPI docs MDX files, versions.json and sidebar.ts
|
|
244
|
+
(if enabled)
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Generating OpenAPI Docs
|
|
248
|
+
|
|
249
|
+
To generate all OpenAPI docs, run the following command from the root directory of your project:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
yarn docusaurus gen-api-docs all
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
> This will generate API docs for all of the OpenAPI specification (OAS) files referenced in your `docusaurus-plugin-openapi-docs` config.
|
|
256
|
+
|
|
257
|
+
You may also generate OpenAPI docs for a single path or OAS by specifying the unique `id`:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
yarn docusaurus gen-api-docs <id>
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Example:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
yarn docusaurus gen-api-docs petstore
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
> The example above will only generate API docs relative to `petstore`.
|
|
270
|
+
|
|
271
|
+
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.
|
|
272
|
+
|
|
273
|
+
Example:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
yarn docusaurus gen-api-docs all --all-versions
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
> This will generate API docs for all versions of all the OpenAPI specification (OAS) files referenced in your `docusaurus-plugin-openapi-docs` config.
|
|
280
|
+
|
|
281
|
+
### Cleaning API Docs
|
|
282
|
+
|
|
283
|
+
To clean/remove all API Docs, run the following command from the root directory of your project:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
yarn docusaurus clean-api-docs all
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
You may also remove a particular set of API docs by specifying the unique `id` of your desired spec instance.
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
yarn docusaurus clean-api-docs <id>
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Example:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
yarn docusaurus clean-api-docs petstore
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
> The example above will remove all API docs relative to `burgers`.
|
|
302
|
+
|
|
303
|
+
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.
|
|
304
|
+
|
|
305
|
+
Example:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
yarn docusaurus clean-api-docs all --all-versions
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
> This will clean API docs for all versions of all the OpenAPI specification (OAS) files referenced in your `docusaurus-plugin-openapi-docs` config.
|
|
312
|
+
|
|
313
|
+
### Versioning OpenAPI docs
|
|
314
|
+
|
|
315
|
+
To generate _all_ versioned OpenAPI docs, run the following command from the root directory of your project:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
yarn docusaurus gen-api-docs:version <id>:all
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Example:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
yarn docusaurus gen-api-docs:version petstore:all
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
> 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.
|
|
328
|
+
|
|
329
|
+
> Substitue `all` with a specific version ID to generate/clean a specific version. Generating for `all` or a specific version ID will automatically update the `versions.json` file.
|
|
330
|
+
|
|
331
|
+
## Developer Quick Start
|
|
332
|
+
|
|
333
|
+
> Looking to make a contribution? Make sure to checkout out our contributing guide.
|
|
334
|
+
|
|
335
|
+
After [forking](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/fork) the main repository, run the following:
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
git clone https://github.com/<your account>/docusaurus-openapi-docs.git
|
|
339
|
+
cd docusaurus-openapi-docs
|
|
340
|
+
yarn
|
|
341
|
+
yarn build-packages
|
|
342
|
+
yarn watch:demo
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Credits
|
|
346
|
+
|
|
347
|
+
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.
|
|
348
|
+
|
|
349
|
+
For more insight into why we decided to completely fork see [#47](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/47)
|
|
350
|
+
|
|
351
|
+
## Contributors
|
|
352
|
+
|
|
353
|
+
<a href="https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/graphs/contributors">
|
|
354
|
+
<img src="https://contrib.rocks/image?repo=PaloAltoNetworks/docusaurus-openapi-docs" />
|
|
355
|
+
</a>
|
|
356
|
+
|
|
357
|
+
## Support
|
|
358
|
+
|
|
359
|
+
See [SUPPORT.md](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/SUPPORT.md) for our support agreement and guidelines.
|
|
360
|
+
|
|
361
|
+
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;
|