FM-005 Data Contracts and Schema Validation

Incorrect Optional, Nullable, and Required Field Behavior

The API treats missing, null, empty string, or empty array interchangeably when the spec and business logic require distinct handling.

Failure explanation

The API implementation confuses a missing property, explicit null, an empty value, and a valid value. These are distinct states in JSON and in many business domains. A schema may say a field is optional but non-nullable when present; another field may be required but nullable. Implementations that collapse these distinctions can reject valid requests, accept invalid requests, or erase existing data during updates.

Example

A PATCH contract allows nickname to be omitted to leave it unchanged and allows null to clear it. The server treats both as null and clears the nickname even when the client omitted the property.

How to test

For each relevant property, test: omitted, null, empty string, empty array/object, valid value, wrong type, and boundary value. Test both create and update semantics. Compare actual validation errors with the OpenAPI schema and documented business rules.

Expected behavior

The API distinguishes presence from value and applies the documented required, optional, nullable, and update semantics consistently.

Runnable examples

Each example includes a broken server, a fixed server, an OpenAPI spec, and a clrsig scenario that detects the failure.