@@ -23,13 +23,6 @@ import { JsonSpec } from '../model/json-spec'
23
23
import assert from 'assert'
24
24
import { TypeName } from '../model/metamodel'
25
25
26
- // Superclasses (i.e. non-leaf types, who are inherited or implemented) that are ok to be used as field types because
27
- // they're used as definition reuse and not as polymorphic types.
28
- // See also validateIsLeafType() below.
29
- const allowedSuperclasses = new Set ( [
30
- '_types:ErrorCause'
31
- ] )
32
-
33
26
enum TypeDefKind {
34
27
type ,
35
28
behavior
@@ -231,7 +224,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
231
224
modelError ( `Type ${ fqn ( endpoint . request ) } is not a request definition` )
232
225
} else {
233
226
validateTypeDef ( reqType )
234
- validateIsLeafType ( endpoint . request )
235
227
236
228
// Request path properties and url template properties should be the same
237
229
const reqProperties = new Set ( reqType . path . map ( p => p . name ) )
@@ -276,7 +268,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
276
268
modelError ( `Type ${ fqn ( endpoint . response ) } not found` )
277
269
} else {
278
270
validateTypeDef ( respType )
279
- validateIsLeafType ( endpoint . response )
280
271
}
281
272
}
282
273
}
@@ -731,44 +722,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
731
722
}
732
723
}
733
724
734
- // Validates that use of non-leaf types (i.e. those who are inherited or implemented) are used either
735
- // in contexts that are distinct from that of their children, or are abstract parent classes providing a way
736
- // way to identify actual concrete implementations in strongly typed languages.
737
- function validateIsLeafType ( type : model . TypeName ) : void {
738
- if ( parentTypes . has ( fqn ( type ) ) ) {
739
- // Aggregations are disambiguated with the 'typed_keys' parameter
740
- if ( type . namespace === 'aggregations' ) return
741
-
742
- const fqName = fqn ( type )
743
-
744
- switch ( fqName ) {
745
- // Base type also used as property, no polymorphic usage
746
- case '_builtins:ErrorCause' :
747
- case 'x_pack.enrich:EnrichPolicy' :
748
- case 'x_pack.info.x_pack_usage:XPackUsage' :
749
- case 'x_pack.info.x_pack_usage:SecurityFeatureToggle' :
750
- case 'x_pack.watcher.watcher_stats:WatchRecordQueuedStats' :
751
- case 'x_pack.security.user.get_user:XPackUser' :
752
- case 'cluster.nodes_stats:MemoryStats' :
753
- case 'search.search:SearchResponse' :
754
- return
755
-
756
- // Have a "type" attribute that identifies the variant
757
- case 'mapping.types:PropertyBase' :
758
- case 'analysis.token_filters:TokenFilterBase' :
759
- return
760
-
761
- // Single subclass with no additional properties, can probably be removed
762
- case 'x_pack.watcher.input:HttpInputRequestDefinition' :
763
- return
764
- }
765
-
766
- if ( ! allowedSuperclasses . has ( fqName ) ) {
767
- modelError ( `Non-leaf type cannot be used here: '${ fqName } '` )
768
- }
769
- }
770
- }
771
-
772
725
// -----------------------------------------------------------------------------------------------
773
726
// Value_Of validations
774
727
@@ -777,7 +730,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
777
730
switch ( valueOf . kind ) {
778
731
case 'instance_of' :
779
732
validateTypeRef ( valueOf . type , valueOf . generics , openGenerics )
780
- validateIsLeafType ( valueOf . type )
781
733
break
782
734
783
735
case 'array_of' :
0 commit comments