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
bodyofoperationId; an operation without a JSON body accepts only an empty one. -
response(
String operationId, int status, Object? body) → List< ContractViolation> -
Validates the response
bodyofoperationIdwithstatus; 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; adispatchis checked against the event schema of itstype(asyncapievent.<type>). -
toString(
) → String -
A string representation of this object.
inherited
-
validate(
Object? value, String schemaName) → List< ContractViolation> -
Validates
valueagainst the schemaschemaNameofcomponents.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 bymake contract-documents;make codegen-checkkeeps it equal todocs/api, docs/DECISIONS.md D-M4-18-17). Decoded once per isolate. -
load(
{Directory? from}) → ContractSchemas -
Loads
docs/api/openapi.yamlanddocs/api/asyncapi.yamlof the repository that holdsfrom(default: the working directory), walking up to the folder that hasdocs/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.