@@ -181,9 +181,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
181181 return ep . request != null && ep . response != null
182182 }
183183
184- // Check that all type names are unique
185- validateUniqueTypeNames ( apiModel , modelError )
186-
187184 // Validate all endpoints. We start by those that are ready for validation so that transitive validation of common
188185 // data types is associated with these endpoints and their errors are not filtered out in the error report.
189186 apiModel . endpoints . filter ( ep => readyForValidation ( ep ) ) . forEach ( validateEndpoint )
@@ -217,63 +214,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
217214
218215 // -----------------------------------------------------------------------------------------------
219216
220- /**
221- * Validates that all type names in the model are unique
222- */
223- function validateUniqueTypeNames ( apiModel : model . Model , modelError : ( msg : string ) => void ) : void {
224- const existingDuplicates : Record < string , string [ ] > = {
225- Action : [ 'indices.modify_data_stream' , 'indices.update_aliases' , 'watcher._types' ] ,
226- Actions : [ 'ilm._types' , 'security.put_privileges' , 'watcher._types' ] ,
227- ComponentTemplate : [ 'cat.component_templates' , 'cluster._types' ] ,
228- Context : [ '_global.get_script_context' , '_global.search._types' , 'nodes._types' ] ,
229- DatabaseConfigurationMetadata : [ 'ingest.get_geoip_database' , 'ingest.get_ip_location_database' ] ,
230- Datafeed : [ 'ml._types' , 'xpack.usage' ] ,
231- Destination : [ '_global.reindex' , 'transform._types' ] ,
232- Feature : [ 'features._types' , 'indices.get' , 'xpack.info' ] ,
233- Features : [ 'indices.get' , 'xpack.info' ] ,
234- Filter : [ '_global.termvectors' , 'ml._types' ] ,
235- IndexingPressure : [ 'cluster.stats' , 'indices._types' , 'nodes._types' ] ,
236- IndexingPressureMemory : [ 'cluster.stats' , 'indices._types' , 'nodes._types' ] ,
237- Ingest : [ 'ingest._types' , 'nodes._types' ] ,
238- MigrationFeature : [ 'migration.get_feature_upgrade_status' , 'migration.post_feature_upgrade' ] ,
239- Operation : [ '_global.mget' , '_global.mtermvectors' ] ,
240- Phase : [ 'ilm._types' , 'xpack.usage' ] ,
241- Phases : [ 'ilm._types' , 'xpack.usage' ] ,
242- Pipeline : [ 'ingest._types' , 'logstash._types' ] ,
243- Policy : [ 'enrich._types' , 'ilm._types' , 'slm._types' ] ,
244- RequestItem : [ '_global.msearch' , '_global.msearch_template' ] ,
245- ResponseItem : [ '_global.bulk' , '_global.mget' , '_global.msearch' ] ,
246- RoleMapping : [ 'security._types' , 'xpack.usage' ] ,
247- RuntimeFieldTypes : [ 'cluster.stats' , 'xpack.usage' ] ,
248- ShardsStats : [ 'indices.field_usage_stats' , 'snapshot._types' ] ,
249- ShardStats : [ 'ccr._types' , 'indices.stats' ] ,
250- Source : [ '_global.reindex' , 'transform._types' ] ,
251- Token : [ '_global.termvectors' , 'security.authenticate' , 'security.create_service_token' , 'security.enroll_kibana' ]
252- }
253-
254- // collect namespaces for each type name
255- const typeNames = new Map < string , string [ ] > ( )
256- for ( const type of apiModel . types ) {
257- const name = type . name . name
258- if ( name !== 'Request' && name !== 'Response' && name !== 'ResponseBase' ) {
259- const namespaces = typeNames . get ( name ) ?? [ ]
260- namespaces . push ( type . name . namespace )
261- typeNames . set ( name , namespaces )
262- }
263- }
264-
265- // check for duplicates
266- for ( const [ name , namespaces ] of typeNames ) {
267- if ( namespaces . length > 1 ) {
268- const allowedDuplicates = existingDuplicates [ name ] ?? [ ]
269- const hasUnexpectedDuplicate = namespaces . some ( ns => ! allowedDuplicates . includes ( ns ) )
270- if ( hasUnexpectedDuplicate ) {
271- modelError ( `${ name } is present in multiple namespaces: ${ namespaces . sort ( ) . join ( ' and ' ) } ` )
272- }
273- }
274- }
275- }
276-
277217 /**
278218 * Validate an endpoint
279219 */
0 commit comments