Applying trait to all resources


#1

Very dumb question: how do I define a trait that is applied to all resources?

EDIT: Extending my question a little.

I’d like to create a trait that defines custom X- response headers that are added to all responses (all status codes) for all resources of the API.

How can I do that?


#2

Hi David,

I think (someone correct me if I’m wrong) that today you would need to fully specify the header for each response code in some trait, and then either include that in some resourceType you applied to each resource, or apply the trait within resource.

For RAML 1.0, I know the workgroup is looking at additional API-level patterns to increase the DRYness of API definitions - I think this is a good candidate. I could see a few improvements to be made, including allowing definitions of ranges or wildcards of response codes (so you don’t need to write 200, 201, etc explicitly) as well as something similar to defaultMediaType, but for traits and/or resourceTypes.

@usarid @damipoo any thoughts on this?


#3

Any progress on this?