schema-contains-only-for-arrays
Overview
This rule belongs to the openapi-v3-standards-linting ruleset and states that:
The property contains can only be used for Schema Objects when the type is either unspecified (implying any type) or set as array. This property is not applicable for any other types.
| Property | Value |
|---|---|
| Enabled | Yes |
| Maximum Severity | Warning |
| Message | Property contains is not applicable for the current Schema Object type. |
| Code | OPENAPI3STANDARDS_L164 |
| Type | Linting |
| Rule System | Semantic |
| Broad Category | Schemas |
| Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
| Tags | openapi3 openapi standards semantic linting contains array schema |
Suggested Fixes
- Ensure that the value of
typein the Schema Object is not set to a value other thanarray. - Type names are compared in a case-sensitive manner.
- If you use the
containskeyword, ensure that the data instance you intend to validate can be an array. - If the type of the instance can vary i.e. it can be an array or some other type, consider removing the
typekeyword to allow any types. If you use theoneOf/anyOfconstructs instead, consider moving thecontainsto theoneOf/anyOfschema that has the type set asarray.