valid-trait-name
Overview
This rule belongs to the raml-validation
ruleset and states that:
A method can specify one or more traits it inherits by using the optional is
property. Each element in the is
list must be the name of a trait defined within the root-level traits
property or in a library. A trait can also be applied to a resource by using the is
property.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Error |
Message | Trait with provided name could not be found. |
Code | RAML_V501 |
Type | Validation |
Rule System | Semantic |
Broad Category | Resource Types and Traits |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | raml semantic validation name trait method resource |
Suggested Fixes
- Ensure that the trait name matches name of the pre-defined trait exactly and has no typos. Names are compared in a case-sensitive manner.
- Ensure that a trait with that name is defined in the root object level
traits
property in the same RAML file or an external library. - If you are trying to reference a library's trait, ensure that the library is accessible and the library key used in the reference matches with the library declaration. Also ensure that the trait does indeed exist in the same library.
For More Information
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#applying-resource-types-and-traits
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#resource-types-and-traits
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#resource-property
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#methods
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-08/raml-08.md#applying-resource-types-and-traits
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-08/raml-08.md#resource-types-and-traits
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-08/raml-08.md#resources-and-nested-resources
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-08/raml-08.md#methods
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md
- https://github.com/raml-org/raml-spec/blob/master/versions/raml-08/raml-08.md
- https://docs.apimatic.io/rulesets/overview/