docusaurus-plugin-openapi-docs 0.0.0-beta.670 → 0.0.0-beta.672

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.
@@ -13,7 +13,7 @@ function createAdmonition({ children }) {
13
13
  }
14
14
  function createDeprecationNotice({ deprecated, description, }) {
15
15
  return (0, utils_1.guard)(deprecated, () => createAdmonition({
16
- children: description !== null && description !== void 0 ? description : "This endpoint has been deprecated and may be removed in future versions of the API.",
16
+ children: description !== null && description !== void 0 ? description : "This endpoint has been deprecated and may be replaced or removed in future versions of the API.",
17
17
  }));
18
18
  }
19
19
  exports.createDeprecationNotice = createDeprecationNotice;
@@ -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;
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;
65
65
  // TODO: Find a better way to handle this
66
66
  let items = [];
67
67
  const infoIdSpaces = openapiData.info.title.replace(" ", "-").toLowerCase();
@@ -132,12 +132,20 @@ function createItems(openapiData, options, sidebarOptions) {
132
132
  }
133
133
  }
134
134
  let jsonRequestBodyExample;
135
- const body = (_o = (_m = operationObject.requestBody) === null || _m === void 0 ? void 0 : _m.content) === null || _o === void 0 ? void 0 : _o["application/json"];
135
+ const content = (_m = operationObject.requestBody) === null || _m === void 0 ? void 0 : _m.content;
136
+ let body;
137
+ for (let key in content) {
138
+ if (key.toLowerCase() === "application/json" ||
139
+ key.toLowerCase() === "application/json; charset=utf-8") {
140
+ body = content[key];
141
+ break;
142
+ }
143
+ }
136
144
  if (body === null || body === void 0 ? void 0 : body.schema) {
137
145
  jsonRequestBodyExample = (0, createRequestExample_1.sampleRequestFromSchema)(body.schema);
138
146
  }
139
147
  // Handle vendor JSON media types
140
- const bodyContent = (_p = operationObject.requestBody) === null || _p === void 0 ? void 0 : _p.content;
148
+ const bodyContent = (_o = operationObject.requestBody) === null || _o === void 0 ? void 0 : _o.content;
141
149
  if (bodyContent) {
142
150
  const firstBodyContentKey = Object.keys(bodyContent)[0];
143
151
  if (firstBodyContentKey.endsWith("+json")) {
@@ -204,15 +212,15 @@ function createItems(openapiData, options, sidebarOptions) {
204
212
  }
205
213
  }
206
214
  // Gather x-webhooks endpoints
207
- for (let [path, pathObject] of Object.entries((_q = openapiData["x-webhooks"]) !== null && _q !== void 0 ? _q : {})) {
215
+ for (let [path, pathObject] of Object.entries((_p = openapiData["x-webhooks"]) !== null && _p !== void 0 ? _p : {})) {
208
216
  path = "webhook";
209
217
  const { $ref, description, parameters, servers, summary, ...rest } = pathObject;
210
218
  for (let [method, operationObject] of Object.entries({ ...rest })) {
211
219
  method = "event";
212
- const title = (_s = (_r = operationObject.summary) !== null && _r !== void 0 ? _r : operationObject.operationId) !== null && _s !== void 0 ? _s : "Missing summary";
220
+ const title = (_r = (_q = operationObject.summary) !== null && _q !== void 0 ? _q : operationObject.operationId) !== null && _r !== void 0 ? _r : "Missing summary";
213
221
  if (operationObject.description === undefined) {
214
222
  operationObject.description =
215
- (_u = (_t = operationObject.summary) !== null && _t !== void 0 ? _t : operationObject.operationId) !== null && _u !== void 0 ? _u : "";
223
+ (_t = (_s = operationObject.summary) !== null && _s !== void 0 ? _s : operationObject.operationId) !== null && _t !== void 0 ? _t : "";
216
224
  }
217
225
  const baseId = operationObject.operationId
218
226
  ? (0, kebabCase_1.default)(operationObject.operationId)
@@ -224,10 +232,10 @@ function createItems(openapiData, options, sidebarOptions) {
224
232
  extensions.push({ key, value });
225
233
  }
226
234
  }
227
- const servers = (_w = (_v = operationObject.servers) !== null && _v !== void 0 ? _v : pathObject.servers) !== null && _w !== void 0 ? _w : openapiData.servers;
228
- const security = (_x = operationObject.security) !== null && _x !== void 0 ? _x : openapiData.security;
235
+ const servers = (_v = (_u = operationObject.servers) !== null && _u !== void 0 ? _u : pathObject.servers) !== null && _v !== void 0 ? _v : openapiData.servers;
236
+ const security = (_w = operationObject.security) !== null && _w !== void 0 ? _w : openapiData.security;
229
237
  // Add security schemes so we know how to handle security.
230
- const securitySchemes = (_y = openapiData.components) === null || _y === void 0 ? void 0 : _y.securitySchemes;
238
+ const securitySchemes = (_x = openapiData.components) === null || _x === void 0 ? void 0 : _x.securitySchemes;
231
239
  // Make sure schemes are lowercase. See: https://github.com/cloud-annotations/docusaurus-plugin-openapi/issues/79
232
240
  if (securitySchemes) {
233
241
  for (let securityScheme of Object.values(securitySchemes)) {
@@ -237,12 +245,20 @@ function createItems(openapiData, options, sidebarOptions) {
237
245
  }
238
246
  }
239
247
  let jsonRequestBodyExample;
240
- const body = (_0 = (_z = operationObject.requestBody) === null || _z === void 0 ? void 0 : _z.content) === null || _0 === void 0 ? void 0 : _0["application/json"];
248
+ const content = (_y = operationObject.requestBody) === null || _y === void 0 ? void 0 : _y.content;
249
+ let body;
250
+ for (let key in content) {
251
+ if (key.toLowerCase() === "application/json" ||
252
+ key.toLowerCase() === "application/json; charset=utf-8") {
253
+ body = content[key];
254
+ break;
255
+ }
256
+ }
241
257
  if (body === null || body === void 0 ? void 0 : body.schema) {
242
258
  jsonRequestBodyExample = (0, createRequestExample_1.sampleRequestFromSchema)(body.schema);
243
259
  }
244
260
  // Handle vendor JSON media types
245
- const bodyContent = (_1 = operationObject.requestBody) === null || _1 === void 0 ? void 0 : _1.content;
261
+ const bodyContent = (_z = operationObject.requestBody) === null || _z === void 0 ? void 0 : _z.content;
246
262
  if (bodyContent) {
247
263
  const firstBodyContentKey = Object.keys(bodyContent)[0];
248
264
  if (firstBodyContentKey.endsWith("+json")) {
@@ -310,7 +326,7 @@ function createItems(openapiData, options, sidebarOptions) {
310
326
  }
311
327
  if ((sidebarOptions === null || sidebarOptions === void 0 ? void 0 : sidebarOptions.categoryLinkSource) === "tag") {
312
328
  // Get global tags
313
- const tags = (_2 = openapiData.tags) !== null && _2 !== void 0 ? _2 : [];
329
+ const tags = (_0 = openapiData.tags) !== null && _0 !== void 0 ? _0 : [];
314
330
  // Get operation tags
315
331
  const apiItems = items.filter((item) => {
316
332
  return item.type === "api";
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-beta.670",
4
+ "version": "0.0.0-beta.672",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -60,5 +60,5 @@
60
60
  "engines": {
61
61
  "node": ">=14"
62
62
  },
63
- "gitHead": "027a734f68092976b1e49ba8475b4f9a0909db67"
63
+ "gitHead": "7a6cdc1a2a7d2a01bd1ca473a4d1bbc7952ac808"
64
64
  }
@@ -24,7 +24,7 @@ export function createDeprecationNotice({
24
24
  createAdmonition({
25
25
  children:
26
26
  description ??
27
- "This endpoint has been deprecated and may be removed in future versions of the API.",
27
+ "This endpoint has been deprecated and may be replaced or removed in future versions of the API.",
28
28
  })
29
29
  );
30
30
  }
@@ -171,7 +171,18 @@ function createItems(
171
171
  }
172
172
 
173
173
  let jsonRequestBodyExample;
174
- const body = operationObject.requestBody?.content?.["application/json"];
174
+ const content = operationObject.requestBody?.content;
175
+ let body;
176
+ for (let key in content) {
177
+ if (
178
+ key.toLowerCase() === "application/json" ||
179
+ key.toLowerCase() === "application/json; charset=utf-8"
180
+ ) {
181
+ body = content[key];
182
+ break;
183
+ }
184
+ }
185
+
175
186
  if (body?.schema) {
176
187
  jsonRequestBodyExample = sampleRequestFromSchema(body.schema);
177
188
  }
@@ -304,7 +315,18 @@ function createItems(
304
315
  }
305
316
 
306
317
  let jsonRequestBodyExample;
307
- const body = operationObject.requestBody?.content?.["application/json"];
318
+ const content = operationObject.requestBody?.content;
319
+ let body;
320
+ for (let key in content) {
321
+ if (
322
+ key.toLowerCase() === "application/json" ||
323
+ key.toLowerCase() === "application/json; charset=utf-8"
324
+ ) {
325
+ body = content[key];
326
+ break;
327
+ }
328
+ }
329
+
308
330
  if (body?.schema) {
309
331
  jsonRequestBodyExample = sampleRequestFromSchema(body.schema);
310
332
  }