@redocly/cli 1.18.1 → 1.19.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/CHANGELOG.md +11 -0
- package/lib/__mocks__/@redocly/openapi-core.d.ts +2 -2
- package/lib/__mocks__/@redocly/openapi-core.js +1 -0
- package/lib/__mocks__/fs.d.ts +0 -1
- package/lib/__mocks__/perf_hooks.d.ts +0 -1
- package/lib/__mocks__/redoc.d.ts +0 -1
- package/lib/__tests__/commands/build-docs.test.js +21 -23
- package/lib/__tests__/commands/bundle.test.js +21 -30
- package/lib/__tests__/commands/join.test.js +101 -70
- package/lib/__tests__/commands/lint.test.js +54 -54
- package/lib/__tests__/commands/push-region.test.js +24 -25
- package/lib/__tests__/commands/push.test.js +269 -170
- package/lib/__tests__/fetch-with-timeout.test.js +3 -12
- package/lib/__tests__/fixtures/config.d.ts +0 -1
- package/lib/__tests__/utils.test.js +32 -37
- package/lib/__tests__/wrapper.test.js +31 -20
- package/lib/cms/api/__tests__/api.client.test.js +29 -38
- package/lib/cms/api/api-client.d.ts +0 -2
- package/lib/cms/api/api-client.js +106 -127
- package/lib/cms/api/api-keys.js +1 -2
- package/lib/cms/api/domains.js +1 -2
- package/lib/cms/commands/__tests__/push-status.test.js +251 -162
- package/lib/cms/commands/__tests__/push.test.js +120 -102
- package/lib/cms/commands/__tests__/utils.test.js +12 -21
- package/lib/cms/commands/push-status.d.ts +3 -2
- package/lib/cms/commands/push-status.js +94 -106
- package/lib/cms/commands/push.d.ts +3 -2
- package/lib/cms/commands/push.js +66 -74
- package/lib/cms/commands/utils.js +20 -34
- package/lib/commands/build-docs/index.d.ts +2 -2
- package/lib/commands/build-docs/index.js +8 -17
- package/lib/commands/build-docs/utils.js +26 -38
- package/lib/commands/bundle.d.ts +2 -2
- package/lib/commands/bundle.js +70 -94
- package/lib/commands/join.d.ts +2 -2
- package/lib/commands/join.js +375 -388
- package/lib/commands/lint.d.ts +2 -2
- package/lib/commands/lint.js +64 -75
- package/lib/commands/login.d.ts +3 -2
- package/lib/commands/login.js +9 -21
- package/lib/commands/preview-docs/index.d.ts +2 -2
- package/lib/commands/preview-docs/index.js +92 -106
- package/lib/commands/preview-docs/preview-server/preview-server.js +64 -76
- package/lib/commands/preview-docs/preview-server/server.d.ts +0 -3
- package/lib/commands/preview-docs/preview-server/server.js +6 -6
- package/lib/commands/preview-project/index.d.ts +2 -1
- package/lib/commands/preview-project/index.js +5 -14
- package/lib/commands/push.d.ts +8 -11
- package/lib/commands/push.js +177 -195
- package/lib/commands/split/__tests__/index.test.js +31 -25
- package/lib/commands/split/index.d.ts +2 -1
- package/lib/commands/split/index.js +20 -33
- package/lib/commands/stats.d.ts +2 -2
- package/lib/commands/stats.js +34 -45
- package/lib/index.js +32 -46
- package/lib/types.d.ts +2 -2
- package/lib/utils/__mocks__/miscellaneous.d.ts +0 -1
- package/lib/utils/fetch-with-timeout.js +7 -12
- package/lib/utils/getCommandNameFromArgs.js +2 -4
- package/lib/utils/js-utils.js +6 -7
- package/lib/utils/miscellaneous.d.ts +4 -1
- package/lib/utils/miscellaneous.js +130 -152
- package/lib/utils/update-version-notifier.js +4 -13
- package/lib/wrapper.d.ts +9 -2
- package/lib/wrapper.js +27 -16
- package/package.json +3 -3
- package/src/__mocks__/@redocly/openapi-core.ts +1 -0
- package/src/__tests__/commands/build-docs.test.ts +5 -4
- package/src/__tests__/commands/join.test.ts +51 -51
- package/src/__tests__/commands/push-region.test.ts +10 -8
- package/src/__tests__/commands/push.test.ts +127 -102
- package/src/__tests__/utils.test.ts +1 -0
- package/src/__tests__/wrapper.test.ts +24 -2
- package/src/cms/commands/__tests__/push-status.test.ts +70 -56
- package/src/cms/commands/__tests__/push.test.ts +30 -24
- package/src/cms/commands/push-status.ts +8 -7
- package/src/cms/commands/push.ts +12 -9
- package/src/commands/build-docs/index.ts +10 -5
- package/src/commands/bundle.ts +14 -6
- package/src/commands/join.ts +6 -2
- package/src/commands/lint.ts +9 -3
- package/src/commands/login.ts +4 -2
- package/src/commands/preview-docs/index.ts +6 -1
- package/src/commands/preview-project/index.ts +5 -4
- package/src/commands/push.ts +13 -15
- package/src/commands/split/__tests__/index.test.ts +17 -6
- package/src/commands/split/index.ts +4 -2
- package/src/commands/stats.ts +4 -2
- package/src/utils/miscellaneous.ts +11 -1
- package/src/wrapper.ts +37 -11
- package/tsconfig.tsbuildinfo +1 -1
package/lib/commands/join.js
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
97
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
145
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
185
|
-
|
|
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
|
-
|
|
188
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
184
|
+
const indexGroup = getIndexGroup(name);
|
|
185
|
+
if (!joinedDef[xTagGroups][indexGroup].hasOwnProperty(Tags)) {
|
|
186
|
+
joinedDef[xTagGroups][indexGroup][Tags] = [];
|
|
203
187
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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 (
|
|
239
|
-
|
|
236
|
+
if (field === 'servers') {
|
|
237
|
+
collectPathServers(pathItem, path);
|
|
240
238
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
-
|
|
322
|
-
const pathOperation = pathItem[operation];
|
|
323
|
-
if (!pathOperation) {
|
|
324
|
-
return;
|
|
306
|
+
if (!isFoundParameter) {
|
|
307
|
+
joinedDef.paths[path].parameters.push(parameter);
|
|
325
308
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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
|
|
410
|
-
joinedDef[webhooks][webhook]
|
|
411
|
-
if (
|
|
412
|
-
|
|
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
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
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
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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
|
|
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 });
|