@@ -227,13 +227,11 @@ export const calculateSpecRefs = (
227227      return 
228228    } 
229229    const  componentName  =  matchResult . grepValues [ grepKey ] . toString ( ) 
230-     let  component  =  getKeyValue ( sourceDocument ,  ...matchResult . path )  as  Record < string ,  unknown > 
230+     const  component  =  getKeyValue ( sourceDocument ,  ...matchResult . path )  as  Record < string ,  unknown > 
231231    if  ( ! component )  { 
232232      return 
233233    } 
234-     if  ( isObject ( component ) )  { 
235-       component  =  {  ...component  } 
236-     } 
234+ 
237235    if  ( models  &&  ! models [ componentName ]  &&  isComponentsSchemaRef ( matchResult . path ) )  { 
238236      let  componentHash  =  componentsHashMap ?. get ( componentName ) 
239237      if  ( componentHash )  { 
@@ -253,7 +251,7 @@ export const calculateSpecRefs = (
253251  } 
254252} 
255253
256- export   function  reduceComponentPathItemsToOperations ( 
254+ function  reduceComponentPathItemsToOperations ( 
257255  resultSpec : RestOperationData , 
258256  normalizedDocument : RestOperationData , 
259257  operations : OperationId [ ] , 
@@ -262,21 +260,14 @@ export function reduceComponentPathItemsToOperations(
262260
263261  for  ( const  path  of  Object . keys ( paths ) )  { 
264262    const  sourcePathItem  =  paths [ path ]  as  OpenAPIV3 . PathItemObject 
265-     if  ( ! isNonNullObject ( sourcePathItem ) )  { 
266-       continue 
267-     } 
268-     const  refs  =  getSymbolValueIfDefined ( sourcePathItem ,  INLINE_REFS_FLAG )  as  string [ ]  |  undefined 
269-     if  ( ! refs  ||  refs ?. length  ===  0 )  { 
270-       continue 
271-     } 
272-     const  {  jsonPath }  =  parseRef ( refs [ 0 ] ) 
273-     if  ( ! jsonPath )  { 
263+     const  pathItemComponentJsonPath  =  getPathItemComponentJsonPath ( sourcePathItem ) 
264+     if  ( ! pathItemComponentJsonPath )  { 
274265      continue 
275266    } 
276267
277-     const  valueByPath  =  getValueByPath ( resultSpec ,  jsonPath )  as  OpenAPIV3 . PathItemObject 
268+     const  pathItemComponent  =  getValueByPath ( resultSpec ,  pathItemComponentJsonPath )  as  OpenAPIV3 . PathItemObject 
278269
279-     const  operationIds : OpenAPIV3 . HttpMethods [ ]  =  ( Object . keys ( valueByPath )  as  OpenAPIV3 . HttpMethods [ ] ) 
270+     const  operationIds : OpenAPIV3 . HttpMethods [ ]  =  ( Object . keys ( pathItemComponent )  as  OpenAPIV3 . HttpMethods [ ] ) 
280271      . filter ( ( httpMethod )  =>  isValidHttpMethod ( httpMethod ) ) 
281272      . filter ( httpMethod  =>  { 
282273        const  methodData  =  sourcePathItem [ httpMethod  as  OpenAPIV3 . HttpMethods ] 
@@ -292,22 +283,27 @@ export function reduceComponentPathItemsToOperations(
292283
293284    if  ( operationIds ?. length )  { 
294285      const  pathItemObject  =  { 
295-         ...extractCommonPathItemProperties ( valueByPath ) , 
286+         ...extractCommonPathItemProperties ( pathItemComponent ) , 
296287        ...operationIds . reduce < OpenAPIV3 . PathItemObject > ( ( pathItemObject : OpenAPIV3 . PathItemObject ,  operationId : OpenAPIV3 . HttpMethods )  =>  { 
297-           const  operationData  =  valueByPath [ operationId ] 
288+           const  operationData  =  pathItemComponent [ operationId ] 
298289          if  ( operationData )  { 
299290            pathItemObject [ operationId ]  =  {  ...operationData  } 
300291          } 
301292          return  pathItemObject 
302293        } ,  { } ) , 
303294      } 
304-       setValueByPath ( resultSpec ,  jsonPath ,  pathItemObject ) 
295+       setValueByPath ( resultSpec ,  pathItemComponentJsonPath ,  pathItemObject ) 
305296    } 
306297  } 
307298} 
308299
309- function  isNonNullObject ( value : unknown ) : value  is Record < string ,  unknown >  { 
310-   return  typeof  value  ===  'object'  &&  value  !==  null 
300+ const  getPathItemComponentJsonPath  =  ( sourcePathItem : OpenAPIV3 . PathItemObject ) : JsonPath  |  undefined =>  { 
301+   const  refs  =  getSymbolValueIfDefined ( sourcePathItem ,  INLINE_REFS_FLAG )  as  string [ ]  |  undefined 
302+   if  ( ! refs  ||  refs . length  ===  0 )  { 
303+     return  undefined 
304+   } 
305+ 
306+   return  parseRef ( refs [ 0 ] ) ?. jsonPath 
311307} 
312308
313309export  const  isComponentsSchemaRef  =  ( path : JsonPath ) : boolean  =>  { 
0 commit comments