@@ -283,14 +283,12 @@ export function createSinglePathItemOperationSpec(
283283 sourcePathItem ?. servers ||
284284 [ ] ,
285285 )
286-
287- const operationPath = basePath + path
288- const operationId = slugify ( `${ removeFirstSlash ( operationPath ) } -${ httpMethod } ` )
286+ const operationId = getOperationId ( basePath , httpMethod , path )
289287 return operations . includes ( operationId )
290288 } )
291289
292290 if ( operationIds ?. length ) {
293- const pathItem = {
291+ const pathItemObject = {
294292 ...extractCommonPathItemProperties ( valueByPath ) ,
295293 ...operationIds . reduce < OpenAPIV3 . PathItemObject > ( ( pathItemObject : OpenAPIV3 . PathItemObject , operationId : OpenAPIV3 . HttpMethods ) => {
296294 const operationData = valueByPath [ operationId ]
@@ -300,7 +298,7 @@ export function createSinglePathItemOperationSpec(
300298 return pathItemObject
301299 } , { } ) ,
302300 }
303- setValueByPath ( sourceDocument , richReference . jsonPath , pathItem )
301+ setValueByPath ( sourceDocument , richReference . jsonPath , pathItemObject )
304302 }
305303 }
306304}
@@ -374,3 +372,12 @@ export const extractCommonPathItemProperties = (
374372function isValidHttpMethod ( method : string ) : method is OpenAPIV3 . HttpMethods {
375373 return ( Object . values ( OpenAPIV3 . HttpMethods ) as string [ ] ) . includes ( method )
376374}
375+
376+ export function getOperationId (
377+ basePath : string ,
378+ key : string ,
379+ path : string ,
380+ ) : string {
381+ const operationPath = basePath + path
382+ return slugify ( `${ removeFirstSlash ( operationPath ) } -${ key } ` )
383+ }
0 commit comments