Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
2test cases
2files differ
1modified
1new
0deleted
141changed lines
+138 −3insertions / deletions
Base 66df8a7480383ad7d4784464b395df83fd482c7f · PR merge fc206be076c04c3011614ba36cb94821cc7ff9e2 · Head b0cae2fb8da25fe931249cce49f33a63680f89c4 · raw patch
Test case

test/inputs/dart/dart-runtime-type-names.schema

1 generated file · +135 −0
Aschema-dartdefault / TopLevel.dart+135 −0
@@ -0,0 +1,135 @@
1+// To parse this JSON data, do
2+//
3+// final topLevel = topLevelFromJson(jsonString);
4+
5+import 'dart:convert';
6+
7+TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
8+
9+String topLevelToJson(TopLevel data) => json.encode(data.toJson());
10+
11+class TopLevel {
12+ final String code;
13+ final DateTimeClass dateTime;
14+ final EnumValuesClass enumValues;
15+ final FormatExceptionClass formatException;
16+ final RegExpClass regExp;
17+ final Status status;
18+ final DateTime timestamp;
19+
20+ TopLevel({
21+ required this.code,
22+ required this.dateTime,
23+ required this.enumValues,
24+ required this.formatException,
25+ required this.regExp,
26+ required this.status,
27+ required this.timestamp,
28+ });
29+
30+ factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
31+ code: ((x) => RegExp("^[a-z]+\u0024").hasMatch(x) ? x : throw FormatException("Expected matching string"))(((x) => x.length >= 1 && true ? x : throw FormatException("Expected bounded string"))(json["code"])),
32+ dateTime: DateTimeClass.fromJson(json["dateTime"]),
33+ enumValues: EnumValuesClass.fromJson(json["enumValues"]),
34+ formatException: FormatExceptionClass.fromJson(json["formatException"]),
35+ regExp: RegExpClass.fromJson(json["regExp"]),
36+ status: statusValues.map[json["status"]]!,
37+ timestamp: DateTime.parse(json["timestamp"]),
38+ );
39+
40+ Map<String, dynamic> toJson() => {
41+ "code": code,
42+ "dateTime": dateTime.toJson(),
43+ "enumValues": enumValues.toJson(),
44+ "formatException": formatException.toJson(),
45+ "regExp": regExp.toJson(),
46+ "status": statusValues.reverse[status],
47+ "timestamp": timestamp.toIso8601String(),
48+ };
49+}
50+
51+class DateTimeClass {
52+ final int value;
53+
54+ DateTimeClass({
55+ required this.value,
56+ });
57+
58+ factory DateTimeClass.fromJson(Map<String, dynamic> json) => DateTimeClass(
59+ value: json["value"],
60+ );
61+
62+ Map<String, dynamic> toJson() => {
63+ "value": value,
64+ };
65+}
66+
67+class EnumValuesClass {
68+ final String label;
69+
70+ EnumValuesClass({
71+ required this.label,
72+ });
73+
74+ factory EnumValuesClass.fromJson(Map<String, dynamic> json) => EnumValuesClass(
75+ label: json["label"],
76+ );
77+
78+ Map<String, dynamic> toJson() => {
79+ "label": label,
80+ };
81+}
82+
83+class FormatExceptionClass {
84+ final int count;
85+
86+ FormatExceptionClass({
87+ required this.count,
88+ });
89+
90+ factory FormatExceptionClass.fromJson(Map<String, dynamic> json) => FormatExceptionClass(
91+ count: json["count"],
92+ );
93+
94+ Map<String, dynamic> toJson() => {
95+ "count": count,
96+ };
97+}
98+
99+class RegExpClass {
100+ final bool active;
101+
102+ RegExpClass({
103+ required this.active,
104+ });
105+
106+ factory RegExpClass.fromJson(Map<String, dynamic> json) => RegExpClass(
107+ active: json["active"],
108+ );
109+
110+ Map<String, dynamic> toJson() => {
111+ "active": active,
112+ };
113+}
114+
115+enum Status {
116+ READY,
117+ DONE
118+}
119+
120+final statusValues = EnumValues({
121+ "ready": Status.READY,
122+ "done": Status.DONE
123+});
124+
125+class EnumValues<T> {
126+ Map<String, T> map;
127+ late Map<T, String> reverseMap;
128+
129+ EnumValues(this.map);
130+
131+ Map<T, String> get reverse {
132+ reverseMap = map.map((k, v) => MapEntry(v, k));
133+ return reverseMap;
134+ }
135+}
Test case

test/inputs/schema/vega-lite.schema

1 generated file · +3 −3
Mschema-dartdefault / TopLevel.dart+3 −3
@@ -4840,7 +4840,7 @@ class Predicate {
48404840 ///If both month and quarter are provided, month has higher precedence.
48414841 ///`day` cannot be combined with other date.
48424842 ///We accept string for month and day names.
4843-class DateTime {
4843+class DateTimeClass {
48444844
48454845 ///Integer value representing the date from 1-31.
48464846 final double? date;
@@ -4879,7 +4879,7 @@ class DateTime {
48794879 ///Integer value representing the year.
48804880 final double? year;
48814881
4882- DateTime({
4882+ DateTimeClass({
48834883 this.date,
48844884 this.day,
48854885 this.hours,
@@ -4892,7 +4892,7 @@ class DateTime {
48924892 this.year,
48934893 });
48944894
4895- factory DateTime.fromJson(Map<String, dynamic> json) => DateTime(
4895+ factory DateTimeClass.fromJson(Map<String, dynamic> json) => DateTimeClass(
48964896 date: json["date"]?.toDouble() == null ? null : ((x) => x >= 1 && x <= 31 ? x : throw FormatException("Expected bounded number"))(json["date"]?.toDouble()),
48974897 day: json["day"],
48984898 hours: json["hours"]?.toDouble() == null ? null : ((x) => x >= 0 && x <= 23 ? x : throw FormatException("Expected bounded number"))(json["hours"]?.toDouble()),
No generated files match these filters.