ContractSchemas class final

The API documents of the repository, loaded once per isolate.

Validates the JSON Schema subset the documents use: type, required, properties, additionalProperties, enum, items, $ref, allOf, oneOf with a discriminator, format for uuid and date-time, and the bounds minimum, maximum, minLength, maxLength, minItems, maxItems and pattern. Every other keyword is ignored. JSON null never validates, because the API has no null (ADR 0053).

Example:

final contract = ContractSchemas.load();
final problems = contract.validate({'id': 'x'}, 'Thread');
// [/id: invalid_format (uuid), /channel_id: required (...), ...]

Properties

hashCode → int
The hash code for this object.
no setterinherited
operations → Iterable<ContractOperation>
Every operation of openapi.yaml.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clientFrame(Map<String, Object?> frame) → List<ContractViolation>
Validates a gateway frame {op, d} a client sends.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
operation(String operationId) → ContractOperation
The operation operationId; throws an ArgumentError for an unknown ID.
request(String operationId, Object? body) → List<ContractViolation>
Validates the request body of operationId; an operation without a JSON body accepts only an empty one.
response(String operationId, int status, Object? body) → List<ContractViolation>
Validates the response body of operationId with status; a status the operation does not list is a violation.
serverFrame(Map<String, Object?> frame) → List<ContractViolation>
Validates a gateway frame {op, d} the server sends; a dispatch is checked against the event schema of its type (asyncapi event.<type>).
toString() → String
A string representation of this object.
inherited
validate(Object? value, String schemaName) → List<ContractViolation>
Validates value against the schema schemaName of components.schemas.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

embedded() → ContractSchemas
The copy of both documents compiled into this library (contract_documents.g.dart, written by make contract-documents; make codegen-check keeps it equal to docs/api, docs/DECISIONS.md D-M4-18-17). Decoded once per isolate.
load({Directory? from}) → ContractSchemas
Loads docs/api/openapi.yaml and docs/api/asyncapi.yaml of the repository that holds from (default: the working directory), walking up to the folder that has docs/api. Without such a folder (an app under test in the macOS app sandbox, whose working directory is / and which cannot read the repository) it uses embedded.