@@ -258,21 +258,28 @@ const createSingleOperationSpec = (
258258) : TYPE . RestOperationData  =>  { 
259259  const  pathData  =  document . paths [ path ]  as  OpenAPIV3 . PathItemObject 
260260
261-   const  resolveRefPathItem  =  ( ref : string ) : OpenAPIV3 . PathItemObject  =>  { 
261+   const  resolveRefPathItem  =  ( ref : string ) : OpenAPIV3 . PathItemObject  |  null  =>  { 
262+     if  ( ! ref )  { 
263+       return  null 
264+     } 
262265    const  {  jsonPath }  =  parseRef ( ref ) 
263266    const  target  =  getValueByPath ( document ,  jsonPath )  as  OpenAPIV3 . PathItemObject 
267+     if  ( ! target  ||  typeof  target  !==  'object' )  { 
268+       return  null 
269+     } 
264270    return  { 
265271      ...extractCommonPathItemProperties ( target ) , 
266272      [ method ] : {  ...target [ method ]  } , 
267273    } 
268274  } 
269275
270-   const  buildComponentsFromRef  =  ( ref : string ) : any  =>  { 
271-     const  {  jsonPath }  =  parseRef ( ref ) 
276+   const  buildComponentsFromRef  =  ( ref : string ) : OpenAPIV3 . ComponentsObject  =>  { 
272277    const  resolved  =  resolveRefPathItem ( ref ) 
278+     if  ( ! resolved )  { return  { } } 
279+     const  {  jsonPath }  =  parseRef ( ref ) 
273280    const  container : any  =  { } 
274281    setValueByPath ( container ,  jsonPath ,  resolved ) 
275-     return  container . components 
282+     return  container . components   ||   { } 
276283  } 
277284
278285  const  specBase  =  { 
@@ -284,7 +291,7 @@ const createSingleOperationSpec = (
284291    } , 
285292  } 
286293
287-   if  ( '$ref'  in  pathData )  { 
294+   if  ( pathData   &&   '$ref'  in  pathData   &&   pathData . $ref )  { 
288295    return  { 
289296      ...specBase , 
290297      paths : { 
0 commit comments