Resource level trait inheritance?


No luck at the Github repo, so maybe I’ll have better luck here.

The spec defines resource level traits, stating they should be applied to all methods within the resource:

A trait may also be applied to a resource by using the is key, which is equivalent to applying the trait to all methods for that resource, whether declared explicitly in the resource definition or inherited from a resource type.

But the spec is silent on whether these traits should also be inherited by nested resources.

Should they?


Hi elevy,

Traits are inherited by methods within a resource, but not by nested resources. There isn’t necessarily an inheritance relationship within nested resources, so when designing RAML we opted to allow for application of a trait to all methods in a resource, but also to maintain flexibility in your API definition by not cascading the trait to all nested resources.




Makes sense. Might be good to explicitly state the lack of trait inheritance to nested resources in the spec.


Totally agree. I’m not actually working on the spec development anymore, but still have contacts over on the RAML workgroup, so I pinged some folks about this, and the other pending PRs/bugs/etc. I expect we’ll see some responses soon :-).