How would you combine an API schema with property-based or fuzz testing?
Answer
Generate valid requests from the schema, then mutate boundaries, optional fields, encodings and structural constraints to produce targeted invalid cases. Assert protocol invariants such as no server errors for client mistakes, schema-valid responses, authorization isolation and consistent idempotency. Rate-limit the campaign, preserve seeds and minimized requests, and add important failures as deterministic regression tests.
Strong answer includes
- generates both schema-valid and targeted invalid requests
- asserts security and protocol invariants
- preserves minimized failures as regression cases
Practical example
Fuzzing an OpenAPI-described endpoint with deeply nested and oversized JSON payloads triggers a 500 error instead of the expected 400 for malformed input, revealing an unhandled stack-depth exception; the minimized failing payload gets saved as a permanent regression test rather than being lost when the fuzzing campaign ends.