1717import { OpenAPIV3 } from 'openapi-types'
1818
1919import { buildRestOperation } from './rest.operation'
20- import { OperationsBuilder } from '../../types'
21- import { createBundlingErrorHandler , removeComponents , removeFirstSlash , slugify } from '../../utils'
20+ import { OperationIdNormalizer , OperationsBuilder } from '../../types'
21+ import {
22+ createBundlingErrorHandler ,
23+ IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER ,
24+ removeComponents ,
25+ removeFirstSlash ,
26+ slugify ,
27+ } from '../../utils'
2228import { getOperationBasePath } from './rest.utils'
2329import type * as TYPE from './rest.types'
2430import { HASH_FLAG , INLINE_REFS_FLAG , MESSAGE_SEVERITY , NORMALIZE_OPTIONS , ORIGINS_SYMBOL } from '../../consts'
2531import { asyncFunction } from '../../utils/async'
2632import { logLongBuild , syncDebugPerformance } from '../../utils/logs'
27- import { normalize } from '@netcracker/qubership-apihub-api-unifier'
33+ import { normalize , RefErrorType } from '@netcracker/qubership-apihub-api-unifier'
2834
2935export const buildRestOperations : OperationsBuilder < OpenAPIV3 . Document > = async ( document , ctx , debugCtx ) => {
3036 const documentWithoutComponents = removeComponents ( document . data )
@@ -38,8 +44,8 @@ export const buildRestOperations: OperationsBuilder<OpenAPIV3.Document> = async
3844 originsFlag : ORIGINS_SYMBOL ,
3945 hashFlag : HASH_FLAG ,
4046 source : document . data ,
41- onRefResolveError : ( _ : string , __ : PropertyKey [ ] , ref : string ) =>
42- bundlingErrorHandler ( [ `The $ref " ${ ref } " references an invalid location in the document.` ] ) ,
47+ onRefResolveError : ( message : string , _path : PropertyKey [ ] , _ref : string , errorType : RefErrorType ) =>
48+ bundlingErrorHandler ( [ { message , errorType } ] ) ,
4349 } ,
4450 ) as OpenAPIV3 . Document
4551 const refsOnlyDocument = normalize (
@@ -106,3 +112,8 @@ export const buildRestOperations: OperationsBuilder<OpenAPIV3.Document> = async
106112 }
107113 return operations
108114}
115+
116+ export const createNormalizedOperationId : OperationIdNormalizer = ( operation ) => {
117+ const { metadata : { path, method } } = operation
118+ return slugify ( `${ path } -${ method } ` , [ ] , IGNORE_PATH_PARAM_UNIFIED_PLACEHOLDER )
119+ }
0 commit comments