docusaurus-plugin-openapi-docs 1.6.1 → 2.0.0-beta.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/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 +10 -8
- package/lib/markdown/createResponseSchema.js +10 -8
- 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 +2 -2
- 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 +10 -8
- package/src/markdown/createResponseSchema.ts +10 -8
- package/src/markdown/createStatusCodes.ts +38 -35
- package/src/markdown/index.ts +9 -3
- package/src/markdown/utils.ts +2 -2
- package/src/types.ts +2 -0
|
@@ -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;
|
|
@@ -327,7 +327,7 @@ function createItems(schema) {
|
|
|
327
327
|
// }
|
|
328
328
|
// }
|
|
329
329
|
// return create("div", {
|
|
330
|
-
// className: "
|
|
330
|
+
// className: "openapi-discriminator__item",
|
|
331
331
|
// children: create("div", {
|
|
332
332
|
// children: [
|
|
333
333
|
// create("strong", {
|
|
@@ -392,6 +392,7 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
392
392
|
className: "schemaItem",
|
|
393
393
|
children: [
|
|
394
394
|
(0, createDetails_1.createDetails)({
|
|
395
|
+
className: "openapi-markdown__details",
|
|
395
396
|
children: [
|
|
396
397
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
397
398
|
children: [
|
|
@@ -454,7 +455,7 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
454
455
|
return undefined;
|
|
455
456
|
}
|
|
456
457
|
return (0, utils_1.create)("div", {
|
|
457
|
-
className: "
|
|
458
|
+
className: "openapi-discriminator__item",
|
|
458
459
|
children: (0, utils_1.create)("div", {
|
|
459
460
|
children: [
|
|
460
461
|
(0, utils_1.create)("strong", { style: { paddingLeft: "1rem" }, children: name }),
|
|
@@ -484,17 +485,14 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
484
485
|
children: (0, createDescription_1.createDescription)(description),
|
|
485
486
|
})),
|
|
486
487
|
(0, utils_1.create)("DiscriminatorTabs", {
|
|
488
|
+
className: "openapi-tabs__discriminator",
|
|
487
489
|
children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
|
|
488
490
|
const label = key;
|
|
489
491
|
return (0, utils_1.create)("TabItem", {
|
|
492
|
+
// className: "openapi-tabs__discriminator-item",
|
|
490
493
|
label: label,
|
|
491
494
|
value: `${index}-item-discriminator`,
|
|
492
|
-
children: [
|
|
493
|
-
(0, utils_1.create)("div", {
|
|
494
|
-
style: { marginLeft: "-4px" },
|
|
495
|
-
children: createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key]),
|
|
496
|
-
}),
|
|
497
|
-
],
|
|
495
|
+
children: [createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key])],
|
|
498
496
|
});
|
|
499
497
|
}),
|
|
500
498
|
}),
|
|
@@ -638,6 +636,7 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
638
636
|
const mimeTypes = Object.keys(body.content);
|
|
639
637
|
if (mimeTypes && mimeTypes.length > 1) {
|
|
640
638
|
return (0, utils_1.create)("MimeTabs", {
|
|
639
|
+
className: "openapi-tabs__mime",
|
|
641
640
|
schemaType: "request",
|
|
642
641
|
children: mimeTypes.map((mimeType) => {
|
|
643
642
|
const firstBody = body.content[mimeType].schema;
|
|
@@ -654,6 +653,7 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
654
653
|
value: `${mimeType}`,
|
|
655
654
|
children: [
|
|
656
655
|
(0, createDetails_1.createDetails)({
|
|
656
|
+
className: "openapi-markdown__details",
|
|
657
657
|
"data-collapsed": false,
|
|
658
658
|
open: true,
|
|
659
659
|
...rest,
|
|
@@ -707,12 +707,14 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
709
|
return (0, utils_1.create)("MimeTabs", {
|
|
710
|
+
className: "openapi-tabs__mime",
|
|
710
711
|
children: [
|
|
711
712
|
(0, utils_1.create)("TabItem", {
|
|
712
713
|
label: randomFirstKey,
|
|
713
714
|
value: `${randomFirstKey}-schema`,
|
|
714
715
|
children: [
|
|
715
716
|
(0, createDetails_1.createDetails)({
|
|
717
|
+
className: "openapi-markdown__details",
|
|
716
718
|
"data-collapsed": false,
|
|
717
719
|
open: true,
|
|
718
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
|
|
@@ -328,7 +329,7 @@ function createItems(schema) {
|
|
|
328
329
|
// }
|
|
329
330
|
// }
|
|
330
331
|
// return create("div", {
|
|
331
|
-
// className: "
|
|
332
|
+
// className: "openapi-discriminator__item",
|
|
332
333
|
// children: create("div", {
|
|
333
334
|
// children: [
|
|
334
335
|
// create("strong", {
|
|
@@ -393,6 +394,7 @@ function createDetailsNode(name, schemaName, schema, required, nullable) {
|
|
|
393
394
|
className: "schemaItem",
|
|
394
395
|
children: [
|
|
395
396
|
(0, createDetails_1.createDetails)({
|
|
397
|
+
className: "openapi-markdown__details",
|
|
396
398
|
children: [
|
|
397
399
|
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
398
400
|
children: [
|
|
@@ -455,7 +457,7 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
455
457
|
return undefined;
|
|
456
458
|
}
|
|
457
459
|
return (0, utils_1.create)("div", {
|
|
458
|
-
className: "
|
|
460
|
+
className: "openapi-discriminator__item",
|
|
459
461
|
children: (0, utils_1.create)("div", {
|
|
460
462
|
children: [
|
|
461
463
|
(0, utils_1.create)("strong", { style: { paddingLeft: "1rem" }, children: name }),
|
|
@@ -485,17 +487,14 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
485
487
|
children: (0, createDescription_1.createDescription)(description),
|
|
486
488
|
})),
|
|
487
489
|
(0, utils_1.create)("DiscriminatorTabs", {
|
|
490
|
+
className: "openapi-tabs__discriminator",
|
|
488
491
|
children: Object.keys(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping).map((key, index) => {
|
|
489
492
|
const label = key;
|
|
490
493
|
return (0, utils_1.create)("TabItem", {
|
|
494
|
+
// className: "openapi-tabs__discriminator-item",
|
|
491
495
|
label: label,
|
|
492
496
|
value: `${index}-item-discriminator`,
|
|
493
|
-
children: [
|
|
494
|
-
(0, utils_1.create)("div", {
|
|
495
|
-
style: { marginLeft: "-4px" },
|
|
496
|
-
children: createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key]),
|
|
497
|
-
}),
|
|
498
|
-
],
|
|
497
|
+
children: [createNodes(discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping[key])],
|
|
499
498
|
});
|
|
500
499
|
}),
|
|
501
500
|
}),
|
|
@@ -640,6 +639,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
640
639
|
const mimeTypes = Object.keys(body.content);
|
|
641
640
|
if (mimeTypes && mimeTypes.length) {
|
|
642
641
|
return (0, utils_1.create)("MimeTabs", {
|
|
642
|
+
className: "openapi-tabs__mime",
|
|
643
643
|
schemaType: "response",
|
|
644
644
|
children: mimeTypes.map((mimeType) => {
|
|
645
645
|
var _a;
|
|
@@ -661,6 +661,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
661
661
|
value: `${mimeType}`,
|
|
662
662
|
children: [
|
|
663
663
|
(0, utils_1.create)("SchemaTabs", {
|
|
664
|
+
className: "openapi-tabs__schema",
|
|
664
665
|
// TODO: determine if we should persist this
|
|
665
666
|
// groupId: "schema-tabs",
|
|
666
667
|
children: [
|
|
@@ -670,6 +671,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
670
671
|
value: `${title}`,
|
|
671
672
|
children: [
|
|
672
673
|
(0, createDetails_1.createDetails)({
|
|
674
|
+
className: "openapi-markdown__details",
|
|
673
675
|
"data-collapsed": false,
|
|
674
676
|
open: true,
|
|
675
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
|
@@ -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|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|
|
|
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/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.1",
|
|
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": "adcd05075257f6d00321dc289445d0306306b7ee"
|
|
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
|
+
}
|
|
@@ -391,7 +391,7 @@ function createItems(schema: SchemaObject) {
|
|
|
391
391
|
// }
|
|
392
392
|
|
|
393
393
|
// return create("div", {
|
|
394
|
-
// className: "
|
|
394
|
+
// className: "openapi-discriminator__item",
|
|
395
395
|
// children: create("div", {
|
|
396
396
|
// children: [
|
|
397
397
|
// create("strong", {
|
|
@@ -465,6 +465,7 @@ function createDetailsNode(
|
|
|
465
465
|
className: "schemaItem",
|
|
466
466
|
children: [
|
|
467
467
|
createDetails({
|
|
468
|
+
className: "openapi-markdown__details",
|
|
468
469
|
children: [
|
|
469
470
|
createDetailsSummary({
|
|
470
471
|
children: [
|
|
@@ -546,7 +547,7 @@ function createPropertyDiscriminator(
|
|
|
546
547
|
}
|
|
547
548
|
|
|
548
549
|
return create("div", {
|
|
549
|
-
className: "
|
|
550
|
+
className: "openapi-discriminator__item",
|
|
550
551
|
children: create("div", {
|
|
551
552
|
children: [
|
|
552
553
|
create("strong", { style: { paddingLeft: "1rem" }, children: name }),
|
|
@@ -582,17 +583,14 @@ function createPropertyDiscriminator(
|
|
|
582
583
|
})
|
|
583
584
|
),
|
|
584
585
|
create("DiscriminatorTabs", {
|
|
586
|
+
className: "openapi-tabs__discriminator",
|
|
585
587
|
children: Object.keys(discriminator?.mapping!).map((key, index) => {
|
|
586
588
|
const label = key;
|
|
587
589
|
return create("TabItem", {
|
|
590
|
+
// className: "openapi-tabs__discriminator-item",
|
|
588
591
|
label: label,
|
|
589
592
|
value: `${index}-item-discriminator`,
|
|
590
|
-
children: [
|
|
591
|
-
create("div", {
|
|
592
|
-
style: { marginLeft: "-4px" },
|
|
593
|
-
children: createNodes(discriminator?.mapping[key]),
|
|
594
|
-
}),
|
|
595
|
-
],
|
|
593
|
+
children: [createNodes(discriminator?.mapping[key])],
|
|
596
594
|
});
|
|
597
595
|
}),
|
|
598
596
|
}),
|
|
@@ -861,6 +859,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
861
859
|
|
|
862
860
|
if (mimeTypes && mimeTypes.length > 1) {
|
|
863
861
|
return create("MimeTabs", {
|
|
862
|
+
className: "openapi-tabs__mime",
|
|
864
863
|
schemaType: "request",
|
|
865
864
|
children: mimeTypes.map((mimeType) => {
|
|
866
865
|
const firstBody = body.content![mimeType].schema;
|
|
@@ -877,6 +876,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
877
876
|
value: `${mimeType}`,
|
|
878
877
|
children: [
|
|
879
878
|
createDetails({
|
|
879
|
+
className: "openapi-markdown__details",
|
|
880
880
|
"data-collapsed": false,
|
|
881
881
|
open: true,
|
|
882
882
|
...rest,
|
|
@@ -934,12 +934,14 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
934
934
|
}
|
|
935
935
|
}
|
|
936
936
|
return create("MimeTabs", {
|
|
937
|
+
className: "openapi-tabs__mime",
|
|
937
938
|
children: [
|
|
938
939
|
create("TabItem", {
|
|
939
940
|
label: randomFirstKey,
|
|
940
941
|
value: `${randomFirstKey}-schema`,
|
|
941
942
|
children: [
|
|
942
943
|
createDetails({
|
|
944
|
+
className: "openapi-markdown__details",
|
|
943
945
|
"data-collapsed": false,
|
|
944
946
|
open: true,
|
|
945
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
|
|
@@ -397,7 +398,7 @@ function createItems(schema: SchemaObject) {
|
|
|
397
398
|
// }
|
|
398
399
|
|
|
399
400
|
// return create("div", {
|
|
400
|
-
// className: "
|
|
401
|
+
// className: "openapi-discriminator__item",
|
|
401
402
|
// children: create("div", {
|
|
402
403
|
// children: [
|
|
403
404
|
// create("strong", {
|
|
@@ -471,6 +472,7 @@ function createDetailsNode(
|
|
|
471
472
|
className: "schemaItem",
|
|
472
473
|
children: [
|
|
473
474
|
createDetails({
|
|
475
|
+
className: "openapi-markdown__details",
|
|
474
476
|
children: [
|
|
475
477
|
createDetailsSummary({
|
|
476
478
|
children: [
|
|
@@ -552,7 +554,7 @@ function createPropertyDiscriminator(
|
|
|
552
554
|
}
|
|
553
555
|
|
|
554
556
|
return create("div", {
|
|
555
|
-
className: "
|
|
557
|
+
className: "openapi-discriminator__item",
|
|
556
558
|
children: create("div", {
|
|
557
559
|
children: [
|
|
558
560
|
create("strong", { style: { paddingLeft: "1rem" }, children: name }),
|
|
@@ -588,17 +590,14 @@ function createPropertyDiscriminator(
|
|
|
588
590
|
})
|
|
589
591
|
),
|
|
590
592
|
create("DiscriminatorTabs", {
|
|
593
|
+
className: "openapi-tabs__discriminator",
|
|
591
594
|
children: Object.keys(discriminator?.mapping!).map((key, index) => {
|
|
592
595
|
const label = key;
|
|
593
596
|
return create("TabItem", {
|
|
597
|
+
// className: "openapi-tabs__discriminator-item",
|
|
594
598
|
label: label,
|
|
595
599
|
value: `${index}-item-discriminator`,
|
|
596
|
-
children: [
|
|
597
|
-
create("div", {
|
|
598
|
-
style: { marginLeft: "-4px" },
|
|
599
|
-
children: createNodes(discriminator?.mapping[key]),
|
|
600
|
-
}),
|
|
601
|
-
],
|
|
600
|
+
children: [createNodes(discriminator?.mapping[key])],
|
|
602
601
|
});
|
|
603
602
|
}),
|
|
604
603
|
}),
|
|
@@ -869,6 +868,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
869
868
|
|
|
870
869
|
if (mimeTypes && mimeTypes.length) {
|
|
871
870
|
return create("MimeTabs", {
|
|
871
|
+
className: "openapi-tabs__mime",
|
|
872
872
|
schemaType: "response",
|
|
873
873
|
children: mimeTypes.map((mimeType: any) => {
|
|
874
874
|
const responseExamples = body.content![mimeType].examples;
|
|
@@ -895,6 +895,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
895
895
|
value: `${mimeType}`,
|
|
896
896
|
children: [
|
|
897
897
|
create("SchemaTabs", {
|
|
898
|
+
className: "openapi-tabs__schema",
|
|
898
899
|
// TODO: determine if we should persist this
|
|
899
900
|
// groupId: "schema-tabs",
|
|
900
901
|
children: [
|
|
@@ -904,6 +905,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
904
905
|
value: `${title}`,
|
|
905
906
|
children: [
|
|
906
907
|
createDetails({
|
|
908
|
+
className: "openapi-markdown__details",
|
|
907
909
|
"data-collapsed": false,
|
|
908
910
|
open: true,
|
|
909
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
|
@@ -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|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|
|
|
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/types.ts
CHANGED