Generate adversarial test cases for a route's input schema.
Produces focused, non-redundant cases:
- Whole-body: send array instead of object, extra unknown key
- Missing required fields (without defaults)
- One wrong-type value per field
- Null for required non-nullable fields
- One format violation per constrained field
- String length (empty, one under
minLength, one over maxLength), numeric
(out of range, non-integer) and array-length
(empty, one under minItems, one over maxItems) boundaries
Format and boundaries come from the field's input-side JSON Schema
(to_field_json_schema), so a field carrying a transform in a pipe and a
nullable field get them too. A bound only a check enforces generates
nothing — JSON Schema can't express it.
Each per-field case is single-fault: valid except for the field it breaks.
It changes one field of a valid base body — options.base when given, else
one built by generate_valid_object — or, for a field that base omits, of
the valid body generate_valid_object_with_field builds around it, so a case
can't also break an object-level rule (adding scope_kind without its
paired scope_id, or slug beside an exactly-one-of id). A field no valid
body carries keeps its wrong-type and null cases on the base and gets no
format or boundary cases, which would test no bound. A per-field case is
emitted only when the field refuses its value, so no case is accidentally
valid.
A void or null input takes no body and gets no cases; a value that is no
schema, or an input that is no object schema, throws rather than yielding
none.