You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| const | string | Asserts equality of a value. The behavior is the same as the `enum` assertion with exactly one value. See [const example](#const-example). |
50
+
| contains | [string] | Asserts that all listed strings are included in the value array. See [contains example](#contains-example). |
50
51
| defined | boolean | Asserts a property is defined. See [defined example](#defined-example). |
51
52
| disallowed | [string] | Asserts all listed values are not defined. See [disallowed example](#disallowed-example). |
52
53
| enum | [string] | Asserts a value is within a predefined list of values. Providing a single value in a list is an equality check. See [enum example](#enum-example). |
@@ -315,6 +316,32 @@ rules:
315
316
message: Only application/json can be used
316
317
```
317
318
319
+
### `contains` example
320
+
321
+
Use `contains` to assert that every listed string appears as an element of a **string array** property (for example, the `required` field of a `Schema`).
322
+
This differs from `required`, which checks for **object keys** rather than array values.
323
+
324
+
The following example asserts that the `required` array of every schema includes both `page` and `items`.
325
+
326
+
```yaml Response example
327
+
rules:
328
+
rule/list-schema-required-fields:
329
+
subject:
330
+
type: Schema
331
+
property: required
332
+
where:
333
+
- subject:
334
+
type: Schema
335
+
property: properties
336
+
assertions:
337
+
defined: true
338
+
message: 'List schemas must include "page" and "items" in the required array'
339
+
assertions:
340
+
contains:
341
+
- page
342
+
- items
343
+
```
344
+
318
345
### `defined` example
319
346
320
347
The following example asserts that `x-codeSamples` is defined.
0 commit comments