api_contract library

Runtime API response contract validator for Flutter/Dart.

Detects mismatches between expected API contracts and actual responses, preventing silent bugs when the backend changes its response structure.

Classes

ApiContract
Defines the expected shape of an API JSON response.
ApiContractConfig
Global configuration for the API contract validator.
ContractField
Defines the expected shape and constraints of a single field within an ApiContract.
ContractValidationResult
The result of validating a JSON response against an ApiContract.
Reporter
Reports contract validation results based on the current ApiContractConfig settings.
Violation
Represents a single contract violation found during validation.

Enums

ContractMode
Defines whether unexpected fields in the response trigger violations.
FieldType
Represents the expected data type of a field in an HTTP contract.
ViolationBehavior
Defines how violations are handled at runtime.
ViolationType
The type of contract violation detected during validation.

Exceptions / Errors

ContractViolationException
Exception thrown when contract validation fails and throwing is enabled.