Skip to content

Commit 7c48a26

Browse files
authored
HCK-9667: small refactoring (#82)
* HCK-9667: fix application crash & small refactoring * HCK-9667: Remove fix
1 parent afdb149 commit 7c48a26

File tree

8 files changed

+139
-108
lines changed

8 files changed

+139
-108
lines changed

forward_engineering/helpers/componentsHelpers/parametersHelper.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ function getSchemaKeyword(properties = {}) {
237237
return defaultKeyword;
238238
}
239239

240-
const schemaKey = Object.keys(properties).find(key => !restRequestPropNames.includes(key));
241-
return schemaKey;
240+
return Object.keys(properties).find(key => !restRequestPropNames.includes(key));
242241
}
243242

244243
module.exports = {

forward_engineering/helpers/componentsHelpers/responsesHelper.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ function mapResponse({ data, responseCollectionDescription, shouldResponseBeComm
4242
});
4343
const links = getLinks(get(data, `properties.links`), specVersion);
4444
const extensions = getExtensions(data.scopesExtensions);
45-
const response = {};
46-
if (shouldResponseBeCommented) {
47-
response[`hackoladeInnerCommentStart`] = true;
48-
}
49-
50-
Object.assign(response, { description, headers, content, links }, extensions);
45+
const response = {
46+
...(shouldResponseBeCommented && { hackoladeInnerCommentStart: true }),
47+
description,
48+
headers,
49+
content,
50+
links,
51+
...extensions,
52+
};
5153

5254
if (shouldResponseBeCommented) {
5355
response[`hackoladeInnerCommentEnd`] = true;

forward_engineering/helpers/componentsHelpers/securitySchemesHelper.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ function mapSecurityScheme(data, specVersion) {
8787
};
8888
const extensions = getExtensions(data.scopesExtensions);
8989

90-
return Object.assign({}, securitySchemeProps, commonFields, extensions);
90+
return {
91+
...securitySchemeProps,
92+
...commonFields,
93+
...extensions,
94+
};
9195
}
9296

9397
function mapOAuthFlows(data) {
@@ -110,7 +114,10 @@ function mapOAuthFlows(data) {
110114

111115
const extensions = getExtensions(data.scopesExtensions);
112116

113-
return cleanUp(Object.assign({}, flows, extensions));
117+
return cleanUp({
118+
...flows,
119+
...extensions,
120+
});
114121
}
115122

116123
function mapOAuthFlowObject({ authorizationUrl, tokenUrl, refreshUrl, scopes, scopesExtensions }) {
@@ -122,7 +129,10 @@ function mapOAuthFlowObject({ authorizationUrl, tokenUrl, refreshUrl, scopes, sc
122129
};
123130
const extensions = getExtensions(scopesExtensions);
124131

125-
return Object.assign({}, flow, extensions);
132+
return {
133+
...flow,
134+
...extensions,
135+
};
126136
}
127137

128138
function mapScopes(data) {

forward_engineering/helpers/generateModelScript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const handleRefInContainers = (containers, externalDefinitions, resolveApiExtern
5656
const separatePathAndWebhooks = containers => {
5757
const pathContainers = [];
5858
const webhookContainers = [];
59-
console.log('containers', containers);
59+
6060
containers.forEach(container => {
6161
if (container.containerData?.[0]?.webhook) {
6262
webhookContainers.push(container);

forward_engineering/helpers/pathHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { getArrayItems } = require('./sharedHelper');
1010

1111
function getPaths(containers, containersIdsForCallbacks = [], specVersion) {
1212
return containers
13-
.filter(({ id }) => !containersIdsForCallbacks.includes(id))
13+
.filter(({ id, containerData }) => !containersIdsForCallbacks.includes(id))
1414
.reduce((acc, container, index) => {
1515
const { name, isActivated } = container.containerData[0];
1616
const containerData = getRequestsForContainer({

forward_engineering/utils/utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ function removeEmptyObjectFields(inputObj) {
1212
.reduce((newObj, key) => {
1313
const isObjectAndNotArray = typeof obj[key] === 'object' && !Array.isArray(obj[key]);
1414
if (isObjectAndNotArray) {
15-
return Object.assign(newObj, {
15+
return {
16+
...newObj,
1617
[key]: removeEmptyObjectFields(obj[key]),
17-
});
18+
};
1819
}
19-
return Object.assign(newObj, { [key]: obj[key] });
20+
return { ...newObj, [key]: obj[key] };
2021
}, {});
2122
}
2223

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)