JsonSchemaSource class
Names the JSON Schema that the JSON of an @Introspected class is
checked against.
Put it on a class whose JSON comes from outside and has a published
schema: an order from a partner, a configuration file. When the
ObjectMapper has a schemaResolver, it checks the decoded JSON
against the schema before it builds the object, and throws a
JsonSchemaValidationException listing every violation with its path.
The location is one of:
resources:schemas/order.json: a file belowlib/resources/;https://example.com/schemas/order.json(orhttp://);github:owner/repo/path/to/order.json@ref(@refoptional).
The build keeps a copy of a remote schema below lib/resources/, at
JsonSchemaLocations.resourceOf, so it is read like a resource.
@Introspected()
@JsonSchemaSource('resources:schemas/order.json')
class Order {
const Order({required this.id, required this.items});
final String id;
final List<OrderItem> items;
}
Spring (Java): Spring has no counterpart.
Constructors
- JsonSchemaSource(String location)
-
The schema at
location(see the class description for the forms).const
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited