docusaurus-plugin-openapi-docs 0.0.0-379 → 0.0.0-380

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/README.md CHANGED
@@ -107,16 +107,19 @@ Here is an example of properly configuring your `docusaurus.config.js` file for
107
107
 
108
108
  `docusaurus-plugin-openapi-docs` can be configured with the following options:
109
109
 
110
- | Name | Type | Default | Description |
111
- | ---------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
112
- | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
113
- | `ouputDir` | `string` | `null` | Desired output path for generated MDX files. |
114
- | `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
115
- | `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
116
- | `version` | `string` | `null` | _Optional:_ Version assigned to single or micro-spec API specified in `specPath`. |
117
- | `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
118
- | `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |
119
- | `versions` | `object` | `null` | _Optional:_ Set of options for versioning configuration. See below for a list of supported options. |
110
+ | Name | Type | Default | Description |
111
+ | ----------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
112
+ | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
113
+ | `ouputDir` | `string` | `null` | Desired output path for generated MDX files. |
114
+ | `contentDocsPath` | `string` | `null` | Should be equal to the `path` value set in `plugin-content-docs` or preset. |
115
+ | `ouputDir` | `string` | `null` | Desired output path for generated MDX files. |
116
+ | `routeBasePath` | `string` | `null` | _Optional:_ Should be equal to the `routeBasePath` value set in `plugin-content-docs or preset (if present). |
117
+ | `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
118
+ | `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
119
+ | `version` | `string` | `null` | _Optional:_ Version assigned to single or micro-spec API specified in `specPath`. |
120
+ | `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
121
+ | `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |
122
+ | `versions` | `object` | `null` | _Optional:_ Set of options for versioning configuration. See below for a list of supported options. |
120
123
 
121
124
  `sidebarOptions` can be configured with the following options:
122
125
 
package/lib/index.js CHANGED
@@ -27,7 +27,7 @@ function pluginOpenAPIDocs(context, options) {
27
27
  let { config } = options;
28
28
  let { siteDir } = context;
29
29
  async function generateApiDocs(options) {
30
- let { specPath, outputDir, template, sidebarOptions } = options;
30
+ let { specPath, outputDir, contentDocsPath, routeBasePath, template, sidebarOptions, } = options;
31
31
  const contentPath = isURL(specPath)
32
32
  ? specPath
33
33
  : path_1.default.resolve(siteDir, specPath);
@@ -135,8 +135,14 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
135
135
  item.markdown = markdown;
136
136
  if (item.type === "api") {
137
137
  item.json = JSON.stringify(item.api);
138
+ let infoBasePath = `${outputDir}/${item.infoId}`;
139
+ if (routeBasePath) {
140
+ infoBasePath = `${routeBasePath}/${outputDir
141
+ .split(contentDocsPath)[1]
142
+ .replace(/^\/+/g, "")}/${item.infoId}`.replace(/^\/+/g, "");
143
+ }
138
144
  if (item.infoId)
139
- item.infoPath = `${outputDir}/${item.infoId}`;
145
+ item.infoPath = infoBasePath;
140
146
  }
141
147
  const view = (0, mustache_1.render)(mdTemplate, item);
142
148
  const utils = (0, mustache_1.render)(infoMdTemplate, item);
package/lib/options.js CHANGED
@@ -9,19 +9,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.OptionsSchema = void 0;
10
10
  const utils_validation_1 = require("@docusaurus/utils-validation");
11
11
  const sidebarOptions = utils_validation_1.Joi.object({
12
- contentDocsPath: utils_validation_1.Joi.string(),
13
12
  groupPathsBy: utils_validation_1.Joi.string().valid("tag"),
14
13
  categoryLinkSource: utils_validation_1.Joi.string().valid("tag", "info"),
15
14
  customProps: utils_validation_1.Joi.object(),
16
15
  sidebarCollapsible: utils_validation_1.Joi.boolean(),
17
16
  sidebarCollapsed: utils_validation_1.Joi.boolean(),
18
- }).with("groupPathsBy", "contentDocsPath");
17
+ });
19
18
  exports.OptionsSchema = utils_validation_1.Joi.object({
20
19
  id: utils_validation_1.Joi.string().required(),
21
20
  config: utils_validation_1.Joi.object()
22
21
  .pattern(/^/, utils_validation_1.Joi.object({
23
22
  specPath: utils_validation_1.Joi.string().required(),
24
23
  outputDir: utils_validation_1.Joi.string().required(),
24
+ contentDocsPath: utils_validation_1.Joi.string().required(),
25
+ routeBasePath: utils_validation_1.Joi.string(),
25
26
  template: utils_validation_1.Joi.string(),
26
27
  sidebarOptions: sidebarOptions,
27
28
  version: utils_validation_1.Joi.string().when("versions", {
@@ -20,7 +20,8 @@ function isInfoItem(item) {
20
20
  }
21
21
  function groupByTags(items, sidebarOptions, options, tags) {
22
22
  const { outputDir } = options;
23
- const { sidebarCollapsed, sidebarCollapsible, customProps, categoryLinkSource, contentDocsPath, } = sidebarOptions;
23
+ const { sidebarCollapsed, sidebarCollapsible, customProps, categoryLinkSource, } = sidebarOptions;
24
+ const { contentDocsPath } = options;
24
25
  const apiItems = items.filter(isApiItem);
25
26
  const infoItems = items.filter(isInfoItem);
26
27
  const intros = infoItems.map((item) => {
package/lib/types.d.ts CHANGED
@@ -10,6 +10,8 @@ export interface PluginOptions {
10
10
  export interface APIOptions {
11
11
  specPath: string;
12
12
  outputDir: string;
13
+ contentDocsPath: string;
14
+ routeBasePath?: string;
13
15
  template?: string;
14
16
  sidebarOptions?: SidebarOptions;
15
17
  version?: string;
@@ -19,6 +21,15 @@ export interface APIOptions {
19
21
  [key: string]: APIVersionOptions;
20
22
  };
21
23
  }
24
+ export interface SidebarOptions {
25
+ groupPathsBy?: string;
26
+ categoryLinkSource?: string;
27
+ customProps?: {
28
+ [key: string]: unknown;
29
+ };
30
+ sidebarCollapsible?: boolean;
31
+ sidebarCollapsed?: boolean;
32
+ }
22
33
  export interface APIVersionOptions {
23
34
  specPath: string;
24
35
  outputDir: string;
@@ -80,13 +91,3 @@ export interface ApiNavLink {
80
91
  title: string;
81
92
  permalink: string;
82
93
  }
83
- export interface SidebarOptions {
84
- contentDocsPath?: string;
85
- groupPathsBy?: string;
86
- categoryLinkSource?: string;
87
- customProps?: {
88
- [key: string]: unknown;
89
- };
90
- sidebarCollapsible?: boolean;
91
- sidebarCollapsed?: boolean;
92
- }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-openapi-docs",
3
3
  "description": "OpenAPI plugin for Docusaurus.",
4
- "version": "0.0.0-379",
4
+ "version": "0.0.0-380",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -62,5 +62,5 @@
62
62
  "engines": {
63
63
  "node": ">=14"
64
64
  },
65
- "gitHead": "87e5b6e59b66aae31c2f163060b030b232a45d39"
65
+ "gitHead": "3322e621893b40124fed23abd7f7aa8f12fed5af"
66
66
  }
package/src/index.ts CHANGED
@@ -31,7 +31,14 @@ export default function pluginOpenAPIDocs(
31
31
  let { siteDir } = context;
32
32
 
33
33
  async function generateApiDocs(options: APIOptions) {
34
- let { specPath, outputDir, template, sidebarOptions } = options;
34
+ let {
35
+ specPath,
36
+ outputDir,
37
+ contentDocsPath,
38
+ routeBasePath,
39
+ template,
40
+ sidebarOptions,
41
+ } = options;
35
42
 
36
43
  const contentPath = isURL(specPath)
37
44
  ? specPath
@@ -164,7 +171,13 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
164
171
  item.markdown = markdown;
165
172
  if (item.type === "api") {
166
173
  item.json = JSON.stringify(item.api);
167
- if (item.infoId) item.infoPath = `${outputDir}/${item.infoId}`;
174
+ let infoBasePath = `${outputDir}/${item.infoId}`;
175
+ if (routeBasePath) {
176
+ infoBasePath = `${routeBasePath}/${outputDir
177
+ .split(contentDocsPath!)[1]
178
+ .replace(/^\/+/g, "")}/${item.infoId}`.replace(/^\/+/g, "");
179
+ }
180
+ if (item.infoId) item.infoPath = infoBasePath;
168
181
  }
169
182
 
170
183
  const view = render(mdTemplate, item);
package/src/options.ts CHANGED
@@ -8,13 +8,12 @@
8
8
  import { Joi } from "@docusaurus/utils-validation";
9
9
 
10
10
  const sidebarOptions = Joi.object({
11
- contentDocsPath: Joi.string(),
12
11
  groupPathsBy: Joi.string().valid("tag"),
13
12
  categoryLinkSource: Joi.string().valid("tag", "info"),
14
13
  customProps: Joi.object(),
15
14
  sidebarCollapsible: Joi.boolean(),
16
15
  sidebarCollapsed: Joi.boolean(),
17
- }).with("groupPathsBy", "contentDocsPath");
16
+ });
18
17
 
19
18
  export const OptionsSchema = Joi.object({
20
19
  id: Joi.string().required(),
@@ -24,6 +23,8 @@ export const OptionsSchema = Joi.object({
24
23
  Joi.object({
25
24
  specPath: Joi.string().required(),
26
25
  outputDir: Joi.string().required(),
26
+ contentDocsPath: Joi.string().required(),
27
+ routeBasePath: Joi.string(),
27
28
  template: Joi.string(),
28
29
  sidebarOptions: sidebarOptions,
29
30
  version: Joi.string().when("versions", {
@@ -43,9 +43,10 @@ function groupByTags(
43
43
  sidebarCollapsible,
44
44
  customProps,
45
45
  categoryLinkSource,
46
- contentDocsPath,
47
46
  } = sidebarOptions;
48
47
 
48
+ const { contentDocsPath } = options;
49
+
49
50
  const apiItems = items.filter(isApiItem);
50
51
  const infoItems = items.filter(isInfoItem);
51
52
  const intros = infoItems.map((item: any) => {
package/src/types.ts CHANGED
@@ -30,6 +30,8 @@ export interface PluginOptions {
30
30
  export interface APIOptions {
31
31
  specPath: string;
32
32
  outputDir: string;
33
+ contentDocsPath: string;
34
+ routeBasePath?: string;
33
35
  template?: string;
34
36
  sidebarOptions?: SidebarOptions;
35
37
  version?: string;
@@ -40,6 +42,14 @@ export interface APIOptions {
40
42
  };
41
43
  }
42
44
 
45
+ export interface SidebarOptions {
46
+ groupPathsBy?: string;
47
+ categoryLinkSource?: string;
48
+ customProps?: { [key: string]: unknown };
49
+ sidebarCollapsible?: boolean;
50
+ sidebarCollapsed?: boolean;
51
+ }
52
+
43
53
  export interface APIVersionOptions {
44
54
  specPath: string;
45
55
  outputDir: string;
@@ -112,12 +122,3 @@ export interface ApiNavLink {
112
122
  title: string;
113
123
  permalink: string;
114
124
  }
115
-
116
- export interface SidebarOptions {
117
- contentDocsPath?: string;
118
- groupPathsBy?: string;
119
- categoryLinkSource?: string;
120
- customProps?: { [key: string]: unknown };
121
- sidebarCollapsible?: boolean;
122
- sidebarCollapsed?: boolean;
123
- }