docusaurus-plugin-openapi-docs 2.0.0-beta.2 → 2.0.0-beta.3
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 +1 -0
- package/lib/index.js +9 -6
- package/lib/markdown/createAuthorization.d.ts +1 -0
- package/lib/markdown/createAuthorization.js +16 -0
- package/lib/markdown/createParamsDetails.js +2 -1
- package/lib/markdown/createRequestHeader.d.ts +1 -0
- package/lib/markdown/createRequestHeader.js +13 -0
- package/lib/markdown/createRequestSchema.js +119 -92
- package/lib/markdown/createResponseSchema.js +108 -85
- package/lib/markdown/createVendorExtensions.d.ts +1 -0
- package/lib/markdown/createVendorExtensions.js +25 -0
- package/lib/markdown/index.d.ts +1 -1
- package/lib/markdown/index.js +9 -2
- package/lib/openapi/openapi.js +22 -0
- package/lib/openapi/utils/loadAndResolveSpec.js +9 -2
- package/lib/options.js +1 -0
- package/lib/types.d.ts +2 -0
- package/package.json +9 -17
- package/src/index.ts +10 -7
- package/src/markdown/createAuthorization.ts +13 -0
- package/src/markdown/createParamsDetails.ts +2 -1
- package/src/markdown/createRequestHeader.ts +10 -0
- package/src/markdown/createRequestSchema.ts +129 -109
- package/src/markdown/createResponseSchema.ts +118 -103
- package/src/markdown/createVendorExtensions.ts +22 -0
- package/src/markdown/index.ts +11 -1
- package/src/openapi/openapi.ts +26 -0
- package/src/openapi/utils/loadAndResolveSpec.ts +10 -1
- package/src/options.ts +1 -0
- package/src/types.ts +2 -0
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.createResponseSchema = exports.mergeAllOf = void 0;
|
|
13
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
10
14
|
const createArrayBracket_1 = require("./createArrayBracket");
|
|
11
15
|
const createDescription_1 = require("./createDescription");
|
|
12
16
|
const createDetails_1 = require("./createDetails");
|
|
@@ -48,14 +52,13 @@ exports.mergeAllOf = mergeAllOf;
|
|
|
48
52
|
*/
|
|
49
53
|
function createAnyOneOf(schema) {
|
|
50
54
|
const type = schema.oneOf ? "oneOf" : "anyOf";
|
|
51
|
-
return (0, utils_1.create)("
|
|
55
|
+
return (0, utils_1.create)("div", {
|
|
52
56
|
children: [
|
|
53
57
|
(0, utils_1.create)("span", {
|
|
54
58
|
className: "badge badge--info",
|
|
55
59
|
children: type,
|
|
56
60
|
}),
|
|
57
61
|
(0, utils_1.create)("SchemaTabs", {
|
|
58
|
-
className: "openapi-tabs__schema",
|
|
59
62
|
children: schema[type].map((anyOneSchema, index) => {
|
|
60
63
|
const label = anyOneSchema.title
|
|
61
64
|
? anyOneSchema.title
|
|
@@ -63,12 +66,15 @@ function createAnyOneOf(schema) {
|
|
|
63
66
|
const anyOneChildren = [];
|
|
64
67
|
if (anyOneSchema.properties !== undefined) {
|
|
65
68
|
anyOneChildren.push(createProperties(anyOneSchema));
|
|
69
|
+
delete anyOneSchema.properties;
|
|
66
70
|
}
|
|
67
71
|
if (anyOneSchema.allOf !== undefined) {
|
|
68
72
|
anyOneChildren.push(createNodes(anyOneSchema));
|
|
73
|
+
delete anyOneSchema.allOf;
|
|
69
74
|
}
|
|
70
75
|
if (anyOneSchema.items !== undefined) {
|
|
71
76
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
77
|
+
delete anyOneSchema.items;
|
|
72
78
|
}
|
|
73
79
|
if (anyOneSchema.type === "string" ||
|
|
74
80
|
anyOneSchema.type === "number" ||
|
|
@@ -93,7 +99,7 @@ function createAnyOneOf(schema) {
|
|
|
93
99
|
return (0, utils_1.create)("TabItem", {
|
|
94
100
|
label: label,
|
|
95
101
|
value: `${index}-item-properties`,
|
|
96
|
-
children: anyOneChildren,
|
|
102
|
+
children: anyOneChildren.filter(Boolean).flat(),
|
|
97
103
|
});
|
|
98
104
|
}
|
|
99
105
|
return undefined;
|
|
@@ -146,6 +152,18 @@ function createAdditionalProperties(schema) {
|
|
|
146
152
|
// }
|
|
147
153
|
const additionalProperties = schema.additionalProperties;
|
|
148
154
|
const type = additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.type;
|
|
155
|
+
// Handle free-form objects
|
|
156
|
+
if (String(additionalProperties) === "true" && schema.type === "object") {
|
|
157
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
158
|
+
name: "property name*",
|
|
159
|
+
required: false,
|
|
160
|
+
schemaName: "any",
|
|
161
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema.additionalProperties),
|
|
162
|
+
schema: schema,
|
|
163
|
+
collapsible: false,
|
|
164
|
+
discriminator: false,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
149
167
|
if ((type === "object" || type === "array") &&
|
|
150
168
|
((additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.properties) ||
|
|
151
169
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.items) ||
|
|
@@ -154,9 +172,9 @@ function createAdditionalProperties(schema) {
|
|
|
154
172
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.oneOf) ||
|
|
155
173
|
(additionalProperties === null || additionalProperties === void 0 ? void 0 : additionalProperties.anyOf))) {
|
|
156
174
|
const title = additionalProperties.title;
|
|
157
|
-
const schemaName =
|
|
175
|
+
const schemaName = (0, schema_1.getSchemaName)(additionalProperties);
|
|
158
176
|
const required = (_a = schema.required) !== null && _a !== void 0 ? _a : false;
|
|
159
|
-
return createDetailsNode("property name*", schemaName, additionalProperties, required, schema.nullable);
|
|
177
|
+
return createDetailsNode("property name*", title !== null && title !== void 0 ? title : schemaName, additionalProperties, required, schema.nullable);
|
|
160
178
|
}
|
|
161
179
|
if (((_b = schema.additionalProperties) === null || _b === void 0 ? void 0 : _b.type) === "string" ||
|
|
162
180
|
((_c = schema.additionalProperties) === null || _c === void 0 ? void 0 : _c.type) === "object" ||
|
|
@@ -166,41 +184,26 @@ function createAdditionalProperties(schema) {
|
|
|
166
184
|
const additionalProperties = (_g = schema.additionalProperties) === null || _g === void 0 ? void 0 : _g.additionalProperties;
|
|
167
185
|
if (additionalProperties !== undefined) {
|
|
168
186
|
const type = (_j = (_h = schema.additionalProperties) === null || _h === void 0 ? void 0 : _h.additionalProperties) === null || _j === void 0 ? void 0 : _j.type;
|
|
169
|
-
const
|
|
170
|
-
return (0, utils_1.create)("
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
(0, utils_1.guard)(format, (format) => (0, utils_1.create)("span", {
|
|
179
|
-
style: { opacity: "0.6" },
|
|
180
|
-
children: ` (${format})`,
|
|
181
|
-
})),
|
|
182
|
-
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(schema.additionalProperties), (message) => (0, utils_1.create)("div", {
|
|
183
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
184
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
185
|
-
})),
|
|
186
|
-
],
|
|
187
|
-
}),
|
|
187
|
+
const schemaName = (0, schema_1.getSchemaName)((_k = schema.additionalProperties) === null || _k === void 0 ? void 0 : _k.additionalProperties);
|
|
188
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
189
|
+
name: "property name*",
|
|
190
|
+
required: false,
|
|
191
|
+
schemaName: schemaName !== null && schemaName !== void 0 ? schemaName : type,
|
|
192
|
+
qualifierMessage: (_l = schema.additionalProperties) !== null && _l !== void 0 ? _l : (0, schema_1.getQualifierMessage)(schema.additionalProperties),
|
|
193
|
+
schema: schema,
|
|
194
|
+
collapsible: false,
|
|
195
|
+
discriminator: false,
|
|
188
196
|
});
|
|
189
197
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
style: { marginTop: "var(--ifm-table-cell-padding)" },
|
|
200
|
-
children: (0, createDescription_1.createDescription)(message),
|
|
201
|
-
})),
|
|
202
|
-
],
|
|
203
|
-
}),
|
|
198
|
+
const schemaName = (0, schema_1.getSchemaName)(schema.additionalProperties);
|
|
199
|
+
return (0, utils_1.create)("SchemaItem", {
|
|
200
|
+
name: "property name*",
|
|
201
|
+
required: false,
|
|
202
|
+
schemaName: schemaName,
|
|
203
|
+
qualifierMessage: (0, schema_1.getQualifierMessage)(schema),
|
|
204
|
+
schema: schema.additionalProperties,
|
|
205
|
+
collapsible: false,
|
|
206
|
+
discriminator: false,
|
|
204
207
|
});
|
|
205
208
|
}
|
|
206
209
|
return Object.entries(schema.additionalProperties).map(([key, val]) => createEdges({
|
|
@@ -398,32 +401,50 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
398
401
|
children: [
|
|
399
402
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
400
403
|
children: [
|
|
401
|
-
(0, utils_1.create)("strong", { children: name }),
|
|
402
404
|
(0, utils_1.create)("span", {
|
|
403
|
-
|
|
404
|
-
children:
|
|
405
|
+
className: "openapi-schema__container",
|
|
406
|
+
children: [
|
|
407
|
+
(0, utils_1.create)("strong", {
|
|
408
|
+
className: (0, clsx_1.default)("openapi-schema__property", {
|
|
409
|
+
"openapi-schema__strikethrough": schema.deprecated,
|
|
410
|
+
}),
|
|
411
|
+
children: name,
|
|
412
|
+
}),
|
|
413
|
+
(0, utils_1.create)("span", {
|
|
414
|
+
className: "openapi-schema__name",
|
|
415
|
+
children: ` ${schemaName}`,
|
|
416
|
+
}),
|
|
417
|
+
(0, utils_1.guard)((Array.isArray(required)
|
|
418
|
+
? required.includes(name)
|
|
419
|
+
: required === true) ||
|
|
420
|
+
schema.deprecated ||
|
|
421
|
+
nullable, () => [
|
|
422
|
+
(0, utils_1.create)("span", {
|
|
423
|
+
className: "openapi-schema__divider",
|
|
424
|
+
}),
|
|
425
|
+
]),
|
|
426
|
+
(0, utils_1.guard)(nullable, () => [
|
|
427
|
+
(0, utils_1.create)("span", {
|
|
428
|
+
className: "openapi-schema__nullable",
|
|
429
|
+
children: "nullable",
|
|
430
|
+
}),
|
|
431
|
+
]),
|
|
432
|
+
(0, utils_1.guard)(Array.isArray(required)
|
|
433
|
+
? required.includes(name)
|
|
434
|
+
: required === true, () => [
|
|
435
|
+
(0, utils_1.create)("span", {
|
|
436
|
+
className: "openapi-schema__required",
|
|
437
|
+
children: "required",
|
|
438
|
+
}),
|
|
439
|
+
]),
|
|
440
|
+
(0, utils_1.guard)(schema.deprecated, () => [
|
|
441
|
+
(0, utils_1.create)("span", {
|
|
442
|
+
className: "openapi-schema__deprecated",
|
|
443
|
+
children: "deprecated",
|
|
444
|
+
}),
|
|
445
|
+
]),
|
|
446
|
+
],
|
|
405
447
|
}),
|
|
406
|
-
(0, utils_1.guard)((schema.nullable && schema.nullable === true) ||
|
|
407
|
-
(nullable && nullable === true), () => [
|
|
408
|
-
(0, utils_1.create)("strong", {
|
|
409
|
-
style: {
|
|
410
|
-
fontSize: "var(--ifm-code-font-size)",
|
|
411
|
-
color: "var(--openapi-nullable)",
|
|
412
|
-
},
|
|
413
|
-
children: " nullable",
|
|
414
|
-
}),
|
|
415
|
-
]),
|
|
416
|
-
(0, utils_1.guard)(Array.isArray(required)
|
|
417
|
-
? required.includes(name)
|
|
418
|
-
: required === true, () => [
|
|
419
|
-
(0, utils_1.create)("strong", {
|
|
420
|
-
style: {
|
|
421
|
-
fontSize: "var(--ifm-code-font-size)",
|
|
422
|
-
color: "var(--openapi-required)",
|
|
423
|
-
},
|
|
424
|
-
children: " required",
|
|
425
|
-
}),
|
|
426
|
-
]),
|
|
427
448
|
],
|
|
428
449
|
}),
|
|
429
450
|
(0, utils_1.create)("div", {
|
|
@@ -457,23 +478,28 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
457
478
|
return undefined;
|
|
458
479
|
}
|
|
459
480
|
return (0, utils_1.create)("div", {
|
|
460
|
-
className: "openapi-discriminator__item",
|
|
481
|
+
className: "openapi-discriminator__item openapi-schema__list-item",
|
|
461
482
|
children: (0, utils_1.create)("div", {
|
|
462
483
|
children: [
|
|
463
|
-
(0, utils_1.create)("
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
},
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
484
|
+
(0, utils_1.create)("span", {
|
|
485
|
+
className: "openapi-schema__container",
|
|
486
|
+
children: [
|
|
487
|
+
(0, utils_1.create)("strong", {
|
|
488
|
+
className: "openapi-discriminator__name openapi-schema__property",
|
|
489
|
+
children: name,
|
|
490
|
+
}),
|
|
491
|
+
(0, utils_1.guard)(schemaName, (name) => (0, utils_1.create)("span", {
|
|
492
|
+
className: "openapi-schema__name",
|
|
493
|
+
children: ` ${schemaName}`,
|
|
494
|
+
})),
|
|
495
|
+
(0, utils_1.guard)(required, () => [
|
|
496
|
+
(0, utils_1.create)("span", {
|
|
497
|
+
className: "openapi-schema__required",
|
|
498
|
+
children: "required",
|
|
499
|
+
}),
|
|
500
|
+
]),
|
|
501
|
+
],
|
|
502
|
+
}),
|
|
477
503
|
(0, utils_1.guard)((0, schema_1.getQualifierMessage)(discriminator), (message) => (0, utils_1.create)("div", {
|
|
478
504
|
style: {
|
|
479
505
|
paddingLeft: "1rem",
|
|
@@ -671,22 +697,19 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
671
697
|
value: `${title}`,
|
|
672
698
|
children: [
|
|
673
699
|
(0, createDetails_1.createDetails)({
|
|
674
|
-
className: "openapi-markdown__details",
|
|
700
|
+
className: "openapi-markdown__details response",
|
|
675
701
|
"data-collapsed": false,
|
|
676
702
|
open: true,
|
|
677
703
|
...rest,
|
|
678
704
|
children: [
|
|
679
705
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
680
|
-
|
|
706
|
+
className: "openapi-markdown__details-summary-response",
|
|
681
707
|
children: [
|
|
682
708
|
(0, utils_1.create)("strong", { children: `${title}` }),
|
|
683
709
|
(0, utils_1.guard)(body.required && body.required === true, () => [
|
|
684
|
-
(0, utils_1.create)("
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
color: "var(--openapi-required)",
|
|
688
|
-
},
|
|
689
|
-
children: " required",
|
|
710
|
+
(0, utils_1.create)("span", {
|
|
711
|
+
className: "openapi-schema__required",
|
|
712
|
+
children: "required",
|
|
690
713
|
}),
|
|
691
714
|
]),
|
|
692
715
|
],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createVendorExtensions(extensions: any): string | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
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.createVendorExtensions = void 0;
|
|
10
|
+
function createVendorExtensions(extensions) {
|
|
11
|
+
if (!extensions || typeof extensions !== "object") {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const rows = [];
|
|
15
|
+
extensions.map((extension) => {
|
|
16
|
+
const extensionRow = () => {
|
|
17
|
+
return `${extension.key}: ${JSON.stringify(extension.value)}`;
|
|
18
|
+
};
|
|
19
|
+
return rows.push(extensionRow());
|
|
20
|
+
});
|
|
21
|
+
return `\n\n\`\`\`
|
|
22
|
+
${rows.join("\n")}
|
|
23
|
+
\`\`\`\n\n`;
|
|
24
|
+
}
|
|
25
|
+
exports.createVendorExtensions = createVendorExtensions;
|
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, method, path, parameters, requestBody, responses, }, }: ApiPageMetadata): string;
|
|
2
|
+
export declare function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, extensions, parameters, requestBody, responses, }, infoPath, frontMatter, }: 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
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createTagPageMD = exports.createInfoPageMD = exports.createApiPageMD = void 0;
|
|
10
10
|
const createAuthentication_1 = require("./createAuthentication");
|
|
11
|
+
const createAuthorization_1 = require("./createAuthorization");
|
|
11
12
|
const createContactInfo_1 = require("./createContactInfo");
|
|
12
13
|
const createDeprecationNotice_1 = require("./createDeprecationNotice");
|
|
13
14
|
const createDescription_1 = require("./createDescription");
|
|
@@ -18,15 +19,18 @@ const createLogo_1 = require("./createLogo");
|
|
|
18
19
|
const createMethodEndpoint_1 = require("./createMethodEndpoint");
|
|
19
20
|
const createParamsDetails_1 = require("./createParamsDetails");
|
|
20
21
|
const createRequestBodyDetails_1 = require("./createRequestBodyDetails");
|
|
22
|
+
const createRequestHeader_1 = require("./createRequestHeader");
|
|
21
23
|
const createStatusCodes_1 = require("./createStatusCodes");
|
|
22
24
|
const createTermsOfService_1 = require("./createTermsOfService");
|
|
25
|
+
const createVendorExtensions_1 = require("./createVendorExtensions");
|
|
23
26
|
const createVersionBadge_1 = require("./createVersionBadge");
|
|
24
27
|
const utils_1 = require("./utils");
|
|
25
|
-
function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, parameters, requestBody, responses, }, }) {
|
|
28
|
+
function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, extensions, parameters, requestBody, responses, }, infoPath, frontMatter, }) {
|
|
26
29
|
return (0, utils_1.render)([
|
|
27
30
|
`import ApiTabs from "@theme/ApiTabs";\n`,
|
|
28
31
|
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
29
32
|
`import MethodEndpoint from "@theme/ApiDemoPanel/MethodEndpoint";\n`,
|
|
33
|
+
`import SecuritySchemes from "@theme/ApiDemoPanel/SecuritySchemes";\n`,
|
|
30
34
|
`import MimeTabs from "@theme/MimeTabs";\n`,
|
|
31
35
|
`import ParamsItem from "@theme/ParamsItem";\n`,
|
|
32
36
|
`import ResponseSamples from "@theme/ResponseSamples";\n`,
|
|
@@ -35,14 +39,17 @@ function createApiPageMD({ title, api: { deprecated, "x-deprecated-description":
|
|
|
35
39
|
`import TabItem from "@theme/TabItem";\n\n`,
|
|
36
40
|
(0, createHeading_1.createHeading)(title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")),
|
|
37
41
|
(0, createMethodEndpoint_1.createMethodEndpoint)(method, path),
|
|
42
|
+
infoPath && (0, createAuthorization_1.createAuthorization)(infoPath),
|
|
43
|
+
frontMatter.show_extensions && (0, createVendorExtensions_1.createVendorExtensions)(extensions),
|
|
38
44
|
(0, createDeprecationNotice_1.createDeprecationNotice)({ deprecated, description: deprecatedDescription }),
|
|
39
45
|
(0, createDescription_1.createDescription)(description),
|
|
46
|
+
(0, createRequestHeader_1.createRequestHeader)("Request"),
|
|
40
47
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "path" }),
|
|
41
48
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "query" }),
|
|
42
49
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "header" }),
|
|
43
50
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "cookie" }),
|
|
44
51
|
(0, createRequestBodyDetails_1.createRequestBodyDetails)({
|
|
45
|
-
title: "
|
|
52
|
+
title: "Body",
|
|
46
53
|
body: requestBody,
|
|
47
54
|
}),
|
|
48
55
|
(0, createStatusCodes_1.createStatusCodes)({ responses }),
|
package/lib/openapi/openapi.js
CHANGED
|
@@ -112,6 +112,13 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
112
112
|
const baseId = operationObject.operationId
|
|
113
113
|
? (0, kebabCase_1.default)(operationObject.operationId)
|
|
114
114
|
: (0, kebabCase_1.default)(operationObject.summary);
|
|
115
|
+
const extensions = [];
|
|
116
|
+
const commonExtensions = ["x-codeSamples"];
|
|
117
|
+
for (const [key, value] of Object.entries(operationObject)) {
|
|
118
|
+
if (key.startsWith("x-") && !commonExtensions.includes(key)) {
|
|
119
|
+
extensions.push({ key, value });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
115
122
|
const servers = (_j = (_h = operationObject.servers) !== null && _h !== void 0 ? _h : pathObject.servers) !== null && _j !== void 0 ? _j : openapiData.servers;
|
|
116
123
|
const security = (_k = operationObject.security) !== null && _k !== void 0 ? _k : openapiData.security;
|
|
117
124
|
// Add security schemes so we know how to handle security.
|
|
@@ -176,9 +183,13 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
176
183
|
...((options === null || options === void 0 ? void 0 : options.hideSendButton) && {
|
|
177
184
|
hide_send_button: options.hideSendButton,
|
|
178
185
|
}),
|
|
186
|
+
...((options === null || options === void 0 ? void 0 : options.showExtensions) && {
|
|
187
|
+
show_extensions: options.showExtensions,
|
|
188
|
+
}),
|
|
179
189
|
},
|
|
180
190
|
api: {
|
|
181
191
|
...defaults,
|
|
192
|
+
...(extensions.length > 0 && { extensions: extensions }),
|
|
182
193
|
tags: operationObject.tags,
|
|
183
194
|
method,
|
|
184
195
|
path,
|
|
@@ -206,6 +217,13 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
206
217
|
const baseId = operationObject.operationId
|
|
207
218
|
? (0, kebabCase_1.default)(operationObject.operationId)
|
|
208
219
|
: (0, kebabCase_1.default)(operationObject.summary);
|
|
220
|
+
const extensions = [];
|
|
221
|
+
const commonExtensions = ["x-codeSamples"];
|
|
222
|
+
for (const [key, value] of Object.entries(operationObject)) {
|
|
223
|
+
if (key.startsWith("x-") && !commonExtensions.includes(key)) {
|
|
224
|
+
extensions.push({ key, value });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
209
227
|
const servers = (_w = (_v = operationObject.servers) !== null && _v !== void 0 ? _v : pathObject.servers) !== null && _w !== void 0 ? _w : openapiData.servers;
|
|
210
228
|
const security = (_x = operationObject.security) !== null && _x !== void 0 ? _x : openapiData.security;
|
|
211
229
|
// Add security schemes so we know how to handle security.
|
|
@@ -270,9 +288,13 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
270
288
|
...((options === null || options === void 0 ? void 0 : options.hideSendButton) && {
|
|
271
289
|
hide_send_button: options.hideSendButton,
|
|
272
290
|
}),
|
|
291
|
+
...((options === null || options === void 0 ? void 0 : options.showExtensions) && {
|
|
292
|
+
show_extensions: options.showExtensions,
|
|
293
|
+
}),
|
|
273
294
|
},
|
|
274
295
|
api: {
|
|
275
296
|
...defaults,
|
|
297
|
+
...(extensions.length > 0 && { extensions: extensions }),
|
|
276
298
|
tags: operationObject.tags,
|
|
277
299
|
method,
|
|
278
300
|
path,
|
|
@@ -74,7 +74,6 @@ function convertSwagger2OpenAPI(spec) {
|
|
|
74
74
|
}
|
|
75
75
|
exports.convertSwagger2OpenAPI = convertSwagger2OpenAPI;
|
|
76
76
|
async function resolveJsonRefs(specUrlOrObject) {
|
|
77
|
-
var _a, _b;
|
|
78
77
|
try {
|
|
79
78
|
let schema = await json_schema_ref_parser_1.default.dereference(specUrlOrObject, {
|
|
80
79
|
continueOnError: true,
|
|
@@ -92,7 +91,15 @@ async function resolveJsonRefs(specUrlOrObject) {
|
|
|
92
91
|
return schema;
|
|
93
92
|
}
|
|
94
93
|
catch (err) {
|
|
95
|
-
|
|
94
|
+
let errorMsg = "";
|
|
95
|
+
if (err.errors[0] !== undefined) {
|
|
96
|
+
const error = err.errors[0];
|
|
97
|
+
errorMsg = `Error: [${error.message}] with footprint [${error.footprint}]`;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
errorMsg = err;
|
|
101
|
+
}
|
|
102
|
+
console.error(chalk_1.default.yellow(errorMsg));
|
|
96
103
|
return;
|
|
97
104
|
}
|
|
98
105
|
}
|
package/lib/options.js
CHANGED
|
@@ -26,6 +26,7 @@ exports.OptionsSchema = utils_validation_1.Joi.object({
|
|
|
26
26
|
template: utils_validation_1.Joi.string(),
|
|
27
27
|
downloadUrl: utils_validation_1.Joi.string(),
|
|
28
28
|
hideSendButton: utils_validation_1.Joi.boolean(),
|
|
29
|
+
showExtensions: utils_validation_1.Joi.boolean(),
|
|
29
30
|
sidebarOptions: sidebarOptions,
|
|
30
31
|
version: utils_validation_1.Joi.string().when("versions", {
|
|
31
32
|
is: utils_validation_1.Joi.exist(),
|
package/lib/types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface APIOptions {
|
|
|
14
14
|
template?: string;
|
|
15
15
|
downloadUrl?: string;
|
|
16
16
|
hideSendButton?: boolean;
|
|
17
|
+
showExtensions?: boolean;
|
|
17
18
|
sidebarOptions?: SidebarOptions;
|
|
18
19
|
version?: string;
|
|
19
20
|
label?: string;
|
|
@@ -78,6 +79,7 @@ export interface ApiItem extends OperationObject {
|
|
|
78
79
|
postman?: Request;
|
|
79
80
|
proxy?: string;
|
|
80
81
|
info: InfoObject;
|
|
82
|
+
extensions?: object;
|
|
81
83
|
}
|
|
82
84
|
export interface InfoPageMetadata extends ApiMetadataBase {
|
|
83
85
|
type: "info";
|
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": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,38 +28,30 @@
|
|
|
28
28
|
"watch": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/
|
|
32
|
-
"@docusaurus/types": "^2.3.0",
|
|
31
|
+
"@docusaurus/types": ">=2.3.0 <2.5.0",
|
|
33
32
|
"@types/fs-extra": "^9.0.13",
|
|
34
|
-
"@types/js-yaml": "^4.0.5",
|
|
35
33
|
"@types/json-pointer": "^1.0.31",
|
|
36
34
|
"@types/json-schema": "^7.0.9",
|
|
37
35
|
"@types/lodash": "^4.14.176",
|
|
38
|
-
"@types/mustache": "^4.1.2"
|
|
39
|
-
"utility-types": "^3.10.0"
|
|
36
|
+
"@types/mustache": "^4.1.2"
|
|
40
37
|
},
|
|
41
38
|
"dependencies": {
|
|
42
|
-
"@apidevtools/json-schema-ref-parser": "^
|
|
43
|
-
"@docusaurus/
|
|
44
|
-
"@docusaurus/
|
|
45
|
-
"@docusaurus/utils": "
|
|
46
|
-
"@docusaurus/utils-validation": "^2.3.0",
|
|
39
|
+
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
40
|
+
"@docusaurus/plugin-content-docs": ">=2.3.0 <2.5.0",
|
|
41
|
+
"@docusaurus/utils": ">=2.3.0 <2.5.0",
|
|
42
|
+
"@docusaurus/utils-validation": ">=2.3.0 <2.5.0",
|
|
47
43
|
"@paloaltonetworks/openapi-to-postmanv2": "3.1.0-hotfix.1",
|
|
48
44
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
49
|
-
"@redocly/openapi-core": "^1.0.0-beta.
|
|
45
|
+
"@redocly/openapi-core": "^1.0.0-beta.125",
|
|
50
46
|
"chalk": "^4.1.2",
|
|
51
47
|
"clsx": "^1.1.1",
|
|
52
48
|
"fs-extra": "^9.0.1",
|
|
53
|
-
"js-yaml": "^4.1.0",
|
|
54
49
|
"json-pointer": "^0.6.2",
|
|
55
|
-
"json-refs": "^3.0.15",
|
|
56
50
|
"json-schema-merge-allof": "^0.8.1",
|
|
57
51
|
"lodash": "^4.17.20",
|
|
58
52
|
"mustache": "^4.2.0",
|
|
59
53
|
"slugify": "^1.6.5",
|
|
60
54
|
"swagger2openapi": "^7.0.8",
|
|
61
|
-
"url-template": "^3.0.0",
|
|
62
|
-
"webpack": "^5.61.0",
|
|
63
55
|
"xml-formatter": "^2.6.1"
|
|
64
56
|
},
|
|
65
57
|
"peerDependencies": {
|
|
@@ -68,5 +60,5 @@
|
|
|
68
60
|
"engines": {
|
|
69
61
|
"node": ">=14"
|
|
70
62
|
},
|
|
71
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "f02561b29cdee2dfa56ccf0ea1a63f9324d8044c"
|
|
72
64
|
}
|
package/src/index.ts
CHANGED
|
@@ -193,6 +193,9 @@ proxy: {{{frontMatter.proxy}}}
|
|
|
193
193
|
{{#frontMatter.hide_send_button}}
|
|
194
194
|
hide_send_button: true
|
|
195
195
|
{{/frontMatter.hide_send_button}}
|
|
196
|
+
{{#frontMatter.show_extensions}}
|
|
197
|
+
show_extensions: true
|
|
198
|
+
{{/frontMatter.show_extensions}}
|
|
196
199
|
---
|
|
197
200
|
|
|
198
201
|
{{{markdown}}}
|
|
@@ -240,13 +243,6 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
240
243
|
item.downloadUrl = downloadUrl;
|
|
241
244
|
}
|
|
242
245
|
}
|
|
243
|
-
const markdown =
|
|
244
|
-
item.type === "api"
|
|
245
|
-
? createApiPageMD(item)
|
|
246
|
-
: item.type === "info"
|
|
247
|
-
? createInfoPageMD(item)
|
|
248
|
-
: createTagPageMD(item);
|
|
249
|
-
item.markdown = markdown;
|
|
250
246
|
if (item.type === "api") {
|
|
251
247
|
item.json = JSON.stringify(item.api);
|
|
252
248
|
let infoBasePath = `${outputDir}/${item.infoId}`;
|
|
@@ -257,6 +253,13 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
257
253
|
}
|
|
258
254
|
if (item.infoId) item.infoPath = infoBasePath;
|
|
259
255
|
}
|
|
256
|
+
const markdown =
|
|
257
|
+
item.type === "api"
|
|
258
|
+
? createApiPageMD(item)
|
|
259
|
+
: item.type === "info"
|
|
260
|
+
? createInfoPageMD(item)
|
|
261
|
+
: createTagPageMD(item);
|
|
262
|
+
item.markdown = markdown;
|
|
260
263
|
|
|
261
264
|
const view = render(mdTemplate, item);
|
|
262
265
|
const utils = render(infoMdTemplate, item);
|
|
@@ -0,0 +1,13 @@
|
|
|
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 createAuthorization(infoPath: string) {
|
|
11
|
+
if (!infoPath) return undefined;
|
|
12
|
+
return [create("SecuritySchemes", { infoPath: infoPath }), "\n\n"];
|
|
13
|
+
}
|
|
@@ -32,7 +32,8 @@ export function createParamsDetails({ parameters, type }: Props) {
|
|
|
32
32
|
children: [
|
|
33
33
|
createDetailsSummary({
|
|
34
34
|
children: [
|
|
35
|
-
create("
|
|
35
|
+
create("h3", {
|
|
36
|
+
className: "openapi-markdown__details-summary-header-params",
|
|
36
37
|
children: `${
|
|
37
38
|
type.charAt(0).toUpperCase() + type.slice(1)
|
|
38
39
|
} Parameters`,
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export function createRequestHeader(header: string) {
|
|
9
|
+
return `## ${header}\n\n`;
|
|
10
|
+
}
|