Skip to content

Commit 11f601d

Browse files
committed
feat: Refactoring
1 parent ffdc348 commit 11f601d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/apitypes/rest/rest.operation.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ import {
3232
capitalize,
3333
getKeyValue,
3434
getSplittedVersionKey,
35+
getValueByRefAndUpdate,
3536
isDeprecatedOperationItem,
3637
isOperationDeprecated,
3738
normalizePath,
3839
rawToApiKind,
39-
getValueByRefAndUpdate,
4040
setValueByPath,
4141
takeIf,
4242
takeIfDefined,
@@ -310,11 +310,15 @@ const createSingleOperationSpec = (
310310
},
311311
}
312312

313-
if (pathData.$ref) {
314-
const cleanedDocument = getValueByRefAndUpdate(pathData.$ref, document, (pathItemObject: OpenAPIV3.PathItemObject) => ({
315-
...extractCommonPathItemProperties(pathItemObject),
316-
[method]: { ...pathItemObject[method] },
317-
}))
313+
const ref = pathData.$ref
314+
if (ref) {
315+
const cleanedDocument = getValueByRefAndUpdate(
316+
ref,
317+
document,
318+
(pathItemObject: OpenAPIV3.PathItemObject) => ({
319+
...extractCommonPathItemProperties(pathItemObject),
320+
[method]: { ...pathItemObject[method] },
321+
}))
318322

319323
return {
320324
...baseSpec,
@@ -323,7 +327,7 @@ const createSingleOperationSpec = (
323327
},
324328
components: {
325329
...baseSpec.components,
326-
...cleanedDocument?.components ?? {},
330+
...cleanedDocument.components ?? {},
327331
},
328332
}
329333
}

src/strategies/document-group.strategy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,18 @@ function handleRefPathItem(
190190
const ref = pathData.$ref ?? ''
191191
const operationsFormResult = getParentValueByRef(ref, resultDocument)
192192

193-
const clearedDocument = getValueByRefAndUpdate(ref, sourceDocument, (pathItemObject: OpenAPIV3.PathItemObject) => ({
193+
const cleanedDocument = getValueByRefAndUpdate(ref, sourceDocument, (pathItemObject: OpenAPIV3.PathItemObject) => ({
194194
...operationsFormResult,
195195
...extractCommonPathItemProperties(pathItemObject),
196196
[method]: { ...pathItemObject[method] },
197197
}))
198198

199199
resultDocument.paths[path] = pathData
200200

201-
if (clearedDocument.components) {
201+
if (cleanedDocument.components) {
202202
resultDocument.components = {
203203
...resultDocument.components,
204-
...clearedDocument.components,
204+
...cleanedDocument.components,
205205
}
206206
}
207207
}

0 commit comments

Comments
 (0)