@redocly/cli 1.18.1 → 1.20.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/lib/__mocks__/@redocly/openapi-core.d.ts +2 -2
  3. package/lib/__mocks__/@redocly/openapi-core.js +1 -0
  4. package/lib/__mocks__/fs.d.ts +0 -1
  5. package/lib/__mocks__/perf_hooks.d.ts +0 -1
  6. package/lib/__mocks__/redoc.d.ts +0 -1
  7. package/lib/__tests__/commands/build-docs.test.js +21 -23
  8. package/lib/__tests__/commands/bundle.test.js +21 -30
  9. package/lib/__tests__/commands/join.test.js +101 -70
  10. package/lib/__tests__/commands/lint.test.js +54 -54
  11. package/lib/__tests__/commands/push-region.test.js +24 -25
  12. package/lib/__tests__/commands/push.test.js +269 -170
  13. package/lib/__tests__/fetch-with-timeout.test.js +3 -12
  14. package/lib/__tests__/fixtures/config.d.ts +0 -1
  15. package/lib/__tests__/utils.test.js +32 -37
  16. package/lib/__tests__/wrapper.test.js +31 -20
  17. package/lib/cms/api/__tests__/api.client.test.js +29 -38
  18. package/lib/cms/api/api-client.d.ts +0 -2
  19. package/lib/cms/api/api-client.js +107 -128
  20. package/lib/cms/api/api-keys.js +1 -2
  21. package/lib/cms/api/domains.js +1 -2
  22. package/lib/cms/commands/__tests__/push-status.test.js +251 -162
  23. package/lib/cms/commands/__tests__/push.test.js +120 -102
  24. package/lib/cms/commands/__tests__/utils.test.js +12 -21
  25. package/lib/cms/commands/push-status.d.ts +3 -2
  26. package/lib/cms/commands/push-status.js +94 -106
  27. package/lib/cms/commands/push.d.ts +3 -2
  28. package/lib/cms/commands/push.js +66 -74
  29. package/lib/cms/commands/utils.js +20 -34
  30. package/lib/commands/build-docs/index.d.ts +2 -2
  31. package/lib/commands/build-docs/index.js +8 -17
  32. package/lib/commands/build-docs/utils.d.ts +1 -1
  33. package/lib/commands/build-docs/utils.js +27 -39
  34. package/lib/commands/bundle.d.ts +2 -2
  35. package/lib/commands/bundle.js +70 -94
  36. package/lib/commands/join.d.ts +2 -2
  37. package/lib/commands/join.js +375 -388
  38. package/lib/commands/lint.d.ts +2 -2
  39. package/lib/commands/lint.js +64 -75
  40. package/lib/commands/login.d.ts +3 -2
  41. package/lib/commands/login.js +10 -22
  42. package/lib/commands/preview-docs/index.d.ts +2 -2
  43. package/lib/commands/preview-docs/index.js +93 -106
  44. package/lib/commands/preview-docs/preview-server/preview-server.js +64 -76
  45. package/lib/commands/preview-docs/preview-server/server.d.ts +1 -4
  46. package/lib/commands/preview-docs/preview-server/server.js +6 -6
  47. package/lib/commands/preview-project/constants.d.ts +1 -1
  48. package/lib/commands/preview-project/index.d.ts +2 -1
  49. package/lib/commands/preview-project/index.js +5 -14
  50. package/lib/commands/preview-project/types.d.ts +1 -1
  51. package/lib/commands/push.d.ts +9 -12
  52. package/lib/commands/push.js +180 -196
  53. package/lib/commands/split/__tests__/index.test.js +31 -25
  54. package/lib/commands/split/index.d.ts +2 -1
  55. package/lib/commands/split/index.js +20 -33
  56. package/lib/commands/stats.d.ts +2 -2
  57. package/lib/commands/stats.js +36 -47
  58. package/lib/index.js +34 -49
  59. package/lib/types.d.ts +4 -5
  60. package/lib/utils/__mocks__/miscellaneous.d.ts +0 -1
  61. package/lib/utils/fetch-with-timeout.js +7 -12
  62. package/lib/utils/getCommandNameFromArgs.d.ts +1 -1
  63. package/lib/utils/getCommandNameFromArgs.js +2 -4
  64. package/lib/utils/js-utils.js +6 -7
  65. package/lib/utils/miscellaneous.d.ts +4 -1
  66. package/lib/utils/miscellaneous.js +130 -152
  67. package/lib/utils/update-version-notifier.js +4 -13
  68. package/lib/wrapper.d.ts +9 -2
  69. package/lib/wrapper.js +27 -16
  70. package/package.json +3 -3
  71. package/src/__mocks__/@redocly/openapi-core.ts +1 -0
  72. package/src/__tests__/commands/build-docs.test.ts +5 -4
  73. package/src/__tests__/commands/join.test.ts +51 -51
  74. package/src/__tests__/commands/push-region.test.ts +10 -8
  75. package/src/__tests__/commands/push.test.ts +127 -102
  76. package/src/__tests__/utils.test.ts +1 -0
  77. package/src/__tests__/wrapper.test.ts +24 -2
  78. package/src/cms/api/api-client.ts +2 -1
  79. package/src/cms/commands/__tests__/push-status.test.ts +70 -56
  80. package/src/cms/commands/__tests__/push.test.ts +30 -24
  81. package/src/cms/commands/push-status.ts +8 -7
  82. package/src/cms/commands/push.ts +12 -9
  83. package/src/commands/build-docs/index.ts +10 -5
  84. package/src/commands/build-docs/utils.ts +4 -4
  85. package/src/commands/bundle.ts +14 -6
  86. package/src/commands/join.ts +6 -2
  87. package/src/commands/lint.ts +9 -3
  88. package/src/commands/login.ts +5 -2
  89. package/src/commands/preview-docs/index.ts +7 -1
  90. package/src/commands/preview-docs/preview-server/preview-server.ts +4 -3
  91. package/src/commands/preview-docs/preview-server/server.ts +2 -1
  92. package/src/commands/preview-project/constants.ts +1 -1
  93. package/src/commands/preview-project/index.ts +5 -4
  94. package/src/commands/preview-project/types.ts +1 -1
  95. package/src/commands/push.ts +15 -18
  96. package/src/commands/split/__tests__/index.test.ts +17 -6
  97. package/src/commands/split/index.ts +4 -2
  98. package/src/commands/stats.ts +13 -6
  99. package/src/index.ts +13 -7
  100. package/src/types.ts +2 -3
  101. package/src/utils/getCommandNameFromArgs.ts +1 -1
  102. package/src/utils/miscellaneous.ts +11 -1
  103. package/src/wrapper.ts +37 -11
  104. package/tsconfig.tsbuildinfo +1 -1
@@ -1,15 +1,6 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.handleJoin = void 0;
3
+ exports.handleJoin = handleJoin;
13
4
  const path = require("path");
14
5
  const colorette_1 = require("colorette");
15
6
  const perf_hooks_1 = require("perf_hooks");
@@ -22,437 +13,433 @@ const split_1 = require("./split");
22
13
  const Tags = 'tags';
23
14
  const xTagGroups = 'x-tagGroups';
24
15
  let potentialConflictsTotal = 0;
25
- function handleJoin(argv, config, packageVersion) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const startedAt = perf_hooks_1.performance.now();
28
- if (argv.apis.length < 2) {
29
- return (0, miscellaneous_1.exitWithError)(`At least 2 apis should be provided.`);
30
- }
31
- const fileExtension = (0, miscellaneous_1.getAndValidateFileExtension)(argv.output || argv.apis[0]);
32
- const { 'prefix-components-with-info-prop': prefixComponentsWithInfoProp, 'prefix-tags-with-filename': prefixTagsWithFilename, 'prefix-tags-with-info-prop': prefixTagsWithInfoProp, 'without-x-tag-groups': withoutXTagGroups, output: specFilename = `openapi.${fileExtension}`, } = argv;
33
- const usedTagsOptions = [
34
- prefixTagsWithFilename && 'prefix-tags-with-filename',
35
- prefixTagsWithInfoProp && 'prefix-tags-with-info-prop',
36
- withoutXTagGroups && 'without-x-tag-groups',
37
- ].filter(Boolean);
38
- if (usedTagsOptions.length > 1) {
39
- return (0, miscellaneous_1.exitWithError)(`You use ${(0, colorette_1.yellow)(usedTagsOptions.join(', '))} together.\nPlease choose only one!`);
40
- }
41
- const apis = yield (0, miscellaneous_1.getFallbackApisOrExit)(argv.apis, config);
42
- const externalRefResolver = new openapi_core_1.BaseResolver(config.resolve);
43
- const documents = yield Promise.all(apis.map(({ path }) => externalRefResolver.resolveDocument(null, path, true)));
44
- const decorators = new Set([
45
- ...Object.keys(config.styleguide.decorators.oas3_0),
46
- ...Object.keys(config.styleguide.decorators.oas3_1),
47
- ...Object.keys(config.styleguide.decorators.oas2),
48
- ]);
49
- config.styleguide.skipDecorators(Array.from(decorators));
50
- const preprocessors = new Set([
51
- ...Object.keys(config.styleguide.preprocessors.oas3_0),
52
- ...Object.keys(config.styleguide.preprocessors.oas3_1),
53
- ...Object.keys(config.styleguide.preprocessors.oas2),
54
- ]);
55
- config.styleguide.skipPreprocessors(Array.from(preprocessors));
56
- const bundleResults = yield Promise.all(documents.map((document) => (0, openapi_core_1.bundleDocument)({
57
- document,
58
- config: config.styleguide,
59
- externalRefResolver: new openapi_core_1.BaseResolver(config.resolve),
60
- }).catch((e) => {
61
- (0, miscellaneous_1.exitWithError)(`${e.message}: ${(0, colorette_1.blue)(document.source.absoluteRef)}`);
62
- })));
63
- for (const { problems, bundle: document } of bundleResults) {
64
- const fileTotals = (0, openapi_core_1.getTotals)(problems);
65
- if (fileTotals.errors) {
66
- (0, openapi_core_1.formatProblems)(problems, {
67
- totals: fileTotals,
68
- version: packageVersion,
69
- });
70
- (0, miscellaneous_1.exitWithError)(`❌ Errors encountered while bundling ${(0, colorette_1.blue)(document.source.absoluteRef)}: join will not proceed.`);
71
- }
16
+ async function handleJoin({ argv, config, version: packageVersion, }) {
17
+ const startedAt = perf_hooks_1.performance.now();
18
+ if (argv.apis.length < 2) {
19
+ return (0, miscellaneous_1.exitWithError)(`At least 2 apis should be provided.`);
20
+ }
21
+ const fileExtension = (0, miscellaneous_1.getAndValidateFileExtension)(argv.output || argv.apis[0]);
22
+ const { 'prefix-components-with-info-prop': prefixComponentsWithInfoProp, 'prefix-tags-with-filename': prefixTagsWithFilename, 'prefix-tags-with-info-prop': prefixTagsWithInfoProp, 'without-x-tag-groups': withoutXTagGroups, output: specFilename = `openapi.${fileExtension}`, } = argv;
23
+ const usedTagsOptions = [
24
+ prefixTagsWithFilename && 'prefix-tags-with-filename',
25
+ prefixTagsWithInfoProp && 'prefix-tags-with-info-prop',
26
+ withoutXTagGroups && 'without-x-tag-groups',
27
+ ].filter(Boolean);
28
+ if (usedTagsOptions.length > 1) {
29
+ return (0, miscellaneous_1.exitWithError)(`You use ${(0, colorette_1.yellow)(usedTagsOptions.join(', '))} together.\nPlease choose only one!`);
30
+ }
31
+ const apis = await (0, miscellaneous_1.getFallbackApisOrExit)(argv.apis, config);
32
+ const externalRefResolver = new openapi_core_1.BaseResolver(config.resolve);
33
+ const documents = await Promise.all(apis.map(({ path }) => externalRefResolver.resolveDocument(null, path, true)));
34
+ const decorators = new Set([
35
+ ...Object.keys(config.styleguide.decorators.oas3_0),
36
+ ...Object.keys(config.styleguide.decorators.oas3_1),
37
+ ...Object.keys(config.styleguide.decorators.oas2),
38
+ ]);
39
+ config.styleguide.skipDecorators(Array.from(decorators));
40
+ const preprocessors = new Set([
41
+ ...Object.keys(config.styleguide.preprocessors.oas3_0),
42
+ ...Object.keys(config.styleguide.preprocessors.oas3_1),
43
+ ...Object.keys(config.styleguide.preprocessors.oas2),
44
+ ]);
45
+ config.styleguide.skipPreprocessors(Array.from(preprocessors));
46
+ const bundleResults = await Promise.all(documents.map((document) => (0, openapi_core_1.bundleDocument)({
47
+ document,
48
+ config: config.styleguide,
49
+ externalRefResolver: new openapi_core_1.BaseResolver(config.resolve),
50
+ }).catch((e) => {
51
+ (0, miscellaneous_1.exitWithError)(`${e.message}: ${(0, colorette_1.blue)(document.source.absoluteRef)}`);
52
+ })));
53
+ for (const { problems, bundle: document } of bundleResults) {
54
+ const fileTotals = (0, openapi_core_1.getTotals)(problems);
55
+ if (fileTotals.errors) {
56
+ (0, openapi_core_1.formatProblems)(problems, {
57
+ totals: fileTotals,
58
+ version: packageVersion,
59
+ });
60
+ (0, miscellaneous_1.exitWithError)(`❌ Errors encountered while bundling ${(0, colorette_1.blue)(document.source.absoluteRef)}: join will not proceed.`);
72
61
  }
73
- let oasVersion = null;
74
- for (const document of documents) {
75
- try {
76
- const version = (0, openapi_core_1.detectSpec)(document.parsed);
77
- if (version !== openapi_core_1.SpecVersion.OAS3_0 && version !== openapi_core_1.SpecVersion.OAS3_1) {
78
- return (0, miscellaneous_1.exitWithError)(`Only OpenAPI 3.0 and OpenAPI 3.1 are supported: ${(0, colorette_1.blue)(document.source.absoluteRef)}.`);
79
- }
80
- oasVersion = oasVersion !== null && oasVersion !== void 0 ? oasVersion : version;
81
- if (oasVersion !== version) {
82
- return (0, miscellaneous_1.exitWithError)(`All APIs must use the same OpenAPI version: ${(0, colorette_1.blue)(document.source.absoluteRef)}.`);
83
- }
62
+ }
63
+ let oasVersion = null;
64
+ for (const document of documents) {
65
+ try {
66
+ const version = (0, openapi_core_1.detectSpec)(document.parsed);
67
+ if (version !== openapi_core_1.SpecVersion.OAS3_0 && version !== openapi_core_1.SpecVersion.OAS3_1) {
68
+ return (0, miscellaneous_1.exitWithError)(`Only OpenAPI 3.0 and OpenAPI 3.1 are supported: ${(0, colorette_1.blue)(document.source.absoluteRef)}.`);
84
69
  }
85
- catch (e) {
86
- return (0, miscellaneous_1.exitWithError)(`${e.message}: ${(0, colorette_1.blue)(document.source.absoluteRef)}.`);
70
+ oasVersion = oasVersion ?? version;
71
+ if (oasVersion !== version) {
72
+ return (0, miscellaneous_1.exitWithError)(`All APIs must use the same OpenAPI version: ${(0, colorette_1.blue)(document.source.absoluteRef)}.`);
87
73
  }
88
74
  }
89
- const joinedDef = {};
90
- const potentialConflicts = {
91
- tags: {},
92
- paths: {},
93
- components: {},
94
- webhooks: {},
75
+ catch (e) {
76
+ return (0, miscellaneous_1.exitWithError)(`${e.message}: ${(0, colorette_1.blue)(document.source.absoluteRef)}.`);
77
+ }
78
+ }
79
+ const joinedDef = {};
80
+ const potentialConflicts = {
81
+ tags: {},
82
+ paths: {},
83
+ components: {},
84
+ webhooks: {},
85
+ };
86
+ addInfoSectionAndSpecVersion(documents, prefixComponentsWithInfoProp);
87
+ for (const document of documents) {
88
+ const openapi = document.parsed;
89
+ const { tags, info } = openapi;
90
+ const api = path.relative(process.cwd(), document.source.absoluteRef);
91
+ const apiFilename = getApiFilename(api);
92
+ const tagsPrefix = prefixTagsWithFilename
93
+ ? apiFilename
94
+ : getInfoPrefix(info, prefixTagsWithInfoProp, 'tags');
95
+ const componentsPrefix = getInfoPrefix(info, prefixComponentsWithInfoProp, types_1.COMPONENTS);
96
+ if (openapi.hasOwnProperty('x-tagGroups')) {
97
+ process.stderr.write((0, colorette_1.yellow)(`warning: x-tagGroups at ${(0, colorette_1.blue)(api)} will be skipped \n`));
98
+ }
99
+ const context = {
100
+ api,
101
+ apiFilename,
102
+ apiTitle: info?.title,
103
+ tags,
104
+ potentialConflicts,
105
+ tagsPrefix,
106
+ componentsPrefix,
95
107
  };
96
- addInfoSectionAndSpecVersion(documents, prefixComponentsWithInfoProp);
97
- for (const document of documents) {
98
- const openapi = document.parsed;
99
- const { tags, info } = openapi;
100
- const api = path.relative(process.cwd(), document.source.absoluteRef);
101
- const apiFilename = getApiFilename(api);
102
- const tagsPrefix = prefixTagsWithFilename
103
- ? apiFilename
104
- : getInfoPrefix(info, prefixTagsWithInfoProp, 'tags');
105
- const componentsPrefix = getInfoPrefix(info, prefixComponentsWithInfoProp, types_1.COMPONENTS);
106
- if (openapi.hasOwnProperty('x-tagGroups')) {
107
- process.stderr.write((0, colorette_1.yellow)(`warning: x-tagGroups at ${(0, colorette_1.blue)(api)} will be skipped \n`));
108
- }
109
- const context = {
110
- api,
111
- apiFilename,
112
- apiTitle: info === null || info === void 0 ? void 0 : info.title,
113
- tags,
114
- potentialConflicts,
115
- tagsPrefix,
116
- componentsPrefix,
117
- };
118
- if (tags) {
119
- populateTags(context);
120
- }
121
- collectServers(openapi);
122
- collectExternalDocs(openapi, context);
123
- collectPaths(openapi, context);
124
- collectComponents(openapi, context);
125
- collectWebhooks(oasVersion, openapi, context);
126
- if (componentsPrefix) {
127
- replace$Refs(openapi, componentsPrefix);
128
- }
108
+ if (tags) {
109
+ populateTags(context);
129
110
  }
130
- iteratePotentialConflicts(potentialConflicts, withoutXTagGroups);
131
- const noRefs = true;
132
- if (potentialConflictsTotal) {
133
- return (0, miscellaneous_1.exitWithError)(`Please fix conflicts before running ${(0, colorette_1.yellow)('join')}.`);
111
+ collectServers(openapi);
112
+ collectExternalDocs(openapi, context);
113
+ collectPaths(openapi, context);
114
+ collectComponents(openapi, context);
115
+ collectWebhooks(oasVersion, openapi, context);
116
+ if (componentsPrefix) {
117
+ replace$Refs(openapi, componentsPrefix);
134
118
  }
135
- (0, miscellaneous_1.writeToFileByExtension)((0, miscellaneous_1.sortTopLevelKeysForOas)(joinedDef), specFilename, noRefs);
136
- (0, miscellaneous_1.printExecutionTime)('join', startedAt, specFilename);
137
- function populateTags({ api, apiFilename, apiTitle, tags, potentialConflicts, tagsPrefix, componentsPrefix, }) {
138
- if (!joinedDef.hasOwnProperty(Tags)) {
139
- joinedDef[Tags] = [];
140
- }
141
- if (!potentialConflicts.tags.hasOwnProperty('all')) {
142
- potentialConflicts.tags['all'] = {};
119
+ }
120
+ iteratePotentialConflicts(potentialConflicts, withoutXTagGroups);
121
+ const noRefs = true;
122
+ if (potentialConflictsTotal) {
123
+ return (0, miscellaneous_1.exitWithError)(`Please fix conflicts before running ${(0, colorette_1.yellow)('join')}.`);
124
+ }
125
+ (0, miscellaneous_1.writeToFileByExtension)((0, miscellaneous_1.sortTopLevelKeysForOas)(joinedDef), specFilename, noRefs);
126
+ (0, miscellaneous_1.printExecutionTime)('join', startedAt, specFilename);
127
+ function populateTags({ api, apiFilename, apiTitle, tags, potentialConflicts, tagsPrefix, componentsPrefix, }) {
128
+ if (!joinedDef.hasOwnProperty(Tags)) {
129
+ joinedDef[Tags] = [];
130
+ }
131
+ if (!potentialConflicts.tags.hasOwnProperty('all')) {
132
+ potentialConflicts.tags['all'] = {};
133
+ }
134
+ if (withoutXTagGroups && !potentialConflicts.tags.hasOwnProperty('description')) {
135
+ potentialConflicts.tags['description'] = {};
136
+ }
137
+ for (const tag of tags) {
138
+ const entrypointTagName = addPrefix(tag.name, tagsPrefix);
139
+ if (tag.description) {
140
+ tag.description = addComponentsPrefix(tag.description, componentsPrefix);
143
141
  }
144
- if (withoutXTagGroups && !potentialConflicts.tags.hasOwnProperty('description')) {
145
- potentialConflicts.tags['description'] = {};
142
+ const tagDuplicate = joinedDef.tags.find((t) => t.name === entrypointTagName);
143
+ if (tagDuplicate && withoutXTagGroups) {
144
+ // If tag already exist and `without-x-tag-groups` option,
145
+ // check if description are different for potential conflicts warning.
146
+ const isTagDescriptionNotEqual = tag.hasOwnProperty('description') && tagDuplicate.description !== tag.description;
147
+ potentialConflicts.tags.description[entrypointTagName].push(...(isTagDescriptionNotEqual ? [api] : []));
146
148
  }
147
- for (const tag of tags) {
148
- const entrypointTagName = addPrefix(tag.name, tagsPrefix);
149
- if (tag.description) {
150
- tag.description = addComponentsPrefix(tag.description, componentsPrefix);
151
- }
152
- const tagDuplicate = joinedDef.tags.find((t) => t.name === entrypointTagName);
153
- if (tagDuplicate && withoutXTagGroups) {
154
- // If tag already exist and `without-x-tag-groups` option,
155
- // check if description are different for potential conflicts warning.
156
- const isTagDescriptionNotEqual = tag.hasOwnProperty('description') && tagDuplicate.description !== tag.description;
157
- potentialConflicts.tags.description[entrypointTagName].push(...(isTagDescriptionNotEqual ? [api] : []));
149
+ else if (!tagDuplicate) {
150
+ // Instead add tag to joinedDef if there no duplicate;
151
+ tag['x-displayName'] = tag['x-displayName'] || tag.name;
152
+ tag.name = entrypointTagName;
153
+ joinedDef.tags.push(tag);
154
+ if (withoutXTagGroups) {
155
+ potentialConflicts.tags.description[entrypointTagName] = [api];
158
156
  }
159
- else if (!tagDuplicate) {
160
- // Instead add tag to joinedDef if there no duplicate;
161
- tag['x-displayName'] = tag['x-displayName'] || tag.name;
162
- tag.name = entrypointTagName;
163
- joinedDef.tags.push(tag);
164
- if (withoutXTagGroups) {
165
- potentialConflicts.tags.description[entrypointTagName] = [api];
166
- }
167
- }
168
- if (!withoutXTagGroups) {
169
- const groupName = apiTitle || apiFilename;
170
- createXTagGroups(groupName);
171
- if (!tagDuplicate) {
172
- populateXTagGroups(entrypointTagName, getIndexGroup(groupName));
173
- }
157
+ }
158
+ if (!withoutXTagGroups) {
159
+ const groupName = apiTitle || apiFilename;
160
+ createXTagGroups(groupName);
161
+ if (!tagDuplicate) {
162
+ populateXTagGroups(entrypointTagName, getIndexGroup(groupName));
174
163
  }
175
- const doesEntrypointExist = !potentialConflicts.tags.all[entrypointTagName] ||
176
- (potentialConflicts.tags.all[entrypointTagName] &&
177
- !potentialConflicts.tags.all[entrypointTagName].includes(api));
178
- potentialConflicts.tags.all[entrypointTagName] = [
179
- ...(potentialConflicts.tags.all[entrypointTagName] || []),
180
- ...(!withoutXTagGroups && doesEntrypointExist ? [api] : []),
181
- ];
182
164
  }
165
+ const doesEntrypointExist = !potentialConflicts.tags.all[entrypointTagName] ||
166
+ (potentialConflicts.tags.all[entrypointTagName] &&
167
+ !potentialConflicts.tags.all[entrypointTagName].includes(api));
168
+ potentialConflicts.tags.all[entrypointTagName] = [
169
+ ...(potentialConflicts.tags.all[entrypointTagName] || []),
170
+ ...(!withoutXTagGroups && doesEntrypointExist ? [api] : []),
171
+ ];
183
172
  }
184
- function getIndexGroup(name) {
185
- return joinedDef[xTagGroups].findIndex((item) => item.name === name);
173
+ }
174
+ function getIndexGroup(name) {
175
+ return joinedDef[xTagGroups].findIndex((item) => item.name === name);
176
+ }
177
+ function createXTagGroups(name) {
178
+ if (!joinedDef.hasOwnProperty(xTagGroups)) {
179
+ joinedDef[xTagGroups] = [];
186
180
  }
187
- function createXTagGroups(name) {
188
- if (!joinedDef.hasOwnProperty(xTagGroups)) {
189
- joinedDef[xTagGroups] = [];
190
- }
191
- if (!joinedDef[xTagGroups].some((g) => g.name === name)) {
192
- joinedDef[xTagGroups].push({ name, tags: [] });
193
- }
194
- const indexGroup = getIndexGroup(name);
195
- if (!joinedDef[xTagGroups][indexGroup].hasOwnProperty(Tags)) {
196
- joinedDef[xTagGroups][indexGroup][Tags] = [];
197
- }
181
+ if (!joinedDef[xTagGroups].some((g) => g.name === name)) {
182
+ joinedDef[xTagGroups].push({ name, tags: [] });
198
183
  }
199
- function populateXTagGroups(entrypointTagName, indexGroup) {
200
- if (!joinedDef[xTagGroups][indexGroup][Tags].find((t) => t.name === entrypointTagName)) {
201
- joinedDef[xTagGroups][indexGroup][Tags].push(entrypointTagName);
202
- }
184
+ const indexGroup = getIndexGroup(name);
185
+ if (!joinedDef[xTagGroups][indexGroup].hasOwnProperty(Tags)) {
186
+ joinedDef[xTagGroups][indexGroup][Tags] = [];
203
187
  }
204
- function collectServers(openapi) {
205
- const { servers } = openapi;
206
- if (servers) {
207
- if (!joinedDef.hasOwnProperty('servers')) {
208
- joinedDef['servers'] = [];
209
- }
210
- for (const server of servers) {
211
- if (!joinedDef.servers.some((s) => s.url === server.url)) {
212
- joinedDef.servers.push(server);
213
- }
188
+ }
189
+ function populateXTagGroups(entrypointTagName, indexGroup) {
190
+ if (!joinedDef[xTagGroups][indexGroup][Tags].find((t) => t.name === entrypointTagName)) {
191
+ joinedDef[xTagGroups][indexGroup][Tags].push(entrypointTagName);
192
+ }
193
+ }
194
+ function collectServers(openapi) {
195
+ const { servers } = openapi;
196
+ if (servers) {
197
+ if (!joinedDef.hasOwnProperty('servers')) {
198
+ joinedDef['servers'] = [];
199
+ }
200
+ for (const server of servers) {
201
+ if (!joinedDef.servers.some((s) => s.url === server.url)) {
202
+ joinedDef.servers.push(server);
214
203
  }
215
204
  }
216
205
  }
217
- function collectExternalDocs(openapi, { api }) {
218
- const { externalDocs } = openapi;
219
- if (externalDocs) {
220
- if (joinedDef.hasOwnProperty('externalDocs')) {
221
- process.stderr.write((0, colorette_1.yellow)(`warning: skip externalDocs from ${(0, colorette_1.blue)(path.basename(api))} \n`));
222
- return;
223
- }
224
- joinedDef['externalDocs'] = externalDocs;
206
+ }
207
+ function collectExternalDocs(openapi, { api }) {
208
+ const { externalDocs } = openapi;
209
+ if (externalDocs) {
210
+ if (joinedDef.hasOwnProperty('externalDocs')) {
211
+ process.stderr.write((0, colorette_1.yellow)(`warning: skip externalDocs from ${(0, colorette_1.blue)(path.basename(api))} \n`));
212
+ return;
225
213
  }
214
+ joinedDef['externalDocs'] = externalDocs;
226
215
  }
227
- function collectPaths(openapi, { apiFilename, apiTitle, api, potentialConflicts, tagsPrefix, componentsPrefix, }) {
228
- const { paths } = openapi;
229
- const operationsSet = new Set((0, js_utils_1.keysOf)(types_1.OPENAPI3_METHOD));
230
- if (paths) {
231
- if (!joinedDef.hasOwnProperty('paths')) {
232
- joinedDef['paths'] = {};
216
+ }
217
+ function collectPaths(openapi, { apiFilename, apiTitle, api, potentialConflicts, tagsPrefix, componentsPrefix, }) {
218
+ const { paths } = openapi;
219
+ const operationsSet = new Set((0, js_utils_1.keysOf)(types_1.OPENAPI3_METHOD));
220
+ if (paths) {
221
+ if (!joinedDef.hasOwnProperty('paths')) {
222
+ joinedDef['paths'] = {};
223
+ }
224
+ for (const path of (0, js_utils_1.keysOf)(paths)) {
225
+ if (!joinedDef.paths.hasOwnProperty(path)) {
226
+ joinedDef.paths[path] = {};
227
+ }
228
+ if (!potentialConflicts.paths.hasOwnProperty(path)) {
229
+ potentialConflicts.paths[path] = {};
233
230
  }
234
- for (const path of (0, js_utils_1.keysOf)(paths)) {
235
- if (!joinedDef.paths.hasOwnProperty(path)) {
236
- joinedDef.paths[path] = {};
231
+ const pathItem = paths[path];
232
+ for (const field of (0, js_utils_1.keysOf)(pathItem)) {
233
+ if (operationsSet.has(field)) {
234
+ collectPathOperation(pathItem, path, field);
237
235
  }
238
- if (!potentialConflicts.paths.hasOwnProperty(path)) {
239
- potentialConflicts.paths[path] = {};
236
+ if (field === 'servers') {
237
+ collectPathServers(pathItem, path);
240
238
  }
241
- const pathItem = paths[path];
242
- for (const field of (0, js_utils_1.keysOf)(pathItem)) {
243
- if (operationsSet.has(field)) {
244
- collectPathOperation(pathItem, path, field);
245
- }
246
- if (field === 'servers') {
247
- collectPathServers(pathItem, path);
248
- }
249
- if (field === 'parameters') {
250
- collectPathParameters(pathItem, path);
251
- }
252
- if (typeof pathItem[field] === 'string') {
253
- collectPathStringFields(pathItem, path, field);
254
- }
239
+ if (field === 'parameters') {
240
+ collectPathParameters(pathItem, path);
241
+ }
242
+ if (typeof pathItem[field] === 'string') {
243
+ collectPathStringFields(pathItem, path, field);
255
244
  }
256
245
  }
257
246
  }
258
- function collectPathStringFields(pathItem, path, field) {
259
- const fieldValue = pathItem[field];
260
- if (joinedDef.paths[path].hasOwnProperty(field) &&
261
- joinedDef.paths[path][field] !== fieldValue) {
262
- process.stderr.write((0, colorette_1.yellow)(`warning: different ${field} values in ${path}\n`));
263
- return;
264
- }
265
- joinedDef.paths[path][field] = fieldValue;
247
+ }
248
+ function collectPathStringFields(pathItem, path, field) {
249
+ const fieldValue = pathItem[field];
250
+ if (joinedDef.paths[path].hasOwnProperty(field) &&
251
+ joinedDef.paths[path][field] !== fieldValue) {
252
+ process.stderr.write((0, colorette_1.yellow)(`warning: different ${field} values in ${path}\n`));
253
+ return;
266
254
  }
267
- function collectPathServers(pathItem, path) {
268
- if (!pathItem.servers) {
269
- return;
270
- }
271
- if (!joinedDef.paths[path].hasOwnProperty('servers')) {
272
- joinedDef.paths[path].servers = [];
273
- }
274
- for (const server of pathItem.servers) {
275
- let isFoundServer = false;
276
- for (const pathServer of joinedDef.paths[path].servers) {
277
- if (pathServer.url === server.url) {
278
- if (!isServersEqual(pathServer, server)) {
279
- (0, miscellaneous_1.exitWithError)(`Different server values for (${server.url}) in ${path}.`);
280
- }
281
- isFoundServer = true;
255
+ joinedDef.paths[path][field] = fieldValue;
256
+ }
257
+ function collectPathServers(pathItem, path) {
258
+ if (!pathItem.servers) {
259
+ return;
260
+ }
261
+ if (!joinedDef.paths[path].hasOwnProperty('servers')) {
262
+ joinedDef.paths[path].servers = [];
263
+ }
264
+ for (const server of pathItem.servers) {
265
+ let isFoundServer = false;
266
+ for (const pathServer of joinedDef.paths[path].servers) {
267
+ if (pathServer.url === server.url) {
268
+ if (!isServersEqual(pathServer, server)) {
269
+ (0, miscellaneous_1.exitWithError)(`Different server values for (${server.url}) in ${path}.`);
282
270
  }
283
- }
284
- if (!isFoundServer) {
285
- joinedDef.paths[path].servers.push(server);
271
+ isFoundServer = true;
286
272
  }
287
273
  }
288
- }
289
- function collectPathParameters(pathItem, path) {
290
- if (!pathItem.parameters) {
291
- return;
292
- }
293
- if (!joinedDef.paths[path].hasOwnProperty('parameters')) {
294
- joinedDef.paths[path].parameters = [];
274
+ if (!isFoundServer) {
275
+ joinedDef.paths[path].servers.push(server);
295
276
  }
296
- for (const parameter of pathItem.parameters) {
297
- let isFoundParameter = false;
298
- for (const pathParameter of joinedDef.paths[path]
299
- .parameters) {
300
- // Compare $ref only if both are reference objects
301
- if ((0, openapi_core_1.isRef)(pathParameter) && (0, openapi_core_1.isRef)(parameter)) {
302
- if (pathParameter['$ref'] === parameter['$ref']) {
303
- isFoundParameter = true;
304
- }
277
+ }
278
+ }
279
+ function collectPathParameters(pathItem, path) {
280
+ if (!pathItem.parameters) {
281
+ return;
282
+ }
283
+ if (!joinedDef.paths[path].hasOwnProperty('parameters')) {
284
+ joinedDef.paths[path].parameters = [];
285
+ }
286
+ for (const parameter of pathItem.parameters) {
287
+ let isFoundParameter = false;
288
+ for (const pathParameter of joinedDef.paths[path]
289
+ .parameters) {
290
+ // Compare $ref only if both are reference objects
291
+ if ((0, openapi_core_1.isRef)(pathParameter) && (0, openapi_core_1.isRef)(parameter)) {
292
+ if (pathParameter['$ref'] === parameter['$ref']) {
293
+ isFoundParameter = true;
305
294
  }
306
- // Compare properties only if both are reference objects
307
- if (!(0, openapi_core_1.isRef)(pathParameter) && !(0, openapi_core_1.isRef)(parameter)) {
308
- if (pathParameter.name === parameter.name && pathParameter.in === parameter.in) {
309
- if (!(0, utils_1.dequal)(pathParameter.schema, parameter.schema)) {
310
- (0, miscellaneous_1.exitWithError)(`Different parameter schemas for (${parameter.name}) in ${path}.`);
311
- }
312
- isFoundParameter = true;
295
+ }
296
+ // Compare properties only if both are reference objects
297
+ if (!(0, openapi_core_1.isRef)(pathParameter) && !(0, openapi_core_1.isRef)(parameter)) {
298
+ if (pathParameter.name === parameter.name && pathParameter.in === parameter.in) {
299
+ if (!(0, utils_1.dequal)(pathParameter.schema, parameter.schema)) {
300
+ (0, miscellaneous_1.exitWithError)(`Different parameter schemas for (${parameter.name}) in ${path}.`);
313
301
  }
302
+ isFoundParameter = true;
314
303
  }
315
304
  }
316
- if (!isFoundParameter) {
317
- joinedDef.paths[path].parameters.push(parameter);
318
- }
319
305
  }
320
- }
321
- function collectPathOperation(pathItem, path, operation) {
322
- const pathOperation = pathItem[operation];
323
- if (!pathOperation) {
324
- return;
306
+ if (!isFoundParameter) {
307
+ joinedDef.paths[path].parameters.push(parameter);
325
308
  }
326
- joinedDef.paths[path][operation] = pathOperation;
327
- potentialConflicts.paths[path][operation] = [
328
- ...(potentialConflicts.paths[path][operation] || []),
309
+ }
310
+ }
311
+ function collectPathOperation(pathItem, path, operation) {
312
+ const pathOperation = pathItem[operation];
313
+ if (!pathOperation) {
314
+ return;
315
+ }
316
+ joinedDef.paths[path][operation] = pathOperation;
317
+ potentialConflicts.paths[path][operation] = [
318
+ ...(potentialConflicts.paths[path][operation] || []),
319
+ api,
320
+ ];
321
+ const { operationId } = pathOperation;
322
+ if (operationId) {
323
+ if (!potentialConflicts.paths.hasOwnProperty('operationIds')) {
324
+ potentialConflicts.paths['operationIds'] = {};
325
+ }
326
+ potentialConflicts.paths.operationIds[operationId] = [
327
+ ...(potentialConflicts.paths.operationIds[operationId] || []),
329
328
  api,
330
329
  ];
331
- const { operationId } = pathOperation;
332
- if (operationId) {
333
- if (!potentialConflicts.paths.hasOwnProperty('operationIds')) {
334
- potentialConflicts.paths['operationIds'] = {};
335
- }
336
- potentialConflicts.paths.operationIds[operationId] = [
337
- ...(potentialConflicts.paths.operationIds[operationId] || []),
338
- api,
339
- ];
340
- }
341
- const { tags, security } = joinedDef.paths[path][operation];
342
- if (tags) {
343
- joinedDef.paths[path][operation].tags = tags.map((tag) => addPrefix(tag, tagsPrefix));
344
- populateTags({
345
- api,
346
- apiFilename,
347
- apiTitle,
348
- tags: formatTags(tags),
349
- potentialConflicts,
350
- tagsPrefix,
351
- componentsPrefix,
352
- });
353
- }
354
- else {
355
- joinedDef.paths[path][operation]['tags'] = [addPrefix('other', tagsPrefix || apiFilename)];
356
- populateTags({
357
- api,
358
- apiFilename,
359
- apiTitle,
360
- tags: formatTags(['other']),
361
- potentialConflicts,
362
- tagsPrefix: tagsPrefix || apiFilename,
363
- componentsPrefix,
364
- });
365
- }
366
- if (!security && openapi.hasOwnProperty('security')) {
367
- joinedDef.paths[path][operation]['security'] = addSecurityPrefix(openapi.security, componentsPrefix);
368
- }
369
- else if (pathOperation.security) {
370
- joinedDef.paths[path][operation].security = addSecurityPrefix(pathOperation.security, componentsPrefix);
371
- }
372
330
  }
373
- }
374
- function isServersEqual(serverOne, serverTwo) {
375
- if (serverOne.description === serverTwo.description) {
376
- return (0, utils_1.dequal)(serverOne.variables, serverTwo.variables);
331
+ const { tags, security } = joinedDef.paths[path][operation];
332
+ if (tags) {
333
+ joinedDef.paths[path][operation].tags = tags.map((tag) => addPrefix(tag, tagsPrefix));
334
+ populateTags({
335
+ api,
336
+ apiFilename,
337
+ apiTitle,
338
+ tags: formatTags(tags),
339
+ potentialConflicts,
340
+ tagsPrefix,
341
+ componentsPrefix,
342
+ });
343
+ }
344
+ else {
345
+ joinedDef.paths[path][operation]['tags'] = [addPrefix('other', tagsPrefix || apiFilename)];
346
+ populateTags({
347
+ api,
348
+ apiFilename,
349
+ apiTitle,
350
+ tags: formatTags(['other']),
351
+ potentialConflicts,
352
+ tagsPrefix: tagsPrefix || apiFilename,
353
+ componentsPrefix,
354
+ });
355
+ }
356
+ if (!security && openapi.hasOwnProperty('security')) {
357
+ joinedDef.paths[path][operation]['security'] = addSecurityPrefix(openapi.security, componentsPrefix);
358
+ }
359
+ else if (pathOperation.security) {
360
+ joinedDef.paths[path][operation].security = addSecurityPrefix(pathOperation.security, componentsPrefix);
377
361
  }
378
- return false;
379
362
  }
380
- function collectComponents(openapi, { api, potentialConflicts, componentsPrefix }) {
381
- const { components } = openapi;
382
- if (components) {
383
- if (!joinedDef.hasOwnProperty(types_1.COMPONENTS)) {
384
- joinedDef[types_1.COMPONENTS] = {};
385
- }
386
- for (const [component, componentObj] of Object.entries(components)) {
387
- if (!potentialConflicts[types_1.COMPONENTS].hasOwnProperty(component)) {
388
- potentialConflicts[types_1.COMPONENTS][component] = {};
389
- joinedDef[types_1.COMPONENTS][component] = {};
390
- }
391
- for (const item of Object.keys(componentObj)) {
392
- const componentPrefix = addPrefix(item, componentsPrefix);
393
- potentialConflicts.components[component][componentPrefix] = [
394
- ...(potentialConflicts.components[component][item] || []),
395
- { [api]: componentObj[item] },
396
- ];
397
- joinedDef.components[component][componentPrefix] = componentObj[item];
398
- }
363
+ }
364
+ function isServersEqual(serverOne, serverTwo) {
365
+ if (serverOne.description === serverTwo.description) {
366
+ return (0, utils_1.dequal)(serverOne.variables, serverTwo.variables);
367
+ }
368
+ return false;
369
+ }
370
+ function collectComponents(openapi, { api, potentialConflicts, componentsPrefix }) {
371
+ const { components } = openapi;
372
+ if (components) {
373
+ if (!joinedDef.hasOwnProperty(types_1.COMPONENTS)) {
374
+ joinedDef[types_1.COMPONENTS] = {};
375
+ }
376
+ for (const [component, componentObj] of Object.entries(components)) {
377
+ if (!potentialConflicts[types_1.COMPONENTS].hasOwnProperty(component)) {
378
+ potentialConflicts[types_1.COMPONENTS][component] = {};
379
+ joinedDef[types_1.COMPONENTS][component] = {};
380
+ }
381
+ for (const item of Object.keys(componentObj)) {
382
+ const componentPrefix = addPrefix(item, componentsPrefix);
383
+ potentialConflicts.components[component][componentPrefix] = [
384
+ ...(potentialConflicts.components[component][item] || []),
385
+ { [api]: componentObj[item] },
386
+ ];
387
+ joinedDef.components[component][componentPrefix] = componentObj[item];
399
388
  }
400
389
  }
401
390
  }
402
- function collectWebhooks(oasVersion, openapi, { apiFilename, apiTitle, api, potentialConflicts, tagsPrefix, componentsPrefix, }) {
403
- const webhooks = oasVersion === openapi_core_1.SpecVersion.OAS3_1 ? 'webhooks' : 'x-webhooks';
404
- const openapiWebhooks = openapi[webhooks];
405
- if (openapiWebhooks) {
406
- if (!joinedDef.hasOwnProperty(webhooks)) {
407
- joinedDef[webhooks] = {};
391
+ }
392
+ function collectWebhooks(oasVersion, openapi, { apiFilename, apiTitle, api, potentialConflicts, tagsPrefix, componentsPrefix, }) {
393
+ const webhooks = oasVersion === openapi_core_1.SpecVersion.OAS3_1 ? 'webhooks' : 'x-webhooks';
394
+ const openapiWebhooks = openapi[webhooks];
395
+ if (openapiWebhooks) {
396
+ if (!joinedDef.hasOwnProperty(webhooks)) {
397
+ joinedDef[webhooks] = {};
398
+ }
399
+ for (const webhook of Object.keys(openapiWebhooks)) {
400
+ joinedDef[webhooks][webhook] = openapiWebhooks[webhook];
401
+ if (!potentialConflicts.webhooks.hasOwnProperty(webhook)) {
402
+ potentialConflicts.webhooks[webhook] = {};
403
+ }
404
+ for (const operation of Object.keys(openapiWebhooks[webhook])) {
405
+ potentialConflicts.webhooks[webhook][operation] = [
406
+ ...(potentialConflicts.webhooks[webhook][operation] || []),
407
+ api,
408
+ ];
408
409
  }
409
- for (const webhook of Object.keys(openapiWebhooks)) {
410
- joinedDef[webhooks][webhook] = openapiWebhooks[webhook];
411
- if (!potentialConflicts.webhooks.hasOwnProperty(webhook)) {
412
- potentialConflicts.webhooks[webhook] = {};
413
- }
414
- for (const operation of Object.keys(openapiWebhooks[webhook])) {
415
- potentialConflicts.webhooks[webhook][operation] = [
416
- ...(potentialConflicts.webhooks[webhook][operation] || []),
410
+ for (const operationKey of Object.keys(joinedDef[webhooks][webhook])) {
411
+ const { tags } = joinedDef[webhooks][webhook][operationKey];
412
+ if (tags) {
413
+ joinedDef[webhooks][webhook][operationKey].tags = tags.map((tag) => addPrefix(tag, tagsPrefix));
414
+ populateTags({
417
415
  api,
418
- ];
419
- }
420
- for (const operationKey of Object.keys(joinedDef[webhooks][webhook])) {
421
- const { tags } = joinedDef[webhooks][webhook][operationKey];
422
- if (tags) {
423
- joinedDef[webhooks][webhook][operationKey].tags = tags.map((tag) => addPrefix(tag, tagsPrefix));
424
- populateTags({
425
- api,
426
- apiFilename,
427
- apiTitle,
428
- tags: formatTags(tags),
429
- potentialConflicts,
430
- tagsPrefix,
431
- componentsPrefix,
432
- });
433
- }
416
+ apiFilename,
417
+ apiTitle,
418
+ tags: formatTags(tags),
419
+ potentialConflicts,
420
+ tagsPrefix,
421
+ componentsPrefix,
422
+ });
434
423
  }
435
424
  }
436
425
  }
437
426
  }
438
- function addInfoSectionAndSpecVersion(documents, prefixComponentsWithInfoProp) {
439
- var _a;
440
- const firstApi = documents[0];
441
- const openapi = firstApi.parsed;
442
- const componentsPrefix = getInfoPrefix(openapi.info, prefixComponentsWithInfoProp, types_1.COMPONENTS);
443
- if (!openapi.openapi)
444
- (0, miscellaneous_1.exitWithError)('Version of specification is not found.');
445
- if (!openapi.info)
446
- (0, miscellaneous_1.exitWithError)('Info section is not found in specification.');
447
- if ((_a = openapi.info) === null || _a === void 0 ? void 0 : _a.description) {
448
- openapi.info.description = addComponentsPrefix(openapi.info.description, componentsPrefix);
449
- }
450
- joinedDef.openapi = openapi.openapi;
451
- joinedDef.info = openapi.info;
427
+ }
428
+ function addInfoSectionAndSpecVersion(documents, prefixComponentsWithInfoProp) {
429
+ const firstApi = documents[0];
430
+ const openapi = firstApi.parsed;
431
+ const componentsPrefix = getInfoPrefix(openapi.info, prefixComponentsWithInfoProp, types_1.COMPONENTS);
432
+ if (!openapi.openapi)
433
+ (0, miscellaneous_1.exitWithError)('Version of specification is not found.');
434
+ if (!openapi.info)
435
+ (0, miscellaneous_1.exitWithError)('Info section is not found in specification.');
436
+ if (openapi.info?.description) {
437
+ openapi.info.description = addComponentsPrefix(openapi.info.description, componentsPrefix);
452
438
  }
453
- });
439
+ joinedDef.openapi = openapi.openapi;
440
+ joinedDef.info = openapi.info;
441
+ }
454
442
  }
455
- exports.handleJoin = handleJoin;
456
443
  function doesComponentsDiffer(curr, next) {
457
444
  return !(0, utils_1.dequal)(Object.values(curr)[0], Object.values(next)[0]);
458
445
  }
@@ -529,7 +516,7 @@ function addComponentsPrefix(description, componentsPrefix) {
529
516
  }
530
517
  function addSecurityPrefix(security, componentsPrefix) {
531
518
  return componentsPrefix
532
- ? security === null || security === void 0 ? void 0 : security.map((s) => {
519
+ ? security?.map((s) => {
533
520
  const joinedSecuritySchema = {};
534
521
  for (const [key, value] of Object.entries(s)) {
535
522
  Object.assign(joinedSecuritySchema, { [componentsPrefix + '_' + key]: value });