@@ -60,7 +60,7 @@ import {
6060 extractPathParamRenameDiff ,
6161 extractRootSecurityDiffs ,
6262 extractRootServersDiffs ,
63- getOperationBasePath ,
63+ extractOperationBasePath ,
6464} from './rest.utils'
6565import { createOperationChange , getOperationTags , OperationsMap } from '../../components'
6666
@@ -141,14 +141,15 @@ export const compareDocuments = async (
141141
142142 const methodData = pathData [ inferredMethod ]
143143 // todo if there were actually servers here, we wouldn't have handle it, add a test
144- const basePath = getOperationBasePath ( methodData ?. servers || pathData ?. servers || merged . servers || [ ] )
145- const operationPath = basePath + path
146- const operationId = slugify ( `${ operationPath } -${ inferredMethod } ` )
147- const normalizedOperationId = slugify ( `${ normalizePath ( operationPath ) } -${ inferredMethod } ` , [ ] , IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER )
144+ const previousBasePath = extractOperationBasePath ( methodData ?. servers || pathData ?. servers || prevDocData . servers || [ ] )
145+ const currentBasePath = extractOperationBasePath ( methodData ?. servers || pathData ?. servers || currDocData . servers || [ ] )
146+ const prevNormalizedOperationId = slugify ( `${ normalizePath ( previousBasePath + path ) } -${ inferredMethod } ` , [ ] , IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER )
147+ const currNormalizedOperationId = slugify ( `${ normalizePath ( currentBasePath + path ) } -${ inferredMethod } ` , [ ] , IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER )
148148
149- const { current, previous } = operationsMap [ normalizedOperationId ] ?? operationsMap [ operationId ] ?? { }
149+ const { current, previous } = operationsMap [ prevNormalizedOperationId ] ?? operationsMap [ currNormalizedOperationId ] /*?? operationsMap[ operationId]*/ ?? { }
150150 if ( ! current && ! previous ) {
151- throw new Error ( `Can't find the operation ${ operationId } from documents pair ${ prevDoc ?. fileId } and ${ currDoc ?. fileId } ` )
151+ const missingOperations = prevNormalizedOperationId === currNormalizedOperationId ? `the ${ prevNormalizedOperationId } operation` : `the ${ prevNormalizedOperationId } and ${ currNormalizedOperationId } operations`
152+ throw new Error ( `Can't find ${ missingOperations } from documents pair ${ prevDoc ?. fileId } and ${ currDoc ?. fileId } ` )
152153 }
153154 const operationChanged = Boolean ( current && previous )
154155 const operationAddedOrRemoved = ! operationChanged
0 commit comments