@@ -174,9 +174,14 @@ const generateOpenAPISpec = (definitions, plugin, server, origin, identifier) =>
174174 } else if ( ! route . endsWith ( '/' ) ) {
175175 route = route + '/' ;
176176 }
177+ let opIdentifier = identifier . replace ( / \[ ( .* ) \] / gi, '' ) ;
178+ let operationId = `${ opIdentifier } ${ parts . length ? ( '.' + parts . join ( '.' ) ) : '' } ` ;
179+ operationId = operationId . replace ( / [ ^ A - Z 0 - 9 _ ] + / gi, '_' ) ;
180+ operationId = operationId . replace ( / ^ _ + / gi, '' ) ;
181+ operationId = operationId . replace ( / _ + $ / gi, '' ) ;
177182 let pathData = {
178183 description : def . description ,
179- operationId : ` ${ identifier } ${ parts . length ? ( '.' + parts . join ( '.' ) ) : '' } ` ,
184+ operationId : operationId
180185 } ;
181186 // If we have at least one required parameter...
182187 if ( def . params . filter ( param => ! param . hasOwnProperty ( 'defaultValue' ) . length > 0 ) ) {
@@ -335,7 +340,10 @@ const wellKnowns = {
335340 const AIPlugin = { } ;
336341 AIPlugin . schema_version = 'v1' ;
337342 AIPlugin . name_for_human = plugin . name . slice ( 0 , 20 ) ;
338- AIPlugin . name_for_model = plugin . forModel . name . slice ( 0 , 50 ) . replace ( / [ ^ A - Z 0 - 9 _ ] + / gi, '_' ) ;
343+ AIPlugin . name_for_model = plugin . forModel . name . slice ( 0 , 50 ) ;
344+ AIPlugin . name_for_model = AIPlugin . name_for_model . replace ( / [ ^ A - Z 0 - 9 _ ] + / gi, '_' ) ;
345+ AIPlugin . name_for_model = AIPlugin . name_for_model . replace ( / ^ _ + / gi, '' ) ;
346+ AIPlugin . name_for_model = AIPlugin . name_for_model . replace ( / _ + $ / gi, '' ) ;
339347 AIPlugin . description_for_human = plugin . description . slice ( 0 , 100 ) ;
340348 AIPlugin . description_for_model = plugin . forModel . description . slice ( 0 , 8000 ) ;
341349 AIPlugin . auth = {
0 commit comments