Gathering detailed insights and metrics for @mxenabled/docusaurus-plugin-openapi-docs
Gathering detailed insights and metrics for @mxenabled/docusaurus-plugin-openapi-docs
Gathering detailed insights and metrics for @mxenabled/docusaurus-plugin-openapi-docs
Gathering detailed insights and metrics for @mxenabled/docusaurus-plugin-openapi-docs
npm install @mxenabled/docusaurus-plugin-openapi-docs
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (88.64%)
SCSS (9.63%)
JavaScript (1.65%)
CSS (0.07%)
Shell (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
687 Commits
5 Watchers
7 Branches
23 Contributors
Updated on Aug 01, 2023
Latest Version
2.0.3
Package Id
@mxenabled/docusaurus-plugin-openapi-docs@2.0.3
Unpacked Size
535.66 kB
Size
100.12 kB
File Count
144
NPM Version
lerna/5.6.2/node@v18.14.2+arm64 (darwin)
Node Version
18.14.2
Published on
Feb 23, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
23
1
OpenAPI plugin for generating API reference docs in Docusaurus v2.
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 and can be used to render beautiful reference API docs by setting docItemComponent
to @theme/ApiItem
, a custom component included in the docusaurus-theme-openapi-docs
theme.
Key Features:
Plugin:
1yarn add docusaurus-plugin-openapi-docs
Theme:
1yarn add docusaurus-theme-openapi-docs
docusaurus.config.js
(Plugin and theme usage)Here is an example of properly configuring your docusaurus.config.js
file for docusaurus-plugin-openapi-docs
and docusaurus-theme-openapi-docs
usage.
1// docusaurus.config.js 2 3{ 4 presets: [ 5 [ 6 "classic", 7 /** @type {import('@docusaurus/preset-classic').Options} */ 8 ({ 9 docs: { 10 sidebarPath: require.resolve("./sidebars.js"), 11 // Please change this to your repo. 12 // Remove this to remove the "edit this page" links. 13 editUrl: 14 "https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/", 15 docLayoutComponent: "@theme/DocPage", 16 docItemComponent: "@theme/ApiItem" // Derived from docusaurus-theme-openapi-docs 17 }, 18 blog: { 19 showReadingTime: true, 20 // Please change this to your repo. 21 // Remove this to remove the "edit this page" links. 22 editUrl: 23 "https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/" 24 }, 25 theme: { 26 customCss: require.resolve("./src/css/custom.css") 27 } 28 }) 29 ] 30], 31 32 plugins: [ 33 '@mxenabled/docusaurus-plugin-openapi-docs', 34 { 35 id: "apiDocs", 36 docsPluginId: "classic", 37 config: { 38 petstore: { // Note: petstore key is treated as the <id> and can be used to specify an API doc instance when using CLI commands 39 specPath: "examples/petstore.yaml", // Path to designated spec file 40 outputDir: "api/petstore", // Output directory for generated .mdx docs 41 sidebarOptions: { 42 groupPathsBy: "tag", 43 }, 44 }, 45 burgers: { 46 specPath: "examples/food/burgers/openapi.yaml", 47 outputDir: "api/food/burgers", 48 } 49 } 50 }, 51 ] 52 ], 53 themes: ["@mxenabled/docusaurus-theme-openapi-docs"] // Allows use of @theme/ApiItem and other components 54}
Note: You may optionally configure a dedicated
@docusaurus/plugin-content-docs
instance for use withdocusaurus-theme-openapi-docs
by settingdocItemComponent
to@theme/ApiItem
.
The docusaurus-plugin-openapi-docs
plugin can be configured with the following options:
Name | Type | Default | Description |
---|---|---|---|
id | string | null | A unique document id. |
docsPluginId | string | null | The ID associated with the plugin-content-docs or preset instance used to render the OpenAPI docs (e.g. "your-plugin-id", "classic", "default"). |
config
can be configured with the following options:
Name | Type | Default | Description |
---|---|---|---|
specPath | string | null | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
outputDir | string | null | Desired output path for generated MDX files. |
proxy | string | null | Optional: Proxy URL to prepend to base URL when performing API requests from browser. |
template | string | null | Optional: Customize MDX content with a desired template. |
downloadUrl | string | null | Optional: Designated URL for downloading OpenAPI specification. (requires info section/doc) |
hideSendButton | boolean | null | Optional: If set to true , hides the "Send API Request" button in API demo panel |
showExtensions | boolean | null | Optional: If set to true , renders operation-level vendor-extensions in description. |
sidebarOptions | object | null | Optional: Set of options for sidebar configuration. See below for a list of supported options. |
version | string | null | Optional: Version assigned to single or micro-spec API specified in specPath . |
label | string | null | Optional: Version label used when generating version selector dropdown menu. |
baseUrl | string | null | Optional: Version base URL used when generating version selector dropdown menu. |
versions | object | null | Optional: Set of options for versioning configuration. See below for a list of supported options. |
markdownGenerators | object | null | Optional: Customize MDX content with a set of options for markdown generator configuration. See below for a list of supported options. |
sidebarOptions
can be configured with the following options:
Name | Type | Default | Description |
---|---|---|---|
groupPathsBy | string | null | Organize and group sidebar slice by specified option. Note: Currently, groupPathsBy only contains support for grouping by tag . |
categoryLinkSource | string | null | Defines what source to use for rendering category link pages when grouping paths by tag. The supported options are as follows: tag : Sets the category link config type to generated-index and uses the tag description as the link config description. 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). none : Does not create pages for categories, only groups that can be expanded/collapsed. |
sidebarCollapsible | boolean | true | Whether sidebar categories are collapsible by default. |
sidebarCollapsed | boolean | true | Whether sidebar categories are collapsed by default. |
customProps | object | null | Additional props for customizing a sidebar item. |
You may optionally configure a
sidebarOptions
. In doing so, an individualsidebar.js
slice with the configured options will be generated within the respectiveoutputDir
.
versions
can be configured with the following options:
Name | Type | Default | Description |
---|---|---|---|
specPath | string | null | Designated URL or path to the source of an OpenAPI specification file or directory of micro OpenAPI specification files. |
outputDir | string | null | Desired output path for versioned, generated MDX files. |
label | string | null | Optional: Version label used when generating version selector dropdown menu. |
baseUrl | string | null | Optional: Version base URL used when generating version selector dropdown menu. |
All versions will automatically inherit
sidebarOptions
from the parent/base config.
markdownGenerators
can be configured with the following options:
Name | Type | Default | Description |
---|---|---|---|
createApiPageMD | function | null | Optional: Returns a string of the raw markdown body for API pages. Function type: (pageData: ApiPageMetadata) => string |
createInfoPageMD | function | null | Optional: Returns a string of the raw markdown body for info pages. Function type: (pageData: InfoPageMetadata) => string |
createTagPageMD | function | null | Optional: Returns a string of the raw markdown body for tag pages. Function type: (pageData: TagPageMetadata) => string |
1Usage: docusaurus <command> [options] 2 3Options: 4 -V, --version output the version number 5 -h, --help display help for command 6 7Commands: 8 build [options] [siteDir] Build website. 9 swizzle [options] [themeName] [componentName] [siteDir] Wraps or ejects the original theme files into website folder for customization. 10 deploy [options] [siteDir] Deploy website to GitHub pages. 11 start [options] [siteDir] Start the development server. 12 serve [options] [siteDir] Serve website locally. 13 clear [siteDir] Remove build artifacts. 14 write-translations [options] [siteDir] Extract required translations of your site. 15 write-heading-ids [options] [siteDir] [files...] Generate heading ids in Markdown content. 16 docs:version <version> Tag a new docs version 17 gen-api-docs <id> Generates OpenAPI docs in MDX file format and sidebar.js (if enabled). 18 gen-api-docs:version <id:version> Generates versioned OpenAPI docs in MDX file format, versions.js and sidebar.js (if enabled). 19 clean-api-docs <id> Clears the generated OpenAPI docs MDX files and sidebar.js (if enabled). 20 clean-api-docs:version <id:version> Clears the versioned, generated OpenAPI docs MDX files, versions.json and sidebar.js (if 21 enabled).
To generate all OpenAPI docs, run the following command from the root directory of your project:
1yarn docusaurus gen-api-docs all
This will generate API docs for all of the OpenAPI specification (OAS) files referenced in your
docusaurus-plugin-openapi-docs
config.
You may also generate OpenAPI docs for a single path or OAS by specifying the unique id
:
1yarn docusaurus gen-api-docs <id>
Example:
1yarn docusaurus gen-api-docs burgers
The example above will only generate API docs relative to
burgers
.
To clean/remove all API Docs, run the following command from the root directory of your project:
1yarn docusaurus clean-api-docs all
You may also remove a particular set of API docs by specifying the unique id
of your desired spec instance.
1yarn docusaurus clean-api-docs <id>
Example:
1yarn docusaurus clean-api-docs burgers
The example above will remove all API docs relative to
burgers
.
To generate all versioned OpenAPI docs, run the following command from the root directory of your project:
1yarn docusaurus gen-api-docs:version <id>:all
Example:
1yarn docusaurus gen-api-docs:version petstore:all
This will generate API docs for all of the OpenAPI specification (OAS) files referenced in your
versions
config and will also generate aversions.json
file.
Substitue
all
with a specific version ID to generate/clean a specific version. Generating forall
or a specific version ID will automatically update theversions.json
file.
Run the following to bootstrap a Docsaurus v2 site (classic theme) with docusaurus-openapi-docs
:
1npx create-docusaurus@2.0.1 my-website --package-manager yarn
When prompted to select a template choose
Git repository
.
Template Repository URL:
1https://github.com/PaloAltoNetworks/docusaurus-template-openapi-docs.git
When asked how the template repo should be cloned choose "copy" (unless you know better).
1cd my-website 2yarn
Looking to make a contribution? Make sure to checkout out our contributing guide.
After forking the main repository, run the following:
1git clone https://github.com/<your account>/docusaurus-openapi-docs.git 2cd docusaurus-openapi-docs 3yarn 4yarn build-packages 5yarn watch:demo
Please read SUPPORT.md for details on how to get support for this project.
No vulnerabilities found.
No security vulnerabilities found.