in compiler/src/steps/validate-model.ts [683:713]
function validateBehaviors (typeDef: model.Request | model.Response | model.Interface, openGenerics: Set<string>): void {
if (typeDef.kind !== 'response' && typeDef.behaviors != null && typeDef.behaviors.length > 0) {
context.push('Behaviors')
for (const parent of typeDef.behaviors) {
validateTypeRef(parent.type, parent.generics, openGenerics)
if (parent.type.name === 'AdditionalProperty' && (parent.meta == null || parent.meta.key == null || parent.meta.value == null)) {
modelError(`AdditionalProperty behavior for type '${fqn(typeDef.name)}' requires a 'behavior_meta' decorator with at least 2 arguments (key, value)`)
}
if (parent.type.name === 'AdditionalProperties' && (parent.meta == null || parent.meta.fieldname == null || parent.meta.description == null)) {
modelError(`AdditionalProperties behavior for type '${fqn(typeDef.name)}' requires a 'behavior_meta' decorator with exactly 2 arguments (fieldname, description)`)
}
}
context.pop()
}
// Each attached behavior must be in the behaviors attached to this class or an ancestor
if (typeDef.kind !== 'response' && typeDef.attachedBehaviors != null) {
for (const abh of typeDef.attachedBehaviors) {
const bhName = behaviorByShortName.get(abh)
if (bhName == null) {
modelError(`No type definition for behavior '${abh}'`)
continue
}
if (!behaviorExists(typeDef, bhName)) {
modelError(`Attached behavior '${abh}' not found in type or ancestors`)
}
}
}
}