json_schema_utils 1.0.0-dev.10
json_schema_utils: ^1.0.0-dev.10 copied to clipboard
Utilities for building Json Schema Documents to ensure they are valid and assist with reducing the complexity of creating a schema manually
json_schema_utils #
Warning
This Library is under active development and should be considered experimental and subject to large scale change. Please provide feedback of any missing features or bugs!
JSONSchema Utils provides tools to help programmatically build JSONSchema Documents
Compatible with all Dart environments, including Flutter (Web, Mobile and Desktop), Dart Cli, WASM, Server etc.
Features #
- JSONSchema Support
- Opinionated JSONSchema Document for compatibility with external $ref and schema registries
- Required $schema (Currently only supports JSON Schema Draft 7)
- Required $id
- Required title
- Required description
- Validation of spec / schema compliance while building examples
Planned Features #
- Validation of schema restrictions to avoid conflict or impossible schemas
- Support for Additional JSON Schema versions
- Support for utilizing Schema Registries for loading, storage and versioning of schemas (possibly with a separate package TBD)
Getting started #
Usage #
class Example {
Example() {
try {
var schema = JsonSchemaDocument(
"https://indiealexh.dev/schema/vehicle",
"Vehicle Schema",
"A Schema to describe a vehicle",
);
schema
..comment = "This is a comment"
..defaultValue = {"type": "sedan"}
..examples = [
{"type": "sedan"},
{"type": "suv"},
]
..readOnly = true
..writeOnly = false;
} catch (e) {
print('Error: $e');
}
}
}