docusaurus-plugin-openapi-docs 1.0.0
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 +194 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +194 -0
- package/lib/markdown/createDeprecationNotice.d.ts +6 -0
- package/lib/markdown/createDeprecationNotice.js +19 -0
- package/lib/markdown/createDescription.d.ts +1 -0
- package/lib/markdown/createDescription.js +16 -0
- package/lib/markdown/createDetails.d.ts +2 -0
- package/lib/markdown/createDetails.js +18 -0
- package/lib/markdown/createDetailsSummary.d.ts +2 -0
- package/lib/markdown/createDetailsSummary.js +18 -0
- package/lib/markdown/createFullWidthTable.d.ts +2 -0
- package/lib/markdown/createFullWidthTable.js +18 -0
- package/lib/markdown/createParamsDetails.d.ts +7 -0
- package/lib/markdown/createParamsDetails.js +44 -0
- package/lib/markdown/createParamsTable.d.ts +7 -0
- package/lib/markdown/createParamsTable.js +80 -0
- package/lib/markdown/createRequestBodyDetails.d.ts +6 -0
- package/lib/markdown/createRequestBodyDetails.js +14 -0
- package/lib/markdown/createRequestBodyTable.d.ts +6 -0
- package/lib/markdown/createRequestBodyTable.js +14 -0
- package/lib/markdown/createSchemaDetails.d.ts +14 -0
- package/lib/markdown/createSchemaDetails.js +241 -0
- package/lib/markdown/createSchemaTable.d.ts +14 -0
- package/lib/markdown/createSchemaTable.js +217 -0
- package/lib/markdown/createStatusCodes.d.ts +6 -0
- package/lib/markdown/createStatusCodes.js +47 -0
- package/lib/markdown/createVersionBadge.d.ts +1 -0
- package/lib/markdown/createVersionBadge.js +20 -0
- package/lib/markdown/index.d.ts +3 -0
- package/lib/markdown/index.js +43 -0
- package/lib/markdown/schema.d.ts +3 -0
- package/lib/markdown/schema.js +100 -0
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +171 -0
- package/lib/markdown/utils.d.ts +7 -0
- package/lib/markdown/utils.js +33 -0
- package/lib/openapi/createExample.d.ts +2 -0
- package/lib/openapi/createExample.js +113 -0
- package/lib/openapi/index.d.ts +1 -0
- package/lib/openapi/index.js +12 -0
- package/lib/openapi/openapi.d.ts +11 -0
- package/lib/openapi/openapi.js +233 -0
- package/lib/openapi/openapi.test.d.ts +1 -0
- package/lib/openapi/openapi.test.js +33 -0
- package/lib/openapi/types.d.ts +331 -0
- package/lib/openapi/types.js +8 -0
- package/lib/options.d.ts +4 -0
- package/lib/options.js +18 -0
- package/lib/sidebars/index.d.ts +3 -0
- package/lib/sidebars/index.js +89 -0
- package/lib/types.d.ts +68 -0
- package/lib/types.js +8 -0
- package/package.json +58 -0
- package/src/index.ts +244 -0
- package/src/markdown/createDeprecationNotice.ts +30 -0
- package/src/markdown/createDescription.ts +13 -0
- package/src/markdown/createDetails.ts +16 -0
- package/src/markdown/createDetailsSummary.ts +16 -0
- package/src/markdown/createFullWidthTable.ts +16 -0
- package/src/markdown/createParamsDetails.ts +53 -0
- package/src/markdown/createParamsTable.ts +102 -0
- package/src/markdown/createRequestBodyDetails.ts +17 -0
- package/src/markdown/createRequestBodyTable.ts +17 -0
- package/src/markdown/createSchemaDetails.ts +302 -0
- package/src/markdown/createSchemaTable.ts +275 -0
- package/src/markdown/createStatusCodes.ts +52 -0
- package/src/markdown/createVersionBadge.ts +18 -0
- package/src/markdown/index.ts +55 -0
- package/src/markdown/schema.test.ts +196 -0
- package/src/markdown/schema.ts +115 -0
- package/src/markdown/utils.ts +39 -0
- package/src/openapi/__fixtures__/examples/openapi.yaml +13 -0
- package/src/openapi/__fixtures__/examples/yogurtstore/_category_.json +4 -0
- package/src/openapi/__fixtures__/examples/yogurtstore/froyo.yaml +13 -0
- package/src/openapi/__fixtures__/examples/yogurtstore/nested/nested.yaml +13 -0
- package/src/openapi/createExample.ts +143 -0
- package/src/openapi/index.ts +8 -0
- package/src/openapi/openapi.test.ts +37 -0
- package/src/openapi/openapi.ts +293 -0
- package/src/openapi/types.ts +430 -0
- package/src/openapi-to-postmanv2.d.ts +10 -0
- package/src/options.ts +20 -0
- package/src/plugin-content-docs-types.d.ts +42 -0
- package/src/plugin-openapi.d.ts +87 -0
- package/src/sidebars/index.ts +121 -0
- package/src/types.ts +97 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,233 @@
|
|
|
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.processOpenapiFile = exports.processOpenapiFiles = exports.readOpenapiFiles = void 0;
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const utils_1 = require("@docusaurus/utils");
|
|
15
|
+
const openapi_to_postmanv2_1 = __importDefault(require("@paloaltonetworks/openapi-to-postmanv2"));
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const postman_collection_1 = __importDefault(require("@paloaltonetworks/postman-collection"));
|
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
20
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
21
|
+
const json_refs_1 = __importDefault(require("json-refs"));
|
|
22
|
+
const lodash_1 = require("lodash");
|
|
23
|
+
const createExample_1 = require("./createExample");
|
|
24
|
+
/**
|
|
25
|
+
* Finds any reference objects in the OpenAPI definition and resolves them to a finalized value.
|
|
26
|
+
*/
|
|
27
|
+
async function resolveRefs(openapiData) {
|
|
28
|
+
const { resolved } = await json_refs_1.default.resolveRefs(openapiData);
|
|
29
|
+
return resolved;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Convenience function for converting raw JSON to a Postman Collection object.
|
|
33
|
+
*/
|
|
34
|
+
function jsonToCollection(data) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
let schemaPack = new openapi_to_postmanv2_1.default.SchemaPack({ type: "json", data }, { schemaFaker: false });
|
|
37
|
+
schemaPack.computedOptions.schemaFaker = false;
|
|
38
|
+
schemaPack.convert((_err, conversionResult) => {
|
|
39
|
+
if (!conversionResult.result) {
|
|
40
|
+
return reject(conversionResult.reason);
|
|
41
|
+
}
|
|
42
|
+
return resolve(new postman_collection_1.default.Collection(conversionResult.output[0].data));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a Postman Collection object from an OpenAPI definition.
|
|
48
|
+
*/
|
|
49
|
+
async function createPostmanCollection(openapiData) {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
51
|
+
const data = JSON.parse(JSON.stringify(openapiData));
|
|
52
|
+
// Including `servers` breaks postman, so delete all of them.
|
|
53
|
+
delete data.servers;
|
|
54
|
+
for (let pathItemObject of Object.values(data.paths)) {
|
|
55
|
+
delete pathItemObject.servers;
|
|
56
|
+
(_a = pathItemObject.get) === null || _a === void 0 ? true : delete _a.servers;
|
|
57
|
+
(_b = pathItemObject.put) === null || _b === void 0 ? true : delete _b.servers;
|
|
58
|
+
(_c = pathItemObject.post) === null || _c === void 0 ? true : delete _c.servers;
|
|
59
|
+
(_d = pathItemObject.delete) === null || _d === void 0 ? true : delete _d.servers;
|
|
60
|
+
(_e = pathItemObject.options) === null || _e === void 0 ? true : delete _e.servers;
|
|
61
|
+
(_f = pathItemObject.head) === null || _f === void 0 ? true : delete _f.servers;
|
|
62
|
+
(_g = pathItemObject.patch) === null || _g === void 0 ? true : delete _g.servers;
|
|
63
|
+
(_h = pathItemObject.trace) === null || _h === void 0 ? true : delete _h.servers;
|
|
64
|
+
}
|
|
65
|
+
return await jsonToCollection(data);
|
|
66
|
+
}
|
|
67
|
+
function createItems(openapiData) {
|
|
68
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
69
|
+
// TODO: Find a better way to handle this
|
|
70
|
+
let items = [];
|
|
71
|
+
// Only create an info page if we have a description.
|
|
72
|
+
if (openapiData.info.description) {
|
|
73
|
+
const infoPage = {
|
|
74
|
+
type: "info",
|
|
75
|
+
id: "introduction",
|
|
76
|
+
unversionedId: "introduction",
|
|
77
|
+
title: "Introduction",
|
|
78
|
+
description: openapiData.info.description,
|
|
79
|
+
slug: "/introduction",
|
|
80
|
+
frontMatter: {},
|
|
81
|
+
info: {
|
|
82
|
+
...openapiData.info,
|
|
83
|
+
title: (_a = openapiData.info.title) !== null && _a !== void 0 ? _a : "Introduction",
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
items.push(infoPage);
|
|
87
|
+
}
|
|
88
|
+
for (let [path, pathObject] of Object.entries(openapiData.paths)) {
|
|
89
|
+
const { $ref, description, parameters, servers, summary, ...rest } = pathObject;
|
|
90
|
+
for (let [method, operationObject] of Object.entries({ ...rest })) {
|
|
91
|
+
const title = (_c = (_b = operationObject.summary) !== null && _b !== void 0 ? _b : operationObject.operationId) !== null && _c !== void 0 ? _c : "Missing summary";
|
|
92
|
+
if (operationObject.description === undefined) {
|
|
93
|
+
operationObject.description =
|
|
94
|
+
(_e = (_d = operationObject.summary) !== null && _d !== void 0 ? _d : operationObject.operationId) !== null && _e !== void 0 ? _e : "";
|
|
95
|
+
}
|
|
96
|
+
const baseId = (0, lodash_1.kebabCase)(title);
|
|
97
|
+
const servers = (_g = (_f = operationObject.servers) !== null && _f !== void 0 ? _f : pathObject.servers) !== null && _g !== void 0 ? _g : openapiData.servers;
|
|
98
|
+
const security = (_h = operationObject.security) !== null && _h !== void 0 ? _h : openapiData.security;
|
|
99
|
+
// Add security schemes so we know how to handle security.
|
|
100
|
+
const securitySchemes = (_j = openapiData.components) === null || _j === void 0 ? void 0 : _j.securitySchemes;
|
|
101
|
+
// Make sure schemes are lowercase. See: https://github.com/cloud-annotations/docusaurus-plugin-openapi/issues/79
|
|
102
|
+
if (securitySchemes) {
|
|
103
|
+
for (let securityScheme of Object.values(securitySchemes)) {
|
|
104
|
+
if (securityScheme.type === "http") {
|
|
105
|
+
securityScheme.scheme = securityScheme.scheme.toLowerCase();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
let jsonRequestBodyExample;
|
|
110
|
+
const body = (_l = (_k = operationObject.requestBody) === null || _k === void 0 ? void 0 : _k.content) === null || _l === void 0 ? void 0 : _l["application/json"];
|
|
111
|
+
if (body === null || body === void 0 ? void 0 : body.schema) {
|
|
112
|
+
jsonRequestBodyExample = (0, createExample_1.sampleFromSchema)(body.schema);
|
|
113
|
+
}
|
|
114
|
+
// TODO: Don't include summary temporarilly
|
|
115
|
+
const { summary, ...defaults } = operationObject;
|
|
116
|
+
const apiPage = {
|
|
117
|
+
type: "api",
|
|
118
|
+
id: baseId,
|
|
119
|
+
unversionedId: baseId,
|
|
120
|
+
title: title,
|
|
121
|
+
description: description !== null && description !== void 0 ? description : "",
|
|
122
|
+
slug: "/" + baseId,
|
|
123
|
+
frontMatter: {},
|
|
124
|
+
api: {
|
|
125
|
+
...defaults,
|
|
126
|
+
tags: (_m = operationObject.tags) === null || _m === void 0 ? void 0 : _m.map((tagName) => { var _a; return getTagDisplayName(tagName, (_a = openapiData.tags) !== null && _a !== void 0 ? _a : []); }),
|
|
127
|
+
method,
|
|
128
|
+
path,
|
|
129
|
+
servers,
|
|
130
|
+
security,
|
|
131
|
+
securitySchemes,
|
|
132
|
+
jsonRequestBodyExample,
|
|
133
|
+
info: openapiData.info,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
items.push(apiPage);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return items;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Attach Postman Request objects to the corresponding ApiItems.
|
|
143
|
+
*/
|
|
144
|
+
function bindCollectionToApiItems(items, postmanCollection) {
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
postmanCollection.forEachItem((item) => {
|
|
147
|
+
const method = item.request.method.toLowerCase();
|
|
148
|
+
const path = item.request.url
|
|
149
|
+
.getPath({ unresolved: true }) // unresolved returns "/:variableName" instead of "/<type>"
|
|
150
|
+
.replace(/:([a-z0-9-_]+)/gi, "{$1}"); // replace "/:variableName" with "/{variableName}"
|
|
151
|
+
const apiItem = items.find((item) => {
|
|
152
|
+
if (item.type === "info") {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
return item.api.path === path && item.api.method === method;
|
|
156
|
+
});
|
|
157
|
+
if ((apiItem === null || apiItem === void 0 ? void 0 : apiItem.type) === "api") {
|
|
158
|
+
apiItem.api.postman = item.request;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async function readOpenapiFiles(openapiPath, _options) {
|
|
163
|
+
const stat = await fs_extra_1.default.lstat(openapiPath);
|
|
164
|
+
if (stat.isDirectory()) {
|
|
165
|
+
console.warn(chalk_1.default.yellow("WARNING: Loading a directory of OpenAPI definitions is experimental and subject to unannounced breaking changes."));
|
|
166
|
+
// TODO: Add config for inlcude/ignore
|
|
167
|
+
const allFiles = await (0, utils_1.Globby)(["**/*.{json,yaml,yml}"], {
|
|
168
|
+
cwd: openapiPath,
|
|
169
|
+
ignore: utils_1.GlobExcludeDefault,
|
|
170
|
+
});
|
|
171
|
+
const sources = allFiles.filter((x) => !x.includes("_category_")); // todo: regex exclude?
|
|
172
|
+
return Promise.all(sources.map(async (source) => {
|
|
173
|
+
// TODO: make a function for this
|
|
174
|
+
const fullPath = path_1.default.join(openapiPath, source);
|
|
175
|
+
const openapiString = await fs_extra_1.default.readFile(fullPath, "utf-8");
|
|
176
|
+
const data = js_yaml_1.default.load(openapiString);
|
|
177
|
+
return {
|
|
178
|
+
source: fullPath,
|
|
179
|
+
sourceDirName: path_1.default.dirname(source),
|
|
180
|
+
data,
|
|
181
|
+
};
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
const openapiString = await fs_extra_1.default.readFile(openapiPath, "utf-8");
|
|
185
|
+
const data = js_yaml_1.default.load(openapiString);
|
|
186
|
+
return [
|
|
187
|
+
{
|
|
188
|
+
source: openapiPath,
|
|
189
|
+
sourceDirName: ".",
|
|
190
|
+
data,
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
exports.readOpenapiFiles = readOpenapiFiles;
|
|
195
|
+
async function processOpenapiFiles(files) {
|
|
196
|
+
const promises = files.map(async (file) => {
|
|
197
|
+
const items = await processOpenapiFile(file.data);
|
|
198
|
+
return items.map((item) => ({
|
|
199
|
+
...item,
|
|
200
|
+
}));
|
|
201
|
+
});
|
|
202
|
+
const metadata = await Promise.all(promises);
|
|
203
|
+
const items = metadata.flat();
|
|
204
|
+
return items;
|
|
205
|
+
}
|
|
206
|
+
exports.processOpenapiFiles = processOpenapiFiles;
|
|
207
|
+
async function processOpenapiFile(openapiDataWithRefs) {
|
|
208
|
+
const openapiData = await resolveRefs(openapiDataWithRefs);
|
|
209
|
+
const postmanCollection = await createPostmanCollection(openapiData);
|
|
210
|
+
const items = createItems(openapiData);
|
|
211
|
+
bindCollectionToApiItems(items, postmanCollection);
|
|
212
|
+
return items;
|
|
213
|
+
}
|
|
214
|
+
exports.processOpenapiFile = processOpenapiFile;
|
|
215
|
+
// order for picking items as a display name of tags
|
|
216
|
+
const tagDisplayNameProperties = ["x-displayName", "name"];
|
|
217
|
+
function getTagDisplayName(tagName, tags) {
|
|
218
|
+
var _a;
|
|
219
|
+
// find the very own tagObject
|
|
220
|
+
const tagObject = (_a = tags.find((tagObject) => tagObject.name === tagName)) !== null && _a !== void 0 ? _a : {
|
|
221
|
+
// if none found, just fake one
|
|
222
|
+
name: tagName,
|
|
223
|
+
};
|
|
224
|
+
// return the first found and filled value from the property list
|
|
225
|
+
for (const property of tagDisplayNameProperties) {
|
|
226
|
+
const displayName = tagObject[property];
|
|
227
|
+
if (typeof displayName === "string") {
|
|
228
|
+
return displayName;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// always default to the tagName
|
|
232
|
+
return tagName;
|
|
233
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const _1 = require(".");
|
|
14
|
+
// npx jest packages/docusaurus-plugin-openapi/src/openapi/openapi.test.ts --watch
|
|
15
|
+
describe("openapi", () => {
|
|
16
|
+
describe("readOpenapiFiles", () => {
|
|
17
|
+
it("readOpenapiFiles", async () => {
|
|
18
|
+
const results = await (0, _1.readOpenapiFiles)(path_1.default.join(__dirname, "__fixtures__/examples"), {});
|
|
19
|
+
const categoryMeta = results.find((x) => x.source.endsWith("_category_.json"));
|
|
20
|
+
expect(categoryMeta).toBeFalsy();
|
|
21
|
+
// console.log(results);
|
|
22
|
+
const yaml = results.find((x) => x.source.endsWith("openapi.yaml"));
|
|
23
|
+
expect(yaml).toBeTruthy();
|
|
24
|
+
expect(yaml === null || yaml === void 0 ? void 0 : yaml.sourceDirName).toBe(".");
|
|
25
|
+
const froyo = results.find((x) => x.source.endsWith("froyo.yaml"));
|
|
26
|
+
expect(froyo).toBeTruthy();
|
|
27
|
+
expect(froyo === null || froyo === void 0 ? void 0 : froyo.sourceDirName).toBe("yogurtstore");
|
|
28
|
+
const nested = results.find((x) => x.source.endsWith("nested.yaml"));
|
|
29
|
+
expect(nested).toBeTruthy();
|
|
30
|
+
expect(nested === null || nested === void 0 ? void 0 : nested.sourceDirName).toBe("yogurtstore/nested");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import type { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
|
|
2
|
+
interface Map<T> {
|
|
3
|
+
[key: string]: T;
|
|
4
|
+
}
|
|
5
|
+
export interface OpenApiObject {
|
|
6
|
+
openapi: string;
|
|
7
|
+
info: InfoObject;
|
|
8
|
+
servers?: ServerObject[];
|
|
9
|
+
paths: PathsObject;
|
|
10
|
+
components?: ComponentsObject;
|
|
11
|
+
security?: SecurityRequirementObject[];
|
|
12
|
+
tags?: TagObject[];
|
|
13
|
+
externalDocs?: ExternalDocumentationObject;
|
|
14
|
+
}
|
|
15
|
+
export interface OpenApiObjectWithRef {
|
|
16
|
+
openapi: string;
|
|
17
|
+
info: InfoObject;
|
|
18
|
+
servers?: ServerObject[];
|
|
19
|
+
paths: PathsObjectWithRef;
|
|
20
|
+
components?: ComponentsObjectWithRef;
|
|
21
|
+
security?: SecurityRequirementObject[];
|
|
22
|
+
tags?: TagObject[];
|
|
23
|
+
externalDocs?: ExternalDocumentationObject;
|
|
24
|
+
}
|
|
25
|
+
export interface InfoObject {
|
|
26
|
+
title: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
termsOfService?: string;
|
|
29
|
+
contact?: ContactObject;
|
|
30
|
+
license?: LicenseObject;
|
|
31
|
+
version: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ContactObject {
|
|
34
|
+
name?: string;
|
|
35
|
+
url?: string;
|
|
36
|
+
email?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface LicenseObject {
|
|
39
|
+
name: string;
|
|
40
|
+
url?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ServerObject {
|
|
43
|
+
url: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
variables?: Map<ServerVariable>;
|
|
46
|
+
}
|
|
47
|
+
export interface ServerVariable {
|
|
48
|
+
enum?: string[];
|
|
49
|
+
default: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ComponentsObject {
|
|
53
|
+
schemas?: Map<SchemaObject>;
|
|
54
|
+
responses?: Map<ResponseObject>;
|
|
55
|
+
parameters?: Map<ParameterObject>;
|
|
56
|
+
examples?: Map<ExampleObject>;
|
|
57
|
+
requestBodies?: Map<RequestBodyObject>;
|
|
58
|
+
headers?: Map<HeaderObject>;
|
|
59
|
+
securitySchemes?: Map<SecuritySchemeObject>;
|
|
60
|
+
links?: Map<LinkObject>;
|
|
61
|
+
callbacks?: Map<CallbackObject>;
|
|
62
|
+
}
|
|
63
|
+
export interface ComponentsObjectWithRef {
|
|
64
|
+
schemas?: Map<SchemaObjectWithRef | ReferenceObject>;
|
|
65
|
+
responses?: Map<ResponseObjectWithRef | ReferenceObject>;
|
|
66
|
+
parameters?: Map<ParameterObjectWithRef | ReferenceObject>;
|
|
67
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
68
|
+
requestBodies?: Map<RequestBodyObjectWithRef | ReferenceObject>;
|
|
69
|
+
headers?: Map<HeaderObjectWithRef | ReferenceObject>;
|
|
70
|
+
securitySchemes?: Map<SecuritySchemeObject | ReferenceObject>;
|
|
71
|
+
links?: Map<LinkObject | ReferenceObject>;
|
|
72
|
+
callbacks?: Map<CallbackObjectWithRef | ReferenceObject>;
|
|
73
|
+
}
|
|
74
|
+
export declare type PathsObject = Map<PathItemObject>;
|
|
75
|
+
export declare type PathsObjectWithRef = Map<PathItemObjectWithRef>;
|
|
76
|
+
export interface PathItemObject {
|
|
77
|
+
$ref?: string;
|
|
78
|
+
summary?: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
get?: OperationObject;
|
|
81
|
+
put?: OperationObject;
|
|
82
|
+
post?: OperationObject;
|
|
83
|
+
delete?: OperationObject;
|
|
84
|
+
options?: OperationObject;
|
|
85
|
+
head?: OperationObject;
|
|
86
|
+
patch?: OperationObject;
|
|
87
|
+
trace?: OperationObject;
|
|
88
|
+
servers?: ServerObject[];
|
|
89
|
+
parameters?: ParameterObject[];
|
|
90
|
+
}
|
|
91
|
+
export interface PathItemObjectWithRef {
|
|
92
|
+
$ref?: string;
|
|
93
|
+
summary?: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
get?: OperationObjectWithRef;
|
|
96
|
+
put?: OperationObjectWithRef;
|
|
97
|
+
post?: OperationObjectWithRef;
|
|
98
|
+
delete?: OperationObjectWithRef;
|
|
99
|
+
options?: OperationObjectWithRef;
|
|
100
|
+
head?: OperationObjectWithRef;
|
|
101
|
+
patch?: OperationObjectWithRef;
|
|
102
|
+
trace?: OperationObjectWithRef;
|
|
103
|
+
servers?: ServerObject[];
|
|
104
|
+
parameters?: (ParameterObjectWithRef | ReferenceObject)[];
|
|
105
|
+
}
|
|
106
|
+
export interface OperationObject {
|
|
107
|
+
tags?: string[];
|
|
108
|
+
summary?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
externalDocs?: ExternalDocumentationObject;
|
|
111
|
+
operationId?: string;
|
|
112
|
+
parameters?: ParameterObject[];
|
|
113
|
+
requestBody?: RequestBodyObject;
|
|
114
|
+
responses: ResponsesObject;
|
|
115
|
+
callbacks?: Map<CallbackObject>;
|
|
116
|
+
deprecated?: boolean;
|
|
117
|
+
security?: SecurityRequirementObject[];
|
|
118
|
+
servers?: ServerObject[];
|
|
119
|
+
"x-deprecated-description"?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface OperationObjectWithRef {
|
|
122
|
+
tags?: string[];
|
|
123
|
+
summary?: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
externalDocs?: ExternalDocumentationObject;
|
|
126
|
+
operationId?: string;
|
|
127
|
+
parameters?: (ParameterObjectWithRef | ReferenceObject)[];
|
|
128
|
+
requestBody?: RequestBodyObjectWithRef | ReferenceObject;
|
|
129
|
+
responses: ResponsesObjectWithRef;
|
|
130
|
+
callbacks?: Map<CallbackObjectWithRef | ReferenceObject>;
|
|
131
|
+
deprecated?: boolean;
|
|
132
|
+
security?: SecurityRequirementObject[];
|
|
133
|
+
servers?: ServerObject[];
|
|
134
|
+
"x-deprecated-description"?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface ExternalDocumentationObject {
|
|
137
|
+
description?: string;
|
|
138
|
+
url: string;
|
|
139
|
+
}
|
|
140
|
+
export interface ParameterObject {
|
|
141
|
+
name: string;
|
|
142
|
+
in: "query" | "header" | "path" | "cookie";
|
|
143
|
+
description?: string;
|
|
144
|
+
required?: boolean;
|
|
145
|
+
deprecated?: boolean;
|
|
146
|
+
allowEmptyValue?: boolean;
|
|
147
|
+
style?: string;
|
|
148
|
+
explode?: string;
|
|
149
|
+
allowReserved?: boolean;
|
|
150
|
+
schema?: SchemaObject;
|
|
151
|
+
example?: any;
|
|
152
|
+
examples?: Map<ExampleObject>;
|
|
153
|
+
content?: Map<MediaTypeObject>;
|
|
154
|
+
}
|
|
155
|
+
export interface ParameterObjectWithRef {
|
|
156
|
+
name: string;
|
|
157
|
+
in: string;
|
|
158
|
+
description?: string;
|
|
159
|
+
required?: boolean;
|
|
160
|
+
deprecated?: boolean;
|
|
161
|
+
allowEmptyValue?: boolean;
|
|
162
|
+
style?: string;
|
|
163
|
+
explode?: string;
|
|
164
|
+
allowReserved?: boolean;
|
|
165
|
+
schema?: SchemaObjectWithRef | ReferenceObject;
|
|
166
|
+
example?: any;
|
|
167
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
168
|
+
content?: Map<MediaTypeObjectWithRef>;
|
|
169
|
+
}
|
|
170
|
+
export interface RequestBodyObject {
|
|
171
|
+
description?: string;
|
|
172
|
+
content: Map<MediaTypeObject>;
|
|
173
|
+
required?: boolean;
|
|
174
|
+
}
|
|
175
|
+
export interface RequestBodyObjectWithRef {
|
|
176
|
+
description?: string;
|
|
177
|
+
content: Map<MediaTypeObjectWithRef>;
|
|
178
|
+
required?: boolean;
|
|
179
|
+
}
|
|
180
|
+
export interface MediaTypeObject {
|
|
181
|
+
schema?: SchemaObject;
|
|
182
|
+
example?: any;
|
|
183
|
+
examples?: Map<ExampleObject>;
|
|
184
|
+
encoding?: Map<EncodingObject>;
|
|
185
|
+
}
|
|
186
|
+
export interface MediaTypeObjectWithRef {
|
|
187
|
+
schema?: SchemaObjectWithRef | ReferenceObject;
|
|
188
|
+
example?: any;
|
|
189
|
+
examples?: Map<ExampleObject | ReferenceObject>;
|
|
190
|
+
encoding?: Map<EncodingObjectWithRef>;
|
|
191
|
+
}
|
|
192
|
+
export interface EncodingObject {
|
|
193
|
+
contentType?: string;
|
|
194
|
+
headers?: Map<HeaderObject>;
|
|
195
|
+
style?: string;
|
|
196
|
+
explode?: boolean;
|
|
197
|
+
allowReserved?: boolean;
|
|
198
|
+
}
|
|
199
|
+
export interface EncodingObjectWithRef {
|
|
200
|
+
contentType?: string;
|
|
201
|
+
headers?: Map<HeaderObjectWithRef | ReferenceObject>;
|
|
202
|
+
style?: string;
|
|
203
|
+
explode?: boolean;
|
|
204
|
+
allowReserved?: boolean;
|
|
205
|
+
}
|
|
206
|
+
export declare type ResponsesObject = Map<ResponseObject>;
|
|
207
|
+
export declare type ResponsesObjectWithRef = Map<ResponseObjectWithRef | ReferenceObject>;
|
|
208
|
+
export interface ResponseObject {
|
|
209
|
+
description: string;
|
|
210
|
+
headers?: Map<HeaderObject>;
|
|
211
|
+
content?: Map<MediaTypeObject>;
|
|
212
|
+
links?: Map<LinkObject>;
|
|
213
|
+
}
|
|
214
|
+
export interface ResponseObjectWithRef {
|
|
215
|
+
description: string;
|
|
216
|
+
headers?: Map<HeaderObjectWithRef | ReferenceObject>;
|
|
217
|
+
content?: Map<MediaTypeObjectWithRef>;
|
|
218
|
+
links?: Map<LinkObject | ReferenceObject>;
|
|
219
|
+
}
|
|
220
|
+
export declare type CallbackObject = Map<PathItemObject>;
|
|
221
|
+
export declare type CallbackObjectWithRef = Map<PathItemObjectWithRef>;
|
|
222
|
+
export interface ExampleObject {
|
|
223
|
+
summary?: string;
|
|
224
|
+
description?: string;
|
|
225
|
+
value?: any;
|
|
226
|
+
externalValue?: string;
|
|
227
|
+
}
|
|
228
|
+
export interface LinkObject {
|
|
229
|
+
operationRef?: string;
|
|
230
|
+
operationId?: string;
|
|
231
|
+
parameters?: Map<any>;
|
|
232
|
+
requestBody?: any;
|
|
233
|
+
description?: string;
|
|
234
|
+
server?: ServerObject;
|
|
235
|
+
}
|
|
236
|
+
export declare type HeaderObject = Omit<ParameterObject, "name" | "in">;
|
|
237
|
+
export declare type HeaderObjectWithRef = Omit<ParameterObjectWithRef, "name" | "in">;
|
|
238
|
+
export interface TagObject {
|
|
239
|
+
name: string;
|
|
240
|
+
description?: string;
|
|
241
|
+
externalDocs?: ExternalDocumentationObject;
|
|
242
|
+
"x-displayName"?: string;
|
|
243
|
+
}
|
|
244
|
+
export interface ReferenceObject {
|
|
245
|
+
$ref: string;
|
|
246
|
+
}
|
|
247
|
+
export declare type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
248
|
+
export declare type SchemaObject = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf" | "not" | "items" | "properties" | "additionalProperties"> & {
|
|
249
|
+
type?: "string" | "number" | "integer" | "boolean" | "object" | "array";
|
|
250
|
+
allOf?: SchemaObject[];
|
|
251
|
+
oneOf?: SchemaObject[];
|
|
252
|
+
anyOf?: SchemaObject[];
|
|
253
|
+
not?: SchemaObject;
|
|
254
|
+
items?: SchemaObject;
|
|
255
|
+
properties?: Map<SchemaObject>;
|
|
256
|
+
additionalProperties?: boolean | SchemaObject;
|
|
257
|
+
nullable?: boolean;
|
|
258
|
+
discriminator?: DiscriminatorObject;
|
|
259
|
+
readOnly?: boolean;
|
|
260
|
+
writeOnly?: boolean;
|
|
261
|
+
xml?: XMLObject;
|
|
262
|
+
externalDocs?: ExternalDocumentationObject;
|
|
263
|
+
example?: any;
|
|
264
|
+
deprecated?: boolean;
|
|
265
|
+
};
|
|
266
|
+
export declare type SchemaObjectWithRef = Omit<JSONSchema, "type" | "allOf" | "oneOf" | "anyOf" | "not" | "items" | "properties" | "additionalProperties"> & {
|
|
267
|
+
type?: "string" | "number" | "integer" | "boolean" | "object" | "array";
|
|
268
|
+
allOf?: (SchemaObject | ReferenceObject)[];
|
|
269
|
+
oneOf?: (SchemaObject | ReferenceObject)[];
|
|
270
|
+
anyOf?: (SchemaObject | ReferenceObject)[];
|
|
271
|
+
not?: SchemaObject | ReferenceObject;
|
|
272
|
+
items?: SchemaObject | ReferenceObject;
|
|
273
|
+
properties?: Map<SchemaObject | ReferenceObject>;
|
|
274
|
+
additionalProperties?: boolean | SchemaObject | ReferenceObject;
|
|
275
|
+
nullable?: boolean;
|
|
276
|
+
discriminator?: DiscriminatorObject;
|
|
277
|
+
readOnly?: boolean;
|
|
278
|
+
writeOnly?: boolean;
|
|
279
|
+
xml?: XMLObject;
|
|
280
|
+
externalDocs?: ExternalDocumentationObject;
|
|
281
|
+
example?: any;
|
|
282
|
+
deprecated?: boolean;
|
|
283
|
+
};
|
|
284
|
+
export interface DiscriminatorObject {
|
|
285
|
+
propertyName: string;
|
|
286
|
+
mapping?: Map<string>;
|
|
287
|
+
}
|
|
288
|
+
export interface XMLObject {
|
|
289
|
+
name?: string;
|
|
290
|
+
namespace?: string;
|
|
291
|
+
prefix?: string;
|
|
292
|
+
attribute?: boolean;
|
|
293
|
+
wrapped?: boolean;
|
|
294
|
+
}
|
|
295
|
+
export declare type SecuritySchemeObject = ApiKeySecuritySchemeObject | HttpSecuritySchemeObject | Oauth2SecuritySchemeObject | OpenIdConnectSecuritySchemeObject;
|
|
296
|
+
export interface ApiKeySecuritySchemeObject {
|
|
297
|
+
type: "apiKey";
|
|
298
|
+
description?: string;
|
|
299
|
+
name: string;
|
|
300
|
+
in: "query" | "header" | "cookie";
|
|
301
|
+
}
|
|
302
|
+
export interface HttpSecuritySchemeObject {
|
|
303
|
+
type: "http";
|
|
304
|
+
description?: string;
|
|
305
|
+
scheme: string;
|
|
306
|
+
bearerFormat?: string;
|
|
307
|
+
}
|
|
308
|
+
export interface Oauth2SecuritySchemeObject {
|
|
309
|
+
type: "oauth2";
|
|
310
|
+
description?: string;
|
|
311
|
+
flows: OAuthFlowsObject;
|
|
312
|
+
}
|
|
313
|
+
export interface OpenIdConnectSecuritySchemeObject {
|
|
314
|
+
type: "openIdConnect";
|
|
315
|
+
description?: string;
|
|
316
|
+
openIdConnectUrl: string;
|
|
317
|
+
}
|
|
318
|
+
export interface OAuthFlowsObject {
|
|
319
|
+
implicit?: OAuthFlowObject;
|
|
320
|
+
password?: OAuthFlowObject;
|
|
321
|
+
clientCredentials?: OAuthFlowObject;
|
|
322
|
+
authorizationCode?: OAuthFlowObject;
|
|
323
|
+
}
|
|
324
|
+
export interface OAuthFlowObject {
|
|
325
|
+
authorizationUrl?: string;
|
|
326
|
+
tokenUrl?: string;
|
|
327
|
+
refreshUrl?: string;
|
|
328
|
+
scopes: Map<string>;
|
|
329
|
+
}
|
|
330
|
+
export declare type SecurityRequirementObject = Map<string[]>;
|
|
331
|
+
export {};
|
|
@@ -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/lib/options.d.ts
ADDED
package/lib/options.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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.OptionsSchema = exports.DEFAULT_OPTIONS = void 0;
|
|
10
|
+
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
|
+
exports.DEFAULT_OPTIONS = {
|
|
12
|
+
id: "default",
|
|
13
|
+
config: {},
|
|
14
|
+
};
|
|
15
|
+
exports.OptionsSchema = utils_validation_1.Joi.object({
|
|
16
|
+
id: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.id),
|
|
17
|
+
config: utils_validation_1.Joi.object().default(exports.DEFAULT_OPTIONS.config),
|
|
18
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ProcessedSidebar } from "@docusaurus/plugin-content-docs/src/sidebars/types";
|
|
2
|
+
import type { SidebarOptions, APIOptions, ApiMetadata } from "../types";
|
|
3
|
+
export default function generateSidebarSlice(sidebarOptions: SidebarOptions, options: APIOptions, api: ApiMetadata[]): ProcessedSidebar;
|