docusaurus-plugin-openapi-docs 1.6.0 → 1.6.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.
package/README.md CHANGED
@@ -117,28 +117,29 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
117
117
 
118
118
  `config` can be configured with the following options:
119
119
 
120
- | Name | Type | Default | Description |
121
- | ---------------- | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
122
- | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
123
- | `ouputDir` | `string` | `null` | Desired output path for generated MDX files. |
124
- | `proxy` | `string` | `null` | _Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. |
125
- | `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
126
- | `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading OpenAPI specification. (requires `info` section/doc) |
127
- | `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
128
- | `version` | `string` | `null` | _Optional:_ Version assigned to single or micro-spec API specified in `specPath`. |
129
- | `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
130
- | `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |
131
- | `versions` | `object` | `null` | _Optional:_ Set of options for versioning configuration. See below for a list of supported options. |
120
+ | Name | Type | Default | Description |
121
+ | ---------------- | --------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
122
+ | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
123
+ | `ouputDir` | `string` | `null` | Desired output path for generated MDX files. |
124
+ | `proxy` | `string` | `null` | _Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. |
125
+ | `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
126
+ | `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading OpenAPI specification. (requires `info` section/doc) |
127
+ | `hideSendButton` | `boolean` | `null` | _Optional:_ If set to `true`, hides the "Send API Request" button in API demo panel |
128
+ | `sidebarOptions` | `object` | `null` | _Optional:_ Set of options for sidebar configuration. See below for a list of supported options. |
129
+ | `version` | `string` | `null` | _Optional:_ Version assigned to single or micro-spec API specified in `specPath`. |
130
+ | `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
131
+ | `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |
132
+ | `versions` | `object` | `null` | _Optional:_ Set of options for versioning configuration. See below for a list of supported options. |
132
133
 
133
134
  `sidebarOptions` can be configured with the following options:
134
135
 
135
- | Name | Type | Default | Description |
136
- | -------------------- | --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
137
- | `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag`. |
138
- | `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). |
139
- | `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. |
140
- | `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. |
141
- | `customProps` | `object` | `null` | Additional props for customizing a sidebar item. |
136
+ | Name | Type | Default | Description |
137
+ | -------------------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
138
+ | `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag`. |
139
+ | `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. |
140
+ | `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. |
141
+ | `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. |
142
+ | `customProps` | `object` | `null` | Additional props for customizing a sidebar item. |
142
143
 
143
144
  > 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`.
144
145
 
@@ -30,7 +30,7 @@ function mergeAllOf(allOf) {
30
30
  return true;
31
31
  },
32
32
  },
33
- ignoreAdditionalProperties: true,
33
+ ignoreAdditionalProperties: false,
34
34
  });
35
35
  const required = allOf.reduce((acc, cur) => {
36
36
  if (Array.isArray(cur.required)) {
@@ -142,12 +142,25 @@ function createAdditionalProperties(schema) {
142
142
  // },
143
143
  // type: 'array'
144
144
  // }
145
- if (((_a = schema.additionalProperties) === null || _a === void 0 ? void 0 : _a.type) === "string" ||
146
- ((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "object" ||
147
- ((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "boolean" ||
148
- ((_d = schema.additionalProperties) === null || _d === void 0 ? void 0 : _d.type) === "integer" ||
149
- ((_e = schema.additionalProperties) === null || _e === void 0 ? void 0 : _e.type) === "number") {
150
- const type = (_f = schema.additionalProperties) === null || _f === void 0 ? void 0 : _f.type;
145
+ const additionalProperties = schema.additionalProperties;
146
+ const type = additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.type;
147
+ if ((type === "object" || type === "array") &&
148
+ ((additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.properties) ||
149
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.items) ||
150
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.allOf) ||
151
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.additionalProperties) ||
152
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.oneOf) ||
153
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.anyOf))) {
154
+ const title = additionalProperties.title;
155
+ const schemaName = title ? `object (${title})` : "object";
156
+ const required = (_a = schema.required) !== null && _a !== void 0 ? _a : false;
157
+ return createDetailsNode("property name*", schemaName, additionalProperties, required, schema.nullable);
158
+ }
159
+ if (((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "string" ||
160
+ ((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "object" ||
161
+ ((_d = schema.additionalProperties) === null || _d === void 0 ? void 0 : _d.type) === "boolean" ||
162
+ ((_e = schema.additionalProperties) === null || _e === void 0 ? void 0 : _e.type) === "integer" ||
163
+ ((_f = schema.additionalProperties) === null || _f === void 0 ? void 0 : _f.type) === "number") {
151
164
  const additionalProperties = (_g = schema.additionalProperties) === null || _g === void 0 ? void 0 : _g.additionalProperties;
152
165
  if (additionalProperties !== undefined) {
153
166
  const type = (_j = (_h = schema.additionalProperties) === null || _h === void 0 ? void 0 : _h.additionalProperties) === null || _j === void 0 ? void 0 : _j.type;
@@ -143,12 +143,25 @@ function createAdditionalProperties(schema) {
143
143
  // },
144
144
  // type: 'array'
145
145
  // }
146
- if (((_a = schema.additionalProperties) === null || _a === void 0 ? void 0 : _a.type) === "string" ||
147
- ((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "object" ||
148
- ((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "boolean" ||
149
- ((_d = schema.additionalProperties) === null || _d === void 0 ? void 0 : _d.type) === "integer" ||
150
- ((_e = schema.additionalProperties) === null || _e === void 0 ? void 0 : _e.type) === "number") {
151
- const type = (_f = schema.additionalProperties) === null || _f === void 0 ? void 0 : _f.type;
146
+ const additionalProperties = schema.additionalProperties;
147
+ const type = additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.type;
148
+ if ((type === "object" || type === "array") &&
149
+ ((additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.properties) ||
150
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.items) ||
151
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.allOf) ||
152
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.additionalProperties) ||
153
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.oneOf) ||
154
+ (additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.anyOf))) {
155
+ const title = additionalProperties.title;
156
+ const schemaName = title ? `object (${title})` : "object";
157
+ const required = (_a = schema.required) !== null && _a !== void 0 ? _a : false;
158
+ return createDetailsNode("property name*", schemaName, additionalProperties, required, schema.nullable);
159
+ }
160
+ if (((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "string" ||
161
+ ((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "object" ||
162
+ ((_d = schema.additionalProperties) === null || _d === void 0 ? void 0 : _d.type) === "boolean" ||
163
+ ((_e = schema.additionalProperties) === null || _e === void 0 ? void 0 : _e.type) === "integer" ||
164
+ ((_f = schema.additionalProperties) === null || _f === void 0 ? void 0 : _f.type) === "number") {
152
165
  const additionalProperties = (_g = schema.additionalProperties) === null || _g === void 0 ? void 0 : _g.additionalProperties;
153
166
  if (additionalProperties !== undefined) {
154
167
  const type = (_j = (_h = schema.additionalProperties) === null || _h === void 0 ? void 0 : _h.additionalProperties) === null || _j === void 0 ? void 0 : _j.type;
@@ -525,7 +538,7 @@ function createEdges({ name, schema, required, discriminator, }) {
525
538
  return (0, utils_1.create)("SchemaItem", {
526
539
  collapsible: false,
527
540
  name,
528
- required: false,
541
+ required: Array.isArray(required) ? required.includes(name) : required,
529
542
  schemaName: schemaName,
530
543
  qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
531
544
  schema: mergedSchemas,
@@ -551,7 +564,7 @@ function createEdges({ name, schema, required, discriminator, }) {
551
564
  return (0, utils_1.create)("SchemaItem", {
552
565
  collapsible: false,
553
566
  name,
554
- required: false,
567
+ required: Array.isArray(required) ? required.includes(name) : required,
555
568
  schemaName: schemaName,
556
569
  qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
557
570
  schema: schema,
@@ -17,7 +17,7 @@ function create(tag, props) {
17
17
  }
18
18
  exports.create = create;
19
19
  function guard(value, cb) {
20
- if (value) {
20
+ if (!!value) {
21
21
  const children = cb(value);
22
22
  return render(children);
23
23
  }
@@ -36,5 +36,5 @@ function render(children) {
36
36
  exports.render = render;
37
37
  // Regex to selectively URL-encode '>' and '<' chars
38
38
  exports.lessThan = /<(?!(=|button|\s?\/button|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|td|\s?\/td|tr|\s?\/tr|th|\s?\/th|h1|\s?\/h1|h2|\s?\/h2|h3|\s?\/h3|h4|\s?\/h4|h5|\s?\/h5|h6|\s?\/h6|title|\s?\/title|p|\s?\/p|em|\s?\/em|b|\s?\/b|i|\s?\/i|u|\s?\/u|strike|\s?\/strike|a|\s?\/a|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|div|\s?\/div|center|\s?\/center))/gu;
39
- exports.greaterThan = /(?<!(button|details|summary|hr|br|span|strong|small|table|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|a|tag|li|ol|ul|img|div|center|\/|\s|"|'))>/gu;
39
+ exports.greaterThan = /(?<!(button|code|details|summary|hr|br|span|strong|small|table|thead|tbody|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|a|tag|li|ol|ul|img|div|center|\/|\s|"|'))>/gu;
40
40
  exports.codeFence = /`{1,3}[\s\S]*?`{1,3}/g;
package/lib/options.js CHANGED
@@ -10,7 +10,8 @@ exports.OptionsSchema = void 0;
10
10
  const utils_validation_1 = require("@docusaurus/utils-validation");
11
11
  const sidebarOptions = utils_validation_1.Joi.object({
12
12
  groupPathsBy: utils_validation_1.Joi.string().valid("tag"),
13
- categoryLinkSource: utils_validation_1.Joi.string().valid("tag", "info"),
13
+ // TODO: Remove "none" in 2.0, make it the default if not specified
14
+ categoryLinkSource: utils_validation_1.Joi.string().valid("tag", "info", "none"),
14
15
  customProps: utils_validation_1.Joi.object(),
15
16
  sidebarCollapsible: utils_validation_1.Joi.boolean(),
16
17
  sidebarCollapsed: utils_validation_1.Joi.boolean(),
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": "1.6.0",
4
+ "version": "1.6.1",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -68,5 +68,5 @@
68
68
  "engines": {
69
69
  "node": ">=14"
70
70
  },
71
- "gitHead": "937e6543af8c1575877a0ebe7c5732e5cffaa37d"
71
+ "gitHead": "68f648d80d41b82a607215bac0a082f931f80b7c"
72
72
  }
@@ -34,7 +34,7 @@ export function mergeAllOf(allOf: SchemaObject[]) {
34
34
  return true;
35
35
  },
36
36
  },
37
- ignoreAdditionalProperties: true,
37
+ ignoreAdditionalProperties: false,
38
38
  });
39
39
 
40
40
  const required = allOf.reduce((acc, cur) => {
@@ -157,6 +157,28 @@ function createAdditionalProperties(schema: SchemaObject) {
157
157
  // },
158
158
  // type: 'array'
159
159
  // }
160
+ const additionalProperties = schema.additionalProperties;
161
+ const type: string | unknown = additionalProperties?.type;
162
+ if (
163
+ (type === "object" || type === "array") &&
164
+ (additionalProperties?.properties ||
165
+ additionalProperties?.items ||
166
+ additionalProperties?.allOf ||
167
+ additionalProperties?.additionalProperties ||
168
+ additionalProperties?.oneOf ||
169
+ additionalProperties?.anyOf)
170
+ ) {
171
+ const title = additionalProperties.title;
172
+ const schemaName = title ? `object (${title})` : "object";
173
+ const required = schema.required ?? false;
174
+ return createDetailsNode(
175
+ "property name*",
176
+ schemaName,
177
+ additionalProperties,
178
+ required,
179
+ schema.nullable
180
+ );
181
+ }
160
182
 
161
183
  if (
162
184
  (schema.additionalProperties?.type as string) === "string" ||
@@ -165,7 +187,6 @@ function createAdditionalProperties(schema: SchemaObject) {
165
187
  (schema.additionalProperties?.type as string) === "integer" ||
166
188
  (schema.additionalProperties?.type as string) === "number"
167
189
  ) {
168
- const type = schema.additionalProperties?.type;
169
190
  const additionalProperties =
170
191
  schema.additionalProperties?.additionalProperties;
171
192
  if (additionalProperties !== undefined) {
@@ -163,6 +163,28 @@ function createAdditionalProperties(schema: SchemaObject) {
163
163
  // },
164
164
  // type: 'array'
165
165
  // }
166
+ const additionalProperties = schema.additionalProperties;
167
+ const type: string | unknown = additionalProperties?.type;
168
+ if (
169
+ (type === "object" || type === "array") &&
170
+ (additionalProperties?.properties ||
171
+ additionalProperties?.items ||
172
+ additionalProperties?.allOf ||
173
+ additionalProperties?.additionalProperties ||
174
+ additionalProperties?.oneOf ||
175
+ additionalProperties?.anyOf)
176
+ ) {
177
+ const title = additionalProperties.title;
178
+ const schemaName = title ? `object (${title})` : "object";
179
+ const required = schema.required ?? false;
180
+ return createDetailsNode(
181
+ "property name*",
182
+ schemaName,
183
+ additionalProperties,
184
+ required,
185
+ schema.nullable
186
+ );
187
+ }
166
188
 
167
189
  if (
168
190
  (schema.additionalProperties?.type as string) === "string" ||
@@ -171,7 +193,6 @@ function createAdditionalProperties(schema: SchemaObject) {
171
193
  (schema.additionalProperties?.type as string) === "integer" ||
172
194
  (schema.additionalProperties?.type as string) === "number"
173
195
  ) {
174
- const type = schema.additionalProperties?.type;
175
196
  const additionalProperties =
176
197
  schema.additionalProperties?.additionalProperties;
177
198
  if (additionalProperties !== undefined) {
@@ -683,7 +704,7 @@ function createEdges({
683
704
  return create("SchemaItem", {
684
705
  collapsible: false,
685
706
  name,
686
- required: false,
707
+ required: Array.isArray(required) ? required.includes(name) : required,
687
708
  schemaName: schemaName,
688
709
  qualifierMessage: getQualifierMessage(schema),
689
710
  schema: mergedSchemas,
@@ -739,7 +760,7 @@ function createEdges({
739
760
  return create("SchemaItem", {
740
761
  collapsible: false,
741
762
  name,
742
- required: false,
763
+ required: Array.isArray(required) ? required.includes(name) : required,
743
764
  schemaName: schemaName,
744
765
  qualifierMessage: getQualifierMessage(schema),
745
766
  schema: schema,
@@ -24,7 +24,7 @@ export function guard<T>(
24
24
  value: T | undefined,
25
25
  cb: (value: T) => Children
26
26
  ): string {
27
- if (value) {
27
+ if (!!value) {
28
28
  const children = cb(value);
29
29
  return render(children);
30
30
  }
@@ -45,5 +45,5 @@ export function render(children: Children): string {
45
45
  export const lessThan =
46
46
  /<(?!(=|button|\s?\/button|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|td|\s?\/td|tr|\s?\/tr|th|\s?\/th|h1|\s?\/h1|h2|\s?\/h2|h3|\s?\/h3|h4|\s?\/h4|h5|\s?\/h5|h6|\s?\/h6|title|\s?\/title|p|\s?\/p|em|\s?\/em|b|\s?\/b|i|\s?\/i|u|\s?\/u|strike|\s?\/strike|a|\s?\/a|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|div|\s?\/div|center|\s?\/center))/gu;
47
47
  export const greaterThan =
48
- /(?<!(button|details|summary|hr|br|span|strong|small|table|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|a|tag|li|ol|ul|img|div|center|\/|\s|"|'))>/gu;
48
+ /(?<!(button|code|details|summary|hr|br|span|strong|small|table|thead|tbody|td|tr|th|h1|h2|h3|h4|h5|h6|title|p|em|b|i|u|strike|a|tag|li|ol|ul|img|div|center|\/|\s|"|'))>/gu;
49
49
  export const codeFence = /`{1,3}[\s\S]*?`{1,3}/g;
package/src/options.ts CHANGED
@@ -9,7 +9,8 @@ import { Joi } from "@docusaurus/utils-validation";
9
9
 
10
10
  const sidebarOptions = Joi.object({
11
11
  groupPathsBy: Joi.string().valid("tag"),
12
- categoryLinkSource: Joi.string().valid("tag", "info"),
12
+ // TODO: Remove "none" in 2.0, make it the default if not specified
13
+ categoryLinkSource: Joi.string().valid("tag", "info", "none"),
13
14
  customProps: Joi.object(),
14
15
  sidebarCollapsible: Joi.boolean(),
15
16
  sidebarCollapsed: Joi.boolean(),