docusaurus-plugin-openapi-docs 1.6.0 → 2.0.0-beta.0
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 +20 -19
- package/lib/markdown/createHeading.d.ts +1 -0
- package/lib/markdown/createHeading.js +20 -0
- package/lib/markdown/createMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createMethodEndpoint.js +14 -0
- package/lib/markdown/createParamsDetails.js +1 -0
- package/lib/markdown/createRequestSchema.js +30 -15
- package/lib/markdown/createResponseSchema.js +31 -16
- package/lib/markdown/createStatusCodes.js +38 -35
- package/lib/markdown/index.d.ts +1 -1
- package/lib/markdown/index.js +8 -4
- package/lib/markdown/utils.js +3 -3
- package/lib/options.js +2 -1
- package/lib/types.d.ts +2 -0
- package/package.json +8 -8
- package/src/markdown/createHeading.ts +18 -0
- package/src/markdown/createMethodEndpoint.ts +12 -0
- package/src/markdown/createParamsDetails.ts +1 -0
- package/src/markdown/createRequestSchema.ts +33 -10
- package/src/markdown/createResponseSchema.ts +34 -11
- package/src/markdown/createStatusCodes.ts +38 -35
- package/src/markdown/index.ts +9 -3
- package/src/markdown/utils.ts +3 -3
- package/src/options.ts +2 -1
- package/src/types.ts +2 -0
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
|
|
121
|
-
| ---------------- |
|
|
122
|
-
| `specPath` | `string`
|
|
123
|
-
| `ouputDir` | `string`
|
|
124
|
-
| `proxy` | `string`
|
|
125
|
-
| `template` | `string`
|
|
126
|
-
| `downloadUrl` | `string`
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
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
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createHeading(heading: string): string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createHeading = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function createHeading(heading) {
|
|
12
|
+
return [
|
|
13
|
+
(0, utils_1.create)("h1", {
|
|
14
|
+
className: "openapi__heading",
|
|
15
|
+
children: `${heading}`,
|
|
16
|
+
}),
|
|
17
|
+
`\n\n`,
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
exports.createHeading = createHeading;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createMethodEndpoint(method: String, path: String): string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createMethodEndpoint = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function createMethodEndpoint(method, path) {
|
|
12
|
+
return [(0, utils_1.create)("MethodEndpoint", { method: method, path: path }), "\n\n"];
|
|
13
|
+
}
|
|
14
|
+
exports.createMethodEndpoint = createMethodEndpoint;
|
|
@@ -30,7 +30,7 @@ function mergeAllOf(allOf) {
|
|
|
30
30
|
return true;
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
|
-
ignoreAdditionalProperties:
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
((
|
|
149
|
-
|
|
150
|
-
|
|
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;
|
|
@@ -314,7 +327,7 @@ function createItems(schema) {
|
|
|
314
327
|
// }
|
|
315
328
|
// }
|
|
316
329
|
// return create("div", {
|
|
317
|
-
// className: "
|
|
330
|
+
// className: "openapi-discriminator__item",
|
|
318
331
|
// children: create("div", {
|
|
319
332
|
// children: [
|
|
320
333
|
// create("strong", {
|
|
@@ -379,6 +392,7 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
379
392
|
className: "schemaItem",
|
|
380
393
|
children: [
|
|
381
394
|
(0, createDetails_1.createDetails)({
|
|
395
|
+
className: "openapi-markdown__details",
|
|
382
396
|
children: [
|
|
383
397
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
384
398
|
children: [
|
|
@@ -441,7 +455,7 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
441
455
|
return undefined;
|
|
442
456
|
}
|
|
443
457
|
return (0, utils_1.create)("div", {
|
|
444
|
-
className: "
|
|
458
|
+
className: "openapi-discriminator__item",
|
|
445
459
|
children: (0, utils_1.create)("div", {
|
|
446
460
|
children: [
|
|
447
461
|
(0, utils_1.create)("strong", { style: { paddingLeft: "1rem" }, children: name }),
|
|
@@ -471,17 +485,14 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
471
485
|
children: (0, createDescription_1.createDescription)(description),
|
|
472
486
|
})),
|
|
473
487
|
(0, utils_1.create)("DiscriminatorTabs", {
|
|
488
|
+
className: "openapi-tabs__discriminator",
|
|
474
489
|
children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
|
|
475
490
|
const label = key;
|
|
476
491
|
return (0, utils_1.create)("TabItem", {
|
|
492
|
+
// className: "openapi-tabs__discriminator-item",
|
|
477
493
|
label: label,
|
|
478
494
|
value: `${index}-item-discriminator`,
|
|
479
|
-
children: [
|
|
480
|
-
(0, utils_1.create)("div", {
|
|
481
|
-
style: { marginLeft: "-4px" },
|
|
482
|
-
children: createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key]),
|
|
483
|
-
}),
|
|
484
|
-
],
|
|
495
|
+
children: [createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key])],
|
|
485
496
|
});
|
|
486
497
|
}),
|
|
487
498
|
}),
|
|
@@ -625,6 +636,7 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
625
636
|
const mimeTypes = Object.keys(body.content);
|
|
626
637
|
if (mimeTypes && mimeTypes.length > 1) {
|
|
627
638
|
return (0, utils_1.create)("MimeTabs", {
|
|
639
|
+
className: "openapi-tabs__mime",
|
|
628
640
|
schemaType: "request",
|
|
629
641
|
children: mimeTypes.map((mimeType) => {
|
|
630
642
|
const firstBody = body.content[mimeType].schema;
|
|
@@ -641,6 +653,7 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
641
653
|
value: `${mimeType}`,
|
|
642
654
|
children: [
|
|
643
655
|
(0, createDetails_1.createDetails)({
|
|
656
|
+
className: "openapi-markdown__details",
|
|
644
657
|
"data-collapsed": false,
|
|
645
658
|
open: true,
|
|
646
659
|
...rest,
|
|
@@ -694,12 +707,14 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
694
707
|
}
|
|
695
708
|
}
|
|
696
709
|
return (0, utils_1.create)("MimeTabs", {
|
|
710
|
+
className: "openapi-tabs__mime",
|
|
697
711
|
children: [
|
|
698
712
|
(0, utils_1.create)("TabItem", {
|
|
699
713
|
label: randomFirstKey,
|
|
700
714
|
value: `${randomFirstKey}-schema`,
|
|
701
715
|
children: [
|
|
702
716
|
(0, createDetails_1.createDetails)({
|
|
717
|
+
className: "openapi-markdown__details",
|
|
703
718
|
"data-collapsed": false,
|
|
704
719
|
open: true,
|
|
705
720
|
...rest,
|
|
@@ -55,6 +55,7 @@ function createAnyOneOf(schema) {
|
|
|
55
55
|
children: type,
|
|
56
56
|
}),
|
|
57
57
|
(0, utils_1.create)("SchemaTabs", {
|
|
58
|
+
className: "openapi-tabs__schema",
|
|
58
59
|
children: schema[type].map((anyOneSchema, index) => {
|
|
59
60
|
const label = anyOneSchema.title
|
|
60
61
|
? anyOneSchema.title
|
|
@@ -143,12 +144,25 @@ function createAdditionalProperties(schema) {
|
|
|
143
144
|
// },
|
|
144
145
|
// type: 'array'
|
|
145
146
|
// }
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
((
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
const additionalProperties = schema.additionalProperties;
|
|
148
|
+
const type = additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.type;
|
|
149
|
+
if ((type === "object" || type === "array") &&
|
|
150
|
+
((additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.properties) ||
|
|
151
|
+
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.items) ||
|
|
152
|
+
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.allOf) ||
|
|
153
|
+
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.additionalProperties) ||
|
|
154
|
+
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.oneOf) ||
|
|
155
|
+
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.anyOf))) {
|
|
156
|
+
const title = additionalProperties.title;
|
|
157
|
+
const schemaName = title ? `object (${title})` : "object";
|
|
158
|
+
const required = (_a = schema.required) !== null && _a !== void 0 ? _a : false;
|
|
159
|
+
return createDetailsNode("property name*", schemaName, additionalProperties, required, schema.nullable);
|
|
160
|
+
}
|
|
161
|
+
if (((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "string" ||
|
|
162
|
+
((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "object" ||
|
|
163
|
+
((_d = schema.additionalProperties) === null || _d === void 0 ? void 0 : _d.type) === "boolean" ||
|
|
164
|
+
((_e = schema.additionalProperties) === null || _e === void 0 ? void 0 : _e.type) === "integer" ||
|
|
165
|
+
((_f = schema.additionalProperties) === null || _f === void 0 ? void 0 : _f.type) === "number") {
|
|
152
166
|
const additionalProperties = (_g = schema.additionalProperties) === null || _g === void 0 ? void 0 : _g.additionalProperties;
|
|
153
167
|
if (additionalProperties !== undefined) {
|
|
154
168
|
const type = (_j = (_h = schema.additionalProperties) === null || _h === void 0 ? void 0 : _h.additionalProperties) === null || _j === void 0 ? void 0 : _j.type;
|
|
@@ -315,7 +329,7 @@ function createItems(schema) {
|
|
|
315
329
|
// }
|
|
316
330
|
// }
|
|
317
331
|
// return create("div", {
|
|
318
|
-
// className: "
|
|
332
|
+
// className: "openapi-discriminator__item",
|
|
319
333
|
// children: create("div", {
|
|
320
334
|
// children: [
|
|
321
335
|
// create("strong", {
|
|
@@ -380,6 +394,7 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
380
394
|
className: "schemaItem",
|
|
381
395
|
children: [
|
|
382
396
|
(0, createDetails_1.createDetails)({
|
|
397
|
+
className: "openapi-markdown__details",
|
|
383
398
|
children: [
|
|
384
399
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
385
400
|
children: [
|
|
@@ -442,7 +457,7 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
442
457
|
return undefined;
|
|
443
458
|
}
|
|
444
459
|
return (0, utils_1.create)("div", {
|
|
445
|
-
className: "
|
|
460
|
+
className: "openapi-discriminator__item",
|
|
446
461
|
children: (0, utils_1.create)("div", {
|
|
447
462
|
children: [
|
|
448
463
|
(0, utils_1.create)("strong", { style: { paddingLeft: "1rem" }, children: name }),
|
|
@@ -472,17 +487,14 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
472
487
|
children: (0, createDescription_1.createDescription)(description),
|
|
473
488
|
})),
|
|
474
489
|
(0, utils_1.create)("DiscriminatorTabs", {
|
|
490
|
+
className: "openapi-tabs__discriminator",
|
|
475
491
|
children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
|
|
476
492
|
const label = key;
|
|
477
493
|
return (0, utils_1.create)("TabItem", {
|
|
494
|
+
// className: "openapi-tabs__discriminator-item",
|
|
478
495
|
label: label,
|
|
479
496
|
value: `${index}-item-discriminator`,
|
|
480
|
-
children: [
|
|
481
|
-
(0, utils_1.create)("div", {
|
|
482
|
-
style: { marginLeft: "-4px" },
|
|
483
|
-
children: createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key]),
|
|
484
|
-
}),
|
|
485
|
-
],
|
|
497
|
+
children: [createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key])],
|
|
486
498
|
});
|
|
487
499
|
}),
|
|
488
500
|
}),
|
|
@@ -525,7 +537,7 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
525
537
|
return (0, utils_1.create)("SchemaItem", {
|
|
526
538
|
collapsible: false,
|
|
527
539
|
name,
|
|
528
|
-
required:
|
|
540
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
529
541
|
schemaName: schemaName,
|
|
530
542
|
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
531
543
|
schema: mergedSchemas,
|
|
@@ -551,7 +563,7 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
551
563
|
return (0, utils_1.create)("SchemaItem", {
|
|
552
564
|
collapsible: false,
|
|
553
565
|
name,
|
|
554
|
-
required:
|
|
566
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
555
567
|
schemaName: schemaName,
|
|
556
568
|
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
557
569
|
schema: schema,
|
|
@@ -627,6 +639,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
627
639
|
const mimeTypes = Object.keys(body.content);
|
|
628
640
|
if (mimeTypes && mimeTypes.length) {
|
|
629
641
|
return (0, utils_1.create)("MimeTabs", {
|
|
642
|
+
className: "openapi-tabs__mime",
|
|
630
643
|
schemaType: "response",
|
|
631
644
|
children: mimeTypes.map((mimeType) => {
|
|
632
645
|
var _a;
|
|
@@ -648,6 +661,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
648
661
|
value: `${mimeType}`,
|
|
649
662
|
children: [
|
|
650
663
|
(0, utils_1.create)("SchemaTabs", {
|
|
664
|
+
className: "openapi-tabs__schema",
|
|
651
665
|
// TODO: determine if we should persist this
|
|
652
666
|
// groupId: "schema-tabs",
|
|
653
667
|
children: [
|
|
@@ -657,6 +671,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
657
671
|
value: `${title}`,
|
|
658
672
|
children: [
|
|
659
673
|
(0, createDetails_1.createDetails)({
|
|
674
|
+
className: "openapi-markdown__details",
|
|
660
675
|
"data-collapsed": false,
|
|
661
676
|
open: true,
|
|
662
677
|
...rest,
|
|
@@ -258,45 +258,48 @@ function createStatusCodes({ responses }) {
|
|
|
258
258
|
}
|
|
259
259
|
return (0, utils_1.create)("div", {
|
|
260
260
|
children: [
|
|
261
|
-
(0, utils_1.create)("
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
261
|
+
(0, utils_1.create)("div", {
|
|
262
|
+
children: [
|
|
263
|
+
(0, utils_1.create)("ApiTabs", {
|
|
264
|
+
children: codes.map((code) => {
|
|
265
|
+
const responseHeaders = responses[code].headers;
|
|
266
|
+
return (0, utils_1.create)("TabItem", {
|
|
267
|
+
label: code,
|
|
268
|
+
value: code,
|
|
269
|
+
children: [
|
|
270
|
+
(0, utils_1.create)("div", {
|
|
271
|
+
children: (0, createDescription_1.createDescription)(responses[code].description),
|
|
272
|
+
}),
|
|
273
|
+
responseHeaders &&
|
|
274
|
+
(0, createDetails_1.createDetails)({
|
|
275
|
+
className: "openapi-markdown__details",
|
|
276
|
+
"data-collaposed": true,
|
|
277
|
+
open: false,
|
|
278
|
+
style: { textAlign: "left", marginBottom: "1rem" },
|
|
280
279
|
children: [
|
|
281
|
-
(0,
|
|
282
|
-
children:
|
|
280
|
+
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
281
|
+
children: [
|
|
282
|
+
(0, utils_1.create)("strong", {
|
|
283
|
+
children: "Response Headers",
|
|
284
|
+
}),
|
|
285
|
+
],
|
|
283
286
|
}),
|
|
287
|
+
createResponseHeaders(responseHeaders),
|
|
284
288
|
],
|
|
285
289
|
}),
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}),
|
|
290
|
+
(0, utils_1.create)("div", {
|
|
291
|
+
children: (0, createResponseSchema_1.createResponseSchema)({
|
|
292
|
+
title: "Schema",
|
|
293
|
+
body: {
|
|
294
|
+
content: responses[code].content,
|
|
295
|
+
},
|
|
296
|
+
}),
|
|
297
|
+
}),
|
|
298
|
+
],
|
|
299
|
+
});
|
|
300
|
+
}),
|
|
301
|
+
}),
|
|
302
|
+
],
|
|
300
303
|
}),
|
|
301
304
|
],
|
|
302
305
|
});
|
package/lib/markdown/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ApiPageMetadata, InfoPageMetadata, TagPageMetadata } from "../types";
|
|
2
|
-
export declare function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, parameters, requestBody, responses, }, }: ApiPageMetadata): string;
|
|
2
|
+
export declare function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, parameters, requestBody, responses, }, }: ApiPageMetadata): string;
|
|
3
3
|
export declare function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, downloadUrl, }: InfoPageMetadata): string;
|
|
4
4
|
export declare function createTagPageMD({ tag: { description } }: TagPageMetadata): string;
|
package/lib/markdown/index.js
CHANGED
|
@@ -12,25 +12,29 @@ const createContactInfo_1 = require("./createContactInfo");
|
|
|
12
12
|
const createDeprecationNotice_1 = require("./createDeprecationNotice");
|
|
13
13
|
const createDescription_1 = require("./createDescription");
|
|
14
14
|
const createDownload_1 = require("./createDownload");
|
|
15
|
+
const createHeading_1 = require("./createHeading");
|
|
15
16
|
const createLicense_1 = require("./createLicense");
|
|
16
17
|
const createLogo_1 = require("./createLogo");
|
|
18
|
+
const createMethodEndpoint_1 = require("./createMethodEndpoint");
|
|
17
19
|
const createParamsDetails_1 = require("./createParamsDetails");
|
|
18
20
|
const createRequestBodyDetails_1 = require("./createRequestBodyDetails");
|
|
19
21
|
const createStatusCodes_1 = require("./createStatusCodes");
|
|
20
22
|
const createTermsOfService_1 = require("./createTermsOfService");
|
|
21
23
|
const createVersionBadge_1 = require("./createVersionBadge");
|
|
22
24
|
const utils_1 = require("./utils");
|
|
23
|
-
function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, parameters, requestBody, responses, }, }) {
|
|
25
|
+
function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, parameters, requestBody, responses, }, }) {
|
|
24
26
|
return (0, utils_1.render)([
|
|
25
27
|
`import ApiTabs from "@theme/ApiTabs";\n`,
|
|
28
|
+
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
29
|
+
`import MethodEndpoint from "@theme/ApiDemoPanel/MethodEndpoint";\n`,
|
|
26
30
|
`import MimeTabs from "@theme/MimeTabs";\n`,
|
|
27
31
|
`import ParamsItem from "@theme/ParamsItem";\n`,
|
|
28
32
|
`import ResponseSamples from "@theme/ResponseSamples";\n`,
|
|
29
33
|
`import SchemaItem from "@theme/SchemaItem";\n`,
|
|
30
34
|
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
31
|
-
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
32
35
|
`import TabItem from "@theme/TabItem";\n\n`,
|
|
33
|
-
|
|
36
|
+
(0, createHeading_1.createHeading)(title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")),
|
|
37
|
+
(0, createMethodEndpoint_1.createMethodEndpoint)(method, path),
|
|
34
38
|
(0, createDeprecationNotice_1.createDeprecationNotice)({ deprecated, description: deprecatedDescription }),
|
|
35
39
|
(0, createDescription_1.createDescription)(description),
|
|
36
40
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "path" }),
|
|
@@ -53,7 +57,7 @@ function createInfoPageMD({ info: { title, version, description, contact, licens
|
|
|
53
57
|
`import Export from "@theme/ApiDemoPanel/Export";\n\n`,
|
|
54
58
|
(0, createVersionBadge_1.createVersionBadge)(version),
|
|
55
59
|
(0, createDownload_1.createDownload)(downloadUrl),
|
|
56
|
-
|
|
60
|
+
(0, createHeading_1.createHeading)(title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")),
|
|
57
61
|
(0, createLogo_1.createLogo)(logo, darkLogo),
|
|
58
62
|
(0, createDescription_1.createDescription)(description),
|
|
59
63
|
(0, createAuthentication_1.createAuthentication)(securitySchemes),
|
package/lib/markdown/utils.js
CHANGED
|
@@ -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
|
}
|
|
@@ -35,6 +35,6 @@ function render(children) {
|
|
|
35
35
|
}
|
|
36
36
|
exports.render = render;
|
|
37
37
|
// Regex to selectively URL-encode '>' and '<' chars
|
|
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|
|
|
38
|
+
exports.lessThan = /<(?!(=|button|\s?\/button|code|\s?\/code|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|thead|\s?\/thead|tbody|\s?\/tbody|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|bold|\s?\/bold|a|\s?\/a|table|\s?\/table|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|svg|\s?\/svg|div|\s?\/div|center|\s?\/center))/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|bold|a|li|ol|ul|img|svg|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
|
-
|
|
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/lib/types.d.ts
CHANGED
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": "
|
|
4
|
+
"version": "2.0.0-beta.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"watch": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/module-type-aliases": "
|
|
32
|
-
"@docusaurus/types": "
|
|
31
|
+
"@docusaurus/module-type-aliases": "^2.3.0",
|
|
32
|
+
"@docusaurus/types": "^2.3.0",
|
|
33
33
|
"@types/fs-extra": "^9.0.13",
|
|
34
34
|
"@types/js-yaml": "^4.0.5",
|
|
35
35
|
"@types/json-pointer": "^1.0.31",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@apidevtools/json-schema-ref-parser": "^9.0.9",
|
|
43
|
-
"@docusaurus/mdx-loader": "
|
|
44
|
-
"@docusaurus/plugin-content-docs": "
|
|
45
|
-
"@docusaurus/utils": "
|
|
46
|
-
"@docusaurus/utils-validation": "
|
|
43
|
+
"@docusaurus/mdx-loader": "^2.3.0",
|
|
44
|
+
"@docusaurus/plugin-content-docs": "^2.3.0",
|
|
45
|
+
"@docusaurus/utils": "^2.3.0",
|
|
46
|
+
"@docusaurus/utils-validation": "^2.3.0",
|
|
47
47
|
"@paloaltonetworks/openapi-to-postmanv2": "3.1.0-hotfix.1",
|
|
48
48
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
49
49
|
"@redocly/openapi-core": "^1.0.0-beta.103",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "ef8b94ff1654153646f3616afb17fab7e267c51f"
|
|
72
72
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { create } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createHeading(heading: string) {
|
|
11
|
+
return [
|
|
12
|
+
create("h1", {
|
|
13
|
+
className: "openapi__heading",
|
|
14
|
+
children: `${heading}`,
|
|
15
|
+
}),
|
|
16
|
+
`\n\n`,
|
|
17
|
+
];
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { create } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createMethodEndpoint(method: String, path: String) {
|
|
11
|
+
return [create("MethodEndpoint", { method: method, path: path }), "\n\n"];
|
|
12
|
+
}
|
|
@@ -34,7 +34,7 @@ export function mergeAllOf(allOf: SchemaObject[]) {
|
|
|
34
34
|
return true;
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
-
ignoreAdditionalProperties:
|
|
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) {
|
|
@@ -370,7 +391,7 @@ function createItems(schema: SchemaObject) {
|
|
|
370
391
|
// }
|
|
371
392
|
|
|
372
393
|
// return create("div", {
|
|
373
|
-
// className: "
|
|
394
|
+
// className: "openapi-discriminator__item",
|
|
374
395
|
// children: create("div", {
|
|
375
396
|
// children: [
|
|
376
397
|
// create("strong", {
|
|
@@ -444,6 +465,7 @@ function createDetailsNode(
|
|
|
444
465
|
className: "schemaItem",
|
|
445
466
|
children: [
|
|
446
467
|
createDetails({
|
|
468
|
+
className: "openapi-markdown__details",
|
|
447
469
|
children: [
|
|
448
470
|
createDetailsSummary({
|
|
449
471
|
children: [
|
|
@@ -525,7 +547,7 @@ function createPropertyDiscriminator(
|
|
|
525
547
|
}
|
|
526
548
|
|
|
527
549
|
return create("div", {
|
|
528
|
-
className: "
|
|
550
|
+
className: "openapi-discriminator__item",
|
|
529
551
|
children: create("div", {
|
|
530
552
|
children: [
|
|
531
553
|
create("strong", { style: { paddingLeft: "1rem" }, children: name }),
|
|
@@ -561,17 +583,14 @@ function createPropertyDiscriminator(
|
|
|
561
583
|
})
|
|
562
584
|
),
|
|
563
585
|
create("DiscriminatorTabs", {
|
|
586
|
+
className: "openapi-tabs__discriminator",
|
|
564
587
|
children: Object.keys(discriminator?.mapping!).map((key, index) => {
|
|
565
588
|
const label = key;
|
|
566
589
|
return create("TabItem", {
|
|
590
|
+
// className: "openapi-tabs__discriminator-item",
|
|
567
591
|
label: label,
|
|
568
592
|
value: `${index}-item-discriminator`,
|
|
569
|
-
children: [
|
|
570
|
-
create("div", {
|
|
571
|
-
style: { marginLeft: "-4px" },
|
|
572
|
-
children: createNodes(discriminator?.mapping[key]),
|
|
573
|
-
}),
|
|
574
|
-
],
|
|
593
|
+
children: [createNodes(discriminator?.mapping[key])],
|
|
575
594
|
});
|
|
576
595
|
}),
|
|
577
596
|
}),
|
|
@@ -840,6 +859,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
840
859
|
|
|
841
860
|
if (mimeTypes && mimeTypes.length > 1) {
|
|
842
861
|
return create("MimeTabs", {
|
|
862
|
+
className: "openapi-tabs__mime",
|
|
843
863
|
schemaType: "request",
|
|
844
864
|
children: mimeTypes.map((mimeType) => {
|
|
845
865
|
const firstBody = body.content![mimeType].schema;
|
|
@@ -856,6 +876,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
856
876
|
value: `${mimeType}`,
|
|
857
877
|
children: [
|
|
858
878
|
createDetails({
|
|
879
|
+
className: "openapi-markdown__details",
|
|
859
880
|
"data-collapsed": false,
|
|
860
881
|
open: true,
|
|
861
882
|
...rest,
|
|
@@ -913,12 +934,14 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
913
934
|
}
|
|
914
935
|
}
|
|
915
936
|
return create("MimeTabs", {
|
|
937
|
+
className: "openapi-tabs__mime",
|
|
916
938
|
children: [
|
|
917
939
|
create("TabItem", {
|
|
918
940
|
label: randomFirstKey,
|
|
919
941
|
value: `${randomFirstKey}-schema`,
|
|
920
942
|
children: [
|
|
921
943
|
createDetails({
|
|
944
|
+
className: "openapi-markdown__details",
|
|
922
945
|
"data-collapsed": false,
|
|
923
946
|
open: true,
|
|
924
947
|
...rest,
|
|
@@ -65,6 +65,7 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
65
65
|
children: type,
|
|
66
66
|
}),
|
|
67
67
|
create("SchemaTabs", {
|
|
68
|
+
className: "openapi-tabs__schema",
|
|
68
69
|
children: schema[type]!.map((anyOneSchema, index) => {
|
|
69
70
|
const label = anyOneSchema.title
|
|
70
71
|
? anyOneSchema.title
|
|
@@ -163,6 +164,28 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
163
164
|
// },
|
|
164
165
|
// type: 'array'
|
|
165
166
|
// }
|
|
167
|
+
const additionalProperties = schema.additionalProperties;
|
|
168
|
+
const type: string | unknown = additionalProperties?.type;
|
|
169
|
+
if (
|
|
170
|
+
(type === "object" || type === "array") &&
|
|
171
|
+
(additionalProperties?.properties ||
|
|
172
|
+
additionalProperties?.items ||
|
|
173
|
+
additionalProperties?.allOf ||
|
|
174
|
+
additionalProperties?.additionalProperties ||
|
|
175
|
+
additionalProperties?.oneOf ||
|
|
176
|
+
additionalProperties?.anyOf)
|
|
177
|
+
) {
|
|
178
|
+
const title = additionalProperties.title;
|
|
179
|
+
const schemaName = title ? `object (${title})` : "object";
|
|
180
|
+
const required = schema.required ?? false;
|
|
181
|
+
return createDetailsNode(
|
|
182
|
+
"property name*",
|
|
183
|
+
schemaName,
|
|
184
|
+
additionalProperties,
|
|
185
|
+
required,
|
|
186
|
+
schema.nullable
|
|
187
|
+
);
|
|
188
|
+
}
|
|
166
189
|
|
|
167
190
|
if (
|
|
168
191
|
(schema.additionalProperties?.type as string) === "string" ||
|
|
@@ -171,7 +194,6 @@ function createAdditionalProperties(schema: SchemaObject) {
|
|
|
171
194
|
(schema.additionalProperties?.type as string) === "integer" ||
|
|
172
195
|
(schema.additionalProperties?.type as string) === "number"
|
|
173
196
|
) {
|
|
174
|
-
const type = schema.additionalProperties?.type;
|
|
175
197
|
const additionalProperties =
|
|
176
198
|
schema.additionalProperties?.additionalProperties;
|
|
177
199
|
if (additionalProperties !== undefined) {
|
|
@@ -376,7 +398,7 @@ function createItems(schema: SchemaObject) {
|
|
|
376
398
|
// }
|
|
377
399
|
|
|
378
400
|
// return create("div", {
|
|
379
|
-
// className: "
|
|
401
|
+
// className: "openapi-discriminator__item",
|
|
380
402
|
// children: create("div", {
|
|
381
403
|
// children: [
|
|
382
404
|
// create("strong", {
|
|
@@ -450,6 +472,7 @@ function createDetailsNode(
|
|
|
450
472
|
className: "schemaItem",
|
|
451
473
|
children: [
|
|
452
474
|
createDetails({
|
|
475
|
+
className: "openapi-markdown__details",
|
|
453
476
|
children: [
|
|
454
477
|
createDetailsSummary({
|
|
455
478
|
children: [
|
|
@@ -531,7 +554,7 @@ function createPropertyDiscriminator(
|
|
|
531
554
|
}
|
|
532
555
|
|
|
533
556
|
return create("div", {
|
|
534
|
-
className: "
|
|
557
|
+
className: "openapi-discriminator__item",
|
|
535
558
|
children: create("div", {
|
|
536
559
|
children: [
|
|
537
560
|
create("strong", { style: { paddingLeft: "1rem" }, children: name }),
|
|
@@ -567,17 +590,14 @@ function createPropertyDiscriminator(
|
|
|
567
590
|
})
|
|
568
591
|
),
|
|
569
592
|
create("DiscriminatorTabs", {
|
|
593
|
+
className: "openapi-tabs__discriminator",
|
|
570
594
|
children: Object.keys(discriminator?.mapping!).map((key, index) => {
|
|
571
595
|
const label = key;
|
|
572
596
|
return create("TabItem", {
|
|
597
|
+
// className: "openapi-tabs__discriminator-item",
|
|
573
598
|
label: label,
|
|
574
599
|
value: `${index}-item-discriminator`,
|
|
575
|
-
children: [
|
|
576
|
-
create("div", {
|
|
577
|
-
style: { marginLeft: "-4px" },
|
|
578
|
-
children: createNodes(discriminator?.mapping[key]),
|
|
579
|
-
}),
|
|
580
|
-
],
|
|
600
|
+
children: [createNodes(discriminator?.mapping[key])],
|
|
581
601
|
});
|
|
582
602
|
}),
|
|
583
603
|
}),
|
|
@@ -683,7 +703,7 @@ function createEdges({
|
|
|
683
703
|
return create("SchemaItem", {
|
|
684
704
|
collapsible: false,
|
|
685
705
|
name,
|
|
686
|
-
required:
|
|
706
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
687
707
|
schemaName: schemaName,
|
|
688
708
|
qualifierMessage: getQualifierMessage(schema),
|
|
689
709
|
schema: mergedSchemas,
|
|
@@ -739,7 +759,7 @@ function createEdges({
|
|
|
739
759
|
return create("SchemaItem", {
|
|
740
760
|
collapsible: false,
|
|
741
761
|
name,
|
|
742
|
-
required:
|
|
762
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
743
763
|
schemaName: schemaName,
|
|
744
764
|
qualifierMessage: getQualifierMessage(schema),
|
|
745
765
|
schema: schema,
|
|
@@ -848,6 +868,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
848
868
|
|
|
849
869
|
if (mimeTypes && mimeTypes.length) {
|
|
850
870
|
return create("MimeTabs", {
|
|
871
|
+
className: "openapi-tabs__mime",
|
|
851
872
|
schemaType: "response",
|
|
852
873
|
children: mimeTypes.map((mimeType: any) => {
|
|
853
874
|
const responseExamples = body.content![mimeType].examples;
|
|
@@ -874,6 +895,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
874
895
|
value: `${mimeType}`,
|
|
875
896
|
children: [
|
|
876
897
|
create("SchemaTabs", {
|
|
898
|
+
className: "openapi-tabs__schema",
|
|
877
899
|
// TODO: determine if we should persist this
|
|
878
900
|
// groupId: "schema-tabs",
|
|
879
901
|
children: [
|
|
@@ -883,6 +905,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
883
905
|
value: `${title}`,
|
|
884
906
|
children: [
|
|
885
907
|
createDetails({
|
|
908
|
+
className: "openapi-markdown__details",
|
|
886
909
|
"data-collapsed": false,
|
|
887
910
|
open: true,
|
|
888
911
|
...rest,
|
|
@@ -266,45 +266,48 @@ export function createStatusCodes({ responses }: Props) {
|
|
|
266
266
|
|
|
267
267
|
return create("div", {
|
|
268
268
|
children: [
|
|
269
|
-
create("
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
createDetailsSummary({
|
|
269
|
+
create("div", {
|
|
270
|
+
children: [
|
|
271
|
+
create("ApiTabs", {
|
|
272
|
+
children: codes.map((code) => {
|
|
273
|
+
const responseHeaders: any = responses[code].headers;
|
|
274
|
+
return create("TabItem", {
|
|
275
|
+
label: code,
|
|
276
|
+
value: code,
|
|
277
|
+
children: [
|
|
278
|
+
create("div", {
|
|
279
|
+
children: createDescription(responses[code].description),
|
|
280
|
+
}),
|
|
281
|
+
responseHeaders &&
|
|
282
|
+
createDetails({
|
|
283
|
+
className: "openapi-markdown__details",
|
|
284
|
+
"data-collaposed": true,
|
|
285
|
+
open: false,
|
|
286
|
+
style: { textAlign: "left", marginBottom: "1rem" },
|
|
288
287
|
children: [
|
|
289
|
-
|
|
290
|
-
children:
|
|
288
|
+
createDetailsSummary({
|
|
289
|
+
children: [
|
|
290
|
+
create("strong", {
|
|
291
|
+
children: "Response Headers",
|
|
292
|
+
}),
|
|
293
|
+
],
|
|
291
294
|
}),
|
|
295
|
+
createResponseHeaders(responseHeaders),
|
|
292
296
|
],
|
|
293
297
|
}),
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}),
|
|
298
|
+
create("div", {
|
|
299
|
+
children: createResponseSchema({
|
|
300
|
+
title: "Schema",
|
|
301
|
+
body: {
|
|
302
|
+
content: responses[code].content,
|
|
303
|
+
},
|
|
304
|
+
}),
|
|
305
|
+
}),
|
|
306
|
+
],
|
|
307
|
+
});
|
|
308
|
+
}),
|
|
309
|
+
}),
|
|
310
|
+
],
|
|
308
311
|
}),
|
|
309
312
|
],
|
|
310
313
|
});
|
package/src/markdown/index.ts
CHANGED
|
@@ -17,8 +17,10 @@ import { createContactInfo } from "./createContactInfo";
|
|
|
17
17
|
import { createDeprecationNotice } from "./createDeprecationNotice";
|
|
18
18
|
import { createDescription } from "./createDescription";
|
|
19
19
|
import { createDownload } from "./createDownload";
|
|
20
|
+
import { createHeading } from "./createHeading";
|
|
20
21
|
import { createLicense } from "./createLicense";
|
|
21
22
|
import { createLogo } from "./createLogo";
|
|
23
|
+
import { createMethodEndpoint } from "./createMethodEndpoint";
|
|
22
24
|
import { createParamsDetails } from "./createParamsDetails";
|
|
23
25
|
import { createRequestBodyDetails } from "./createRequestBodyDetails";
|
|
24
26
|
import { createStatusCodes } from "./createStatusCodes";
|
|
@@ -43,6 +45,8 @@ export function createApiPageMD({
|
|
|
43
45
|
deprecated,
|
|
44
46
|
"x-deprecated-description": deprecatedDescription,
|
|
45
47
|
description,
|
|
48
|
+
method,
|
|
49
|
+
path,
|
|
46
50
|
parameters,
|
|
47
51
|
requestBody,
|
|
48
52
|
responses,
|
|
@@ -50,14 +54,16 @@ export function createApiPageMD({
|
|
|
50
54
|
}: ApiPageMetadata) {
|
|
51
55
|
return render([
|
|
52
56
|
`import ApiTabs from "@theme/ApiTabs";\n`,
|
|
57
|
+
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
58
|
+
`import MethodEndpoint from "@theme/ApiDemoPanel/MethodEndpoint";\n`,
|
|
53
59
|
`import MimeTabs from "@theme/MimeTabs";\n`,
|
|
54
60
|
`import ParamsItem from "@theme/ParamsItem";\n`,
|
|
55
61
|
`import ResponseSamples from "@theme/ResponseSamples";\n`,
|
|
56
62
|
`import SchemaItem from "@theme/SchemaItem";\n`,
|
|
57
63
|
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
58
|
-
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
59
64
|
`import TabItem from "@theme/TabItem";\n\n`,
|
|
60
|
-
|
|
65
|
+
createHeading(title.replace(lessThan, "<").replace(greaterThan, ">")),
|
|
66
|
+
createMethodEndpoint(method, path),
|
|
61
67
|
createDeprecationNotice({ deprecated, description: deprecatedDescription }),
|
|
62
68
|
createDescription(description),
|
|
63
69
|
createParamsDetails({ parameters, type: "path" }),
|
|
@@ -94,7 +100,7 @@ export function createInfoPageMD({
|
|
|
94
100
|
|
|
95
101
|
createVersionBadge(version),
|
|
96
102
|
createDownload(downloadUrl),
|
|
97
|
-
|
|
103
|
+
createHeading(title.replace(lessThan, "<").replace(greaterThan, ">")),
|
|
98
104
|
createLogo(logo, darkLogo),
|
|
99
105
|
createDescription(description),
|
|
100
106
|
createAuthentication(securitySchemes as unknown as SecuritySchemeObject),
|
package/src/markdown/utils.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -43,7 +43,7 @@ export function render(children: Children): string {
|
|
|
43
43
|
|
|
44
44
|
// Regex to selectively URL-encode '>' and '<' chars
|
|
45
45
|
export const lessThan =
|
|
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;
|
|
46
|
+
/<(?!(=|button|\s?\/button|code|\s?\/code|details|\s?\/details|summary|\s?\/summary|hr|\s?\/hr|br|\s?\/br|span|\s?\/span|strong|\s?\/strong|small|\s?\/small|table|\s?\/table|thead|\s?\/thead|tbody|\s?\/tbody|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|bold|\s?\/bold|a|\s?\/a|table|\s?\/table|li|\s?\/li|ol|\s?\/ol|ul|\s?\/ul|img|\s?\/img|svg|\s?\/svg|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|
|
|
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|bold|a|li|ol|ul|img|svg|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
|
-
|
|
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(),
|
package/src/types.ts
CHANGED