schemantic_builder 1.0.0
schemantic_builder: ^1.0.0 copied to clipboard
A code generator for schemantic that produces type-safe data classes and JSON schemas from abstract definitions.
The code generator for schemantic. It
generates type-safe data classes and runtime-accessible JSON Schemas from
abstract class definitions annotated with @Schema.
This package is a development-time dependency. The runtime API lives in the
schemantic package.
Building with a coding agent? Install the Genkit Dart skill first.
npx skills add genkit-ai/skills --skill developing-genkit-dartIt teaches your agent the current Genkit Dart APIs and common gotchas. Source, manual install and skills for other languages: genkit-ai/skills.
Installation #
Add schemantic as a regular dependency, and schemantic_builder plus
build_runner as dev dependencies:
dart pub add schemantic
dart pub add dev:schemantic_builder
dart pub add dev:build_runner
Usage #
- Define your schema using the
@Schemaannotation frompackage:schemantic:
import 'package:schemantic/schemantic.dart';
part 'user.g.dart';
@Schema()
abstract class $User {
String get name;
int? get age;
bool get isAdmin;
}
- Run the build runner to generate the implementation:
dart run build_runner build
See the schemantic README for full
documentation on the generated APIs.