docusaurus-plugin-openapi-docs 0.0.0-420 → 0.0.0-421

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.
@@ -59,7 +59,7 @@ async function createPostmanCollection(openapiData) {
59
59
  return await jsonToCollection(data);
60
60
  }
61
61
  function createItems(openapiData, sidebarOptions) {
62
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
63
63
  // TODO: Find a better way to handle this
64
64
  let items = [];
65
65
  const infoId = (0, kebabCase_1.default)(openapiData.info.title);
@@ -100,8 +100,8 @@ function createItems(openapiData, sidebarOptions) {
100
100
  securitySchemes: (_b = openapiData.components) === null || _b === void 0 ? void 0 : _b.securitySchemes,
101
101
  info: {
102
102
  ...openapiData.info,
103
- tags: (_c = openapiData.tags) === null || _c === void 0 ? void 0 : _c.map((tagName) => { var _a; return getTagDisplayName(tagName.name, (_a = openapiData.tags) !== null && _a !== void 0 ? _a : []); }),
104
- title: (_d = openapiData.info.title) !== null && _d !== void 0 ? _d : "Introduction",
103
+ tags: openapiData.tags,
104
+ title: (_c = openapiData.info.title) !== null && _c !== void 0 ? _c : "Introduction",
105
105
  logo: openapiData.info["x-logo"],
106
106
  darkLogo: openapiData.info["x-dark-logo"],
107
107
  },
@@ -111,18 +111,18 @@ function createItems(openapiData, sidebarOptions) {
111
111
  for (let [path, pathObject] of Object.entries(openapiData.paths)) {
112
112
  const { $ref, description, parameters, servers, summary, ...rest } = pathObject;
113
113
  for (let [method, operationObject] of Object.entries({ ...rest })) {
114
- const title = (_f = (_e = operationObject.summary) !== null && _e !== void 0 ? _e : operationObject.operationId) !== null && _f !== void 0 ? _f : "Missing summary";
114
+ const title = (_e = (_d = operationObject.summary) !== null && _d !== void 0 ? _d : operationObject.operationId) !== null && _e !== void 0 ? _e : "Missing summary";
115
115
  if (operationObject.description === undefined) {
116
116
  operationObject.description =
117
- (_h = (_g = operationObject.summary) !== null && _g !== void 0 ? _g : operationObject.operationId) !== null && _h !== void 0 ? _h : "";
117
+ (_g = (_f = operationObject.summary) !== null && _f !== void 0 ? _f : operationObject.operationId) !== null && _g !== void 0 ? _g : "";
118
118
  }
119
119
  const baseId = operationObject.operationId
120
120
  ? (0, kebabCase_1.default)(operationObject.operationId)
121
121
  : (0, kebabCase_1.default)(operationObject.summary);
122
- const servers = (_k = (_j = operationObject.servers) !== null && _j !== void 0 ? _j : pathObject.servers) !== null && _k !== void 0 ? _k : openapiData.servers;
123
- const security = (_l = operationObject.security) !== null && _l !== void 0 ? _l : openapiData.security;
122
+ const servers = (_j = (_h = operationObject.servers) !== null && _h !== void 0 ? _h : pathObject.servers) !== null && _j !== void 0 ? _j : openapiData.servers;
123
+ const security = (_k = operationObject.security) !== null && _k !== void 0 ? _k : openapiData.security;
124
124
  // Add security schemes so we know how to handle security.
125
- const securitySchemes = (_m = openapiData.components) === null || _m === void 0 ? void 0 : _m.securitySchemes;
125
+ const securitySchemes = (_l = openapiData.components) === null || _l === void 0 ? void 0 : _l.securitySchemes;
126
126
  // Make sure schemes are lowercase. See: https://github.com/cloud-annotations/docusaurus-plugin-openapi/issues/79
127
127
  if (securitySchemes) {
128
128
  for (let securityScheme of Object.values(securitySchemes)) {
@@ -132,12 +132,12 @@ function createItems(openapiData, sidebarOptions) {
132
132
  }
133
133
  }
134
134
  let jsonRequestBodyExample;
135
- const body = (_p = (_o = operationObject.requestBody) === null || _o === void 0 ? void 0 : _o.content) === null || _p === void 0 ? void 0 : _p["application/json"];
135
+ const body = (_o = (_m = operationObject.requestBody) === null || _m === void 0 ? void 0 : _m.content) === null || _o === void 0 ? void 0 : _o["application/json"];
136
136
  if (body === null || body === void 0 ? void 0 : body.schema) {
137
137
  jsonRequestBodyExample = (0, createExample_1.sampleFromSchema)(body.schema);
138
138
  }
139
139
  // Handle vendor JSON media types
140
- const bodyContent = (_q = operationObject.requestBody) === null || _q === void 0 ? void 0 : _q.content;
140
+ const bodyContent = (_p = operationObject.requestBody) === null || _p === void 0 ? void 0 : _p.content;
141
141
  if (bodyContent) {
142
142
  const firstBodyContentKey = Object.keys(bodyContent)[0];
143
143
  if (firstBodyContentKey.endsWith("+json")) {
@@ -159,7 +159,7 @@ function createItems(openapiData, sidebarOptions) {
159
159
  frontMatter: {},
160
160
  api: {
161
161
  ...defaults,
162
- tags: (_r = operationObject.tags) === null || _r === void 0 ? void 0 : _r.map((tagName) => { var _a; return getTagDisplayName(tagName, (_a = openapiData.tags) !== null && _a !== void 0 ? _a : []); }),
162
+ tags: operationObject.tags,
163
163
  method,
164
164
  path,
165
165
  servers,
@@ -30,7 +30,7 @@ export interface InfoObject {
30
30
  contact?: ContactObject;
31
31
  license?: LicenseObject;
32
32
  version: string;
33
- tags?: String[];
33
+ tags?: TagObject[];
34
34
  "x-logo"?: LogoObject;
35
35
  "x-dark-logo"?: LogoObject;
36
36
  logo?: LogoObject;
@@ -36,9 +36,9 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
36
36
  const operationTags = (0, uniq_1.default)(apiItems
37
37
  .flatMap((item) => item.api.tags)
38
38
  .filter((item) => !!item));
39
+ // Only include operation tags that are globally defined
39
40
  const apiTags = [];
40
- // eslint-disable-next-line array-callback-return
41
- tags.map((tag) => {
41
+ tags.forEach((tag) => {
42
42
  if (operationTags.includes(tag.name)) {
43
43
  apiTags.push(tag.name);
44
44
  }
@@ -73,11 +73,12 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
73
73
  }
74
74
  const tagged = apiTags
75
75
  .map((tag) => {
76
+ var _a;
76
77
  // Map info object to tag
77
78
  const taggedInfoObject = intros.find((i) => i.tags ? i.tags.includes(tag) : undefined);
78
79
  const tagObject = tags.flat().find((t) => {
79
80
  var _a;
80
- return (_a = (tag === t.name || tag === t["x-displayName"])) !== null && _a !== void 0 ? _a : {
81
+ return (_a = tag === t.name) !== null && _a !== void 0 ? _a : {
81
82
  name: tag,
82
83
  description: `${tag} Index`,
83
84
  };
@@ -112,7 +113,7 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
112
113
  }
113
114
  return {
114
115
  type: "category",
115
- label: tag,
116
+ label: (_a = tagObject === null || tagObject === void 0 ? void 0 : tagObject["x-displayName"]) !== null && _a !== void 0 ? _a : tag,
116
117
  link: linkConfig,
117
118
  collapsible: sidebarCollapsible,
118
119
  collapsed: sidebarCollapsed,
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-420",
4
+ "version": "0.0.0-421",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -67,5 +67,5 @@
67
67
  "engines": {
68
68
  "node": ">=14"
69
69
  },
70
- "gitHead": "d3a62f626be0bc127f6d9f3534a20e8a1ff84192"
70
+ "gitHead": "5ca3bcb461f9dad4a78d51fb7c3c59657528e24e"
71
71
  }
@@ -124,9 +124,7 @@ function createItems(
124
124
  securitySchemes: openapiData.components?.securitySchemes,
125
125
  info: {
126
126
  ...openapiData.info,
127
- tags: openapiData.tags?.map((tagName) =>
128
- getTagDisplayName(tagName.name!, openapiData.tags ?? [])
129
- ),
127
+ tags: openapiData.tags,
130
128
  title: openapiData.info.title ?? "Introduction",
131
129
  logo: openapiData.info["x-logo"]! as any,
132
130
  darkLogo: openapiData.info["x-dark-logo"]! as any,
@@ -200,9 +198,7 @@ function createItems(
200
198
  frontMatter: {},
201
199
  api: {
202
200
  ...defaults,
203
- tags: operationObject.tags?.map((tagName) =>
204
- getTagDisplayName(tagName, openapiData.tags ?? [])
205
- ),
201
+ tags: operationObject.tags,
206
202
  method,
207
203
  path,
208
204
  servers,
@@ -41,7 +41,7 @@ export interface InfoObject {
41
41
  contact?: ContactObject;
42
42
  license?: LicenseObject;
43
43
  version: string;
44
- tags?: String[];
44
+ tags?: TagObject[];
45
45
  "x-logo"?: LogoObject;
46
46
  "x-dark-logo"?: LogoObject;
47
47
  logo?: LogoObject;
@@ -65,9 +65,10 @@ function groupByTags(
65
65
  .flatMap((item) => item.api.tags)
66
66
  .filter((item): item is string => !!item)
67
67
  );
68
+
69
+ // Only include operation tags that are globally defined
68
70
  const apiTags: string[] = [];
69
- // eslint-disable-next-line array-callback-return
70
- tags.map((tag) => {
71
+ tags.forEach((tag) => {
71
72
  if (operationTags.includes(tag.name!)) {
72
73
  apiTags.push(tag.name!);
73
74
  }
@@ -114,7 +115,7 @@ function groupByTags(
114
115
  );
115
116
  const tagObject = tags.flat().find(
116
117
  (t) =>
117
- (tag === t.name || tag === t["x-displayName"]) ?? {
118
+ tag === t.name ?? {
118
119
  name: tag,
119
120
  description: `${tag} Index`,
120
121
  }
@@ -155,7 +156,7 @@ function groupByTags(
155
156
 
156
157
  return {
157
158
  type: "category" as const,
158
- label: tag,
159
+ label: tagObject?.["x-displayName"] ?? tag,
159
160
  link: linkConfig,
160
161
  collapsible: sidebarCollapsible,
161
162
  collapsed: sidebarCollapsed,