File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 1616
1717library ;
1818
19+ import "dart:convert" ;
20+
1921import "dogs_core.dart" ;
2022
2123/// Creates a schema type representing a string.
@@ -59,6 +61,15 @@ SchemaType enumeration(List<String> values) {
5961 return SchemaType .string.property (SchemaProperties .$enum, values);
6062}
6163
64+ /// Parses a JSON string into a [SchemaType] .
65+ SchemaType parseSchema (String json) {
66+ final map = jsonDecode (json);
67+ if (map is ! Map <String , dynamic >) {
68+ throw ArgumentError ("Invalid schema JSON: $json " );
69+ }
70+ return SchemaType .fromProperties (map);
71+ }
72+
6273/// Extension methods for SchemaType to provide a fluent API for schema definitions.
6374extension SchemaTypeExtension on SchemaType {
6475 /// Makes this schema type an array of itself.
You can’t perform that action at this time.
0 commit comments