docusaurus-plugin-openapi-docs 0.0.0-824 → 0.0.0-827
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/openapi/openapi.js +13 -13
- package/lib/openapi/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/openapi/openapi.ts +1 -1
- package/src/openapi/types.ts +1 -0
package/lib/openapi/openapi.js
CHANGED
|
@@ -61,7 +61,7 @@ async function createPostmanCollection(openapiData) {
|
|
|
61
61
|
return await jsonToCollection(data);
|
|
62
62
|
}
|
|
63
63
|
function createItems(openapiData, options, sidebarOptions) {
|
|
64
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
65
65
|
// TODO: Find a better way to handle this
|
|
66
66
|
let items = [];
|
|
67
67
|
const infoIdSpaces = openapiData.info.title.replace(" ", "-").toLowerCase();
|
|
@@ -212,15 +212,15 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
// Gather x-webhooks endpoints
|
|
215
|
-
for (let [path, pathObject] of Object.entries((_p = openapiData["x-webhooks"]) !== null && _p !== void 0 ? _p : {})) {
|
|
215
|
+
for (let [path, pathObject] of Object.entries((_q = (_p = openapiData["x-webhooks"]) !== null && _p !== void 0 ? _p : openapiData["webhooks"]) !== null && _q !== void 0 ? _q : {})) {
|
|
216
216
|
path = "webhook";
|
|
217
217
|
const { $ref, description, parameters, servers, summary, ...rest } = pathObject;
|
|
218
218
|
for (let [method, operationObject] of Object.entries({ ...rest })) {
|
|
219
219
|
method = "event";
|
|
220
|
-
const title = (
|
|
220
|
+
const title = (_s = (_r = operationObject.summary) !== null && _r !== void 0 ? _r : operationObject.operationId) !== null && _s !== void 0 ? _s : "Missing summary";
|
|
221
221
|
if (operationObject.description === undefined) {
|
|
222
222
|
operationObject.description =
|
|
223
|
-
(
|
|
223
|
+
(_u = (_t = operationObject.summary) !== null && _t !== void 0 ? _t : operationObject.operationId) !== null && _u !== void 0 ? _u : "";
|
|
224
224
|
}
|
|
225
225
|
const baseId = operationObject.operationId
|
|
226
226
|
? (0, kebabCase_1.default)(operationObject.operationId)
|
|
@@ -232,10 +232,10 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
232
232
|
extensions.push({ key, value });
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
const servers = (
|
|
236
|
-
const security = (
|
|
235
|
+
const servers = (_w = (_v = operationObject.servers) !== null && _v !== void 0 ? _v : pathObject.servers) !== null && _w !== void 0 ? _w : openapiData.servers;
|
|
236
|
+
const security = (_x = operationObject.security) !== null && _x !== void 0 ? _x : openapiData.security;
|
|
237
237
|
// Add security schemes so we know how to handle security.
|
|
238
|
-
const securitySchemes = (
|
|
238
|
+
const securitySchemes = (_y = openapiData.components) === null || _y === void 0 ? void 0 : _y.securitySchemes;
|
|
239
239
|
// Make sure schemes are lowercase. See: https://github.com/cloud-annotations/docusaurus-plugin-openapi/issues/79
|
|
240
240
|
if (securitySchemes) {
|
|
241
241
|
for (let securityScheme of Object.values(securitySchemes)) {
|
|
@@ -245,7 +245,7 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
let jsonRequestBodyExample;
|
|
248
|
-
const content = (
|
|
248
|
+
const content = (_z = operationObject.requestBody) === null || _z === void 0 ? void 0 : _z.content;
|
|
249
249
|
let body;
|
|
250
250
|
for (let key in content) {
|
|
251
251
|
if (key.toLowerCase() === "application/json" ||
|
|
@@ -258,7 +258,7 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
258
258
|
jsonRequestBodyExample = (0, createRequestExample_1.sampleRequestFromSchema)(body.schema);
|
|
259
259
|
}
|
|
260
260
|
// Handle vendor JSON media types
|
|
261
|
-
const bodyContent = (
|
|
261
|
+
const bodyContent = (_0 = operationObject.requestBody) === null || _0 === void 0 ? void 0 : _0.content;
|
|
262
262
|
if (bodyContent) {
|
|
263
263
|
const firstBodyContentKey = Object.keys(bodyContent)[0];
|
|
264
264
|
if (firstBodyContentKey.endsWith("+json")) {
|
|
@@ -325,13 +325,13 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
if ((options === null || options === void 0 ? void 0 : options.showSchemas) === true ||
|
|
328
|
-
Object.entries((
|
|
328
|
+
Object.entries((_2 = (_1 = openapiData === null || openapiData === void 0 ? void 0 : openapiData.components) === null || _1 === void 0 ? void 0 : _1.schemas) !== null && _2 !== void 0 ? _2 : {})
|
|
329
329
|
.flatMap(([_, s]) => s["x-tags"])
|
|
330
330
|
.filter((item) => !!item).length > 0) {
|
|
331
331
|
// Gather schemas
|
|
332
|
-
for (let [schema, schemaObject] of Object.entries((
|
|
332
|
+
for (let [schema, schemaObject] of Object.entries((_4 = (_3 = openapiData === null || openapiData === void 0 ? void 0 : openapiData.components) === null || _3 === void 0 ? void 0 : _3.schemas) !== null && _4 !== void 0 ? _4 : {})) {
|
|
333
333
|
if ((options === null || options === void 0 ? void 0 : options.showSchemas) === true || schemaObject["x-tags"]) {
|
|
334
|
-
const baseIdSpaces = (
|
|
334
|
+
const baseIdSpaces = (_6 = (_5 = schemaObject === null || schemaObject === void 0 ? void 0 : schemaObject.title) === null || _5 === void 0 ? void 0 : _5.replace(" ", "-").toLowerCase()) !== null && _6 !== void 0 ? _6 : "";
|
|
335
335
|
const baseId = (0, kebabCase_1.default)(baseIdSpaces);
|
|
336
336
|
const schemaDescription = schemaObject.description;
|
|
337
337
|
let splitDescription;
|
|
@@ -364,7 +364,7 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
364
364
|
}
|
|
365
365
|
if ((sidebarOptions === null || sidebarOptions === void 0 ? void 0 : sidebarOptions.categoryLinkSource) === "tag") {
|
|
366
366
|
// Get global tags
|
|
367
|
-
const tags = (
|
|
367
|
+
const tags = (_7 = openapiData.tags) !== null && _7 !== void 0 ? _7 : [];
|
|
368
368
|
// Get operation tags
|
|
369
369
|
const apiItems = items.filter((item) => {
|
|
370
370
|
return item.type === "api";
|
package/lib/openapi/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-827",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "759e2c14c7471bcc90a83071407fb0a8fd47ec35"
|
|
66
66
|
}
|
package/src/openapi/openapi.ts
CHANGED
|
@@ -269,7 +269,7 @@ function createItems(
|
|
|
269
269
|
|
|
270
270
|
// Gather x-webhooks endpoints
|
|
271
271
|
for (let [path, pathObject] of Object.entries(
|
|
272
|
-
openapiData["x-webhooks"] ?? {}
|
|
272
|
+
openapiData["x-webhooks"] ?? openapiData["webhooks"] ?? {}
|
|
273
273
|
)) {
|
|
274
274
|
path = "webhook";
|
|
275
275
|
const { $ref, description, parameters, servers, summary, ...rest } =
|