docusaurus-plugin-openapi-docs 2.0.0-beta.2 → 2.0.0-beta.4
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 +2 -1
- package/lib/index.js +20 -7
- 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.d.ts +1 -8
- package/lib/markdown/createRequestSchema.js +21 -633
- package/lib/markdown/createResponseSchema.d.ts +1 -8
- package/lib/markdown/createResponseSchema.js +8 -626
- package/lib/markdown/createSchema.d.ts +12 -0
- package/lib/markdown/createSchema.js +647 -0
- 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 +11 -4
- package/lib/openapi/createRequestExample.js +3 -3
- package/lib/openapi/createResponseExample.js +3 -3
- 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 +21 -8
- 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 +20 -839
- package/src/markdown/createResponseSchema.ts +8 -834
- package/src/markdown/createSchema.ts +850 -0
- package/src/markdown/createVendorExtensions.ts +22 -0
- package/src/markdown/index.ts +13 -3
- package/src/openapi/createRequestExample.ts +1 -1
- package/src/openapi/createResponseExample.ts +1 -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
|
@@ -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
|
-
`import MethodEndpoint from "@theme/
|
|
32
|
+
`import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";\n`,
|
|
33
|
+
`import SecuritySchemes from "@theme/ApiExplorer/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 }),
|
|
@@ -54,7 +61,7 @@ function createInfoPageMD({ info: { title, version, description, contact, licens
|
|
|
54
61
|
`import ApiLogo from "@theme/ApiLogo";\n`,
|
|
55
62
|
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
56
63
|
`import TabItem from "@theme/TabItem";\n`,
|
|
57
|
-
`import Export from "@theme/
|
|
64
|
+
`import Export from "@theme/ApiExplorer/Export";\n\n`,
|
|
58
65
|
(0, createVersionBadge_1.createVersionBadge)(version),
|
|
59
66
|
(0, createDownload_1.createDownload)(downloadUrl),
|
|
60
67
|
(0, createHeading_1.createHeading)(title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")),
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.sampleRequestFromSchema = void 0;
|
|
13
13
|
const chalk_1 = __importDefault(require("chalk"));
|
|
14
14
|
const merge_1 = __importDefault(require("lodash/merge"));
|
|
15
|
-
const
|
|
15
|
+
const createSchema_1 = require("../markdown/createSchema");
|
|
16
16
|
const primitives = {
|
|
17
17
|
string: {
|
|
18
18
|
default: () => "string",
|
|
@@ -51,7 +51,7 @@ function sampleRequestFromProp(name, prop, obj) {
|
|
|
51
51
|
obj[name] = (0, exports.sampleRequestFromSchema)(prop.anyOf[0]);
|
|
52
52
|
}
|
|
53
53
|
else if (prop.allOf) {
|
|
54
|
-
const { mergedSchemas } = (0,
|
|
54
|
+
const { mergedSchemas } = (0, createSchema_1.mergeAllOf)(prop.allOf);
|
|
55
55
|
sampleRequestFromProp(name, mergedSchemas, obj);
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
@@ -86,7 +86,7 @@ const sampleRequestFromSchema = (schema = {}) => {
|
|
|
86
86
|
return (0, exports.sampleRequestFromSchema)(anyOf[0]);
|
|
87
87
|
}
|
|
88
88
|
if (allOf) {
|
|
89
|
-
const { mergedSchemas } = (0,
|
|
89
|
+
const { mergedSchemas } = (0, createSchema_1.mergeAllOf)(allOf);
|
|
90
90
|
if (mergedSchemas.properties) {
|
|
91
91
|
for (const [key, value] of Object.entries(mergedSchemas.properties)) {
|
|
92
92
|
if ((value.readOnly && value.readOnly === true) || value.deprecated) {
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.sampleResponseFromSchema = void 0;
|
|
13
13
|
const chalk_1 = __importDefault(require("chalk"));
|
|
14
14
|
const merge_1 = __importDefault(require("lodash/merge"));
|
|
15
|
-
const
|
|
15
|
+
const createSchema_1 = require("../markdown/createSchema");
|
|
16
16
|
const primitives = {
|
|
17
17
|
string: {
|
|
18
18
|
default: () => "string",
|
|
@@ -51,7 +51,7 @@ function sampleResponseFromProp(name, prop, obj) {
|
|
|
51
51
|
obj[name] = (0, exports.sampleResponseFromSchema)(prop.anyOf[0]);
|
|
52
52
|
}
|
|
53
53
|
else if (prop.allOf) {
|
|
54
|
-
const { mergedSchemas } = (0,
|
|
54
|
+
const { mergedSchemas } = (0, createSchema_1.mergeAllOf)(prop.allOf);
|
|
55
55
|
sampleResponseFromProp(name, mergedSchemas, obj);
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
@@ -68,7 +68,7 @@ const sampleResponseFromSchema = (schema = {}) => {
|
|
|
68
68
|
return example;
|
|
69
69
|
}
|
|
70
70
|
if (allOf) {
|
|
71
|
-
const { mergedSchemas } = (0,
|
|
71
|
+
const { mergedSchemas } = (0, createSchema_1.mergeAllOf)(allOf);
|
|
72
72
|
if (mergedSchemas.properties) {
|
|
73
73
|
for (const [key, value] of Object.entries(mergedSchemas.properties)) {
|
|
74
74
|
if ((value.writeOnly && value.writeOnly === true) ||
|
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.4",
|
|
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": "d7c1319c7977c3e7c54827b3950e5c9b66106e30"
|
|
72
64
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import fs from "fs";
|
|
9
9
|
import path from "path";
|
|
10
|
+
import zlib from "zlib";
|
|
10
11
|
|
|
11
12
|
import type { LoadContext, Plugin } from "@docusaurus/types";
|
|
12
13
|
import { Globby, posixPath } from "@docusaurus/utils";
|
|
@@ -193,6 +194,9 @@ proxy: {{{frontMatter.proxy}}}
|
|
|
193
194
|
{{#frontMatter.hide_send_button}}
|
|
194
195
|
hide_send_button: true
|
|
195
196
|
{{/frontMatter.hide_send_button}}
|
|
197
|
+
{{#frontMatter.show_extensions}}
|
|
198
|
+
show_extensions: true
|
|
199
|
+
{{/frontMatter.show_extensions}}
|
|
196
200
|
---
|
|
197
201
|
|
|
198
202
|
{{{markdown}}}
|
|
@@ -240,15 +244,17 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
240
244
|
item.downloadUrl = downloadUrl;
|
|
241
245
|
}
|
|
242
246
|
}
|
|
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
247
|
if (item.type === "api") {
|
|
251
|
-
|
|
248
|
+
// opportunity to compress JSON
|
|
249
|
+
// const serialize = (o: any) => {
|
|
250
|
+
// return zlib.deflateSync(JSON.stringify(o)).toString("base64");
|
|
251
|
+
// };
|
|
252
|
+
// const deserialize = (s: any) => {
|
|
253
|
+
// return zlib.inflateSync(Buffer.from(s, "base64")).toString();
|
|
254
|
+
// };
|
|
255
|
+
item.json = zlib
|
|
256
|
+
.deflateSync(JSON.stringify(item.api))
|
|
257
|
+
.toString("base64");
|
|
252
258
|
let infoBasePath = `${outputDir}/${item.infoId}`;
|
|
253
259
|
if (docRouteBasePath) {
|
|
254
260
|
infoBasePath = `${docRouteBasePath}/${outputDir
|
|
@@ -257,6 +263,13 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
|
257
263
|
}
|
|
258
264
|
if (item.infoId) item.infoPath = infoBasePath;
|
|
259
265
|
}
|
|
266
|
+
const markdown =
|
|
267
|
+
item.type === "api"
|
|
268
|
+
? createApiPageMD(item)
|
|
269
|
+
: item.type === "info"
|
|
270
|
+
? createInfoPageMD(item)
|
|
271
|
+
: createTagPageMD(item);
|
|
272
|
+
item.markdown = markdown;
|
|
260
273
|
|
|
261
274
|
const view = render(mdTemplate, item);
|
|
262
275
|
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
|
+
}
|