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,226 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.default = generateSidebarSlice;
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const utils_1 = require("@docusaurus/utils");
|
|
15
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
16
|
+
const lodash_1 = require("lodash");
|
|
17
|
+
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
18
|
+
function isApiItem(item) {
|
|
19
|
+
return item.type === "api";
|
|
20
|
+
}
|
|
21
|
+
function isInfoItem(item) {
|
|
22
|
+
return item.type === "info";
|
|
23
|
+
}
|
|
24
|
+
function isSchemaItem(item) {
|
|
25
|
+
return item.type === "schema";
|
|
26
|
+
}
|
|
27
|
+
const createDocItem = (item, { sidebarOptions: { customProps }, basePath }) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
const sidebar_label = item.frontMatter.sidebar_label;
|
|
30
|
+
const title = item.title;
|
|
31
|
+
const id = item.type === "schema" ? `schemas/${item.id}` : item.id;
|
|
32
|
+
const className = item.type === "api"
|
|
33
|
+
? (0, clsx_1.default)({
|
|
34
|
+
"menu__list-item--deprecated": item.api.deprecated,
|
|
35
|
+
"api-method": !!item.api.method,
|
|
36
|
+
}, item.api.method)
|
|
37
|
+
: (0, clsx_1.default)({
|
|
38
|
+
"menu__list-item--deprecated": item.schema.deprecated,
|
|
39
|
+
}, "schema");
|
|
40
|
+
return {
|
|
41
|
+
type: "doc",
|
|
42
|
+
id: basePath === "" || undefined ? `${id}` : `${basePath}/${id}`,
|
|
43
|
+
label: (_b = (_a = sidebar_label) !== null && _a !== void 0 ? _a : title) !== null && _b !== void 0 ? _b : id,
|
|
44
|
+
customProps: customProps,
|
|
45
|
+
className: className ? className : undefined,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
let { outputDir, label, showSchemas } = options;
|
|
51
|
+
// Remove trailing slash before proceeding
|
|
52
|
+
outputDir = outputDir.replace(/\/$/, "");
|
|
53
|
+
const { sidebarCollapsed, sidebarCollapsible, categoryLinkSource } = sidebarOptions;
|
|
54
|
+
const apiItems = items.filter(isApiItem);
|
|
55
|
+
const infoItems = items.filter(isInfoItem);
|
|
56
|
+
const schemaItems = items.filter(isSchemaItem);
|
|
57
|
+
const intros = infoItems.map((item) => {
|
|
58
|
+
return {
|
|
59
|
+
id: item.id,
|
|
60
|
+
title: item.title,
|
|
61
|
+
description: item.description,
|
|
62
|
+
tags: item.info.tags,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
// TODO: make sure we only take the first tag
|
|
66
|
+
const operationTags = (0, uniq_1.default)(apiItems
|
|
67
|
+
.flatMap((item) => item.api.tags)
|
|
68
|
+
.filter((item) => !!item));
|
|
69
|
+
const schemaTags = (0, uniq_1.default)(schemaItems
|
|
70
|
+
.flatMap((item) => item.schema["x-tags"])
|
|
71
|
+
.filter((item) => !!item));
|
|
72
|
+
// Combine globally defined tags with operation and schema tags
|
|
73
|
+
// Only include global tag if referenced in operation/schema tags
|
|
74
|
+
let apiTags = [];
|
|
75
|
+
tags.flat().forEach((tag) => {
|
|
76
|
+
// Should we also check x-displayName?
|
|
77
|
+
if (operationTags.includes(tag.name) || schemaTags.includes(tag.name)) {
|
|
78
|
+
apiTags.push(tag.name);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
if (sidebarOptions.groupPathsBy !== "tagGroup") {
|
|
82
|
+
apiTags = (0, uniq_1.default)(apiTags.concat(operationTags, schemaTags));
|
|
83
|
+
}
|
|
84
|
+
const basePath = docPath
|
|
85
|
+
? outputDir.split(docPath)[1].replace(/^\/+/g, "")
|
|
86
|
+
: outputDir.slice(outputDir.indexOf("/", 1)).replace(/^\/+/g, "");
|
|
87
|
+
const createDocItemFnContext = {
|
|
88
|
+
sidebarOptions,
|
|
89
|
+
basePath,
|
|
90
|
+
};
|
|
91
|
+
const createDocItemFn = (_b = (_a = sidebarOptions.sidebarGenerators) === null || _a === void 0 ? void 0 : _a.createDocItem) !== null && _b !== void 0 ? _b : createDocItem;
|
|
92
|
+
let rootIntroDoc = undefined;
|
|
93
|
+
if (infoItems.length === 1) {
|
|
94
|
+
const infoItem = infoItems[0];
|
|
95
|
+
const id = infoItem.id;
|
|
96
|
+
rootIntroDoc = {
|
|
97
|
+
type: "doc",
|
|
98
|
+
id: basePath === "" || undefined ? `${id}` : `${basePath}/${id}`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const tagged = apiTags
|
|
102
|
+
.map((tag) => {
|
|
103
|
+
var _a;
|
|
104
|
+
// Map info object to tag
|
|
105
|
+
const taggedInfoObject = intros.find((i) => i.tags ? i.tags.find((t) => t.name === tag) : undefined);
|
|
106
|
+
const tagObject = tags.flat().find((t) => tag === t.name && {
|
|
107
|
+
name: tag,
|
|
108
|
+
description: `${tag} Index`,
|
|
109
|
+
});
|
|
110
|
+
// TODO: perhaps move this into a getLinkConfig() function
|
|
111
|
+
// Default to no link config (spindowns only)
|
|
112
|
+
let linkConfig = undefined;
|
|
113
|
+
if (taggedInfoObject !== undefined && categoryLinkSource === "info") {
|
|
114
|
+
linkConfig = {
|
|
115
|
+
type: "doc",
|
|
116
|
+
id: basePath === "" || undefined
|
|
117
|
+
? `${taggedInfoObject.id}`
|
|
118
|
+
: `${basePath}/${taggedInfoObject.id}`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// TODO: perhaps move this into a getLinkConfig() function
|
|
122
|
+
if (tagObject !== undefined && categoryLinkSource === "tag") {
|
|
123
|
+
const tagId = (0, lodash_1.kebabCase)(tagObject.name);
|
|
124
|
+
linkConfig = {
|
|
125
|
+
type: "doc",
|
|
126
|
+
id: basePath === "" || undefined ? `${tagId}` : `${basePath}/${tagId}`,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (categoryLinkSource === "auto") {
|
|
130
|
+
linkConfig = {
|
|
131
|
+
type: "generated-index",
|
|
132
|
+
title: tag,
|
|
133
|
+
slug: label
|
|
134
|
+
? (0, utils_1.posixPath)(path_1.default.join("/category", basePath, (0, lodash_1.kebabCase)(label), (0, lodash_1.kebabCase)(tag)))
|
|
135
|
+
: (0, utils_1.posixPath)(path_1.default.join("/category", basePath, (0, lodash_1.kebabCase)(tag))),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const taggedApiItems = apiItems.filter((item) => { var _a; return !!((_a = item.api.tags) === null || _a === void 0 ? void 0 : _a.includes(tag)); });
|
|
139
|
+
const taggedSchemaItems = schemaItems.filter((item) => { var _a; return !!((_a = item.schema["x-tags"]) === null || _a === void 0 ? void 0 : _a.includes(tag)); });
|
|
140
|
+
return {
|
|
141
|
+
type: "category",
|
|
142
|
+
label: (_a = tagObject === null || tagObject === void 0 ? void 0 : tagObject["x-displayName"]) !== null && _a !== void 0 ? _a : tag,
|
|
143
|
+
link: linkConfig,
|
|
144
|
+
collapsible: sidebarCollapsible,
|
|
145
|
+
collapsed: sidebarCollapsed,
|
|
146
|
+
items: [...taggedSchemaItems, ...taggedApiItems].map((item) => createDocItemFn(item, createDocItemFnContext)),
|
|
147
|
+
};
|
|
148
|
+
})
|
|
149
|
+
.filter((item) => item.items.length > 0); // Filter out any categories with no items.
|
|
150
|
+
// Handle items with no tag
|
|
151
|
+
const untaggedItems = apiItems
|
|
152
|
+
.filter(({ api }) => api.tags === undefined || api.tags.length === 0)
|
|
153
|
+
.map((item) => createDocItemFn(item, createDocItemFnContext));
|
|
154
|
+
let untagged = [];
|
|
155
|
+
if (untaggedItems.length > 0) {
|
|
156
|
+
untagged = [
|
|
157
|
+
{
|
|
158
|
+
type: "category",
|
|
159
|
+
label: "UNTAGGED",
|
|
160
|
+
collapsible: sidebarCollapsible,
|
|
161
|
+
collapsed: sidebarCollapsed,
|
|
162
|
+
items: apiItems
|
|
163
|
+
.filter(({ api }) => api.tags === undefined || api.tags.length === 0)
|
|
164
|
+
.map((item) => createDocItemFn(item, createDocItemFnContext)),
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
let schemas = [];
|
|
169
|
+
if (showSchemas && schemaItems.length > 0) {
|
|
170
|
+
schemas = [
|
|
171
|
+
{
|
|
172
|
+
type: "category",
|
|
173
|
+
label: "Schemas",
|
|
174
|
+
collapsible: sidebarCollapsible,
|
|
175
|
+
collapsed: sidebarCollapsed,
|
|
176
|
+
items: schemaItems
|
|
177
|
+
.filter(({ schema }) => !schema["x-tags"])
|
|
178
|
+
.map((item) => createDocItemFn(item, createDocItemFnContext)),
|
|
179
|
+
},
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
// Shift root intro doc to top of sidebar
|
|
183
|
+
// TODO: Add input validation for categoryLinkSource options
|
|
184
|
+
if (rootIntroDoc && categoryLinkSource !== "info") {
|
|
185
|
+
tagged.unshift(rootIntroDoc);
|
|
186
|
+
}
|
|
187
|
+
return [...tagged, ...untagged, ...schemas];
|
|
188
|
+
}
|
|
189
|
+
function generateSidebarSlice(sidebarOptions, options, api, tags, docPath, tagGroups) {
|
|
190
|
+
let sidebarSlice = [];
|
|
191
|
+
if (sidebarOptions.groupPathsBy === "tagGroup") {
|
|
192
|
+
let schemasGroup = [];
|
|
193
|
+
tagGroups === null || tagGroups === void 0 ? void 0 : tagGroups.forEach((tagGroup) => {
|
|
194
|
+
var _a;
|
|
195
|
+
//filter tags only included in group
|
|
196
|
+
const filteredTags = [];
|
|
197
|
+
tags[0].forEach((tag) => {
|
|
198
|
+
if (tagGroup.tags.includes(tag.name)) {
|
|
199
|
+
filteredTags.push(tag);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
const groupCategory = {
|
|
203
|
+
type: "category",
|
|
204
|
+
label: tagGroup.name,
|
|
205
|
+
collapsible: true,
|
|
206
|
+
collapsed: true,
|
|
207
|
+
items: groupByTags(api, sidebarOptions, options, [filteredTags], docPath),
|
|
208
|
+
};
|
|
209
|
+
if (options.showSchemas) {
|
|
210
|
+
// For the first tagGroup, save the generated "Schemas" category for later.
|
|
211
|
+
if (schemasGroup.length === 0) {
|
|
212
|
+
schemasGroup = (_a = groupCategory.items) === null || _a === void 0 ? void 0 : _a.filter((item) => item.type === "category" && item.label === "Schemas");
|
|
213
|
+
}
|
|
214
|
+
// Remove the "Schemas" category from every `groupCategory`.
|
|
215
|
+
groupCategory.items = groupCategory.items.filter((item) => "label" in item ? item.label !== "Schemas" : true);
|
|
216
|
+
}
|
|
217
|
+
sidebarSlice.push(groupCategory);
|
|
218
|
+
});
|
|
219
|
+
// Add `schemasGroup` to the end of the sidebar.
|
|
220
|
+
sidebarSlice.push(...schemasGroup);
|
|
221
|
+
}
|
|
222
|
+
else if (sidebarOptions.groupPathsBy === "tag") {
|
|
223
|
+
sidebarSlice = groupByTags(api, sidebarOptions, options, tags, docPath);
|
|
224
|
+
}
|
|
225
|
+
return sidebarSlice;
|
|
226
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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.versionSelector = versionSelector;
|
|
10
|
+
exports.versionCrumb = versionCrumb;
|
|
11
|
+
const mustache_1 = require("mustache");
|
|
12
|
+
function versionSelector(versions) {
|
|
13
|
+
const template = `<div class="dropdown dropdown--hoverable dropdown--right">
|
|
14
|
+
<button class="button button--block button--sm button--secondary"><span>Select API Version</span></button>
|
|
15
|
+
<ul class="dropdown__menu">
|
|
16
|
+
{{#.}}<li><a class="dropdown__link" href="{{{baseUrl}}}">{{{label}}}</a></li>{{/.}}
|
|
17
|
+
</ul>
|
|
18
|
+
</div>
|
|
19
|
+
`;
|
|
20
|
+
const view = (0, mustache_1.render)(template, versions);
|
|
21
|
+
return view;
|
|
22
|
+
}
|
|
23
|
+
function versionCrumb(version) {
|
|
24
|
+
const template = `<ul style="display: flex;" class="breadcrumbs breadcrumbs--sm">
|
|
25
|
+
<li style="margin-left: auto; margin-right: 0;" class="breadcrumbs__item breadcrumbs__item--active">
|
|
26
|
+
<a class="breadcrumbs__link"><span>{{{.}}}</span></a></li></ul>
|
|
27
|
+
`;
|
|
28
|
+
const view = (0, mustache_1.render)(template, version);
|
|
29
|
+
return view;
|
|
30
|
+
}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { SidebarItemDoc } from "@docusaurus/plugin-content-docs/src/sidebars/types";
|
|
2
|
+
import type Request from "postman-collection";
|
|
3
|
+
import { InfoObject, OperationObject, SchemaObject, SecuritySchemeObject, TagObject } from "./openapi/types";
|
|
4
|
+
export type { PropSidebarItemCategory, SidebarItemLink, PropSidebar, PropSidebarItem, } from "@docusaurus/plugin-content-docs-types";
|
|
5
|
+
export interface PluginOptions {
|
|
6
|
+
id?: string;
|
|
7
|
+
docsPlugin?: string;
|
|
8
|
+
docsPluginId: string;
|
|
9
|
+
config: {
|
|
10
|
+
[key: string]: APIOptions;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface APIOptions {
|
|
14
|
+
specPath: string;
|
|
15
|
+
outputDir: string;
|
|
16
|
+
template?: string;
|
|
17
|
+
infoTemplate?: string;
|
|
18
|
+
tagTemplate?: string;
|
|
19
|
+
schemaTemplate?: string;
|
|
20
|
+
downloadUrl?: string;
|
|
21
|
+
hideSendButton?: boolean;
|
|
22
|
+
showExtensions?: boolean;
|
|
23
|
+
sidebarOptions?: SidebarOptions;
|
|
24
|
+
version?: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
versions?: {
|
|
28
|
+
[key: string]: APIVersionOptions;
|
|
29
|
+
};
|
|
30
|
+
proxy?: string;
|
|
31
|
+
markdownGenerators?: MarkdownGenerator;
|
|
32
|
+
showSchemas?: boolean;
|
|
33
|
+
disableCompression?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface MarkdownGenerator {
|
|
36
|
+
createApiPageMD?: (pageData: ApiPageMetadata) => string;
|
|
37
|
+
createInfoPageMD?: (pageData: InfoPageMetadata) => string;
|
|
38
|
+
createTagPageMD?: (pageData: TagPageMetadata) => string;
|
|
39
|
+
createSchemaPageMD?: (pageData: SchemaPageMetadata) => string;
|
|
40
|
+
}
|
|
41
|
+
export type ApiDocItemGenerator = (item: ApiPageMetadata | SchemaPageMetadata, context: {
|
|
42
|
+
sidebarOptions: SidebarOptions;
|
|
43
|
+
basePath: string;
|
|
44
|
+
}) => SidebarItemDoc;
|
|
45
|
+
export interface SidebarGenerators {
|
|
46
|
+
createDocItem?: ApiDocItemGenerator;
|
|
47
|
+
}
|
|
48
|
+
export interface SidebarOptions {
|
|
49
|
+
groupPathsBy?: string;
|
|
50
|
+
categoryLinkSource?: "info" | "tag" | "auto";
|
|
51
|
+
customProps?: {
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
};
|
|
54
|
+
sidebarCollapsible?: boolean;
|
|
55
|
+
sidebarCollapsed?: boolean;
|
|
56
|
+
sidebarGenerators?: SidebarGenerators;
|
|
57
|
+
}
|
|
58
|
+
export interface APIVersionOptions {
|
|
59
|
+
specPath: string;
|
|
60
|
+
outputDir: string;
|
|
61
|
+
label: string;
|
|
62
|
+
baseUrl: string;
|
|
63
|
+
downloadUrl?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface LoadedContent {
|
|
66
|
+
loadedApi: ApiMetadata[];
|
|
67
|
+
}
|
|
68
|
+
export type ApiMetadata = ApiPageMetadata | InfoPageMetadata | TagPageMetadata | SchemaPageMetadata;
|
|
69
|
+
export interface ApiMetadataBase {
|
|
70
|
+
sidebar?: string;
|
|
71
|
+
previous?: ApiNavLink;
|
|
72
|
+
next?: ApiNavLink;
|
|
73
|
+
id: string;
|
|
74
|
+
unversionedId: string;
|
|
75
|
+
infoId?: string;
|
|
76
|
+
infoPath?: string;
|
|
77
|
+
downloadUrl?: string;
|
|
78
|
+
title: string;
|
|
79
|
+
description: string;
|
|
80
|
+
source: string;
|
|
81
|
+
sourceDirName: string;
|
|
82
|
+
slug?: string;
|
|
83
|
+
permalink: string;
|
|
84
|
+
sidebarPosition?: number;
|
|
85
|
+
frontMatter: Record<string, unknown>;
|
|
86
|
+
method?: string;
|
|
87
|
+
path?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface ApiPageMetadata extends ApiMetadataBase {
|
|
90
|
+
json?: string;
|
|
91
|
+
type: "api";
|
|
92
|
+
api: ApiItem;
|
|
93
|
+
markdown?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface ApiItem extends OperationObject {
|
|
96
|
+
method: string;
|
|
97
|
+
path: string;
|
|
98
|
+
jsonRequestBodyExample: string;
|
|
99
|
+
securitySchemes?: {
|
|
100
|
+
[key: string]: SecuritySchemeObject;
|
|
101
|
+
};
|
|
102
|
+
postman?: Request;
|
|
103
|
+
proxy?: string;
|
|
104
|
+
info: InfoObject;
|
|
105
|
+
extensions?: object;
|
|
106
|
+
}
|
|
107
|
+
export interface InfoPageMetadata extends ApiMetadataBase {
|
|
108
|
+
type: "info";
|
|
109
|
+
info: ApiInfo;
|
|
110
|
+
markdown?: string;
|
|
111
|
+
securitySchemes?: {
|
|
112
|
+
[key: string]: SecuritySchemeObject;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export interface TagPageMetadata extends ApiMetadataBase {
|
|
116
|
+
type: "tag";
|
|
117
|
+
tag: TagObject;
|
|
118
|
+
markdown?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface SchemaPageMetadata extends ApiMetadataBase {
|
|
121
|
+
type: "schema";
|
|
122
|
+
schema: SchemaObject;
|
|
123
|
+
markdown?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface TagGroupPageMetadata extends ApiMetadataBase {
|
|
126
|
+
type: "tagGroup";
|
|
127
|
+
name: string;
|
|
128
|
+
tags: TagObject[];
|
|
129
|
+
markdown?: string;
|
|
130
|
+
}
|
|
131
|
+
export type ApiInfo = InfoObject;
|
|
132
|
+
export interface ApiNavLink {
|
|
133
|
+
title: string;
|
|
134
|
+
permalink: string;
|
|
135
|
+
}
|
package/lib/types.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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 });
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "docusaurus-plugin-openapi-docs",
|
|
3
|
+
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
+
"version": "0.0.0-1000",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"openapi",
|
|
8
|
+
"documentation",
|
|
9
|
+
"docusaurus",
|
|
10
|
+
"websites",
|
|
11
|
+
"plugin"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs.git",
|
|
19
|
+
"directory": "packages/docusaurus-plugin-openapi-docs"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues"
|
|
23
|
+
},
|
|
24
|
+
"main": "lib/index.js",
|
|
25
|
+
"types": "src/plugin-openapi.d.ts",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"watch": "tsc --watch"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@docusaurus/plugin-content-docs": "^3.5.0",
|
|
32
|
+
"@docusaurus/types": "^3.5.0",
|
|
33
|
+
"@docusaurus/utils": "^3.5.0",
|
|
34
|
+
"@docusaurus/utils-validation": "^3.5.0",
|
|
35
|
+
"@types/fs-extra": "^9.0.13",
|
|
36
|
+
"@types/json-pointer": "^1.0.31",
|
|
37
|
+
"@types/json-schema": "^7.0.9",
|
|
38
|
+
"@types/lodash": "^4.14.176",
|
|
39
|
+
"@types/mustache": "^4.1.2",
|
|
40
|
+
"eslint-plugin-prettier": "^5.0.1"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@apidevtools/json-schema-ref-parser": "^11.5.4",
|
|
44
|
+
"@redocly/openapi-core": "^1.10.5",
|
|
45
|
+
"allof-merge": "^0.6.6",
|
|
46
|
+
"chalk": "^4.1.2",
|
|
47
|
+
"clsx": "^1.1.1",
|
|
48
|
+
"fs-extra": "^9.0.1",
|
|
49
|
+
"json-pointer": "^0.6.2",
|
|
50
|
+
"json5": "^2.2.3",
|
|
51
|
+
"lodash": "^4.17.20",
|
|
52
|
+
"mustache": "^4.2.0",
|
|
53
|
+
"openapi-to-postmanv2": "^4.21.0",
|
|
54
|
+
"postman-collection": "^4.4.0",
|
|
55
|
+
"slugify": "^1.6.5",
|
|
56
|
+
"swagger2openapi": "^7.0.8",
|
|
57
|
+
"xml-formatter": "^2.6.1"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@docusaurus/plugin-content-docs": "^3.5.0",
|
|
61
|
+
"@docusaurus/utils": "^3.5.0",
|
|
62
|
+
"@docusaurus/utils-validation": "^3.5.0",
|
|
63
|
+
"react": "^16.8.4 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=14"
|
|
67
|
+
},
|
|
68
|
+
"gitHead": "abdd081aa1d8100eaed69342192f8d84fec853f7"
|
|
69
|
+
}
|