docusaurus-plugin-openapi-docs 0.0.0-1000
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/LICENSE +21 -0
- package/README.md +361 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +709 -0
- package/lib/markdown/createArrayBracket.d.ts +2 -0
- package/lib/markdown/createArrayBracket.js +36 -0
- package/lib/markdown/createAuthentication.d.ts +2 -0
- package/lib/markdown/createAuthentication.js +171 -0
- package/lib/markdown/createAuthorization.d.ts +1 -0
- package/lib/markdown/createAuthorization.js +15 -0
- package/lib/markdown/createCallbackMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createCallbackMethodEndpoint.js +20 -0
- package/lib/markdown/createCallbacks.d.ts +6 -0
- package/lib/markdown/createCallbacks.js +77 -0
- package/lib/markdown/createContactInfo.d.ts +2 -0
- package/lib/markdown/createContactInfo.js +39 -0
- package/lib/markdown/createDeprecationNotice.d.ts +6 -0
- package/lib/markdown/createDeprecationNotice.js +20 -0
- package/lib/markdown/createDescription.d.ts +1 -0
- package/lib/markdown/createDescription.js +13 -0
- package/lib/markdown/createDetails.d.ts +2 -0
- package/lib/markdown/createDetails.js +17 -0
- package/lib/markdown/createDetailsSummary.d.ts +2 -0
- package/lib/markdown/createDetailsSummary.js +17 -0
- package/lib/markdown/createDownload.d.ts +1 -0
- package/lib/markdown/createDownload.js +16 -0
- package/lib/markdown/createHeading.d.ts +1 -0
- package/lib/markdown/createHeading.js +20 -0
- package/lib/markdown/createLicense.d.ts +2 -0
- package/lib/markdown/createLicense.js +32 -0
- package/lib/markdown/createLogo.d.ts +2 -0
- package/lib/markdown/createLogo.js +18 -0
- package/lib/markdown/createMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createMethodEndpoint.js +20 -0
- package/lib/markdown/createParamsDetails.d.ts +6 -0
- package/lib/markdown/createParamsDetails.js +18 -0
- package/lib/markdown/createRequestBodyDetails.d.ts +13 -0
- package/lib/markdown/createRequestBodyDetails.js +13 -0
- package/lib/markdown/createRequestHeader.d.ts +1 -0
- package/lib/markdown/createRequestHeader.js +21 -0
- package/lib/markdown/createRequestSchema.d.ts +14 -0
- package/lib/markdown/createRequestSchema.js +20 -0
- package/lib/markdown/createResponseSchema.d.ts +14 -0
- package/lib/markdown/createResponseSchema.js +20 -0
- package/lib/markdown/createSchema.d.ts +9 -0
- package/lib/markdown/createSchema.js +668 -0
- package/lib/markdown/createSchema.test.d.ts +1 -0
- package/lib/markdown/createSchema.test.js +913 -0
- package/lib/markdown/createStatusCodes.d.ts +9 -0
- package/lib/markdown/createStatusCodes.js +63 -0
- package/lib/markdown/createTermsOfService.d.ts +1 -0
- package/lib/markdown/createTermsOfService.js +31 -0
- package/lib/markdown/createVendorExtensions.d.ts +1 -0
- package/lib/markdown/createVendorExtensions.js +24 -0
- package/lib/markdown/createVersionBadge.d.ts +1 -0
- package/lib/markdown/createVersionBadge.js +19 -0
- package/lib/markdown/index.d.ts +5 -0
- package/lib/markdown/index.js +92 -0
- package/lib/markdown/schema.d.ts +3 -0
- package/lib/markdown/schema.js +154 -0
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +181 -0
- package/lib/markdown/utils.d.ts +20 -0
- package/lib/markdown/utils.js +68 -0
- package/lib/openapi/createRequestExample.d.ts +2 -0
- package/lib/openapi/createRequestExample.js +191 -0
- package/lib/openapi/createResponseExample.d.ts +2 -0
- package/lib/openapi/createResponseExample.js +192 -0
- package/lib/openapi/index.d.ts +1 -0
- package/lib/openapi/index.js +12 -0
- package/lib/openapi/openapi.d.ts +12 -0
- package/lib/openapi/openapi.js +544 -0
- package/lib/openapi/openapi.test.d.ts +1 -0
- package/lib/openapi/openapi.test.js +33 -0
- package/lib/openapi/types.d.ts +354 -0
- package/lib/openapi/types.js +8 -0
- package/lib/openapi/utils/loadAndResolveSpec.d.ts +2 -0
- package/lib/openapi/utils/loadAndResolveSpec.js +153 -0
- package/lib/openapi/utils/services/OpenAPIParser.d.ts +52 -0
- package/lib/openapi/utils/services/OpenAPIParser.js +343 -0
- package/lib/openapi/utils/services/RedocNormalizedOptions.d.ts +100 -0
- package/lib/openapi/utils/services/RedocNormalizedOptions.js +170 -0
- package/lib/openapi/utils/types/index.d.ts +2 -0
- package/lib/openapi/utils/types/index.js +23 -0
- package/lib/openapi/utils/types/open-api.d.ts +305 -0
- package/lib/openapi/utils/types/open-api.js +8 -0
- package/lib/openapi/utils/types.d.ts +306 -0
- package/lib/openapi/utils/types.js +8 -0
- package/lib/openapi/utils/utils/JsonPointer.d.ts +51 -0
- package/lib/openapi/utils/utils/JsonPointer.js +95 -0
- package/lib/openapi/utils/utils/helpers.d.ts +43 -0
- package/lib/openapi/utils/utils/helpers.js +230 -0
- package/lib/openapi/utils/utils/index.d.ts +3 -0
- package/lib/openapi/utils/utils/index.js +25 -0
- package/lib/openapi/utils/utils/openapi.d.ts +40 -0
- package/lib/openapi/utils/utils/openapi.js +605 -0
- package/lib/options.d.ts +2 -0
- package/lib/options.js +69 -0
- package/lib/sidebars/index.d.ts +4 -0
- package/lib/sidebars/index.js +226 -0
- package/lib/sidebars/utils.d.ts +2 -0
- package/lib/sidebars/utils.js +30 -0
- package/lib/types.d.ts +135 -0
- package/lib/types.js +8 -0
- package/package.json +69 -0
- package/src/index.ts +945 -0
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +1605 -0
- package/src/markdown/createArrayBracket.ts +35 -0
- package/src/markdown/createAuthentication.ts +201 -0
- package/src/markdown/createAuthorization.ts +13 -0
- package/src/markdown/createCallbackMethodEndpoint.ts +19 -0
- package/src/markdown/createCallbacks.ts +101 -0
- package/src/markdown/createContactInfo.ts +41 -0
- package/src/markdown/createDeprecationNotice.ts +31 -0
- package/src/markdown/createDescription.ts +12 -0
- package/src/markdown/createDetails.ts +16 -0
- package/src/markdown/createDetailsSummary.ts +16 -0
- package/src/markdown/createDownload.ts +15 -0
- package/src/markdown/createHeading.ts +23 -0
- package/src/markdown/createLicense.ts +34 -0
- package/src/markdown/createLogo.ts +21 -0
- package/src/markdown/createMethodEndpoint.ts +19 -0
- package/src/markdown/createParamsDetails.ts +22 -0
- package/src/markdown/createRequestBodyDetails.ts +24 -0
- package/src/markdown/createRequestHeader.ts +24 -0
- package/src/markdown/createRequestSchema.ts +32 -0
- package/src/markdown/createResponseSchema.ts +32 -0
- package/src/markdown/createSchema.test.ts +1075 -0
- package/src/markdown/createSchema.ts +862 -0
- package/src/markdown/createStatusCodes.ts +63 -0
- package/src/markdown/createTermsOfService.ts +30 -0
- package/src/markdown/createVendorExtensions.ts +22 -0
- package/src/markdown/createVersionBadge.ts +22 -0
- package/src/markdown/index.ts +144 -0
- package/src/markdown/schema.test.ts +208 -0
- package/src/markdown/schema.ts +185 -0
- package/src/markdown/utils.ts +89 -0
- package/src/openapi/__fixtures__/examples/openapi.yaml +49 -0
- package/src/openapi/createRequestExample.ts +235 -0
- package/src/openapi/createResponseExample.ts +238 -0
- package/src/openapi/index.ts +8 -0
- package/src/openapi/openapi.test.ts +40 -0
- package/src/openapi/openapi.ts +697 -0
- package/src/openapi/types.ts +455 -0
- package/src/openapi/utils/loadAndResolveSpec.ts +171 -0
- package/src/openapi/utils/services/OpenAPIParser.ts +434 -0
- package/src/openapi/utils/services/RedocNormalizedOptions.ts +330 -0
- package/src/openapi/utils/types/index.ts +10 -0
- package/src/openapi/utils/types/open-api.ts +303 -0
- package/src/openapi/utils/types.ts +303 -0
- package/src/openapi/utils/utils/JsonPointer.ts +99 -0
- package/src/openapi/utils/utils/helpers.ts +239 -0
- package/src/openapi/utils/utils/index.ts +11 -0
- package/src/openapi/utils/utils/openapi.ts +771 -0
- package/src/openapi-to-postmanv2.d.ts +10 -0
- package/src/options.ts +77 -0
- package/src/plugin-content-docs-types.d.ts +42 -0
- package/src/plugin-openapi.d.ts +87 -0
- package/src/postman-collection.d.ts +10 -0
- package/src/sidebars/index.ts +322 -0
- package/src/sidebars/utils.ts +29 -0
- package/src/types.ts +176 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ApiItem } from "../types";
|
|
2
|
+
export default function json2xml(o: any, tab: any): string;
|
|
3
|
+
interface Props {
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
responses: ApiItem["responses"];
|
|
7
|
+
}
|
|
8
|
+
export declare function createStatusCodes({ id, label, responses }: Props): string[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
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.default = json2xml;
|
|
10
|
+
exports.createStatusCodes = createStatusCodes;
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
function json2xml(o, tab) {
|
|
13
|
+
var toXml = function (v, name, ind) {
|
|
14
|
+
var xml = "";
|
|
15
|
+
if (v instanceof Array) {
|
|
16
|
+
for (var i = 0, n = v.length; i < n; i++)
|
|
17
|
+
xml += ind + toXml(v[i], name, ind + "\t") + "\n";
|
|
18
|
+
}
|
|
19
|
+
else if (typeof v == "object") {
|
|
20
|
+
var hasChild = false;
|
|
21
|
+
xml += ind + "<" + name;
|
|
22
|
+
for (var m in v) {
|
|
23
|
+
if (m.charAt(0) === "@")
|
|
24
|
+
xml += " " + m.substr(1) + '="' + v[m].toString() + '"';
|
|
25
|
+
else
|
|
26
|
+
hasChild = true;
|
|
27
|
+
}
|
|
28
|
+
xml += hasChild ? ">" : "/>";
|
|
29
|
+
if (hasChild) {
|
|
30
|
+
for (var m2 in v) {
|
|
31
|
+
if (m2 === "#text")
|
|
32
|
+
xml += v[m2];
|
|
33
|
+
else if (m2 === "#cdata")
|
|
34
|
+
xml += "<![CDATA[" + v[m2] + "]]>";
|
|
35
|
+
else if (m2.charAt(0) !== "@")
|
|
36
|
+
xml += toXml(v[m2], m2, ind + "\t");
|
|
37
|
+
}
|
|
38
|
+
xml +=
|
|
39
|
+
(xml.charAt(xml.length - 1) === "\n" ? ind : "") +
|
|
40
|
+
"</" +
|
|
41
|
+
name +
|
|
42
|
+
">";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
xml += ind + "<" + name + ">" + v.toString() + "</" + name + ">";
|
|
47
|
+
}
|
|
48
|
+
return xml;
|
|
49
|
+
}, xml = "";
|
|
50
|
+
for (var m3 in o)
|
|
51
|
+
xml += toXml(o[m3], m3, "");
|
|
52
|
+
return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
|
|
53
|
+
}
|
|
54
|
+
function createStatusCodes({ id, label, responses }) {
|
|
55
|
+
return [
|
|
56
|
+
(0, utils_1.create)("StatusCodes", {
|
|
57
|
+
id: id,
|
|
58
|
+
label: label,
|
|
59
|
+
responses: responses,
|
|
60
|
+
}),
|
|
61
|
+
"\n\n",
|
|
62
|
+
];
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createTermsOfService(termsOfService: string | undefined): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
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.createTermsOfService = createTermsOfService;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function createTermsOfService(termsOfService) {
|
|
12
|
+
if (!termsOfService)
|
|
13
|
+
return "";
|
|
14
|
+
return (0, utils_1.create)("div", {
|
|
15
|
+
style: {
|
|
16
|
+
marginBottom: "var(--ifm-paragraph-margin-bottom)",
|
|
17
|
+
},
|
|
18
|
+
children: [
|
|
19
|
+
(0, utils_1.create)("h3", {
|
|
20
|
+
style: {
|
|
21
|
+
marginBottom: "0.25rem",
|
|
22
|
+
},
|
|
23
|
+
children: "Terms of Service",
|
|
24
|
+
}),
|
|
25
|
+
(0, utils_1.create)("a", {
|
|
26
|
+
href: `${termsOfService}`,
|
|
27
|
+
children: `{'${termsOfService}'}`,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createVendorExtensions(extensions: any): string | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 = createVendorExtensions;
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createVersionBadge(version: string | undefined): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
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.createVersionBadge = createVersionBadge;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function createVersionBadge(version) {
|
|
12
|
+
return (0, utils_1.guard)(version, (version) => [
|
|
13
|
+
(0, utils_1.create)("span", {
|
|
14
|
+
className: "theme-doc-version-badge badge badge--secondary",
|
|
15
|
+
children: `Version: ${escape(version)}`,
|
|
16
|
+
}, { inline: true }),
|
|
17
|
+
`\n\n`,
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ApiPageMetadata, InfoPageMetadata, SchemaPageMetadata, TagPageMetadata } from "../types";
|
|
2
|
+
export declare function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, extensions, parameters, requestBody, responses, callbacks, }, infoPath, frontMatter, }: ApiPageMetadata): string;
|
|
3
|
+
export declare function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, downloadUrl, }: InfoPageMetadata): string;
|
|
4
|
+
export declare function createTagPageMD({ tag: { description } }: TagPageMetadata): string;
|
|
5
|
+
export declare function createSchemaPageMD({ schema }: SchemaPageMetadata): string;
|
|
@@ -0,0 +1,92 @@
|
|
|
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.createApiPageMD = createApiPageMD;
|
|
10
|
+
exports.createInfoPageMD = createInfoPageMD;
|
|
11
|
+
exports.createTagPageMD = createTagPageMD;
|
|
12
|
+
exports.createSchemaPageMD = createSchemaPageMD;
|
|
13
|
+
const createAuthentication_1 = require("./createAuthentication");
|
|
14
|
+
const createAuthorization_1 = require("./createAuthorization");
|
|
15
|
+
const createCallbacks_1 = require("./createCallbacks");
|
|
16
|
+
const createContactInfo_1 = require("./createContactInfo");
|
|
17
|
+
const createDeprecationNotice_1 = require("./createDeprecationNotice");
|
|
18
|
+
const createDescription_1 = require("./createDescription");
|
|
19
|
+
const createDownload_1 = require("./createDownload");
|
|
20
|
+
const createHeading_1 = require("./createHeading");
|
|
21
|
+
const createLicense_1 = require("./createLicense");
|
|
22
|
+
const createLogo_1 = require("./createLogo");
|
|
23
|
+
const createMethodEndpoint_1 = require("./createMethodEndpoint");
|
|
24
|
+
const createParamsDetails_1 = require("./createParamsDetails");
|
|
25
|
+
const createRequestBodyDetails_1 = require("./createRequestBodyDetails");
|
|
26
|
+
const createRequestHeader_1 = require("./createRequestHeader");
|
|
27
|
+
const createStatusCodes_1 = require("./createStatusCodes");
|
|
28
|
+
const createTermsOfService_1 = require("./createTermsOfService");
|
|
29
|
+
const createVendorExtensions_1 = require("./createVendorExtensions");
|
|
30
|
+
const createVersionBadge_1 = require("./createVersionBadge");
|
|
31
|
+
const utils_1 = require("./utils");
|
|
32
|
+
function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, extensions, parameters, requestBody, responses, callbacks, }, infoPath, frontMatter, }) {
|
|
33
|
+
return (0, utils_1.render)([
|
|
34
|
+
`import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";\n`,
|
|
35
|
+
`import ParamsDetails from "@theme/ParamsDetails";\n`,
|
|
36
|
+
`import RequestSchema from "@theme/RequestSchema";\n`,
|
|
37
|
+
`import StatusCodes from "@theme/StatusCodes";\n`,
|
|
38
|
+
`import OperationTabs from "@theme/OperationTabs";\n`,
|
|
39
|
+
`import TabItem from "@theme/TabItem";\n`,
|
|
40
|
+
`import Heading from "@theme/Heading";\n\n`,
|
|
41
|
+
(0, createHeading_1.createHeading)(title),
|
|
42
|
+
(0, createMethodEndpoint_1.createMethodEndpoint)(method, path),
|
|
43
|
+
infoPath && (0, createAuthorization_1.createAuthorization)(infoPath),
|
|
44
|
+
frontMatter.show_extensions
|
|
45
|
+
? (0, createVendorExtensions_1.createVendorExtensions)(extensions)
|
|
46
|
+
: undefined,
|
|
47
|
+
(0, createDeprecationNotice_1.createDeprecationNotice)({ deprecated, description: deprecatedDescription }),
|
|
48
|
+
(0, createDescription_1.createDescription)(description),
|
|
49
|
+
requestBody || parameters ? (0, createRequestHeader_1.createRequestHeader)("Request") : undefined,
|
|
50
|
+
(0, createParamsDetails_1.createParamsDetails)({ parameters }),
|
|
51
|
+
(0, createRequestBodyDetails_1.createRequestBodyDetails)({
|
|
52
|
+
title: "Body",
|
|
53
|
+
body: requestBody,
|
|
54
|
+
}),
|
|
55
|
+
(0, createStatusCodes_1.createStatusCodes)({ responses }),
|
|
56
|
+
(0, createCallbacks_1.createCallbacks)({ callbacks }),
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, downloadUrl, }) {
|
|
60
|
+
return (0, utils_1.render)([
|
|
61
|
+
`import ApiLogo from "@theme/ApiLogo";\n`,
|
|
62
|
+
`import Heading from "@theme/Heading";\n`,
|
|
63
|
+
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
64
|
+
`import TabItem from "@theme/TabItem";\n`,
|
|
65
|
+
`import Export from "@theme/ApiExplorer/Export";\n\n`,
|
|
66
|
+
(0, createVersionBadge_1.createVersionBadge)(version),
|
|
67
|
+
(0, createDownload_1.createDownload)(downloadUrl),
|
|
68
|
+
(0, createHeading_1.createHeading)(title),
|
|
69
|
+
(0, createLogo_1.createLogo)(logo, darkLogo),
|
|
70
|
+
(0, createDescription_1.createDescription)(description),
|
|
71
|
+
(0, createAuthentication_1.createAuthentication)(securitySchemes),
|
|
72
|
+
(0, createContactInfo_1.createContactInfo)(contact),
|
|
73
|
+
(0, createTermsOfService_1.createTermsOfService)(termsOfService),
|
|
74
|
+
(0, createLicense_1.createLicense)(license),
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
function createTagPageMD({ tag: { description } }) {
|
|
78
|
+
return (0, utils_1.render)([(0, createDescription_1.createDescription)(description)]);
|
|
79
|
+
}
|
|
80
|
+
function createSchemaPageMD({ schema }) {
|
|
81
|
+
const { title = "", description } = schema;
|
|
82
|
+
return (0, utils_1.render)([
|
|
83
|
+
`import Schema from "@theme/Schema";\n`,
|
|
84
|
+
`import Heading from "@theme/Heading";\n\n`,
|
|
85
|
+
(0, createHeading_1.createHeading)(title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")),
|
|
86
|
+
(0, createDescription_1.createDescription)(description),
|
|
87
|
+
(0, utils_1.create)("Schema", {
|
|
88
|
+
schema: schema,
|
|
89
|
+
schemaType: "response",
|
|
90
|
+
}),
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
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.getSchemaName = getSchemaName;
|
|
10
|
+
exports.getQualifierMessage = getQualifierMessage;
|
|
11
|
+
function prettyName(schema, circular) {
|
|
12
|
+
var _a, _b, _c, _d, _e;
|
|
13
|
+
if (schema.format) {
|
|
14
|
+
return schema.format;
|
|
15
|
+
}
|
|
16
|
+
if (schema.allOf) {
|
|
17
|
+
if (typeof schema.allOf[0] === "string") {
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
if (schema.allOf[0].includes("circular")) {
|
|
20
|
+
return schema.allOf[0];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return "object";
|
|
24
|
+
}
|
|
25
|
+
if (schema.oneOf) {
|
|
26
|
+
return "object";
|
|
27
|
+
}
|
|
28
|
+
if (schema.anyOf) {
|
|
29
|
+
return "object";
|
|
30
|
+
}
|
|
31
|
+
if (schema.type === "object") {
|
|
32
|
+
return (_b = (_a = schema.xml) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : schema.type;
|
|
33
|
+
// return schema.type;
|
|
34
|
+
}
|
|
35
|
+
if (schema.type === "array") {
|
|
36
|
+
return (_d = (_c = schema.xml) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : schema.type;
|
|
37
|
+
// return schema.type;
|
|
38
|
+
}
|
|
39
|
+
if (schema.title && schema.type) {
|
|
40
|
+
return `${schema.title} (${schema.type})`;
|
|
41
|
+
}
|
|
42
|
+
return (_e = schema.title) !== null && _e !== void 0 ? _e : schema.type;
|
|
43
|
+
}
|
|
44
|
+
function getSchemaName(schema, circular) {
|
|
45
|
+
var _a;
|
|
46
|
+
if (schema.items) {
|
|
47
|
+
return prettyName(schema.items, circular) + "[]";
|
|
48
|
+
}
|
|
49
|
+
return (_a = prettyName(schema, circular)) !== null && _a !== void 0 ? _a : "";
|
|
50
|
+
}
|
|
51
|
+
function getQualifierMessage(schema) {
|
|
52
|
+
// TODO:
|
|
53
|
+
// - uniqueItems
|
|
54
|
+
// - maxProperties
|
|
55
|
+
// - minProperties
|
|
56
|
+
// - multipleOf
|
|
57
|
+
if (!schema) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if (schema.items &&
|
|
61
|
+
schema.minItems === undefined &&
|
|
62
|
+
schema.maxItems === undefined) {
|
|
63
|
+
return getQualifierMessage(schema.items);
|
|
64
|
+
}
|
|
65
|
+
let message = "**Possible values:** ";
|
|
66
|
+
let qualifierGroups = [];
|
|
67
|
+
if (schema.items && schema.items.enum) {
|
|
68
|
+
if (schema.items.enum) {
|
|
69
|
+
qualifierGroups.push(`[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (schema.minLength || schema.maxLength) {
|
|
73
|
+
let lengthQualifier = "";
|
|
74
|
+
let minLength;
|
|
75
|
+
let maxLength;
|
|
76
|
+
if (schema.minLength && schema.minLength > 1) {
|
|
77
|
+
minLength = `\`>= ${schema.minLength} characters\``;
|
|
78
|
+
}
|
|
79
|
+
if (schema.minLength && schema.minLength === 1) {
|
|
80
|
+
minLength = `\`non-empty\``;
|
|
81
|
+
}
|
|
82
|
+
if (schema.maxLength) {
|
|
83
|
+
maxLength = `\`<= ${schema.maxLength} characters\``;
|
|
84
|
+
}
|
|
85
|
+
if (minLength && !maxLength) {
|
|
86
|
+
lengthQualifier += minLength;
|
|
87
|
+
}
|
|
88
|
+
if (maxLength && !minLength) {
|
|
89
|
+
lengthQualifier += maxLength;
|
|
90
|
+
}
|
|
91
|
+
if (minLength && maxLength) {
|
|
92
|
+
lengthQualifier += `${minLength} and ${maxLength}`;
|
|
93
|
+
}
|
|
94
|
+
qualifierGroups.push(lengthQualifier);
|
|
95
|
+
}
|
|
96
|
+
if (schema.minimum != null ||
|
|
97
|
+
schema.maximum != null ||
|
|
98
|
+
typeof schema.exclusiveMinimum === "number" ||
|
|
99
|
+
typeof schema.exclusiveMaximum === "number") {
|
|
100
|
+
let minmaxQualifier = "";
|
|
101
|
+
let minimum;
|
|
102
|
+
let maximum;
|
|
103
|
+
if (typeof schema.exclusiveMinimum === "number") {
|
|
104
|
+
minimum = `\`> ${schema.exclusiveMinimum}\``;
|
|
105
|
+
}
|
|
106
|
+
else if (schema.minimum != null && !schema.exclusiveMinimum) {
|
|
107
|
+
minimum = `\`>= ${schema.minimum}\``;
|
|
108
|
+
}
|
|
109
|
+
else if (schema.minimum != null && schema.exclusiveMinimum === true) {
|
|
110
|
+
minimum = `\`> ${schema.minimum}\``;
|
|
111
|
+
}
|
|
112
|
+
if (typeof schema.exclusiveMaximum === "number") {
|
|
113
|
+
maximum = `\`< ${schema.exclusiveMaximum}\``;
|
|
114
|
+
}
|
|
115
|
+
else if (schema.maximum != null && !schema.exclusiveMaximum) {
|
|
116
|
+
maximum = `\`<= ${schema.maximum}\``;
|
|
117
|
+
}
|
|
118
|
+
else if (schema.maximum != null && schema.exclusiveMaximum === true) {
|
|
119
|
+
maximum = `\`< ${schema.maximum}\``;
|
|
120
|
+
}
|
|
121
|
+
if (minimum && !maximum) {
|
|
122
|
+
minmaxQualifier += minimum;
|
|
123
|
+
}
|
|
124
|
+
if (maximum && !minimum) {
|
|
125
|
+
minmaxQualifier += maximum;
|
|
126
|
+
}
|
|
127
|
+
if (minimum && maximum) {
|
|
128
|
+
minmaxQualifier += `${minimum} and ${maximum}`;
|
|
129
|
+
}
|
|
130
|
+
qualifierGroups.push(minmaxQualifier);
|
|
131
|
+
}
|
|
132
|
+
if (schema.pattern) {
|
|
133
|
+
qualifierGroups.push(`Value must match regular expression \`${schema.pattern}\``);
|
|
134
|
+
}
|
|
135
|
+
// Check if discriminator mapping
|
|
136
|
+
const discriminator = schema;
|
|
137
|
+
if (discriminator.mapping) {
|
|
138
|
+
const values = Object.keys(discriminator.mapping);
|
|
139
|
+
qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
|
|
140
|
+
}
|
|
141
|
+
if (schema.enum) {
|
|
142
|
+
qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
143
|
+
}
|
|
144
|
+
if (schema.minItems) {
|
|
145
|
+
qualifierGroups.push(`\`>= ${schema.minItems}\``);
|
|
146
|
+
}
|
|
147
|
+
if (schema.maxItems) {
|
|
148
|
+
qualifierGroups.push(`\`<= ${schema.maxItems}\``);
|
|
149
|
+
}
|
|
150
|
+
if (qualifierGroups.length === 0) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
return message + qualifierGroups.join(", ");
|
|
154
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,181 @@
|
|
|
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
|
+
const schema_1 = require("./schema");
|
|
10
|
+
describe("getQualifierMessage", () => {
|
|
11
|
+
it("should render nothing", () => {
|
|
12
|
+
const actual = (0, schema_1.getQualifierMessage)({});
|
|
13
|
+
expect(actual).toBeUndefined();
|
|
14
|
+
});
|
|
15
|
+
//
|
|
16
|
+
// minLength + maxLength
|
|
17
|
+
//
|
|
18
|
+
it("should render minLength", () => {
|
|
19
|
+
const expected = "**Possible values:** `non-empty`";
|
|
20
|
+
const actual = (0, schema_1.getQualifierMessage)({ minLength: 1 });
|
|
21
|
+
expect(actual).toBe(expected);
|
|
22
|
+
});
|
|
23
|
+
it("should render maxLength", () => {
|
|
24
|
+
const expected = "**Possible values:** `<= 40 characters`";
|
|
25
|
+
const actual = (0, schema_1.getQualifierMessage)({ maxLength: 40 });
|
|
26
|
+
expect(actual).toBe(expected);
|
|
27
|
+
});
|
|
28
|
+
it("should render minLength and maxLength", () => {
|
|
29
|
+
const expected = "**Possible values:** `non-empty` and `<= 40 characters`";
|
|
30
|
+
const actual = (0, schema_1.getQualifierMessage)({ minLength: 1, maxLength: 40 });
|
|
31
|
+
expect(actual).toBe(expected);
|
|
32
|
+
});
|
|
33
|
+
//
|
|
34
|
+
// pattern
|
|
35
|
+
//
|
|
36
|
+
it("should render pattern", () => {
|
|
37
|
+
const expected = "**Possible values:** Value must match regular expression `^[a-zA-Z0-9_-]*$`";
|
|
38
|
+
const actual = (0, schema_1.getQualifierMessage)({ pattern: "^[a-zA-Z0-9_-]*$" });
|
|
39
|
+
expect(actual).toBe(expected);
|
|
40
|
+
});
|
|
41
|
+
it("should render multiple string qualifiers", () => {
|
|
42
|
+
const expected = "**Possible values:** `non-empty` and `<= 40 characters`, Value must match regular expression `^[a-zA-Z0-9_-]*$`";
|
|
43
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
44
|
+
minLength: 1,
|
|
45
|
+
maxLength: 40,
|
|
46
|
+
pattern: "^[a-zA-Z0-9_-]*$",
|
|
47
|
+
});
|
|
48
|
+
expect(actual).toBe(expected);
|
|
49
|
+
});
|
|
50
|
+
//
|
|
51
|
+
// enum
|
|
52
|
+
//
|
|
53
|
+
it("should render enum", () => {
|
|
54
|
+
const expected = "**Possible values:** [`cat`, `dog`, `mouse`]";
|
|
55
|
+
const actual = (0, schema_1.getQualifierMessage)({ enum: ["cat", "dog", "mouse"] });
|
|
56
|
+
expect(actual).toBe(expected);
|
|
57
|
+
});
|
|
58
|
+
//
|
|
59
|
+
// minimum + maximum + exclusiveMinimum + exclusiveMaximum
|
|
60
|
+
//
|
|
61
|
+
it("should render minimum", () => {
|
|
62
|
+
const expected = "**Possible values:** `>= 1`";
|
|
63
|
+
const actual = (0, schema_1.getQualifierMessage)({ minimum: 1 });
|
|
64
|
+
expect(actual).toBe(expected);
|
|
65
|
+
});
|
|
66
|
+
it("should render maximum", () => {
|
|
67
|
+
const expected = "**Possible values:** `<= 40`";
|
|
68
|
+
const actual = (0, schema_1.getQualifierMessage)({ maximum: 40 });
|
|
69
|
+
expect(actual).toBe(expected);
|
|
70
|
+
});
|
|
71
|
+
it("should render numeric exclusiveMinimum", () => {
|
|
72
|
+
const expected = "**Possible values:** `> 1`";
|
|
73
|
+
const actual = (0, schema_1.getQualifierMessage)({ exclusiveMinimum: 1 });
|
|
74
|
+
expect(actual).toBe(expected);
|
|
75
|
+
});
|
|
76
|
+
it("should render numeric exclusiveMaximum", () => {
|
|
77
|
+
const expected = "**Possible values:** `< 40`";
|
|
78
|
+
const actual = (0, schema_1.getQualifierMessage)({ exclusiveMaximum: 40 });
|
|
79
|
+
expect(actual).toBe(expected);
|
|
80
|
+
});
|
|
81
|
+
it("should render boolean exclusiveMinimum", () => {
|
|
82
|
+
const expected = "**Possible values:** `> 1`";
|
|
83
|
+
const actual = (0, schema_1.getQualifierMessage)({ minimum: 1, exclusiveMinimum: true });
|
|
84
|
+
expect(actual).toBe(expected);
|
|
85
|
+
});
|
|
86
|
+
it("should render boolean exclusiveMaximum", () => {
|
|
87
|
+
const expected = "**Possible values:** `< 40`";
|
|
88
|
+
const actual = (0, schema_1.getQualifierMessage)({ maximum: 40, exclusiveMaximum: true });
|
|
89
|
+
expect(actual).toBe(expected);
|
|
90
|
+
});
|
|
91
|
+
it("should render minimum when exclusiveMinimum is false", () => {
|
|
92
|
+
const expected = "**Possible values:** `>= 1`";
|
|
93
|
+
const actual = (0, schema_1.getQualifierMessage)({ minimum: 1, exclusiveMinimum: false });
|
|
94
|
+
expect(actual).toBe(expected);
|
|
95
|
+
});
|
|
96
|
+
it("should render maximum when exclusiveMaximum is false", () => {
|
|
97
|
+
const expected = "**Possible values:** `<= 40`";
|
|
98
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
99
|
+
maximum: 40,
|
|
100
|
+
exclusiveMaximum: false,
|
|
101
|
+
});
|
|
102
|
+
expect(actual).toBe(expected);
|
|
103
|
+
});
|
|
104
|
+
it("should render minimum and maximum", () => {
|
|
105
|
+
const expected = "**Possible values:** `>= 1` and `<= 40`";
|
|
106
|
+
const actual = (0, schema_1.getQualifierMessage)({ minimum: 1, maximum: 40 });
|
|
107
|
+
expect(actual).toBe(expected);
|
|
108
|
+
});
|
|
109
|
+
it("should render 0 minimum and maximum", () => {
|
|
110
|
+
const expected = "**Possible values:** `>= 0` and `<= 40`";
|
|
111
|
+
const actual = (0, schema_1.getQualifierMessage)({ minimum: 0, maximum: 40 });
|
|
112
|
+
expect(actual).toBe(expected);
|
|
113
|
+
});
|
|
114
|
+
it("should render minimum and 0 maximum", () => {
|
|
115
|
+
const expected = "**Possible values:** `>= -10` and `<= 0`";
|
|
116
|
+
const actual = (0, schema_1.getQualifierMessage)({ minimum: -10, maximum: 0 });
|
|
117
|
+
expect(actual).toBe(expected);
|
|
118
|
+
});
|
|
119
|
+
it("should render boolean exclusiveMinimum and maximum", () => {
|
|
120
|
+
const expected = "**Possible values:** `> 1` and `<= 40`";
|
|
121
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
122
|
+
minimum: 1,
|
|
123
|
+
maximum: 40,
|
|
124
|
+
exclusiveMinimum: true,
|
|
125
|
+
});
|
|
126
|
+
expect(actual).toBe(expected);
|
|
127
|
+
});
|
|
128
|
+
it("should render minimum and boolean exclusiveMaximum", () => {
|
|
129
|
+
const expected = "**Possible values:** `>= 1` and `< 40`";
|
|
130
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
131
|
+
minimum: 1,
|
|
132
|
+
maximum: 40,
|
|
133
|
+
exclusiveMaximum: true,
|
|
134
|
+
});
|
|
135
|
+
expect(actual).toBe(expected);
|
|
136
|
+
});
|
|
137
|
+
it("should render numeric exclusiveMinimum and maximum", () => {
|
|
138
|
+
const expected = "**Possible values:** `> 1` and `<= 40`";
|
|
139
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
140
|
+
exclusiveMinimum: 1,
|
|
141
|
+
maximum: 40,
|
|
142
|
+
});
|
|
143
|
+
expect(actual).toBe(expected);
|
|
144
|
+
});
|
|
145
|
+
it("should render minimum and numeric exclusiveMaximum", () => {
|
|
146
|
+
const expected = "**Possible values:** `>= 1` and `< 40`";
|
|
147
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
148
|
+
minimum: 1,
|
|
149
|
+
exclusiveMaximum: 40,
|
|
150
|
+
});
|
|
151
|
+
expect(actual).toBe(expected);
|
|
152
|
+
});
|
|
153
|
+
it("should render numeric exclusiveMinimum and boolean exclusiveMaximum", () => {
|
|
154
|
+
const expected = "**Possible values:** `> 1` and `< 40`";
|
|
155
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
156
|
+
exclusiveMinimum: 1,
|
|
157
|
+
maximum: 40,
|
|
158
|
+
exclusiveMaximum: true,
|
|
159
|
+
});
|
|
160
|
+
expect(actual).toBe(expected);
|
|
161
|
+
});
|
|
162
|
+
it("should render nothing with empty boolean exclusiveMinimum", () => {
|
|
163
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
164
|
+
exclusiveMinimum: true,
|
|
165
|
+
});
|
|
166
|
+
expect(actual).toBeUndefined();
|
|
167
|
+
});
|
|
168
|
+
it("should render nothing with empty boolean exclusiveMaximum", () => {
|
|
169
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
170
|
+
exclusiveMaximum: true,
|
|
171
|
+
});
|
|
172
|
+
expect(actual).toBeUndefined();
|
|
173
|
+
});
|
|
174
|
+
it("should render nothing with empty boolean exclusiveMinimum and exclusiveMaximum", () => {
|
|
175
|
+
const actual = (0, schema_1.getQualifierMessage)({
|
|
176
|
+
exclusiveMinimum: true,
|
|
177
|
+
exclusiveMaximum: true,
|
|
178
|
+
});
|
|
179
|
+
expect(actual).toBeUndefined();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Children in the plugin does not accept DOM elements, when compared with Children in the theme.
|
|
3
|
+
* It is designed for rendering HTML a strings.
|
|
4
|
+
*/
|
|
5
|
+
export type Children = string | undefined | (string | string[] | undefined)[];
|
|
6
|
+
export type Props = Record<string, any> & {
|
|
7
|
+
children?: Children;
|
|
8
|
+
};
|
|
9
|
+
export type Options = {
|
|
10
|
+
inline?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function create(tag: string, props: Props, options?: Options): string;
|
|
13
|
+
export declare function guard<T>(value: T | undefined, cb: (value: T) => Children): string;
|
|
14
|
+
export declare function render(children: Children): string;
|
|
15
|
+
export declare const lessThan: RegExp;
|
|
16
|
+
export declare const greaterThan: RegExp;
|
|
17
|
+
export declare const codeFence: RegExp;
|
|
18
|
+
export declare const curlyBrackets: RegExp;
|
|
19
|
+
export declare const codeBlock: RegExp;
|
|
20
|
+
export declare function clean(value: string | undefined): string;
|