Generated-output differences

quicktype output changed between the PR base and head revisions.
← Back to the pull request
840files differ
809modified
31new
0deleted
25,873changed lines
+14,475 −11,398insertions / deletions
Base 3061a7bd52c02eebde32dc0c6fb46069f0ebc0a4 · PR merge 35d1d379e550ff243629d27599f71e67970dbfd4 · Head 786bd3de656ed6f6933ec2b19a225c719d95546f · raw patch
Mcomment-injection-objective-c/test/inputs/schema/comment-injection.schema/default/QTTopLevel.h+6 −6
@@ -31,12 +31,6 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding en
3131 /// }
3232 /// }
3333 @interface QTTopLevel : NSObject
34-/// Ends with a backslash \.
35-@property (nonatomic, nullable, copy) NSString *trailingBackslash;
36-/// Ends with a quote "
37-@property (nonatomic, nullable, copy) NSString *trailingQuote;
38-/// Ends with a triple quote """
39-@property (nonatomic, nullable, copy) NSString *trailingTripleQuote;
4034 /// Property delimiters:
4135 /// */
4236 /// /*
@@ -50,6 +44,12 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding en
5044 /// }
5145 /// }
5246 @property (nonatomic, copy) NSString *value;
47+/// Ends with a backslash \.
48+@property (nonatomic, nullable, copy) NSString *trailingBackslash;
49+/// Ends with a quote "
50+@property (nonatomic, nullable, copy) NSString *trailingQuote;
51+/// Ends with a triple quote """
52+@property (nonatomic, nullable, copy) NSString *trailingTripleQuote;
5353
5454 + (_Nullable instancetype)fromJSON:(NSString *)json encoding:(NSStringEncoding)encoding error:(NSError *_Nullable *)error;
5555 + (_Nullable instancetype)fromData:(NSData *)data error:(NSError *_Nullable *)error;
Mcomment-injection-objective-c/test/inputs/schema/comment-injection.schema/default/QTTopLevel.m+1 −1
@@ -54,10 +54,10 @@ NSString *_Nullable QTTopLevelToJSON(QTTopLevel *topLevel, NSStringEncoding enco
5454 {
5555 static NSDictionary<NSString *, NSString *> *properties;
5656 return properties = properties ? properties : @{
57+ @"value": @"value",
5758 @"trailingBackslash": @"trailingBackslash",
5859 @"trailingQuote": @"trailingQuote",
5960 @"trailingTripleQuote": @"trailingTripleQuote",
60- @"value": @"value",
6161 };
6262 }
Mcomment-injection-typescript/test/inputs/schema/comment-injection.schema/default/TopLevel.ts+13 −13
@@ -22,18 +22,6 @@
2222 * }
2323 */
2424 export interface TopLevel {
25- /**
26- * Ends with a backslash \
27- */
28- trailingBackslash?: string;
29- /**
30- * Ends with a quote "
31- */
32- trailingQuote?: string;
33- /**
34- * Ends with a triple quote """
35- */
36- trailingTripleQuote?: string;
3725 /**
3826 * Property delimiters:
3927 * * /
@@ -49,6 +37,18 @@ export interface TopLevel {
4937 * }
5038 */
5139 value: string;
40+ /**
41+ * Ends with a backslash \
42+ */
43+ trailingBackslash?: string;
44+ /**
45+ * Ends with a quote "
46+ */
47+ trailingQuote?: string;
48+ /**
49+ * Ends with a triple quote """
50+ */
51+ trailingTripleQuote?: string;
5252 }
5353
5454 // Converts JSON strings to/from your types
@@ -218,9 +218,9 @@ function r(name: string) {
218218
219219 const typeMap: any = {
220220 "TopLevel": o([
221+ { json: "value", js: "value", typ: "" },
221222 { json: "trailingBackslash", js: "trailingBackslash", typ: u(undefined, "") },
222223 { json: "trailingQuote", js: "trailingQuote", typ: u(undefined, "") },
223224 { json: "trailingTripleQuote", js: "trailingTripleQuote", typ: u(undefined, "") },
224- { json: "value", js: "value", typ: "" },
225225 ], false),
226226 };
Mschema-cjson/test/inputs/schema/accessors.schema/default/TopLevel.c+20 −20
@@ -81,13 +81,8 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
8181 if (NULL != j) {
8282 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
8383 memset(x, 0, sizeof(struct TopLevel));
84- if (cJSON_HasObjectItem(j, "bar")) {
85- x->barre = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "bar")));
86- }
87- else {
88- if (NULL != (x->barre = cJSON_malloc(sizeof(char)))) {
89- x->barre[0] = '\0';
90- }
84+ if (cJSON_HasObjectItem(j, "union")) {
85+ x->unionization = cJSON_GetUnionValue(cJSON_GetObjectItemCaseSensitive(j, "union"));
9186 }
9287 if (cJSON_HasObjectItem(j, "enum")) {
9388 x->enumerification = cJSON_GetEnumValue(cJSON_GetObjectItemCaseSensitive(j, "enum"));
@@ -100,8 +95,13 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
10095 x->foo[0] = '\0';
10196 }
10297 }
103- if (cJSON_HasObjectItem(j, "union")) {
104- x->unionization = cJSON_GetUnionValue(cJSON_GetObjectItemCaseSensitive(j, "union"));
98+ if (cJSON_HasObjectItem(j, "bar")) {
99+ x->barre = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "bar")));
100+ }
101+ else {
102+ if (NULL != (x->barre = cJSON_malloc(sizeof(char)))) {
103+ x->barre[0] = '\0';
104+ }
105105 }
106106 }
107107 }
@@ -112,12 +112,7 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
112112 cJSON * j = NULL;
113113 if (NULL != x) {
114114 if (NULL != (j = cJSON_CreateObject())) {
115- if (NULL != x->barre) {
116- cJSON_AddStringToObject(j, "bar", x->barre);
117- }
118- else {
119- cJSON_AddStringToObject(j, "bar", "");
120- }
115+ cJSON_AddItemToObject(j, "union", cJSON_CreateUnion(x->unionization));
121116 cJSON_AddItemToObject(j, "enum", cJSON_CreateEnum(x->enumerification));
122117 if (NULL != x->foo) {
123118 cJSON_AddStringToObject(j, "foo", x->foo);
@@ -125,7 +120,12 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
125120 else {
126121 cJSON_AddStringToObject(j, "foo", "");
127122 }
128- cJSON_AddItemToObject(j, "union", cJSON_CreateUnion(x->unionization));
123+ if (NULL != x->barre) {
124+ cJSON_AddStringToObject(j, "bar", x->barre);
125+ }
126+ else {
127+ cJSON_AddStringToObject(j, "bar", "");
128+ }
129129 }
130130 }
131131 return j;
@@ -145,14 +145,14 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
145145
146146 void cJSON_DeleteTopLevel(struct TopLevel * x) {
147147 if (NULL != x) {
148- if (NULL != x->barre) {
149- cJSON_free(x->barre);
148+ if (NULL != x->unionization) {
149+ cJSON_DeleteUnion(x->unionization);
150150 }
151151 if (NULL != x->foo) {
152152 cJSON_free(x->foo);
153153 }
154- if (NULL != x->unionization) {
155- cJSON_DeleteUnion(x->unionization);
154+ if (NULL != x->barre) {
155+ cJSON_free(x->barre);
156156 }
157157 cJSON_free(x);
158158 }
Mschema-cjson/test/inputs/schema/accessors.schema/default/TopLevel.h+2 −2
@@ -49,10 +49,10 @@ struct Union {
4949 };
5050
5151 struct TopLevel {
52- char * barre;
52+ struct Union * unionization;
5353 enum Enum enumerification;
5454 char * foo;
55- struct Union * unionization;
55+ char * barre;
5656 };
5757
5858 enum Enum cJSON_GetEnumValue(const cJSON * j);
Mschema-cjson/test/inputs/schema/bool-string.schema/default/TopLevel.c+67 −67
@@ -62,6 +62,31 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
6262 if (NULL != j) {
6363 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
6464 memset(x, 0, sizeof(struct TopLevel));
65+ if (cJSON_HasObjectItem(j, "one")) {
66+ x->one = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "one")));
67+ }
68+ else {
69+ if (NULL != (x->one = cJSON_malloc(sizeof(char)))) {
70+ x->one[0] = '\0';
71+ }
72+ }
73+ if (cJSON_HasObjectItem(j, "optional")) {
74+ x->optional = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional")));
75+ }
76+ if ((cJSON_HasObjectItem(j, "nullable")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "nullable")))) {
77+ x->nullable = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "nullable")));
78+ }
79+ if (cJSON_HasObjectItem(j, "arrOne")) {
80+ list_t * x1 = list_create(false, NULL);
81+ if (NULL != x1) {
82+ cJSON * e1 = NULL;
83+ cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "arrOne");
84+ cJSON_ArrayForEach(e1, j1) {
85+ list_add_tail(x1, strdup(cJSON_GetStringValue(e1)), sizeof(char *));
86+ }
87+ x->arr_one = x1;
88+ }
89+ }
6590 if (cJSON_HasObjectItem(j, "arrNullable")) {
6691 list_t * x1 = list_create(false, NULL);
6792 if (NULL != x1) {
@@ -78,31 +103,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
78103 x->arr_nullable = x1;
79104 }
80105 }
81- if (cJSON_HasObjectItem(j, "arrOne")) {
82- list_t * x1 = list_create(false, NULL);
83- if (NULL != x1) {
84- cJSON * e1 = NULL;
85- cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "arrOne");
86- cJSON_ArrayForEach(e1, j1) {
87- list_add_tail(x1, strdup(cJSON_GetStringValue(e1)), sizeof(char *));
88- }
89- x->arr_one = x1;
90- }
91- }
92- if ((cJSON_HasObjectItem(j, "nullable")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "nullable")))) {
93- x->nullable = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "nullable")));
94- }
95- if (cJSON_HasObjectItem(j, "one")) {
96- x->one = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "one")));
97- }
98- else {
99- if (NULL != (x->one = cJSON_malloc(sizeof(char)))) {
100- x->one[0] = '\0';
101- }
102- }
103- if (cJSON_HasObjectItem(j, "optional")) {
104- x->optional = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional")));
105- }
106106 if (cJSON_HasObjectItem(j, "unionWithBool")) {
107107 x->union_with_bool = cJSON_GetUnionWithBoolValue(cJSON_GetObjectItemCaseSensitive(j, "unionWithBool"));
108108 }
@@ -118,6 +118,31 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
118118 cJSON * j = NULL;
119119 if (NULL != x) {
120120 if (NULL != (j = cJSON_CreateObject())) {
121+ if (NULL != x->one) {
122+ cJSON_AddStringToObject(j, "one", x->one);
123+ }
124+ else {
125+ cJSON_AddStringToObject(j, "one", "");
126+ }
127+ if (NULL != x->optional) {
128+ cJSON_AddStringToObject(j, "optional", x->optional);
129+ }
130+ if (NULL != x->nullable) {
131+ cJSON_AddStringToObject(j, "nullable", x->nullable);
132+ }
133+ else {
134+ cJSON_AddNullToObject(j, "nullable");
135+ }
136+ if (NULL != x->arr_one) {
137+ cJSON * j1 = cJSON_AddArrayToObject(j, "arrOne");
138+ if (NULL != j1) {
139+ char * x1 = list_get_head(x->arr_one);
140+ while (NULL != x1) {
141+ cJSON_AddItemToArray(j1, cJSON_CreateString(x1));
142+ x1 = list_get_next(x->arr_one);
143+ }
144+ }
145+ }
121146 if (NULL != x->arr_nullable) {
122147 cJSON * j1 = cJSON_AddArrayToObject(j, "arrNullable");
123148 if (NULL != j1) {
@@ -133,31 +158,6 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
133158 }
134159 }
135160 }
136- if (NULL != x->arr_one) {
137- cJSON * j1 = cJSON_AddArrayToObject(j, "arrOne");
138- if (NULL != j1) {
139- char * x1 = list_get_head(x->arr_one);
140- while (NULL != x1) {
141- cJSON_AddItemToArray(j1, cJSON_CreateString(x1));
142- x1 = list_get_next(x->arr_one);
143- }
144- }
145- }
146- if (NULL != x->nullable) {
147- cJSON_AddStringToObject(j, "nullable", x->nullable);
148- }
149- else {
150- cJSON_AddNullToObject(j, "nullable");
151- }
152- if (NULL != x->one) {
153- cJSON_AddStringToObject(j, "one", x->one);
154- }
155- else {
156- cJSON_AddStringToObject(j, "one", "");
157- }
158- if (NULL != x->optional) {
159- cJSON_AddStringToObject(j, "optional", x->optional);
160- }
161161 cJSON_AddItemToObject(j, "unionWithBool", cJSON_CreateUnionWithBool(x->union_with_bool));
162162 cJSON_AddItemToObject(j, "unionWithBoolAndEnum", cJSON_CreateUnionWithBool(x->union_with_bool_and_enum));
163163 }
@@ -179,15 +179,14 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
179179
180180 void cJSON_DeleteTopLevel(struct TopLevel * x) {
181181 if (NULL != x) {
182- if (NULL != x->arr_nullable) {
183- char * x1 = list_get_head(x->arr_nullable);
184- while (NULL != x1) {
185- if ((void *)0xDEADBEEF != x1) {
186- cJSON_free(x1);
187- }
188- x1 = list_get_next(x->arr_nullable);
189- }
190- list_release(x->arr_nullable);
182+ if (NULL != x->one) {
183+ cJSON_free(x->one);
184+ }
185+ if (NULL != x->optional) {
186+ cJSON_free(x->optional);
187+ }
188+ if (NULL != x->nullable) {
189+ cJSON_free(x->nullable);
191190 }
192191 if (NULL != x->arr_one) {
193192 char * x1 = list_get_head(x->arr_one);
@@ -197,14 +196,15 @@ void cJSON_DeleteTopLevel(struct TopLevel * x) {
197196 }
198197 list_release(x->arr_one);
199198 }
200- if (NULL != x->nullable) {
201- cJSON_free(x->nullable);
202- }
203- if (NULL != x->one) {
204- cJSON_free(x->one);
205- }
206- if (NULL != x->optional) {
207- cJSON_free(x->optional);
199+ if (NULL != x->arr_nullable) {
200+ char * x1 = list_get_head(x->arr_nullable);
201+ while (NULL != x1) {
202+ if ((void *)0xDEADBEEF != x1) {
203+ cJSON_free(x1);
204+ }
205+ x1 = list_get_next(x->arr_nullable);
206+ }
207+ list_release(x->arr_nullable);
208208 }
209209 if (NULL != x->union_with_bool) {
210210 cJSON_DeleteUnionWithBool(x->union_with_bool);
Mschema-cjson/test/inputs/schema/bool-string.schema/default/TopLevel.h+3 −3
@@ -43,11 +43,11 @@ struct UnionWithBool {
4343 };
4444
4545 struct TopLevel {
46- list_t * arr_nullable;
47- list_t * arr_one;
48- char * nullable;
4946 char * one;
5047 char * optional;
48+ char * nullable;
49+ list_t * arr_one;
50+ list_t * arr_nullable;
5151 struct UnionWithBool * union_with_bool;
5252 struct UnionWithBool * union_with_bool_and_enum;
5353 };
Mschema-cjson/test/inputs/schema/comment-injection.schema/default/TopLevel.c+17 −17
@@ -22,6 +22,14 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2222 if (NULL != j) {
2323 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
2424 memset(x, 0, sizeof(struct TopLevel));
25+ if (cJSON_HasObjectItem(j, "value")) {
26+ x->value = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "value")));
27+ }
28+ else {
29+ if (NULL != (x->value = cJSON_malloc(sizeof(char)))) {
30+ x->value[0] = '\0';
31+ }
32+ }
2533 if (cJSON_HasObjectItem(j, "trailingBackslash")) {
2634 x->trailing_backslash = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "trailingBackslash")));
2735 }
@@ -31,14 +39,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
3139 if (cJSON_HasObjectItem(j, "trailingTripleQuote")) {
3240 x->trailing_triple_quote = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "trailingTripleQuote")));
3341 }
34- if (cJSON_HasObjectItem(j, "value")) {
35- x->value = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "value")));
36- }
37- else {
38- if (NULL != (x->value = cJSON_malloc(sizeof(char)))) {
39- x->value[0] = '\0';
40- }
41- }
4242 }
4343 }
4444 return x;
@@ -48,6 +48,12 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
4848 cJSON * j = NULL;
4949 if (NULL != x) {
5050 if (NULL != (j = cJSON_CreateObject())) {
51+ if (NULL != x->value) {
52+ cJSON_AddStringToObject(j, "value", x->value);
53+ }
54+ else {
55+ cJSON_AddStringToObject(j, "value", "");
56+ }
5157 if (NULL != x->trailing_backslash) {
5258 cJSON_AddStringToObject(j, "trailingBackslash", x->trailing_backslash);
5359 }
@@ -57,12 +63,6 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
5763 if (NULL != x->trailing_triple_quote) {
5864 cJSON_AddStringToObject(j, "trailingTripleQuote", x->trailing_triple_quote);
5965 }
60- if (NULL != x->value) {
61- cJSON_AddStringToObject(j, "value", x->value);
62- }
63- else {
64- cJSON_AddStringToObject(j, "value", "");
65- }
6666 }
6767 }
6868 return j;
@@ -82,6 +82,9 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
8282
8383 void cJSON_DeleteTopLevel(struct TopLevel * x) {
8484 if (NULL != x) {
85+ if (NULL != x->value) {
86+ cJSON_free(x->value);
87+ }
8588 if (NULL != x->trailing_backslash) {
8689 cJSON_free(x->trailing_backslash);
8790 }
@@ -91,9 +94,6 @@ void cJSON_DeleteTopLevel(struct TopLevel * x) {
9194 if (NULL != x->trailing_triple_quote) {
9295 cJSON_free(x->trailing_triple_quote);
9396 }
94- if (NULL != x->value) {
95- cJSON_free(x->value);
96- }
9797 cJSON_free(x);
9898 }
9999 }
Mschema-cjson/test/inputs/schema/comment-injection.schema/default/TopLevel.h+12 −12
@@ -49,18 +49,6 @@ extern "C" {
4949 * }
5050 */
5151 struct TopLevel {
52- /**
53- * Ends with a backslash \.
54- */
55- char * trailing_backslash;
56- /**
57- * Ends with a quote "
58- */
59- char * trailing_quote;
60- /**
61- * Ends with a triple quote """
62- */
63- char * trailing_triple_quote;
6452 /**
6553 * Property delimiters:
6654 * * /
@@ -76,6 +64,18 @@ struct TopLevel {
7664 * }
7765 */
7866 char * value;
67+ /**
68+ * Ends with a backslash \.
69+ */
70+ char * trailing_backslash;
71+ /**
72+ * Ends with a quote "
73+ */
74+ char * trailing_quote;
75+ /**
76+ * Ends with a triple quote """
77+ */
78+ char * trailing_triple_quote;
7979 };
8080
8181 struct TopLevel * cJSON_ParseTopLevel(const char * s);
Mschema-cjson/test/inputs/schema/date-time-or-string.schema/default/TopLevel.c+17 −17
@@ -22,14 +22,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2222 if (NULL != j) {
2323 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
2424 memset(x, 0, sizeof(struct TopLevel));
25- if (cJSON_HasObjectItem(j, "bar")) {
26- x->bar = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "bar")));
27- }
28- else {
29- if (NULL != (x->bar = cJSON_malloc(sizeof(char)))) {
30- x->bar[0] = '\0';
31- }
32- }
3325 if (cJSON_HasObjectItem(j, "foo")) {
3426 x->foo = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "foo")));
3527 }
@@ -38,6 +30,14 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
3830 x->foo[0] = '\0';
3931 }
4032 }
33+ if (cJSON_HasObjectItem(j, "bar")) {
34+ x->bar = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "bar")));
35+ }
36+ else {
37+ if (NULL != (x->bar = cJSON_malloc(sizeof(char)))) {
38+ x->bar[0] = '\0';
39+ }
40+ }
4141 }
4242 }
4343 return x;
@@ -47,18 +47,18 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
4747 cJSON * j = NULL;
4848 if (NULL != x) {
4949 if (NULL != (j = cJSON_CreateObject())) {
50- if (NULL != x->bar) {
51- cJSON_AddStringToObject(j, "bar", x->bar);
52- }
53- else {
54- cJSON_AddStringToObject(j, "bar", "");
55- }
5650 if (NULL != x->foo) {
5751 cJSON_AddStringToObject(j, "foo", x->foo);
5852 }
5953 else {
6054 cJSON_AddStringToObject(j, "foo", "");
6155 }
56+ if (NULL != x->bar) {
57+ cJSON_AddStringToObject(j, "bar", x->bar);
58+ }
59+ else {
60+ cJSON_AddStringToObject(j, "bar", "");
61+ }
6262 }
6363 }
6464 return j;
@@ -78,12 +78,12 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
7878
7979 void cJSON_DeleteTopLevel(struct TopLevel * x) {
8080 if (NULL != x) {
81- if (NULL != x->bar) {
82- cJSON_free(x->bar);
83- }
8481 if (NULL != x->foo) {
8582 cJSON_free(x->foo);
8683 }
84+ if (NULL != x->bar) {
85+ cJSON_free(x->bar);
86+ }
8787 cJSON_free(x);
8888 }
8989 }
Mschema-cjson/test/inputs/schema/date-time-or-string.schema/default/TopLevel.h+1 −1
@@ -35,8 +35,8 @@ extern "C" {
3535 #endif
3636
3737 struct TopLevel {
38- char * bar;
3938 char * foo;
39+ char * bar;
4040 };
4141
4242 struct TopLevel * cJSON_ParseTopLevel(const char * s);
Mschema-cjson/test/inputs/schema/date-time.schema/default/TopLevel.c+49 −49
@@ -62,20 +62,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
6262 if (NULL != j) {
6363 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
6464 memset(x, 0, sizeof(struct TopLevel));
65- if (cJSON_HasObjectItem(j, "complex-union-array")) {
66- list_t * x1 = list_create(false, NULL);
67- if (NULL != x1) {
68- cJSON * e1 = NULL;
69- cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "complex-union-array");
70- cJSON_ArrayForEach(e1, j1) {
71- list_add_tail(x1, cJSON_GetComplexUnionArrayValue(e1), sizeof(struct ComplexUnionArray *));
72- }
73- x->complex_union_array = x1;
74- }
75- }
76- else {
77- x->complex_union_array = list_create(false, NULL);
78- }
7965 if (cJSON_HasObjectItem(j, "date")) {
8066 x->date = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "date")));
8167 }
@@ -84,14 +70,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
8470 x->date[0] = '\0';
8571 }
8672 }
87- if (cJSON_HasObjectItem(j, "date-time")) {
88- x->date_time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "date-time")));
89- }
90- else {
91- if (NULL != (x->date_time = cJSON_malloc(sizeof(char)))) {
92- x->date_time[0] = '\0';
93- }
94- }
9573 if (cJSON_HasObjectItem(j, "time")) {
9674 x->time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "time")));
9775 }
@@ -100,6 +78,14 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
10078 x->time[0] = '\0';
10179 }
10280 }
81+ if (cJSON_HasObjectItem(j, "date-time")) {
82+ x->date_time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "date-time")));
83+ }
84+ else {
85+ if (NULL != (x->date_time = cJSON_malloc(sizeof(char)))) {
86+ x->date_time[0] = '\0';
87+ }
88+ }
10389 if (cJSON_HasObjectItem(j, "union-array")) {
10490 list_t * x1 = list_create(false, NULL);
10591 if (NULL != x1) {
@@ -114,6 +100,20 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
114100 else {
115101 x->union_array = list_create(false, NULL);
116102 }
103+ if (cJSON_HasObjectItem(j, "complex-union-array")) {
104+ list_t * x1 = list_create(false, NULL);
105+ if (NULL != x1) {
106+ cJSON * e1 = NULL;
107+ cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "complex-union-array");
108+ cJSON_ArrayForEach(e1, j1) {
109+ list_add_tail(x1, cJSON_GetComplexUnionArrayValue(e1), sizeof(struct ComplexUnionArray *));
110+ }
111+ x->complex_union_array = x1;
112+ }
113+ }
114+ else {
115+ x->complex_union_array = list_create(false, NULL);
116+ }
117117 }
118118 }
119119 return x;
@@ -123,34 +123,24 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
123123 cJSON * j = NULL;
124124 if (NULL != x) {
125125 if (NULL != (j = cJSON_CreateObject())) {
126- if (NULL != x->complex_union_array) {
127- cJSON * j1 = cJSON_AddArrayToObject(j, "complex-union-array");
128- if (NULL != j1) {
129- struct ComplexUnionArray * x1 = list_get_head(x->complex_union_array);
130- while (NULL != x1) {
131- cJSON_AddItemToArray(j1, cJSON_CreateComplexUnionArray(x1));
132- x1 = list_get_next(x->complex_union_array);
133- }
134- }
135- }
136126 if (NULL != x->date) {
137127 cJSON_AddStringToObject(j, "date", x->date);
138128 }
139129 else {
140130 cJSON_AddStringToObject(j, "date", "");
141131 }
142- if (NULL != x->date_time) {
143- cJSON_AddStringToObject(j, "date-time", x->date_time);
144- }
145- else {
146- cJSON_AddStringToObject(j, "date-time", "");
147- }
148132 if (NULL != x->time) {
149133 cJSON_AddStringToObject(j, "time", x->time);
150134 }
151135 else {
152136 cJSON_AddStringToObject(j, "time", "");
153137 }
138+ if (NULL != x->date_time) {
139+ cJSON_AddStringToObject(j, "date-time", x->date_time);
140+ }
141+ else {
142+ cJSON_AddStringToObject(j, "date-time", "");
143+ }
154144 if (NULL != x->union_array) {
155145 cJSON * j1 = cJSON_AddArrayToObject(j, "union-array");
156146 if (NULL != j1) {
@@ -161,6 +151,16 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
161151 }
162152 }
163153 }
154+ if (NULL != x->complex_union_array) {
155+ cJSON * j1 = cJSON_AddArrayToObject(j, "complex-union-array");
156+ if (NULL != j1) {
157+ struct ComplexUnionArray * x1 = list_get_head(x->complex_union_array);
158+ while (NULL != x1) {
159+ cJSON_AddItemToArray(j1, cJSON_CreateComplexUnionArray(x1));
160+ x1 = list_get_next(x->complex_union_array);
161+ }
162+ }
163+ }
164164 }
165165 }
166166 return j;
@@ -180,23 +180,15 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
180180
181181 void cJSON_DeleteTopLevel(struct TopLevel * x) {
182182 if (NULL != x) {
183- if (NULL != x->complex_union_array) {
184- struct ComplexUnionArray * x1 = list_get_head(x->complex_union_array);
185- while (NULL != x1) {
186- cJSON_DeleteComplexUnionArray(x1);
187- x1 = list_get_next(x->complex_union_array);
188- }
189- list_release(x->complex_union_array);
190- }
191183 if (NULL != x->date) {
192184 cJSON_free(x->date);
193185 }
194- if (NULL != x->date_time) {
195- cJSON_free(x->date_time);
196- }
197186 if (NULL != x->time) {
198187 cJSON_free(x->time);
199188 }
189+ if (NULL != x->date_time) {
190+ cJSON_free(x->date_time);
191+ }
200192 if (NULL != x->union_array) {
201193 char * x1 = list_get_head(x->union_array);
202194 while (NULL != x1) {
@@ -205,6 +197,14 @@ void cJSON_DeleteTopLevel(struct TopLevel * x) {
205197 }
206198 list_release(x->union_array);
207199 }
200+ if (NULL != x->complex_union_array) {
201+ struct ComplexUnionArray * x1 = list_get_head(x->complex_union_array);
202+ while (NULL != x1) {
203+ cJSON_DeleteComplexUnionArray(x1);
204+ x1 = list_get_next(x->complex_union_array);
205+ }
206+ list_release(x->complex_union_array);
207+ }
208208 cJSON_free(x);
209209 }
210210 }
Mschema-cjson/test/inputs/schema/date-time.schema/default/TopLevel.h+2 −2
@@ -43,11 +43,11 @@ struct ComplexUnionArray {
4343 };
4444
4545 struct TopLevel {
46- list_t * complex_union_array;
4746 char * date;
48- char * date_time;
4947 char * time;
48+ char * date_time;
5049 list_t * union_array;
50+ list_t * complex_union_array;
5151 };
5252
5353 struct ComplexUnionArray * cJSON_GetComplexUnionArrayValue(const cJSON * j);
Mschema-cjson/test/inputs/schema/description.schema/default/TopLevel.c+16 −16
@@ -174,10 +174,8 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
174174 if (NULL != j) {
175175 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
176176 memset(x, 0, sizeof(struct TopLevel));
177- if (cJSON_HasObjectItem(j, "bar")) {
178- if (NULL != (x->bar = cJSON_malloc(sizeof(bool)))) {
179- *x->bar = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(j, "bar"));
180- }
177+ if (cJSON_HasObjectItem(j, "union")) {
178+ x->top_level_union = cJSON_GetUnionValue(cJSON_GetObjectItemCaseSensitive(j, "union"));
181179 }
182180 if (cJSON_HasObjectItem(j, "enum")) {
183181 x->top_level_enum = cJSON_GetEnumValue(cJSON_GetObjectItemCaseSensitive(j, "enum"));
@@ -187,12 +185,14 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
187185 *x->foo = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "foo"));
188186 }
189187 }
188+ if (cJSON_HasObjectItem(j, "bar")) {
189+ if (NULL != (x->bar = cJSON_malloc(sizeof(bool)))) {
190+ *x->bar = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(j, "bar"));
191+ }
192+ }
190193 if (cJSON_HasObjectItem(j, "object-or-string")) {
191194 x->object_or_string = cJSON_GetObjectOrStringUnionValue(cJSON_GetObjectItemCaseSensitive(j, "object-or-string"));
192195 }
193- if (cJSON_HasObjectItem(j, "union")) {
194- x->top_level_union = cJSON_GetUnionValue(cJSON_GetObjectItemCaseSensitive(j, "union"));
195- }
196196 }
197197 }
198198 return x;
@@ -202,15 +202,15 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
202202 cJSON * j = NULL;
203203 if (NULL != x) {
204204 if (NULL != (j = cJSON_CreateObject())) {
205- if (NULL != x->bar) {
206- cJSON_AddBoolToObject(j, "bar", *x->bar);
207- }
205+ cJSON_AddItemToObject(j, "union", cJSON_CreateUnion(x->top_level_union));
208206 cJSON_AddItemToObject(j, "enum", cJSON_CreateEnum(x->top_level_enum));
209207 if (NULL != x->foo) {
210208 cJSON_AddNumberToObject(j, "foo", *x->foo);
211209 }
210+ if (NULL != x->bar) {
211+ cJSON_AddBoolToObject(j, "bar", *x->bar);
212+ }
212213 cJSON_AddItemToObject(j, "object-or-string", cJSON_CreateObjectOrStringUnion(x->object_or_string));
213- cJSON_AddItemToObject(j, "union", cJSON_CreateUnion(x->top_level_union));
214214 }
215215 }
216216 return j;
@@ -230,18 +230,18 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
230230
231231 void cJSON_DeleteTopLevel(struct TopLevel * x) {
232232 if (NULL != x) {
233- if (NULL != x->bar) {
234- cJSON_free(x->bar);
233+ if (NULL != x->top_level_union) {
234+ cJSON_DeleteUnion(x->top_level_union);
235235 }
236236 if (NULL != x->foo) {
237237 cJSON_free(x->foo);
238238 }
239+ if (NULL != x->bar) {
240+ cJSON_free(x->bar);
241+ }
239242 if (NULL != x->object_or_string) {
240243 cJSON_DeleteObjectOrStringUnion(x->object_or_string);
241244 }
242- if (NULL != x->top_level_union) {
243- cJSON_DeleteUnion(x->top_level_union);
244- }
245245 cJSON_free(x);
246246 }
247247 }
Mschema-cjson/test/inputs/schema/description.schema/default/TopLevel.h+5 −5
@@ -74,19 +74,19 @@ struct Union {
7474 */
7575 struct TopLevel {
7676 /**
77- * A pretty boolean
77+ * Either a number or a string
7878 */
79- bool * bar;
79+ struct Union * top_level_union;
8080 /**
8181 * An enumeration
8282 */
8383 enum Enum top_level_enum;
8484 double * foo;
85- struct ObjectOrStringUnion * object_or_string;
8685 /**
87- * Either a number or a string
86+ * A pretty boolean
8887 */
89- struct Union * top_level_union;
88+ bool * bar;
89+ struct ObjectOrStringUnion * object_or_string;
9090 };
9191
9292 enum Enum cJSON_GetEnumValue(const cJSON * j);
Mschema-cjson/test/inputs/schema/integer-string.schema/default/TopLevel.c+67 −67
@@ -62,6 +62,31 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
6262 if (NULL != j) {
6363 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
6464 memset(x, 0, sizeof(struct TopLevel));
65+ if (cJSON_HasObjectItem(j, "one")) {
66+ x->one = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "one")));
67+ }
68+ else {
69+ if (NULL != (x->one = cJSON_malloc(sizeof(char)))) {
70+ x->one[0] = '\0';
71+ }
72+ }
73+ if (cJSON_HasObjectItem(j, "optional")) {
74+ x->optional = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional")));
75+ }
76+ if ((cJSON_HasObjectItem(j, "nullable")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "nullable")))) {
77+ x->nullable = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "nullable")));
78+ }
79+ if (cJSON_HasObjectItem(j, "arrOne")) {
80+ list_t * x1 = list_create(false, NULL);
81+ if (NULL != x1) {
82+ cJSON * e1 = NULL;
83+ cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "arrOne");
84+ cJSON_ArrayForEach(e1, j1) {
85+ list_add_tail(x1, strdup(cJSON_GetStringValue(e1)), sizeof(char *));
86+ }
87+ x->arr_one = x1;
88+ }
89+ }
6590 if (cJSON_HasObjectItem(j, "arrNullable")) {
6691 list_t * x1 = list_create(false, NULL);
6792 if (NULL != x1) {
@@ -78,31 +103,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
78103 x->arr_nullable = x1;
79104 }
80105 }
81- if (cJSON_HasObjectItem(j, "arrOne")) {
82- list_t * x1 = list_create(false, NULL);
83- if (NULL != x1) {
84- cJSON * e1 = NULL;
85- cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "arrOne");
86- cJSON_ArrayForEach(e1, j1) {
87- list_add_tail(x1, strdup(cJSON_GetStringValue(e1)), sizeof(char *));
88- }
89- x->arr_one = x1;
90- }
91- }
92- if ((cJSON_HasObjectItem(j, "nullable")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "nullable")))) {
93- x->nullable = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "nullable")));
94- }
95- if (cJSON_HasObjectItem(j, "one")) {
96- x->one = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "one")));
97- }
98- else {
99- if (NULL != (x->one = cJSON_malloc(sizeof(char)))) {
100- x->one[0] = '\0';
101- }
102- }
103- if (cJSON_HasObjectItem(j, "optional")) {
104- x->optional = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional")));
105- }
106106 if (cJSON_HasObjectItem(j, "unionWithInt")) {
107107 x->union_with_int = cJSON_GetUnionWithIntValue(cJSON_GetObjectItemCaseSensitive(j, "unionWithInt"));
108108 }
@@ -118,6 +118,31 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
118118 cJSON * j = NULL;
119119 if (NULL != x) {
120120 if (NULL != (j = cJSON_CreateObject())) {
121+ if (NULL != x->one) {
122+ cJSON_AddStringToObject(j, "one", x->one);
123+ }
124+ else {
125+ cJSON_AddStringToObject(j, "one", "");
126+ }
127+ if (NULL != x->optional) {
128+ cJSON_AddStringToObject(j, "optional", x->optional);
129+ }
130+ if (NULL != x->nullable) {
131+ cJSON_AddStringToObject(j, "nullable", x->nullable);
132+ }
133+ else {
134+ cJSON_AddNullToObject(j, "nullable");
135+ }
136+ if (NULL != x->arr_one) {
137+ cJSON * j1 = cJSON_AddArrayToObject(j, "arrOne");
138+ if (NULL != j1) {
139+ char * x1 = list_get_head(x->arr_one);
140+ while (NULL != x1) {
141+ cJSON_AddItemToArray(j1, cJSON_CreateString(x1));
142+ x1 = list_get_next(x->arr_one);
143+ }
144+ }
145+ }
121146 if (NULL != x->arr_nullable) {
122147 cJSON * j1 = cJSON_AddArrayToObject(j, "arrNullable");
123148 if (NULL != j1) {
@@ -133,31 +158,6 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
133158 }
134159 }
135160 }
136- if (NULL != x->arr_one) {
137- cJSON * j1 = cJSON_AddArrayToObject(j, "arrOne");
138- if (NULL != j1) {
139- char * x1 = list_get_head(x->arr_one);
140- while (NULL != x1) {
141- cJSON_AddItemToArray(j1, cJSON_CreateString(x1));
142- x1 = list_get_next(x->arr_one);
143- }
144- }
145- }
146- if (NULL != x->nullable) {
147- cJSON_AddStringToObject(j, "nullable", x->nullable);
148- }
149- else {
150- cJSON_AddNullToObject(j, "nullable");
151- }
152- if (NULL != x->one) {
153- cJSON_AddStringToObject(j, "one", x->one);
154- }
155- else {
156- cJSON_AddStringToObject(j, "one", "");
157- }
158- if (NULL != x->optional) {
159- cJSON_AddStringToObject(j, "optional", x->optional);
160- }
161161 cJSON_AddItemToObject(j, "unionWithInt", cJSON_CreateUnionWithInt(x->union_with_int));
162162 cJSON_AddItemToObject(j, "unionWithIntAndEnum", cJSON_CreateUnionWithInt(x->union_with_int_and_enum));
163163 }
@@ -179,15 +179,14 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
179179
180180 void cJSON_DeleteTopLevel(struct TopLevel * x) {
181181 if (NULL != x) {
182- if (NULL != x->arr_nullable) {
183- char * x1 = list_get_head(x->arr_nullable);
184- while (NULL != x1) {
185- if ((void *)0xDEADBEEF != x1) {
186- cJSON_free(x1);
187- }
188- x1 = list_get_next(x->arr_nullable);
189- }
190- list_release(x->arr_nullable);
182+ if (NULL != x->one) {
183+ cJSON_free(x->one);
184+ }
185+ if (NULL != x->optional) {
186+ cJSON_free(x->optional);
187+ }
188+ if (NULL != x->nullable) {
189+ cJSON_free(x->nullable);
191190 }
192191 if (NULL != x->arr_one) {
193192 char * x1 = list_get_head(x->arr_one);
@@ -197,14 +196,15 @@ void cJSON_DeleteTopLevel(struct TopLevel * x) {
197196 }
198197 list_release(x->arr_one);
199198 }
200- if (NULL != x->nullable) {
201- cJSON_free(x->nullable);
202- }
203- if (NULL != x->one) {
204- cJSON_free(x->one);
205- }
206- if (NULL != x->optional) {
207- cJSON_free(x->optional);
199+ if (NULL != x->arr_nullable) {
200+ char * x1 = list_get_head(x->arr_nullable);
201+ while (NULL != x1) {
202+ if ((void *)0xDEADBEEF != x1) {
203+ cJSON_free(x1);
204+ }
205+ x1 = list_get_next(x->arr_nullable);
206+ }
207+ list_release(x->arr_nullable);
208208 }
209209 if (NULL != x->union_with_int) {
210210 cJSON_DeleteUnionWithInt(x->union_with_int);
Mschema-cjson/test/inputs/schema/integer-string.schema/default/TopLevel.h+3 −3
@@ -43,11 +43,11 @@ struct UnionWithInt {
4343 };
4444
4545 struct TopLevel {
46- list_t * arr_nullable;
47- list_t * arr_one;
48- char * nullable;
4946 char * one;
5047 char * optional;
48+ char * nullable;
49+ list_t * arr_one;
50+ list_t * arr_nullable;
5151 struct UnionWithInt * union_with_int;
5252 struct UnionWithInt * union_with_int_and_enum;
5353 };
Mschema-cjson/test/inputs/schema/integer-type.schema/default/TopLevel.c+18 −18
@@ -22,33 +22,33 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2222 if (NULL != j) {
2323 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
2424 memset(x, 0, sizeof(struct TopLevel));
25- if (cJSON_HasObjectItem(j, "above_i32_max")) {
26- x->above_i32_max = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "above_i32_max"));
25+ if (cJSON_HasObjectItem(j, "small_positive")) {
26+ x->small_positive = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "small_positive"));
2727 }
28- if (cJSON_HasObjectItem(j, "below_i32_min")) {
29- x->below_i32_min = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "below_i32_min"));
28+ if (cJSON_HasObjectItem(j, "small_negative")) {
29+ x->small_negative = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "small_negative"));
3030 }
3131 if (cJSON_HasObjectItem(j, "i32_range")) {
3232 x->i32_range = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "i32_range"));
3333 }
34- if (cJSON_HasObjectItem(j, "large_bounds")) {
35- x->large_bounds = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "large_bounds"));
34+ if (cJSON_HasObjectItem(j, "above_i32_max")) {
35+ x->above_i32_max = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "above_i32_max"));
3636 }
37- if (cJSON_HasObjectItem(j, "only_maximum")) {
38- x->only_maximum = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "only_maximum"));
37+ if (cJSON_HasObjectItem(j, "below_i32_min")) {
38+ x->below_i32_min = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "below_i32_min"));
3939 }
4040 if (cJSON_HasObjectItem(j, "only_minimum")) {
4141 x->only_minimum = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "only_minimum"));
4242 }
43- if (cJSON_HasObjectItem(j, "small_negative")) {
44- x->small_negative = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "small_negative"));
45- }
46- if (cJSON_HasObjectItem(j, "small_positive")) {
47- x->small_positive = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "small_positive"));
43+ if (cJSON_HasObjectItem(j, "only_maximum")) {
44+ x->only_maximum = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "only_maximum"));
4845 }
4946 if (cJSON_HasObjectItem(j, "unbounded")) {
5047 x->unbounded = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "unbounded"));
5148 }
49+ if (cJSON_HasObjectItem(j, "large_bounds")) {
50+ x->large_bounds = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "large_bounds"));
51+ }
5252 }
5353 }
5454 return x;
@@ -58,15 +58,15 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
5858 cJSON * j = NULL;
5959 if (NULL != x) {
6060 if (NULL != (j = cJSON_CreateObject())) {
61+ cJSON_AddNumberToObject(j, "small_positive", x->small_positive);
62+ cJSON_AddNumberToObject(j, "small_negative", x->small_negative);
63+ cJSON_AddNumberToObject(j, "i32_range", x->i32_range);
6164 cJSON_AddNumberToObject(j, "above_i32_max", x->above_i32_max);
6265 cJSON_AddNumberToObject(j, "below_i32_min", x->below_i32_min);
63- cJSON_AddNumberToObject(j, "i32_range", x->i32_range);
64- cJSON_AddNumberToObject(j, "large_bounds", x->large_bounds);
65- cJSON_AddNumberToObject(j, "only_maximum", x->only_maximum);
6666 cJSON_AddNumberToObject(j, "only_minimum", x->only_minimum);
67- cJSON_AddNumberToObject(j, "small_negative", x->small_negative);
68- cJSON_AddNumberToObject(j, "small_positive", x->small_positive);
67+ cJSON_AddNumberToObject(j, "only_maximum", x->only_maximum);
6968 cJSON_AddNumberToObject(j, "unbounded", x->unbounded);
69+ cJSON_AddNumberToObject(j, "large_bounds", x->large_bounds);
7070 }
7171 }
7272 return j;
Mschema-cjson/test/inputs/schema/integer-type.schema/default/TopLevel.h+5 −5
@@ -35,15 +35,15 @@ extern "C" {
3535 #endif
3636
3737 struct TopLevel {
38+ int64_t small_positive;
39+ int64_t small_negative;
40+ int64_t i32_range;
3841 int64_t above_i32_max;
3942 int64_t below_i32_min;
40- int64_t i32_range;
41- int64_t large_bounds;
42- int64_t only_maximum;
4343 int64_t only_minimum;
44- int64_t small_negative;
45- int64_t small_positive;
44+ int64_t only_maximum;
4645 int64_t unbounded;
46+ int64_t large_bounds;
4747 };
4848
4949 struct TopLevel * cJSON_ParseTopLevel(const char * s);
Mschema-cjson/test/inputs/schema/keyword-unions.schema/default/TopLevel.c+20 −20
@@ -24814,11 +24814,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2481424814 if (cJSON_HasObjectItem(j, "double")) {
2481524815 x->top_level_double = cJSON_GetUnionDoubleValue(cJSON_GetObjectItemCaseSensitive(j, "double"));
2481624816 }
24817- if (cJSON_HasObjectItem(j, "dummy")) {
24818- if (NULL != (x->dummy = cJSON_malloc(sizeof(double)))) {
24819- *x->dummy = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "dummy"));
24820- }
24821- }
2482224817 if (cJSON_HasObjectItem(j, "dynamic")) {
2482324818 x->dynamic = cJSON_GetUnionDynamicValue(cJSON_GetObjectItemCaseSensitive(j, "dynamic"));
2482424819 }
@@ -24975,12 +24970,12 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2497524970 if (cJSON_HasObjectItem(j, "internal")) {
2497624971 x->internal = cJSON_GetUnionInternalValue(cJSON_GetObjectItemCaseSensitive(j, "internal"));
2497724972 }
24978- if (cJSON_HasObjectItem(j, "is")) {
24979- x->is = cJSON_GetUnionIsValue(cJSON_GetObjectItemCaseSensitive(j, "is"));
24980- }
2498124973 if (cJSON_HasObjectItem(j, "iterable")) {
2498224974 x->iterable = cJSON_GetUnionIterableValue(cJSON_GetObjectItemCaseSensitive(j, "iterable"));
2498324975 }
24976+ if (cJSON_HasObjectItem(j, "is")) {
24977+ x->is = cJSON_GetUnionIsValue(cJSON_GetObjectItemCaseSensitive(j, "is"));
24978+ }
2498424979 if (cJSON_HasObjectItem(j, "jdec")) {
2498524980 x->jdec = cJSON_GetUnionJdecValue(cJSON_GetObjectItemCaseSensitive(j, "jdec"));
2498624981 }
@@ -25419,6 +25414,11 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2541925414 if (cJSON_HasObjectItem(j, "yield")) {
2542025415 x->yield = cJSON_GetUnionYieldValue(cJSON_GetObjectItemCaseSensitive(j, "yield"));
2542125416 }
25417+ if (cJSON_HasObjectItem(j, "dummy")) {
25418+ if (NULL != (x->dummy = cJSON_malloc(sizeof(double)))) {
25419+ *x->dummy = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "dummy"));
25420+ }
25421+ }
2542225422 }
2542325423 }
2542425424 return x;
@@ -25656,9 +25656,6 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
2565625656 if (NULL != x->top_level_double) {
2565725657 cJSON_AddItemToObject(j, "double", cJSON_CreateUnionDouble(x->top_level_double));
2565825658 }
25659- if (NULL != x->dummy) {
25660- cJSON_AddNumberToObject(j, "dummy", *x->dummy);
25661- }
2566225659 if (NULL != x->dynamic) {
2566325660 cJSON_AddItemToObject(j, "dynamic", cJSON_CreateUnionDynamic(x->dynamic));
2566425661 }
@@ -25815,12 +25812,12 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
2581525812 if (NULL != x->internal) {
2581625813 cJSON_AddItemToObject(j, "internal", cJSON_CreateUnionInternal(x->internal));
2581725814 }
25818- if (NULL != x->is) {
25819- cJSON_AddItemToObject(j, "is", cJSON_CreateUnionIs(x->is));
25820- }
2582125815 if (NULL != x->iterable) {
2582225816 cJSON_AddItemToObject(j, "iterable", cJSON_CreateUnionIterable(x->iterable));
2582325817 }
25818+ if (NULL != x->is) {
25819+ cJSON_AddItemToObject(j, "is", cJSON_CreateUnionIs(x->is));
25820+ }
2582425821 if (NULL != x->jdec) {
2582525822 cJSON_AddItemToObject(j, "jdec", cJSON_CreateUnionJdec(x->jdec));
2582625823 }
@@ -26259,6 +26256,9 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
2625926256 if (NULL != x->yield) {
2626026257 cJSON_AddItemToObject(j, "yield", cJSON_CreateUnionYield(x->yield));
2626126258 }
26259+ if (NULL != x->dummy) {
26260+ cJSON_AddNumberToObject(j, "dummy", *x->dummy);
26261+ }
2626226262 }
2626326263 }
2626426264 return j;
@@ -26506,9 +26506,6 @@ void cJSON_DeleteTopLevel(struct TopLevel * x) {
2650626506 if (NULL != x->top_level_double) {
2650726507 cJSON_DeleteUnionDouble(x->top_level_double);
2650826508 }
26509- if (NULL != x->dummy) {
26510- cJSON_free(x->dummy);
26511- }
2651226509 if (NULL != x->dynamic) {
2651326510 cJSON_DeleteUnionDynamic(x->dynamic);
2651426511 }
@@ -26665,12 +26662,12 @@ void cJSON_DeleteTopLevel(struct TopLevel * x) {
2666526662 if (NULL != x->internal) {
2666626663 cJSON_DeleteUnionInternal(x->internal);
2666726664 }
26668- if (NULL != x->is) {
26669- cJSON_DeleteUnionIs(x->is);
26670- }
2667126665 if (NULL != x->iterable) {
2667226666 cJSON_DeleteUnionIterable(x->iterable);
2667326667 }
26668+ if (NULL != x->is) {
26669+ cJSON_DeleteUnionIs(x->is);
26670+ }
2667426671 if (NULL != x->jdec) {
2667526672 cJSON_DeleteUnionJdec(x->jdec);
2667626673 }
@@ -27109,6 +27106,9 @@ void cJSON_DeleteTopLevel(struct TopLevel * x) {
2710927106 if (NULL != x->yield) {
2711027107 cJSON_DeleteUnionYield(x->yield);
2711127108 }
27109+ if (NULL != x->dummy) {
27110+ cJSON_free(x->dummy);
27111+ }
2711227112 cJSON_free(x);
2711327113 }
2711427114 }
Mschema-cjson/test/inputs/schema/keyword-unions.schema/default/TopLevel.h+2 −2
@@ -3147,7 +3147,6 @@ struct TopLevel {
31473147 struct UnionDidSet * did_set;
31483148 struct UnionDo * top_level_do;
31493149 struct UnionDouble * top_level_double;
3150- double * dummy;
31513150 struct UnionDynamic * dynamic;
31523151 struct UnionDynamicCast * top_level_dynamic_cast;
31533152 struct UnionElif * elif;
@@ -3200,8 +3199,8 @@ struct TopLevel {
32003199 struct UnionInt * top_level_int;
32013200 struct UnionInterface * interface;
32023201 struct UnionInternal * internal;
3203- struct UnionIs * is;
32043202 struct UnionIterable * iterable;
3203+ struct UnionIs * is;
32053204 struct UnionJdec * jdec;
32063205 struct UnionJenc * jenc;
32073206 struct UnionJpipe * jpipe;
@@ -3348,6 +3347,7 @@ struct TopLevel {
33483347 struct UnionXorEq * top_level_xor_eq;
33493348 struct UnionYes * yes;
33503349 struct UnionYield * yield;
3350+ double * dummy;
33513351 };
33523352
33533353 struct UnionAbstract * cJSON_GetUnionAbstractValue(const cJSON * j);
Mschema-cjson/test/inputs/schema/light.schema/default/TopLevel.c+17 −17
@@ -22,14 +22,6 @@ struct LightParams * cJSON_GetLightParamsValue(const cJSON * j) {
2222 if (NULL != j) {
2323 if (NULL != (x = cJSON_malloc(sizeof(struct LightParams)))) {
2424 memset(x, 0, sizeof(struct LightParams));
25- if (cJSON_HasObjectItem(j, "app_id")) {
26- x->app_id = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "app_id")));
27- }
28- else {
29- if (NULL != (x->app_id = cJSON_malloc(sizeof(char)))) {
30- x->app_id[0] = '\0';
31- }
32- }
3325 if (cJSON_HasObjectItem(j, "outlet_id")) {
3426 x->outlet_id = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "outlet_id")));
3527 }
@@ -38,6 +30,14 @@ struct LightParams * cJSON_GetLightParamsValue(const cJSON * j) {
3830 x->outlet_id[0] = '\0';
3931 }
4032 }
33+ if (cJSON_HasObjectItem(j, "app_id")) {
34+ x->app_id = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "app_id")));
35+ }
36+ else {
37+ if (NULL != (x->app_id = cJSON_malloc(sizeof(char)))) {
38+ x->app_id[0] = '\0';
39+ }
40+ }
4141 if (cJSON_HasObjectItem(j, "rgba")) {
4242 x->rgba = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "rgba")));
4343 }
@@ -55,18 +55,18 @@ cJSON * cJSON_CreateLightParams(const struct LightParams * x) {
5555 cJSON * j = NULL;
5656 if (NULL != x) {
5757 if (NULL != (j = cJSON_CreateObject())) {
58- if (NULL != x->app_id) {
59- cJSON_AddStringToObject(j, "app_id", x->app_id);
60- }
61- else {
62- cJSON_AddStringToObject(j, "app_id", "");
63- }
6458 if (NULL != x->outlet_id) {
6559 cJSON_AddStringToObject(j, "outlet_id", x->outlet_id);
6660 }
6761 else {
6862 cJSON_AddStringToObject(j, "outlet_id", "");
6963 }
64+ if (NULL != x->app_id) {
65+ cJSON_AddStringToObject(j, "app_id", x->app_id);
66+ }
67+ else {
68+ cJSON_AddStringToObject(j, "app_id", "");
69+ }
7070 if (NULL != x->rgba) {
7171 cJSON_AddStringToObject(j, "rgba", x->rgba);
7272 }
@@ -92,12 +92,12 @@ char * cJSON_PrintLightParams(const struct LightParams * x) {
9292
9393 void cJSON_DeleteLightParams(struct LightParams * x) {
9494 if (NULL != x) {
95- if (NULL != x->app_id) {
96- cJSON_free(x->app_id);
97- }
9895 if (NULL != x->outlet_id) {
9996 cJSON_free(x->outlet_id);
10097 }
98+ if (NULL != x->app_id) {
99+ cJSON_free(x->app_id);
100+ }
101101 if (NULL != x->rgba) {
102102 cJSON_free(x->rgba);
103103 }
Mschema-cjson/test/inputs/schema/light.schema/default/TopLevel.h+1 −1
@@ -35,8 +35,8 @@ extern "C" {
3535 #endif
3636
3737 struct LightParams {
38- char * app_id;
3938 char * outlet_id;
39+ char * app_id;
4040 char * rgba;
4141 };
Mschema-cjson/test/inputs/schema/min-max-items.schema/default/TopLevel.c+32 −32
@@ -62,6 +62,20 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
6262 if (NULL != j) {
6363 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
6464 memset(x, 0, sizeof(struct TopLevel));
65+ if (cJSON_HasObjectItem(j, "minOnly")) {
66+ list_t * x1 = list_create(false, NULL);
67+ if (NULL != x1) {
68+ cJSON * e1 = NULL;
69+ cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "minOnly");
70+ cJSON_ArrayForEach(e1, j1) {
71+ list_add_tail(x1, strdup(cJSON_GetStringValue(e1)), sizeof(char *));
72+ }
73+ x->min_only = x1;
74+ }
75+ }
76+ else {
77+ x->min_only = list_create(false, NULL);
78+ }
6579 if (cJSON_HasObjectItem(j, "maxOnly")) {
6680 list_t * x1 = list_create(false, NULL);
6781 if (NULL != x1) {
@@ -98,20 +112,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
98112 else {
99113 x->min_and_max = list_create(false, NULL);
100114 }
101- if (cJSON_HasObjectItem(j, "minOnly")) {
102- list_t * x1 = list_create(false, NULL);
103- if (NULL != x1) {
104- cJSON * e1 = NULL;
105- cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "minOnly");
106- cJSON_ArrayForEach(e1, j1) {
107- list_add_tail(x1, strdup(cJSON_GetStringValue(e1)), sizeof(char *));
108- }
109- x->min_only = x1;
110- }
111- }
112- else {
113- x->min_only = list_create(false, NULL);
114- }
115115 if (cJSON_HasObjectItem(j, "plain")) {
116116 list_t * x1 = list_create(false, NULL);
117117 if (NULL != x1) {
@@ -149,6 +149,16 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
149149 cJSON * j = NULL;
150150 if (NULL != x) {
151151 if (NULL != (j = cJSON_CreateObject())) {
152+ if (NULL != x->min_only) {
153+ cJSON * j1 = cJSON_AddArrayToObject(j, "minOnly");
154+ if (NULL != j1) {
155+ char * x1 = list_get_head(x->min_only);
156+ while (NULL != x1) {
157+ cJSON_AddItemToArray(j1, cJSON_CreateString(x1));
158+ x1 = list_get_next(x->min_only);
159+ }
160+ }
161+ }
152162 if (NULL != x->max_only) {
153163 cJSON * j1 = cJSON_AddArrayToObject(j, "maxOnly");
154164 if (NULL != j1) {
@@ -169,16 +179,6 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
169179 }
170180 }
171181 }
172- if (NULL != x->min_only) {
173- cJSON * j1 = cJSON_AddArrayToObject(j, "minOnly");
174- if (NULL != j1) {
175- char * x1 = list_get_head(x->min_only);
176- while (NULL != x1) {
177- cJSON_AddItemToArray(j1, cJSON_CreateString(x1));
178- x1 = list_get_next(x->min_only);
179- }
180- }
181- }
182182 if (NULL != x->plain) {
183183 cJSON * j1 = cJSON_AddArrayToObject(j, "plain");
184184 if (NULL != j1) {
@@ -218,6 +218,14 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
218218
219219 void cJSON_DeleteTopLevel(struct TopLevel * x) {
220220 if (NULL != x) {
221+ if (NULL != x->min_only) {
222+ char * x1 = list_get_head(x->min_only);
223+ while (NULL != x1) {
224+ cJSON_free(x1);
225+ x1 = list_get_next(x->min_only);
226+ }
227+ list_release(x->min_only);
228+ }
221229 if (NULL != x->max_only) {
222230 int64_t * x1 = list_get_head(x->max_only);
223231 while (NULL != x1) {
@@ -234,14 +242,6 @@ void cJSON_DeleteTopLevel(struct TopLevel * x) {
234242 }
235243 list_release(x->min_and_max);
236244 }
237- if (NULL != x->min_only) {
238- char * x1 = list_get_head(x->min_only);
239- while (NULL != x1) {
240- cJSON_free(x1);
241- x1 = list_get_next(x->min_only);
242- }
243- list_release(x->min_only);
244- }
245245 if (NULL != x->plain) {
246246 char * x1 = list_get_head(x->plain);
247247 while (NULL != x1) {
Mschema-cjson/test/inputs/schema/min-max-items.schema/default/TopLevel.h+1 −1
@@ -43,9 +43,9 @@ struct UnionItem {
4343 };
4444
4545 struct TopLevel {
46+ list_t * min_only;
4647 list_t * max_only;
4748 list_t * min_and_max;
48- list_t * min_only;
4949 list_t * plain;
5050 list_t * union_items;
5151 };
Mschema-cjson/test/inputs/schema/minmax-integer.schema/default/TopLevel.c+13 −13
@@ -25,26 +25,26 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2525 if (cJSON_HasObjectItem(j, "free")) {
2626 x->free = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "free"));
2727 }
28- if (cJSON_HasObjectItem(j, "intersection")) {
29- x->intersection = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "intersection"));
28+ if (cJSON_HasObjectItem(j, "min")) {
29+ x->min = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "min"));
3030 }
3131 if (cJSON_HasObjectItem(j, "max")) {
3232 x->max = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "max"));
3333 }
34- if (cJSON_HasObjectItem(j, "min")) {
35- x->min = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "min"));
36- }
3734 if (cJSON_HasObjectItem(j, "minmax")) {
3835 x->minmax = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "minmax"));
3936 }
40- if (cJSON_HasObjectItem(j, "minMaxIntersection")) {
41- x->min_max_intersection = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "minMaxIntersection"));
37+ if (cJSON_HasObjectItem(j, "union")) {
38+ x->top_level_union = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "union"));
4239 }
4340 if (cJSON_HasObjectItem(j, "minMaxUnion")) {
4441 x->min_max_union = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "minMaxUnion"));
4542 }
46- if (cJSON_HasObjectItem(j, "union")) {
47- x->top_level_union = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "union"));
43+ if (cJSON_HasObjectItem(j, "intersection")) {
44+ x->intersection = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "intersection"));
45+ }
46+ if (cJSON_HasObjectItem(j, "minMaxIntersection")) {
47+ x->min_max_intersection = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "minMaxIntersection"));
4848 }
4949 }
5050 }
@@ -56,13 +56,13 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
5656 if (NULL != x) {
5757 if (NULL != (j = cJSON_CreateObject())) {
5858 cJSON_AddNumberToObject(j, "free", x->free);
59- cJSON_AddNumberToObject(j, "intersection", x->intersection);
60- cJSON_AddNumberToObject(j, "max", x->max);
6159 cJSON_AddNumberToObject(j, "min", x->min);
60+ cJSON_AddNumberToObject(j, "max", x->max);
6261 cJSON_AddNumberToObject(j, "minmax", x->minmax);
63- cJSON_AddNumberToObject(j, "minMaxIntersection", x->min_max_intersection);
64- cJSON_AddNumberToObject(j, "minMaxUnion", x->min_max_union);
6562 cJSON_AddNumberToObject(j, "union", x->top_level_union);
63+ cJSON_AddNumberToObject(j, "minMaxUnion", x->min_max_union);
64+ cJSON_AddNumberToObject(j, "intersection", x->intersection);
65+ cJSON_AddNumberToObject(j, "minMaxIntersection", x->min_max_intersection);
6666 }
6767 }
6868 return j;
Mschema-cjson/test/inputs/schema/minmax-integer.schema/default/TopLevel.h+4 −4
@@ -36,13 +36,13 @@ extern "C" {
3636
3737 struct TopLevel {
3838 int64_t free;
39- int64_t intersection;
40- int64_t max;
4139 int64_t min;
40+ int64_t max;
4241 int64_t minmax;
43- int64_t min_max_intersection;
44- int64_t min_max_union;
4542 int64_t top_level_union;
43+ int64_t min_max_union;
44+ int64_t intersection;
45+ int64_t min_max_intersection;
4646 };
4747
4848 struct TopLevel * cJSON_ParseTopLevel(const char * s);
Mschema-cjson/test/inputs/schema/non-standard-ref.schema/default/TopLevel.c+4 −4
@@ -22,12 +22,12 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2222 if (NULL != j) {
2323 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
2424 memset(x, 0, sizeof(struct TopLevel));
25- if (cJSON_HasObjectItem(j, "bar")) {
26- x->bar = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "bar"));
27- }
2825 if (cJSON_HasObjectItem(j, "foo")) {
2926 x->foo = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "foo"));
3027 }
28+ if (cJSON_HasObjectItem(j, "bar")) {
29+ x->bar = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "bar"));
30+ }
3131 if (cJSON_HasObjectItem(j, "quux")) {
3232 x->quux = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(j, "quux"));
3333 }
@@ -40,8 +40,8 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
4040 cJSON * j = NULL;
4141 if (NULL != x) {
4242 if (NULL != (j = cJSON_CreateObject())) {
43- cJSON_AddNumberToObject(j, "bar", x->bar);
4443 cJSON_AddNumberToObject(j, "foo", x->foo);
44+ cJSON_AddNumberToObject(j, "bar", x->bar);
4545 cJSON_AddBoolToObject(j, "quux", x->quux);
4646 }
4747 }
Mschema-cjson/test/inputs/schema/non-standard-ref.schema/default/TopLevel.h+1 −1
@@ -35,8 +35,8 @@ extern "C" {
3535 #endif
3636
3737 struct TopLevel {
38- int64_t bar;
3938 int64_t foo;
39+ int64_t bar;
4040 bool quux;
4141 };
Mschema-cjson/test/inputs/schema/optional-date-time.schema/default/TopLevel.c+39 −39
@@ -22,15 +22,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2222 if (NULL != j) {
2323 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
2424 memset(x, 0, sizeof(struct TopLevel));
25- if (cJSON_HasObjectItem(j, "optional-date")) {
26- x->optional_date = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional-date")));
27- }
28- if (cJSON_HasObjectItem(j, "optional-date-time")) {
29- x->optional_date_time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional-date-time")));
30- }
31- if (cJSON_HasObjectItem(j, "optional-time")) {
32- x->optional_time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional-time")));
33- }
3425 if (cJSON_HasObjectItem(j, "required-date")) {
3526 x->required_date = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "required-date")));
3627 }
@@ -39,6 +30,14 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
3930 x->required_date[0] = '\0';
4031 }
4132 }
33+ if (cJSON_HasObjectItem(j, "required-time")) {
34+ x->required_time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "required-time")));
35+ }
36+ else {
37+ if (NULL != (x->required_time = cJSON_malloc(sizeof(char)))) {
38+ x->required_time[0] = '\0';
39+ }
40+ }
4241 if (cJSON_HasObjectItem(j, "required-date-time")) {
4342 x->required_date_time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "required-date-time")));
4443 }
@@ -47,13 +46,14 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
4746 x->required_date_time[0] = '\0';
4847 }
4948 }
50- if (cJSON_HasObjectItem(j, "required-time")) {
51- x->required_time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "required-time")));
49+ if (cJSON_HasObjectItem(j, "optional-date")) {
50+ x->optional_date = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional-date")));
5251 }
53- else {
54- if (NULL != (x->required_time = cJSON_malloc(sizeof(char)))) {
55- x->required_time[0] = '\0';
56- }
52+ if (cJSON_HasObjectItem(j, "optional-time")) {
53+ x->optional_time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional-time")));
54+ }
55+ if (cJSON_HasObjectItem(j, "optional-date-time")) {
56+ x->optional_date_time = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional-date-time")));
5757 }
5858 }
5959 }
@@ -64,32 +64,32 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
6464 cJSON * j = NULL;
6565 if (NULL != x) {
6666 if (NULL != (j = cJSON_CreateObject())) {
67- if (NULL != x->optional_date) {
68- cJSON_AddStringToObject(j, "optional-date", x->optional_date);
69- }
70- if (NULL != x->optional_date_time) {
71- cJSON_AddStringToObject(j, "optional-date-time", x->optional_date_time);
72- }
73- if (NULL != x->optional_time) {
74- cJSON_AddStringToObject(j, "optional-time", x->optional_time);
75- }
7667 if (NULL != x->required_date) {
7768 cJSON_AddStringToObject(j, "required-date", x->required_date);
7869 }
7970 else {
8071 cJSON_AddStringToObject(j, "required-date", "");
8172 }
73+ if (NULL != x->required_time) {
74+ cJSON_AddStringToObject(j, "required-time", x->required_time);
75+ }
76+ else {
77+ cJSON_AddStringToObject(j, "required-time", "");
78+ }
8279 if (NULL != x->required_date_time) {
8380 cJSON_AddStringToObject(j, "required-date-time", x->required_date_time);
8481 }
8582 else {
8683 cJSON_AddStringToObject(j, "required-date-time", "");
8784 }
88- if (NULL != x->required_time) {
89- cJSON_AddStringToObject(j, "required-time", x->required_time);
85+ if (NULL != x->optional_date) {
86+ cJSON_AddStringToObject(j, "optional-date", x->optional_date);
9087 }
91- else {
92- cJSON_AddStringToObject(j, "required-time", "");
88+ if (NULL != x->optional_time) {
89+ cJSON_AddStringToObject(j, "optional-time", x->optional_time);
90+ }
91+ if (NULL != x->optional_date_time) {
92+ cJSON_AddStringToObject(j, "optional-date-time", x->optional_date_time);
9393 }
9494 }
9595 }
@@ -110,23 +110,23 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
110110
111111 void cJSON_DeleteTopLevel(struct TopLevel * x) {
112112 if (NULL != x) {
113- if (NULL != x->optional_date) {
114- cJSON_free(x->optional_date);
115- }
116- if (NULL != x->optional_date_time) {
117- cJSON_free(x->optional_date_time);
118- }
119- if (NULL != x->optional_time) {
120- cJSON_free(x->optional_time);
121- }
122113 if (NULL != x->required_date) {
123114 cJSON_free(x->required_date);
124115 }
116+ if (NULL != x->required_time) {
117+ cJSON_free(x->required_time);
118+ }
125119 if (NULL != x->required_date_time) {
126120 cJSON_free(x->required_date_time);
127121 }
128- if (NULL != x->required_time) {
129- cJSON_free(x->required_time);
122+ if (NULL != x->optional_date) {
123+ cJSON_free(x->optional_date);
124+ }
125+ if (NULL != x->optional_time) {
126+ cJSON_free(x->optional_time);
127+ }
128+ if (NULL != x->optional_date_time) {
129+ cJSON_free(x->optional_date_time);
130130 }
131131 cJSON_free(x);
132132 }
Mschema-cjson/test/inputs/schema/optional-date-time.schema/default/TopLevel.h+4 −4
@@ -35,12 +35,12 @@ extern "C" {
3535 #endif
3636
3737 struct TopLevel {
38- char * optional_date;
39- char * optional_date_time;
40- char * optional_time;
4138 char * required_date;
42- char * required_date_time;
4339 char * required_time;
40+ char * required_date_time;
41+ char * optional_date;
42+ char * optional_time;
43+ char * optional_date_time;
4444 };
4545
4646 struct TopLevel * cJSON_ParseTopLevel(const char * s);
Mschema-cjson/test/inputs/schema/renaming-bug.schema/default/TopLevel.c+76 −76
@@ -198,15 +198,15 @@ struct Part * cJSON_GetPartValue(const cJSON * j) {
198198 if (NULL != j) {
199199 if (NULL != (x = cJSON_malloc(sizeof(struct Part)))) {
200200 memset(x, 0, sizeof(struct Part));
201- if (cJSON_HasObjectItem(j, "depth")) {
202- x->depth = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "depth")));
203- }
204201 if (cJSON_HasObjectItem(j, "length")) {
205202 x->length = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "length")));
206203 }
207204 if (cJSON_HasObjectItem(j, "width")) {
208205 x->width = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "width")));
209206 }
207+ if (cJSON_HasObjectItem(j, "depth")) {
208+ x->depth = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "depth")));
209+ }
210210 }
211211 }
212212 return x;
@@ -216,15 +216,15 @@ cJSON * cJSON_CreatePart(const struct Part * x) {
216216 cJSON * j = NULL;
217217 if (NULL != x) {
218218 if (NULL != (j = cJSON_CreateObject())) {
219- if (NULL != x->depth) {
220- cJSON_AddStringToObject(j, "depth", x->depth);
221- }
222219 if (NULL != x->length) {
223220 cJSON_AddStringToObject(j, "length", x->length);
224221 }
225222 if (NULL != x->width) {
226223 cJSON_AddStringToObject(j, "width", x->width);
227224 }
225+ if (NULL != x->depth) {
226+ cJSON_AddStringToObject(j, "depth", x->depth);
227+ }
228228 }
229229 }
230230 return j;
@@ -244,15 +244,15 @@ char * cJSON_PrintPart(const struct Part * x) {
244244
245245 void cJSON_DeletePart(struct Part * x) {
246246 if (NULL != x) {
247- if (NULL != x->depth) {
248- cJSON_free(x->depth);
249- }
250247 if (NULL != x->length) {
251248 cJSON_free(x->length);
252249 }
253250 if (NULL != x->width) {
254251 cJSON_free(x->width);
255252 }
253+ if (NULL != x->depth) {
254+ cJSON_free(x->depth);
255+ }
256256 cJSON_free(x);
257257 }
258258 }
@@ -497,12 +497,12 @@ struct Shape * cJSON_GetShapeValue(const cJSON * j) {
497497 if (NULL != j) {
498498 if (NULL != (x = cJSON_malloc(sizeof(struct Shape)))) {
499499 memset(x, 0, sizeof(struct Shape));
500- if (cJSON_HasObjectItem(j, "geometry")) {
501- x->geometry = cJSON_GetGeometryValue(cJSON_GetObjectItemCaseSensitive(j, "geometry"));
502- }
503500 if (cJSON_HasObjectItem(j, "history")) {
504501 x->history = cJSON_GetHistoryValue(cJSON_GetObjectItemCaseSensitive(j, "history"));
505502 }
503+ if (cJSON_HasObjectItem(j, "geometry")) {
504+ x->geometry = cJSON_GetGeometryValue(cJSON_GetObjectItemCaseSensitive(j, "geometry"));
505+ }
506506 }
507507 }
508508 return x;
@@ -512,12 +512,12 @@ cJSON * cJSON_CreateShape(const struct Shape * x) {
512512 cJSON * j = NULL;
513513 if (NULL != x) {
514514 if (NULL != (j = cJSON_CreateObject())) {
515- if (NULL != x->geometry) {
516- cJSON_AddItemToObject(j, "geometry", cJSON_CreateGeometry(x->geometry));
517- }
518515 if (NULL != x->history) {
519516 cJSON_AddItemToObject(j, "history", cJSON_CreateHistory(x->history));
520517 }
518+ if (NULL != x->geometry) {
519+ cJSON_AddItemToObject(j, "geometry", cJSON_CreateGeometry(x->geometry));
520+ }
521521 }
522522 }
523523 return j;
@@ -537,12 +537,12 @@ char * cJSON_PrintShape(const struct Shape * x) {
537537
538538 void cJSON_DeleteShape(struct Shape * x) {
539539 if (NULL != x) {
540- if (NULL != x->geometry) {
541- cJSON_DeleteGeometry(x->geometry);
542- }
543540 if (NULL != x->history) {
544541 cJSON_DeleteHistory(x->history);
545542 }
543+ if (NULL != x->geometry) {
544+ cJSON_DeleteGeometry(x->geometry);
545+ }
546546 cJSON_free(x);
547547 }
548548 }
@@ -564,12 +564,12 @@ struct Berry * cJSON_GetBerryValue(const cJSON * j) {
564564 if (NULL != j) {
565565 if (NULL != (x = cJSON_malloc(sizeof(struct Berry)))) {
566566 memset(x, 0, sizeof(struct Berry));
567- if (cJSON_HasObjectItem(j, "color")) {
568- x->color = cJSON_GetColorValue(cJSON_GetObjectItemCaseSensitive(j, "color"));
569- }
570567 if (cJSON_HasObjectItem(j, "name")) {
571568 x->name = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "name")));
572569 }
570+ if (cJSON_HasObjectItem(j, "color")) {
571+ x->color = cJSON_GetColorValue(cJSON_GetObjectItemCaseSensitive(j, "color"));
572+ }
573573 if (cJSON_HasObjectItem(j, "shapes")) {
574574 list_t * x1 = list_create(false, NULL);
575575 if (NULL != x1) {
@@ -590,12 +590,12 @@ cJSON * cJSON_CreateBerry(const struct Berry * x) {
590590 cJSON * j = NULL;
591591 if (NULL != x) {
592592 if (NULL != (j = cJSON_CreateObject())) {
593- if (NULL != x->color) {
594- cJSON_AddItemToObject(j, "color", cJSON_CreateColor(x->color));
595- }
596593 if (NULL != x->name) {
597594 cJSON_AddStringToObject(j, "name", x->name);
598595 }
596+ if (NULL != x->color) {
597+ cJSON_AddItemToObject(j, "color", cJSON_CreateColor(x->color));
598+ }
599599 if (NULL != x->shapes) {
600600 cJSON * j1 = cJSON_AddArrayToObject(j, "shapes");
601601 if (NULL != j1) {
@@ -625,12 +625,12 @@ char * cJSON_PrintBerry(const struct Berry * x) {
625625
626626 void cJSON_DeleteBerry(struct Berry * x) {
627627 if (NULL != x) {
628- if (NULL != x->color) {
629- cJSON_DeleteColor(x->color);
630- }
631628 if (NULL != x->name) {
632629 cJSON_free(x->name);
633630 }
631+ if (NULL != x->color) {
632+ cJSON_DeleteColor(x->color);
633+ }
634634 if (NULL != x->shapes) {
635635 struct Shape * x1 = list_get_head(x->shapes);
636636 while (NULL != x1) {
@@ -665,6 +665,11 @@ struct Fruit * cJSON_GetFruitValue(const cJSON * j) {
665665 *x->apple = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(j, "apple"));
666666 }
667667 }
668+ if (cJSON_HasObjectItem(j, "orange")) {
669+ if (NULL != (x->orange = cJSON_malloc(sizeof(bool)))) {
670+ *x->orange = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(j, "orange"));
671+ }
672+ }
668673 if (cJSON_HasObjectItem(j, "berries")) {
669674 list_t * x1 = list_create(false, NULL);
670675 if (NULL != x1) {
@@ -676,11 +681,6 @@ struct Fruit * cJSON_GetFruitValue(const cJSON * j) {
676681 x->berries = x1;
677682 }
678683 }
679- if (cJSON_HasObjectItem(j, "orange")) {
680- if (NULL != (x->orange = cJSON_malloc(sizeof(bool)))) {
681- *x->orange = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(j, "orange"));
682- }
683- }
684684 }
685685 }
686686 return x;
@@ -693,6 +693,9 @@ cJSON * cJSON_CreateFruit(const struct Fruit * x) {
693693 if (NULL != x->apple) {
694694 cJSON_AddBoolToObject(j, "apple", *x->apple);
695695 }
696+ if (NULL != x->orange) {
697+ cJSON_AddBoolToObject(j, "orange", *x->orange);
698+ }
696699 if (NULL != x->berries) {
697700 cJSON * j1 = cJSON_AddArrayToObject(j, "berries");
698701 if (NULL != j1) {
@@ -703,9 +706,6 @@ cJSON * cJSON_CreateFruit(const struct Fruit * x) {
703706 }
704707 }
705708 }
706- if (NULL != x->orange) {
707- cJSON_AddBoolToObject(j, "orange", *x->orange);
708- }
709709 }
710710 }
711711 return j;
@@ -728,6 +728,9 @@ void cJSON_DeleteFruit(struct Fruit * x) {
728728 if (NULL != x->apple) {
729729 cJSON_free(x->apple);
730730 }
731+ if (NULL != x->orange) {
732+ cJSON_free(x->orange);
733+ }
731734 if (NULL != x->berries) {
732735 struct Berry * x1 = list_get_head(x->berries);
733736 while (NULL != x1) {
@@ -736,9 +739,6 @@ void cJSON_DeleteFruit(struct Fruit * x) {
736739 }
737740 list_release(x->berries);
738741 }
739- if (NULL != x->orange) {
740- cJSON_free(x->orange);
741- }
742742 cJSON_free(x);
743743 }
744744 }
@@ -760,16 +760,16 @@ struct Limit * cJSON_GetLimitValue(const cJSON * j) {
760760 if (NULL != j) {
761761 if (NULL != (x = cJSON_malloc(sizeof(struct Limit)))) {
762762 memset(x, 0, sizeof(struct Limit));
763- if (cJSON_HasObjectItem(j, "maximum")) {
764- if (NULL != (x->maximum = cJSON_malloc(sizeof(double)))) {
765- *x->maximum = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "maximum"));
766- }
767- }
768763 if (cJSON_HasObjectItem(j, "minimum")) {
769764 if (NULL != (x->minimum = cJSON_malloc(sizeof(double)))) {
770765 *x->minimum = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "minimum"));
771766 }
772767 }
768+ if (cJSON_HasObjectItem(j, "maximum")) {
769+ if (NULL != (x->maximum = cJSON_malloc(sizeof(double)))) {
770+ *x->maximum = cJSON_GetNumberValue(cJSON_GetObjectItemCaseSensitive(j, "maximum"));
771+ }
772+ }
773773 }
774774 }
775775 return x;
@@ -779,12 +779,12 @@ cJSON * cJSON_CreateLimit(const struct Limit * x) {
779779 cJSON * j = NULL;
780780 if (NULL != x) {
781781 if (NULL != (j = cJSON_CreateObject())) {
782- if (NULL != x->maximum) {
783- cJSON_AddNumberToObject(j, "maximum", *x->maximum);
784- }
785782 if (NULL != x->minimum) {
786783 cJSON_AddNumberToObject(j, "minimum", *x->minimum);
787784 }
785+ if (NULL != x->maximum) {
786+ cJSON_AddNumberToObject(j, "maximum", *x->maximum);
787+ }
788788 }
789789 }
790790 return j;
@@ -804,12 +804,12 @@ char * cJSON_PrintLimit(const struct Limit * x) {
804804
805805 void cJSON_DeleteLimit(struct Limit * x) {
806806 if (NULL != x) {
807- if (NULL != x->maximum) {
808- cJSON_free(x->maximum);
809- }
810807 if (NULL != x->minimum) {
811808 cJSON_free(x->minimum);
812809 }
810+ if (NULL != x->maximum) {
811+ cJSON_free(x->maximum);
812+ }
813813 cJSON_free(x);
814814 }
815815 }
@@ -971,26 +971,26 @@ struct Vehicle * cJSON_GetVehicleValue(const cJSON * j) {
971971 if (NULL != j) {
972972 if (NULL != (x = cJSON_malloc(sizeof(struct Vehicle)))) {
973973 memset(x, 0, sizeof(struct Vehicle));
974- if (cJSON_HasObjectItem(j, "brand")) {
975- x->brand = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "brand")));
976- }
977974 if (cJSON_HasObjectItem(j, "id")) {
978975 x->id = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "id")));
979976 }
977+ if (cJSON_HasObjectItem(j, "type")) {
978+ x->type = cJSON_GetVehicleTypeValue(cJSON_GetObjectItemCaseSensitive(j, "type"));
979+ }
980980 if (cJSON_HasObjectItem(j, "speed")) {
981981 x->speed = cJSON_GetSpeedValue(cJSON_GetObjectItemCaseSensitive(j, "speed"));
982982 }
983+ if (cJSON_HasObjectItem(j, "year")) {
984+ x->year = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "year")));
985+ }
986+ if (cJSON_HasObjectItem(j, "brand")) {
987+ x->brand = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "brand")));
988+ }
983989 if (cJSON_HasObjectItem(j, "subModule")) {
984990 if (NULL != (x->sub_module = cJSON_malloc(sizeof(bool)))) {
985991 *x->sub_module = cJSON_IsTrue(cJSON_GetObjectItemCaseSensitive(j, "subModule"));
986992 }
987993 }
988- if (cJSON_HasObjectItem(j, "type")) {
989- x->type = cJSON_GetVehicleTypeValue(cJSON_GetObjectItemCaseSensitive(j, "type"));
990- }
991- if (cJSON_HasObjectItem(j, "year")) {
992- x->year = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "year")));
993- }
994994 }
995995 }
996996 return x;
@@ -1000,24 +1000,24 @@ cJSON * cJSON_CreateVehicle(const struct Vehicle * x) {
10001000 cJSON * j = NULL;
10011001 if (NULL != x) {
10021002 if (NULL != (j = cJSON_CreateObject())) {
1003- if (NULL != x->brand) {
1004- cJSON_AddStringToObject(j, "brand", x->brand);
1005- }
10061003 if (NULL != x->id) {
10071004 cJSON_AddStringToObject(j, "id", x->id);
10081005 }
1009- if (NULL != x->speed) {
1010- cJSON_AddItemToObject(j, "speed", cJSON_CreateSpeed(x->speed));
1011- }
1012- if (NULL != x->sub_module) {
1013- cJSON_AddBoolToObject(j, "subModule", *x->sub_module);
1014- }
10151006 if (NULL != x->type) {
10161007 cJSON_AddItemToObject(j, "type", cJSON_CreateVehicleType(x->type));
10171008 }
1009+ if (NULL != x->speed) {
1010+ cJSON_AddItemToObject(j, "speed", cJSON_CreateSpeed(x->speed));
1011+ }
10181012 if (NULL != x->year) {
10191013 cJSON_AddStringToObject(j, "year", x->year);
10201014 }
1015+ if (NULL != x->brand) {
1016+ cJSON_AddStringToObject(j, "brand", x->brand);
1017+ }
1018+ if (NULL != x->sub_module) {
1019+ cJSON_AddBoolToObject(j, "subModule", *x->sub_module);
1020+ }
10211021 }
10221022 }
10231023 return j;
@@ -1037,24 +1037,24 @@ char * cJSON_PrintVehicle(const struct Vehicle * x) {
10371037
10381038 void cJSON_DeleteVehicle(struct Vehicle * x) {
10391039 if (NULL != x) {
1040- if (NULL != x->brand) {
1041- cJSON_free(x->brand);
1042- }
10431040 if (NULL != x->id) {
10441041 cJSON_free(x->id);
10451042 }
1046- if (NULL != x->speed) {
1047- cJSON_DeleteSpeed(x->speed);
1048- }
1049- if (NULL != x->sub_module) {
1050- cJSON_free(x->sub_module);
1051- }
10521043 if (NULL != x->type) {
10531044 cJSON_DeleteVehicleType(x->type);
10541045 }
1046+ if (NULL != x->speed) {
1047+ cJSON_DeleteSpeed(x->speed);
1048+ }
10551049 if (NULL != x->year) {
10561050 cJSON_free(x->year);
10571051 }
1052+ if (NULL != x->brand) {
1053+ cJSON_free(x->brand);
1054+ }
1055+ if (NULL != x->sub_module) {
1056+ cJSON_free(x->sub_module);
1057+ }
10581058 cJSON_free(x);
10591059 }
10601060 }
Mschema-cjson/test/inputs/schema/renaming-bug.schema/default/TopLevel.h+8 −8
@@ -43,9 +43,9 @@ struct CircularShape {
4343 };
4444
4545 struct Part {
46- char * depth;
4746 char * length;
4847 char * width;
48+ char * depth;
4949 };
5050
5151 struct RectShape {
@@ -62,25 +62,25 @@ struct History {
6262 };
6363
6464 struct Shape {
65- struct Geometry * geometry;
6665 struct History * history;
66+ struct Geometry * geometry;
6767 };
6868
6969 struct Berry {
70- struct Color * color;
7170 char * name;
71+ struct Color * color;
7272 list_t * shapes;
7373 };
7474
7575 struct Fruit {
7676 bool * apple;
77- list_t * berries;
7877 bool * orange;
78+ list_t * berries;
7979 };
8080
8181 struct Limit {
82- double * maximum;
8382 double * minimum;
83+ double * maximum;
8484 };
8585
8686 struct Speed {
@@ -115,12 +115,12 @@ struct VehicleType {
115115 };
116116
117117 struct Vehicle {
118- char * brand;
119118 char * id;
120- struct Speed * speed;
121- bool * sub_module;
122119 struct VehicleType * type;
120+ struct Speed * speed;
123121 char * year;
122+ char * brand;
123+ bool * sub_module;
124124 };
125125
126126 struct TopLevel {
Mschema-cjson/test/inputs/schema/uuid.schema/default/TopLevel.c+67 −67
@@ -22,6 +22,31 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
2222 if (NULL != j) {
2323 if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
2424 memset(x, 0, sizeof(struct TopLevel));
25+ if (cJSON_HasObjectItem(j, "one")) {
26+ x->one = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "one")));
27+ }
28+ else {
29+ if (NULL != (x->one = cJSON_malloc(sizeof(char)))) {
30+ x->one[0] = '\0';
31+ }
32+ }
33+ if (cJSON_HasObjectItem(j, "optional")) {
34+ x->optional = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional")));
35+ }
36+ if ((cJSON_HasObjectItem(j, "nullable")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "nullable")))) {
37+ x->nullable = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "nullable")));
38+ }
39+ if (cJSON_HasObjectItem(j, "arrOne")) {
40+ list_t * x1 = list_create(false, NULL);
41+ if (NULL != x1) {
42+ cJSON * e1 = NULL;
43+ cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "arrOne");
44+ cJSON_ArrayForEach(e1, j1) {
45+ list_add_tail(x1, strdup(cJSON_GetStringValue(e1)), sizeof(char *));
46+ }
47+ x->arr_one = x1;
48+ }
49+ }
2550 if (cJSON_HasObjectItem(j, "arrNullable")) {
2651 list_t * x1 = list_create(false, NULL);
2752 if (NULL != x1) {
@@ -38,31 +63,6 @@ struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
3863 x->arr_nullable = x1;
3964 }
4065 }
41- if (cJSON_HasObjectItem(j, "arrOne")) {
42- list_t * x1 = list_create(false, NULL);
43- if (NULL != x1) {
44- cJSON * e1 = NULL;
45- cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "arrOne");
46- cJSON_ArrayForEach(e1, j1) {
47- list_add_tail(x1, strdup(cJSON_GetStringValue(e1)), sizeof(char *));
48- }
49- x->arr_one = x1;
50- }
51- }
52- if ((cJSON_HasObjectItem(j, "nullable")) && (!cJSON_IsNull(cJSON_GetObjectItemCaseSensitive(j, "nullable")))) {
53- x->nullable = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "nullable")));
54- }
55- if (cJSON_HasObjectItem(j, "one")) {
56- x->one = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "one")));
57- }
58- else {
59- if (NULL != (x->one = cJSON_malloc(sizeof(char)))) {
60- x->one[0] = '\0';
61- }
62- }
63- if (cJSON_HasObjectItem(j, "optional")) {
64- x->optional = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "optional")));
65- }
6666 if (cJSON_HasObjectItem(j, "unionWithEnum")) {
6767 x->union_with_enum = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "unionWithEnum")));
6868 }
@@ -80,6 +80,31 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
8080 cJSON * j = NULL;
8181 if (NULL != x) {
8282 if (NULL != (j = cJSON_CreateObject())) {
83+ if (NULL != x->one) {
84+ cJSON_AddStringToObject(j, "one", x->one);
85+ }
86+ else {
87+ cJSON_AddStringToObject(j, "one", "");
88+ }
89+ if (NULL != x->optional) {
90+ cJSON_AddStringToObject(j, "optional", x->optional);
91+ }
92+ if (NULL != x->nullable) {
93+ cJSON_AddStringToObject(j, "nullable", x->nullable);
94+ }
95+ else {
96+ cJSON_AddNullToObject(j, "nullable");
97+ }
98+ if (NULL != x->arr_one) {
99+ cJSON * j1 = cJSON_AddArrayToObject(j, "arrOne");
100+ if (NULL != j1) {
101+ char * x1 = list_get_head(x->arr_one);
102+ while (NULL != x1) {
103+ cJSON_AddItemToArray(j1, cJSON_CreateString(x1));
104+ x1 = list_get_next(x->arr_one);
105+ }
106+ }
107+ }
83108 if (NULL != x->arr_nullable) {
84109 cJSON * j1 = cJSON_AddArrayToObject(j, "arrNullable");
85110 if (NULL != j1) {
@@ -95,31 +120,6 @@ cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
95120 }
96121 }
97122 }
98- if (NULL != x->arr_one) {
99- cJSON * j1 = cJSON_AddArrayToObject(j, "arrOne");
100- if (NULL != j1) {
101- char * x1 = list_get_head(x->arr_one);
102- while (NULL != x1) {
103- cJSON_AddItemToArray(j1, cJSON_CreateString(x1));
104- x1 = list_get_next(x->arr_one);
105- }
106- }
107- }
108- if (NULL != x->nullable) {
109- cJSON_AddStringToObject(j, "nullable", x->nullable);
110- }
111- else {
112- cJSON_AddNullToObject(j, "nullable");
113- }
114- if (NULL != x->one) {
115- cJSON_AddStringToObject(j, "one", x->one);
116- }
117- else {
118- cJSON_AddStringToObject(j, "one", "");
119- }
120- if (NULL != x->optional) {
121- cJSON_AddStringToObject(j, "optional", x->optional);
122- }
123123 if (NULL != x->union_with_enum) {
124124 cJSON_AddStringToObject(j, "unionWithEnum", x->union_with_enum);
125125 }
@@ -145,15 +145,14 @@ char * cJSON_PrintTopLevel(const struct TopLevel * x) {
145145
146146 void cJSON_DeleteTopLevel(struct TopLevel * x) {
147147 if (NULL != x) {
148- if (NULL != x->arr_nullable) {
149- char * x1 = list_get_head(x->arr_nullable);
150- while (NULL != x1) {
151- if ((void *)0xDEADBEEF != x1) {
152- cJSON_free(x1);
153- }
154- x1 = list_get_next(x->arr_nullable);
155- }
156- list_release(x->arr_nullable);
148+ if (NULL != x->one) {
149+ cJSON_free(x->one);
150+ }
151+ if (NULL != x->optional) {
152+ cJSON_free(x->optional);
153+ }
154+ if (NULL != x->nullable) {
155+ cJSON_free(x->nullable);
157156 }
158157 if (NULL != x->arr_one) {
159158 char * x1 = list_get_head(x->arr_one);
@@ -163,14 +162,15 @@ void cJSON_DeleteTopLevel(struct TopLevel * x) {
163162 }
164163 list_release(x->arr_one);
165164 }
166- if (NULL != x->nullable) {
167- cJSON_free(x->nullable);
168- }
169- if (NULL != x->one) {
170- cJSON_free(x->one);
171- }
172- if (NULL != x->optional) {
173- cJSON_free(x->optional);
165+ if (NULL != x->arr_nullable) {
166+ char * x1 = list_get_head(x->arr_nullable);
167+ while (NULL != x1) {
168+ if ((void *)0xDEADBEEF != x1) {
169+ cJSON_free(x1);
170+ }
171+ x1 = list_get_next(x->arr_nullable);
172+ }
173+ list_release(x->arr_nullable);
174174 }
175175 if (NULL != x->union_with_enum) {
176176 cJSON_free(x->union_with_enum);
Mschema-cjson/test/inputs/schema/uuid.schema/default/TopLevel.h+3 −3
@@ -35,11 +35,11 @@ extern "C" {
3535 #endif
3636
3737 struct TopLevel {
38- list_t * arr_nullable;
39- list_t * arr_one;
40- char * nullable;
4138 char * one;
4239 char * optional;
40+ char * nullable;
41+ list_t * arr_one;
42+ list_t * arr_nullable;
4343 char * union_with_enum;
4444 };
Mschema-cplusplus/test/inputs/schema/accessors.schema/default/quicktype.hpp+12 −12
@@ -98,15 +98,15 @@ namespace quicktype {
9898 virtual ~TopLevel() = default;
9999
100100 private:
101- std::string barre;
101+ Union unionization;
102102 Enum enumerification;
103103 std::string foo;
104- Union unionization;
104+ std::string barre;
105105
106106 public:
107- const std::string & get_barre() const { return barre; }
108- std::string & get_mutable_barre() { return barre; }
109- void set_barre(const std::string & value) { this->barre = value; }
107+ const Union & get_unionization() const { return unionization; }
108+ Union & get_mutable_unionization() { return unionization; }
109+ void set_unionization(const Union & value) { this->unionization = value; }
110110
111111 const Enum & get_enumerification() const { return enumerification; }
112112 Enum & get_mutable_enumerification() { return enumerification; }
@@ -116,9 +116,9 @@ namespace quicktype {
116116 std::string & get_mutable_foo() { return foo; }
117117 void set_foo(const std::string & value) { this->foo = value; }
118118
119- const Union & get_unionization() const { return unionization; }
120- Union & get_mutable_unionization() { return unionization; }
121- void set_unionization(const Union & value) { this->unionization = value; }
119+ const std::string & get_barre() const { return barre; }
120+ std::string & get_mutable_barre() { return barre; }
121+ void set_barre(const std::string & value) { this->barre = value; }
122122 };
123123 }
124124
@@ -138,18 +138,18 @@ struct adl_serializer<std::variant<bool, double>> {
138138 }
139139 namespace quicktype {
140140 inline void from_json(const json & j, TopLevel& x) {
141- x.set_barre(j.at("bar").get<std::string>());
141+ x.set_unionization(j.at("union").get<Union>());
142142 x.set_enumerification(j.at("enum").get<Enum>());
143143 x.set_foo(j.at("foo").get<std::string>());
144- x.set_unionization(j.at("union").get<Union>());
144+ x.set_barre(j.at("bar").get<std::string>());
145145 }
146146
147147 inline void to_json(json & j, const TopLevel & x) {
148148 j = json::object();
149- j["bar"] = x.get_barre();
149+ j["union"] = x.get_unionization();
150150 j["enum"] = x.get_enumerification();
151151 j["foo"] = x.get_foo();
152- j["union"] = x.get_unionization();
152+ j["bar"] = x.get_barre();
153153 }
154154
155155 inline void from_json(const json & j, Enum & x) {
Mschema-cplusplus/test/inputs/schema/all-of-additional-properties-false.schema/default/quicktype.hpp+7 −7
@@ -100,8 +100,8 @@ namespace quicktype {
100100 private:
101101 double amount;
102102 Frequency frequency;
103- std::optional<std::string> description;
104103 Type type;
104+ std::optional<std::string> description;
105105
106106 public:
107107 const double & get_amount() const { return amount; }
@@ -112,13 +112,13 @@ namespace quicktype {
112112 Frequency & get_mutable_frequency() { return frequency; }
113113 void set_frequency(const Frequency & value) { this->frequency = value; }
114114
115- const std::optional<std::string> & get_description() const { return description; }
116- std::optional<std::string> & get_mutable_description() { return description; }
117- void set_description(const std::optional<std::string> & value) { this->description = value; }
118-
119115 const Type & get_type() const { return type; }
120116 Type & get_mutable_type() { return type; }
121117 void set_type(const Type & value) { this->type = value; }
118+
119+ const std::optional<std::string> & get_description() const { return description; }
120+ std::optional<std::string> & get_mutable_description() { return description; }
121+ void set_description(const std::optional<std::string> & value) { this->description = value; }
122122 };
123123 }
124124
@@ -135,16 +135,16 @@ namespace quicktype {
135135 inline void from_json(const json & j, TopLevel& x) {
136136 x.set_amount(j.at("amount").get<double>());
137137 x.set_frequency(j.at("frequency").get<Frequency>());
138- x.set_description(get_stack_optional<std::string>(j, "description"));
139138 x.set_type(j.at("type").get<Type>());
139+ x.set_description(get_stack_optional<std::string>(j, "description"));
140140 }
141141
142142 inline void to_json(json & j, const TopLevel & x) {
143143 j = json::object();
144144 j["amount"] = x.get_amount();
145145 j["frequency"] = x.get_frequency();
146- j["description"] = x.get_description();
147146 j["type"] = x.get_type();
147+ j["description"] = x.get_description();
148148 }
149149
150150 inline void from_json(const json & j, Frequency & x) {
Mschema-cplusplus/test/inputs/schema/bool-string.schema/default/quicktype.hpp+20 −20
@@ -97,26 +97,15 @@ namespace quicktype {
9797 virtual ~TopLevel() = default;
9898
9999 private:
100- std::optional<std::vector<std::optional<std::string>>> arr_nullable;
101- std::optional<std::vector<std::string>> arr_one;
102- std::optional<std::string> nullable;
103100 std::string one;
104101 std::optional<std::string> optional;
102+ std::optional<std::string> nullable;
103+ std::optional<std::vector<std::string>> arr_one;
104+ std::optional<std::vector<std::optional<std::string>>> arr_nullable;
105105 UnionWithBool union_with_bool;
106106 UnionWithBool union_with_bool_and_enum;
107107
108108 public:
109- const std::optional<std::vector<std::optional<std::string>>> & get_arr_nullable() const { return arr_nullable; }
110- std::optional<std::vector<std::optional<std::string>>> & get_mutable_arr_nullable() { return arr_nullable; }
111- void set_arr_nullable(const std::optional<std::vector<std::optional<std::string>>> & value) { this->arr_nullable = value; }
112-
113- const std::optional<std::vector<std::string>> & get_arr_one() const { return arr_one; }
114- std::optional<std::vector<std::string>> & get_mutable_arr_one() { return arr_one; }
115- void set_arr_one(const std::optional<std::vector<std::string>> & value) { this->arr_one = value; }
116-
117- std::optional<std::string> get_nullable() const { return nullable; }
118- void set_nullable(std::optional<std::string> value) { this->nullable = value; }
119-
120109 const std::string & get_one() const { return one; }
121110 std::string & get_mutable_one() { return one; }
122111 void set_one(const std::string & value) { this->one = value; }
@@ -125,6 +114,17 @@ namespace quicktype {
125114 std::optional<std::string> & get_mutable_optional() { return optional; }
126115 void set_optional(const std::optional<std::string> & value) { this->optional = value; }
127116
117+ std::optional<std::string> get_nullable() const { return nullable; }
118+ void set_nullable(std::optional<std::string> value) { this->nullable = value; }
119+
120+ const std::optional<std::vector<std::string>> & get_arr_one() const { return arr_one; }
121+ std::optional<std::vector<std::string>> & get_mutable_arr_one() { return arr_one; }
122+ void set_arr_one(const std::optional<std::vector<std::string>> & value) { this->arr_one = value; }
123+
124+ const std::optional<std::vector<std::optional<std::string>>> & get_arr_nullable() const { return arr_nullable; }
125+ std::optional<std::vector<std::optional<std::string>>> & get_mutable_arr_nullable() { return arr_nullable; }
126+ void set_arr_nullable(const std::optional<std::vector<std::optional<std::string>>> & value) { this->arr_nullable = value; }
127+
128128 const UnionWithBool & get_union_with_bool() const { return union_with_bool; }
129129 UnionWithBool & get_mutable_union_with_bool() { return union_with_bool; }
130130 void set_union_with_bool(const UnionWithBool & value) { this->union_with_bool = value; }
@@ -148,22 +148,22 @@ struct adl_serializer<std::variant<bool, std::string>> {
148148 }
149149 namespace quicktype {
150150 inline void from_json(const json & j, TopLevel& x) {
151- x.set_arr_nullable(get_stack_optional<std::vector<std::optional<std::string>>>(j, "arrNullable"));
152- x.set_arr_one(get_stack_optional<std::vector<std::string>>(j, "arrOne"));
153- x.set_nullable(get_stack_optional<std::string>(j, "nullable"));
154151 x.set_one(j.at("one").get<std::string>());
155152 x.set_optional(get_stack_optional<std::string>(j, "optional"));
153+ x.set_nullable(get_stack_optional<std::string>(j, "nullable"));
154+ x.set_arr_one(get_stack_optional<std::vector<std::string>>(j, "arrOne"));
155+ x.set_arr_nullable(get_stack_optional<std::vector<std::optional<std::string>>>(j, "arrNullable"));
156156 x.set_union_with_bool(j.at("unionWithBool").get<UnionWithBool>());
157157 x.set_union_with_bool_and_enum(j.at("unionWithBoolAndEnum").get<UnionWithBool>());
158158 }
159159
160160 inline void to_json(json & j, const TopLevel & x) {
161161 j = json::object();
162- j["arrNullable"] = x.get_arr_nullable();
163- j["arrOne"] = x.get_arr_one();
164- j["nullable"] = x.get_nullable();
165162 j["one"] = x.get_one();
166163 j["optional"] = x.get_optional();
164+ j["nullable"] = x.get_nullable();
165+ j["arrOne"] = x.get_arr_one();
166+ j["arrNullable"] = x.get_arr_nullable();
167167 j["unionWithBool"] = x.get_union_with_bool();
168168 j["unionWithBoolAndEnum"] = x.get_union_with_bool_and_enum();
169169 }
Mschema-cplusplus/test/inputs/schema/boolean-subschema.schema/default/quicktype.hpp+7 −7
@@ -94,12 +94,16 @@ namespace quicktype {
9494 virtual ~TopLevel() = default;
9595
9696 private:
97+ std::string foo;
9798 nlohmann::json disallowed;
9899 std::vector<nlohmann::json> empty;
99- std::string foo;
100100 nlohmann::json impossible;
101101
102102 public:
103+ const std::string & get_foo() const { return foo; }
104+ std::string & get_mutable_foo() { return foo; }
105+ void set_foo(const std::string & value) { this->foo = value; }
106+
103107 const nlohmann::json & get_disallowed() const { return disallowed; }
104108 nlohmann::json & get_mutable_disallowed() { return disallowed; }
105109 void set_disallowed(const nlohmann::json & value) { this->disallowed = value; }
@@ -108,10 +112,6 @@ namespace quicktype {
108112 std::vector<nlohmann::json> & get_mutable_empty() { return empty; }
109113 void set_empty(const std::vector<nlohmann::json> & value) { this->empty = value; }
110114
111- const std::string & get_foo() const { return foo; }
112- std::string & get_mutable_foo() { return foo; }
113- void set_foo(const std::string & value) { this->foo = value; }
114-
115115 const nlohmann::json & get_impossible() const { return impossible; }
116116 nlohmann::json & get_mutable_impossible() { return impossible; }
117117 void set_impossible(const nlohmann::json & value) { this->impossible = value; }
@@ -123,17 +123,17 @@ namespace quicktype {
123123 void to_json(json & j, const TopLevel & x);
124124
125125 inline void from_json(const json & j, TopLevel& x) {
126+ x.set_foo(j.at("foo").get<std::string>());
126127 x.set_disallowed(get_untyped(j, "disallowed"));
127128 x.set_empty(j.at("empty").get<std::vector<nlohmann::json>>());
128- x.set_foo(j.at("foo").get<std::string>());
129129 x.set_impossible(get_untyped(j, "impossible"));
130130 }
131131
132132 inline void to_json(json & j, const TopLevel & x) {
133133 j = json::object();
134+ j["foo"] = x.get_foo();
134135 j["disallowed"] = x.get_disallowed();
135136 j["empty"] = x.get_empty();
136- j["foo"] = x.get_foo();
137137 j["impossible"] = x.get_impossible();
138138 }
139139 }
Mschema-cplusplus/test/inputs/schema/comment-injection.schema/default/quicktype.hpp+21 −21
@@ -108,12 +108,30 @@ namespace quicktype {
108108 virtual ~TopLevel() = default;
109109
110110 private:
111+ std::string value;
111112 std::optional<std::string> trailing_backslash;
112113 std::optional<std::string> trailing_quote;
113114 std::optional<std::string> trailing_triple_quote;
114- std::string value;
115115
116116 public:
117+ /**
118+ * Property delimiters:
119+ * * /
120+ * / *
121+ * {-
122+ * -}
123+ * """
124+ * </summary> & <br>
125+ * }
126+ * }
127+ * }
128+ * }
129+ * }
130+ */
131+ const std::string & get_value() const { return value; }
132+ std::string & get_mutable_value() { return value; }
133+ void set_value(const std::string & value) { this->value = value; }
134+
117135 /**
118136 * Ends with a backslash \.
119137 */
@@ -134,24 +152,6 @@ namespace quicktype {
134152 const std::optional<std::string> & get_trailing_triple_quote() const { return trailing_triple_quote; }
135153 std::optional<std::string> & get_mutable_trailing_triple_quote() { return trailing_triple_quote; }
136154 void set_trailing_triple_quote(const std::optional<std::string> & value) { this->trailing_triple_quote = value; }
137-
138- /**
139- * Property delimiters:
140- * * /
141- * / *
142- * {-
143- * -}
144- * """
145- * </summary> & <br>
146- * }
147- * }
148- * }
149- * }
150- * }
151- */
152- const std::string & get_value() const { return value; }
153- std::string & get_mutable_value() { return value; }
154- void set_value(const std::string & value) { this->value = value; }
155155 };
156156 }
157157
@@ -160,17 +160,17 @@ namespace quicktype {
160160 void to_json(json & j, const TopLevel & x);
161161
162162 inline void from_json(const json & j, TopLevel& x) {
163+ x.set_value(j.at("value").get<std::string>());
163164 x.set_trailing_backslash(get_stack_optional<std::string>(j, "trailingBackslash"));
164165 x.set_trailing_quote(get_stack_optional<std::string>(j, "trailingQuote"));
165166 x.set_trailing_triple_quote(get_stack_optional<std::string>(j, "trailingTripleQuote"));
166- x.set_value(j.at("value").get<std::string>());
167167 }
168168
169169 inline void to_json(json & j, const TopLevel & x) {
170170 j = json::object();
171+ j["value"] = x.get_value();
171172 j["trailingBackslash"] = x.get_trailing_backslash();
172173 j["trailingQuote"] = x.get_trailing_quote();
173174 j["trailingTripleQuote"] = x.get_trailing_triple_quote();
174- j["value"] = x.get_value();
175175 }
176176 }
Mschema-cplusplus/test/inputs/schema/const-non-string.schema/default/quicktype.hpp+14 −14
@@ -39,17 +39,25 @@ namespace quicktype {
3939 virtual ~TopLevel() = default;
4040
4141 private:
42+ double version;
4243 int64_t amount;
44+ double ratio;
4345 bool enabled;
4446 Kind kind;
45- double ratio;
46- double version;
4747
4848 public:
49+ const double & get_version() const { return version; }
50+ double & get_mutable_version() { return version; }
51+ void set_version(const double & value) { this->version = value; }
52+
4953 const int64_t & get_amount() const { return amount; }
5054 int64_t & get_mutable_amount() { return amount; }
5155 void set_amount(const int64_t & value) { this->amount = value; }
5256
57+ const double & get_ratio() const { return ratio; }
58+ double & get_mutable_ratio() { return ratio; }
59+ void set_ratio(const double & value) { this->ratio = value; }
60+
5361 const bool & get_enabled() const { return enabled; }
5462 bool & get_mutable_enabled() { return enabled; }
5563 void set_enabled(const bool & value) { this->enabled = value; }
@@ -57,14 +65,6 @@ namespace quicktype {
5765 const Kind & get_kind() const { return kind; }
5866 Kind & get_mutable_kind() { return kind; }
5967 void set_kind(const Kind & value) { this->kind = value; }
60-
61- const double & get_ratio() const { return ratio; }
62- double & get_mutable_ratio() { return ratio; }
63- void set_ratio(const double & value) { this->ratio = value; }
64-
65- const double & get_version() const { return version; }
66- double & get_mutable_version() { return version; }
67- void set_version(const double & value) { this->version = value; }
6868 };
6969 }
7070
@@ -76,20 +76,20 @@ namespace quicktype {
7676 void to_json(json & j, const Kind & x);
7777
7878 inline void from_json(const json & j, TopLevel& x) {
79+ x.set_version(j.at("version").get<double>());
7980 x.set_amount(j.at("amount").get<int64_t>());
81+ x.set_ratio(j.at("ratio").get<double>());
8082 x.set_enabled(j.at("enabled").get<bool>());
8183 x.set_kind(j.at("kind").get<Kind>());
82- x.set_ratio(j.at("ratio").get<double>());
83- x.set_version(j.at("version").get<double>());
8484 }
8585
8686 inline void to_json(json & j, const TopLevel & x) {
8787 j = json::object();
88+ j["version"] = x.get_version();
8889 j["amount"] = x.get_amount();
90+ j["ratio"] = x.get_ratio();
8991 j["enabled"] = x.get_enabled();
9092 j["kind"] = x.get_kind();
91- j["ratio"] = x.get_ratio();
92- j["version"] = x.get_version();
9393 }
9494
9595 inline void from_json(const json & j, Kind & x) {
Mschema-cplusplus/test/inputs/schema/date-time-or-string.schema/default/quicktype.hpp+7 −7
@@ -37,17 +37,17 @@ namespace quicktype {
3737 virtual ~TopLevel() = default;
3838
3939 private:
40- std::string bar;
4140 std::string foo;
41+ std::string bar;
4242
4343 public:
44- const std::string & get_bar() const { return bar; }
45- std::string & get_mutable_bar() { return bar; }
46- void set_bar(const std::string & value) { this->bar = value; }
47-
4844 const std::string & get_foo() const { return foo; }
4945 std::string & get_mutable_foo() { return foo; }
5046 void set_foo(const std::string & value) { this->foo = value; }
47+
48+ const std::string & get_bar() const { return bar; }
49+ std::string & get_mutable_bar() { return bar; }
50+ void set_bar(const std::string & value) { this->bar = value; }
5151 };
5252 }
5353
@@ -56,13 +56,13 @@ namespace quicktype {
5656 void to_json(json & j, const TopLevel & x);
5757
5858 inline void from_json(const json & j, TopLevel& x) {
59- x.set_bar(j.at("bar").get<std::string>());
6059 x.set_foo(j.at("foo").get<std::string>());
60+ x.set_bar(j.at("bar").get<std::string>());
6161 }
6262
6363 inline void to_json(json & j, const TopLevel & x) {
6464 j = json::object();
65- j["bar"] = x.get_bar();
6665 j["foo"] = x.get_foo();
66+ j["bar"] = x.get_bar();
6767 }
6868 }
Mschema-cplusplus/test/inputs/schema/date-time.schema/default/quicktype.hpp+14 −14
@@ -96,32 +96,32 @@ namespace quicktype {
9696 virtual ~TopLevel() = default;
9797
9898 private:
99- std::vector<ComplexUnionArray> complex_union_array;
10099 std::string date;
101- std::string date_time;
102100 std::string time;
101+ std::string date_time;
103102 std::vector<std::string> union_array;
103+ std::vector<ComplexUnionArray> complex_union_array;
104104
105105 public:
106- const std::vector<ComplexUnionArray> & get_complex_union_array() const { return complex_union_array; }
107- std::vector<ComplexUnionArray> & get_mutable_complex_union_array() { return complex_union_array; }
108- void set_complex_union_array(const std::vector<ComplexUnionArray> & value) { this->complex_union_array = value; }
109-
110106 const std::string & get_date() const { return date; }
111107 std::string & get_mutable_date() { return date; }
112108 void set_date(const std::string & value) { this->date = value; }
113109
114- const std::string & get_date_time() const { return date_time; }
115- std::string & get_mutable_date_time() { return date_time; }
116- void set_date_time(const std::string & value) { this->date_time = value; }
117-
118110 const std::string & get_time() const { return time; }
119111 std::string & get_mutable_time() { return time; }
120112 void set_time(const std::string & value) { this->time = value; }
121113
114+ const std::string & get_date_time() const { return date_time; }
115+ std::string & get_mutable_date_time() { return date_time; }
116+ void set_date_time(const std::string & value) { this->date_time = value; }
117+
122118 const std::vector<std::string> & get_union_array() const { return union_array; }
123119 std::vector<std::string> & get_mutable_union_array() { return union_array; }
124120 void set_union_array(const std::vector<std::string> & value) { this->union_array = value; }
121+
122+ const std::vector<ComplexUnionArray> & get_complex_union_array() const { return complex_union_array; }
123+ std::vector<ComplexUnionArray> & get_mutable_complex_union_array() { return complex_union_array; }
124+ void set_complex_union_array(const std::vector<ComplexUnionArray> & value) { this->complex_union_array = value; }
125125 };
126126 }
127127
@@ -138,20 +138,20 @@ struct adl_serializer<std::variant<int64_t, std::string>> {
138138 }
139139 namespace quicktype {
140140 inline void from_json(const json & j, TopLevel& x) {
141- x.set_complex_union_array(j.at("complex-union-array").get<std::vector<ComplexUnionArray>>());
142141 x.set_date(j.at("date").get<std::string>());
143- x.set_date_time(j.at("date-time").get<std::string>());
144142 x.set_time(j.at("time").get<std::string>());
143+ x.set_date_time(j.at("date-time").get<std::string>());
145144 x.set_union_array(j.at("union-array").get<std::vector<std::string>>());
145+ x.set_complex_union_array(j.at("complex-union-array").get<std::vector<ComplexUnionArray>>());
146146 }
147147
148148 inline void to_json(json & j, const TopLevel & x) {
149149 j = json::object();
150- j["complex-union-array"] = x.get_complex_union_array();
151150 j["date"] = x.get_date();
152- j["date-time"] = x.get_date_time();
153151 j["time"] = x.get_time();
152+ j["date-time"] = x.get_date_time();
154153 j["union-array"] = x.get_union_array();
154+ j["complex-union-array"] = x.get_complex_union_array();
155155 }
156156 }
157157 namespace nlohmann {
Mschema-cplusplus/test/inputs/schema/description.schema/default/quicktype.hpp+17 −17
@@ -125,19 +125,19 @@ namespace quicktype {
125125 virtual ~TopLevel() = default;
126126
127127 private:
128- std::optional<bool> bar;
128+ Union top_level_union;
129129 Enum top_level_enum;
130130 std::optional<double> foo;
131+ std::optional<bool> bar;
131132 ObjectOrStringUnion object_or_string;
132- Union top_level_union;
133133
134134 public:
135135 /**
136- * A pretty boolean
136+ * Either a number or a string
137137 */
138- const std::optional<bool> & get_bar() const { return bar; }
139- std::optional<bool> & get_mutable_bar() { return bar; }
140- void set_bar(const std::optional<bool> & value) { this->bar = value; }
138+ const Union & get_top_level_union() const { return top_level_union; }
139+ Union & get_mutable_top_level_union() { return top_level_union; }
140+ void set_top_level_union(const Union & value) { this->top_level_union = value; }
141141
142142 /**
143143 * An enumeration
@@ -150,16 +150,16 @@ namespace quicktype {
150150 std::optional<double> & get_mutable_foo() { return foo; }
151151 void set_foo(const std::optional<double> & value) { this->foo = value; }
152152
153+ /**
154+ * A pretty boolean
155+ */
156+ const std::optional<bool> & get_bar() const { return bar; }
157+ std::optional<bool> & get_mutable_bar() { return bar; }
158+ void set_bar(const std::optional<bool> & value) { this->bar = value; }
159+
153160 const ObjectOrStringUnion & get_object_or_string() const { return object_or_string; }
154161 ObjectOrStringUnion & get_mutable_object_or_string() { return object_or_string; }
155162 void set_object_or_string(const ObjectOrStringUnion & value) { this->object_or_string = value; }
156-
157- /**
158- * Either a number or a string
159- */
160- const Union & get_top_level_union() const { return top_level_union; }
161- Union & get_mutable_top_level_union() { return top_level_union; }
162- void set_top_level_union(const Union & value) { this->top_level_union = value; }
163163 };
164164 }
165165
@@ -197,20 +197,20 @@ namespace quicktype {
197197 }
198198
199199 inline void from_json(const json & j, TopLevel& x) {
200- x.set_bar(get_stack_optional<bool>(j, "bar"));
200+ x.set_top_level_union(j.at("union").get<Union>());
201201 x.set_top_level_enum(j.at("enum").get<Enum>());
202202 x.set_foo(get_stack_optional<double>(j, "foo"));
203+ x.set_bar(get_stack_optional<bool>(j, "bar"));
203204 x.set_object_or_string(j.at("object-or-string").get<ObjectOrStringUnion>());
204- x.set_top_level_union(j.at("union").get<Union>());
205205 }
206206
207207 inline void to_json(json & j, const TopLevel & x) {
208208 j = json::object();
209- j["bar"] = x.get_bar();
209+ j["union"] = x.get_top_level_union();
210210 j["enum"] = x.get_top_level_enum();
211211 j["foo"] = x.get_foo();
212+ j["bar"] = x.get_bar();
212213 j["object-or-string"] = x.get_object_or_string();
213- j["union"] = x.get_top_level_union();
214214 }
215215
216216 inline void from_json(const json & j, Enum & x) {
Mschema-cplusplus/test/inputs/schema/direct-union.schema/default/quicktype.hpp+6 −6
@@ -97,15 +97,15 @@ namespace quicktype {
9797 virtual ~Thing() = default;
9898
9999 private:
100- Anything optional;
101100 Anything required;
101+ Anything optional;
102102
103103 public:
104- Anything get_optional() const { return optional; }
105- void set_optional(Anything value) { this->optional = value; }
106-
107104 Anything get_required() const { return required; }
108105 void set_required(Anything value) { this->required = value; }
106+
107+ Anything get_optional() const { return optional; }
108+ void set_optional(Anything value) { this->optional = value; }
109109 };
110110
111111 class TopLevel {
@@ -139,14 +139,14 @@ struct adl_serializer<std::variant<std::vector<json>, bool, double, int64_t, std
139139 }
140140 namespace quicktype {
141141 inline void from_json(const json & j, Thing& x) {
142- x.set_optional(get_stack_optional<std::variant<std::vector<nlohmann::json>, bool, double, int64_t, std::map<std::string, nlohmann::json>, std::string>>(j, "optional"));
143142 x.set_required(get_stack_optional<std::variant<std::vector<nlohmann::json>, bool, double, int64_t, std::map<std::string, nlohmann::json>, std::string>>(j, "required"));
143+ x.set_optional(get_stack_optional<std::variant<std::vector<nlohmann::json>, bool, double, int64_t, std::map<std::string, nlohmann::json>, std::string>>(j, "optional"));
144144 }
145145
146146 inline void to_json(json & j, const Thing & x) {
147147 j = json::object();
148- j["optional"] = x.get_optional();
149148 j["required"] = x.get_required();
149+ j["optional"] = x.get_optional();
150150 }
151151
152152 inline void from_json(const json & j, TopLevel& x) {
Mschema-cplusplus/test/inputs/schema/enum.schema/default/quicktype.hpp+19 −19
@@ -103,32 +103,32 @@ namespace quicktype {
103103 virtual ~TopLevel() = default;
104104
105105 private:
106- std::optional<std::vector<Arr>> arr;
107- std::optional<std::string> top_level_for;
108- Gve gve;
109106 std::optional<Lvc> lvc;
107+ Gve gve;
108+ std::optional<std::vector<Arr>> arr;
110109 std::optional<std::vector<OtherArr>> other_arr;
110+ std::optional<std::string> top_level_for;
111111
112112 public:
113- const std::optional<std::vector<Arr>> & get_arr() const { return arr; }
114- std::optional<std::vector<Arr>> & get_mutable_arr() { return arr; }
115- void set_arr(const std::optional<std::vector<Arr>> & value) { this->arr = value; }
116-
117- const std::optional<std::string> & get_top_level_for() const { return top_level_for; }
118- std::optional<std::string> & get_mutable_top_level_for() { return top_level_for; }
119- void set_top_level_for(const std::optional<std::string> & value) { this->top_level_for = value; }
113+ const std::optional<Lvc> & get_lvc() const { return lvc; }
114+ std::optional<Lvc> & get_mutable_lvc() { return lvc; }
115+ void set_lvc(const std::optional<Lvc> & value) { this->lvc = value; }
120116
121117 const Gve & get_gve() const { return gve; }
122118 Gve & get_mutable_gve() { return gve; }
123119 void set_gve(const Gve & value) { this->gve = value; }
124120
125- const std::optional<Lvc> & get_lvc() const { return lvc; }
126- std::optional<Lvc> & get_mutable_lvc() { return lvc; }
127- void set_lvc(const std::optional<Lvc> & value) { this->lvc = value; }
121+ const std::optional<std::vector<Arr>> & get_arr() const { return arr; }
122+ std::optional<std::vector<Arr>> & get_mutable_arr() { return arr; }
123+ void set_arr(const std::optional<std::vector<Arr>> & value) { this->arr = value; }
128124
129125 const std::optional<std::vector<OtherArr>> & get_other_arr() const { return other_arr; }
130126 std::optional<std::vector<OtherArr>> & get_mutable_other_arr() { return other_arr; }
131127 void set_other_arr(const std::optional<std::vector<OtherArr>> & value) { this->other_arr = value; }
128+
129+ const std::optional<std::string> & get_top_level_for() const { return top_level_for; }
130+ std::optional<std::string> & get_mutable_top_level_for() { return top_level_for; }
131+ void set_top_level_for(const std::optional<std::string> & value) { this->top_level_for = value; }
132132 };
133133 }
134134
@@ -154,20 +154,20 @@ struct adl_serializer<std::variant<quicktype::OtherArr, int64_t>> {
154154 }
155155 namespace quicktype {
156156 inline void from_json(const json & j, TopLevel& x) {
157- x.set_arr(get_stack_optional<std::vector<Arr>>(j, "arr"));
158- x.set_top_level_for(get_stack_optional<std::string>(j, "for"));
159- x.set_gve(j.at("gve").get<Gve>());
160157 x.set_lvc(get_stack_optional<Lvc>(j, "lvc"));
158+ x.set_gve(j.at("gve").get<Gve>());
159+ x.set_arr(get_stack_optional<std::vector<Arr>>(j, "arr"));
161160 x.set_other_arr(get_stack_optional<std::vector<OtherArr>>(j, "otherArr"));
161+ x.set_top_level_for(get_stack_optional<std::string>(j, "for"));
162162 }
163163
164164 inline void to_json(json & j, const TopLevel & x) {
165165 j = json::object();
166- j["arr"] = x.get_arr();
167- j["for"] = x.get_top_level_for();
168- j["gve"] = x.get_gve();
169166 j["lvc"] = x.get_lvc();
167+ j["gve"] = x.get_gve();
168+ j["arr"] = x.get_arr();
170169 j["otherArr"] = x.get_other_arr();
170+ j["for"] = x.get_top_level_for();
171171 }
172172
173173 inline void from_json(const json & j, OtherArr & x) {
Mschema-cplusplus/test/inputs/schema/integer-string.schema/default/quicktype.hpp+20 −20
@@ -97,26 +97,15 @@ namespace quicktype {
9797 virtual ~TopLevel() = default;
9898
9999 private:
100- std::optional<std::vector<std::optional<std::string>>> arr_nullable;
101- std::optional<std::vector<std::string>> arr_one;
102- std::optional<std::string> nullable;
103100 std::string one;
104101 std::optional<std::string> optional;
102+ std::optional<std::string> nullable;
103+ std::optional<std::vector<std::string>> arr_one;
104+ std::optional<std::vector<std::optional<std::string>>> arr_nullable;
105105 UnionWithInt union_with_int;
106106 UnionWithInt union_with_int_and_enum;
107107
108108 public:
109- const std::optional<std::vector<std::optional<std::string>>> & get_arr_nullable() const { return arr_nullable; }
110- std::optional<std::vector<std::optional<std::string>>> & get_mutable_arr_nullable() { return arr_nullable; }
111- void set_arr_nullable(const std::optional<std::vector<std::optional<std::string>>> & value) { this->arr_nullable = value; }
112-
113- const std::optional<std::vector<std::string>> & get_arr_one() const { return arr_one; }
114- std::optional<std::vector<std::string>> & get_mutable_arr_one() { return arr_one; }
115- void set_arr_one(const std::optional<std::vector<std::string>> & value) { this->arr_one = value; }
116-
117- std::optional<std::string> get_nullable() const { return nullable; }
118- void set_nullable(std::optional<std::string> value) { this->nullable = value; }
119-
120109 const std::string & get_one() const { return one; }
121110 std::string & get_mutable_one() { return one; }
122111 void set_one(const std::string & value) { this->one = value; }
@@ -125,6 +114,17 @@ namespace quicktype {
125114 std::optional<std::string> & get_mutable_optional() { return optional; }
126115 void set_optional(const std::optional<std::string> & value) { this->optional = value; }
127116
117+ std::optional<std::string> get_nullable() const { return nullable; }
118+ void set_nullable(std::optional<std::string> value) { this->nullable = value; }
119+
120+ const std::optional<std::vector<std::string>> & get_arr_one() const { return arr_one; }
121+ std::optional<std::vector<std::string>> & get_mutable_arr_one() { return arr_one; }
122+ void set_arr_one(const std::optional<std::vector<std::string>> & value) { this->arr_one = value; }
123+
124+ const std::optional<std::vector<std::optional<std::string>>> & get_arr_nullable() const { return arr_nullable; }
125+ std::optional<std::vector<std::optional<std::string>>> & get_mutable_arr_nullable() { return arr_nullable; }
126+ void set_arr_nullable(const std::optional<std::vector<std::optional<std::string>>> & value) { this->arr_nullable = value; }
127+
128128 const UnionWithInt & get_union_with_int() const { return union_with_int; }
129129 UnionWithInt & get_mutable_union_with_int() { return union_with_int; }
130130 void set_union_with_int(const UnionWithInt & value) { this->union_with_int = value; }
@@ -148,22 +148,22 @@ struct adl_serializer<std::variant<int64_t, std::string>> {
148148 }
149149 namespace quicktype {
150150 inline void from_json(const json & j, TopLevel& x) {
151- x.set_arr_nullable(get_stack_optional<std::vector<std::optional<std::string>>>(j, "arrNullable"));
152- x.set_arr_one(get_stack_optional<std::vector<std::string>>(j, "arrOne"));
153- x.set_nullable(get_stack_optional<std::string>(j, "nullable"));
154151 x.set_one(j.at("one").get<std::string>());
155152 x.set_optional(get_stack_optional<std::string>(j, "optional"));
153+ x.set_nullable(get_stack_optional<std::string>(j, "nullable"));
154+ x.set_arr_one(get_stack_optional<std::vector<std::string>>(j, "arrOne"));
155+ x.set_arr_nullable(get_stack_optional<std::vector<std::optional<std::string>>>(j, "arrNullable"));
156156 x.set_union_with_int(j.at("unionWithInt").get<UnionWithInt>());
157157 x.set_union_with_int_and_enum(j.at("unionWithIntAndEnum").get<UnionWithInt>());
158158 }
159159
160160 inline void to_json(json & j, const TopLevel & x) {
161161 j = json::object();
162- j["arrNullable"] = x.get_arr_nullable();
163- j["arrOne"] = x.get_arr_one();
164- j["nullable"] = x.get_nullable();
165162 j["one"] = x.get_one();
166163 j["optional"] = x.get_optional();
164+ j["nullable"] = x.get_nullable();
165+ j["arrOne"] = x.get_arr_one();
166+ j["arrNullable"] = x.get_arr_nullable();
167167 j["unionWithInt"] = x.get_union_with_int();
168168 j["unionWithIntAndEnum"] = x.get_union_with_int_and_enum();
169169 }
Mschema-cplusplus/test/inputs/schema/integer-type.schema/default/quicktype.hpp+44 −44
@@ -165,72 +165,72 @@ namespace quicktype {
165165 class TopLevel {
166166 public:
167167 TopLevel() :
168+ small_positive_constraint(0, 100, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
169+ small_negative_constraint(-100, 0, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
170+ i32_range_constraint(-2147483648, 2147483647, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
168171 above_i32_max_constraint(0, 2147483648, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
169172 below_i32_min_constraint(-2147483649, 0, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
170- i32_range_constraint(-2147483648, 2147483647, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
171- large_bounds_constraint(-9007199254740991, 9007199254740991, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
172- only_maximum_constraint(std::nullopt, 0, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
173173 only_minimum_constraint(0, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
174- small_negative_constraint(-100, 0, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
175- small_positive_constraint(0, 100, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt)
174+ only_maximum_constraint(std::nullopt, 0, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
175+ large_bounds_constraint(-9007199254740991, 9007199254740991, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt)
176176 {}
177177 virtual ~TopLevel() = default;
178178
179179 private:
180+ int64_t small_positive;
181+ ClassMemberConstraints small_positive_constraint;
182+ int64_t small_negative;
183+ ClassMemberConstraints small_negative_constraint;
184+ int64_t i32_range;
185+ ClassMemberConstraints i32_range_constraint;
180186 int64_t above_i32_max;
181187 ClassMemberConstraints above_i32_max_constraint;
182188 int64_t below_i32_min;
183189 ClassMemberConstraints below_i32_min_constraint;
184- int64_t i32_range;
185- ClassMemberConstraints i32_range_constraint;
186- int64_t large_bounds;
187- ClassMemberConstraints large_bounds_constraint;
188- int64_t only_maximum;
189- ClassMemberConstraints only_maximum_constraint;
190190 int64_t only_minimum;
191191 ClassMemberConstraints only_minimum_constraint;
192- int64_t small_negative;
193- ClassMemberConstraints small_negative_constraint;
194- int64_t small_positive;
195- ClassMemberConstraints small_positive_constraint;
192+ int64_t only_maximum;
193+ ClassMemberConstraints only_maximum_constraint;
196194 int64_t unbounded;
195+ int64_t large_bounds;
196+ ClassMemberConstraints large_bounds_constraint;
197197
198198 public:
199- const int64_t & get_above_i32_max() const { return above_i32_max; }
200- int64_t & get_mutable_above_i32_max() { return above_i32_max; }
201- void set_above_i32_max(const int64_t & value) { CheckConstraint("above_i32_max", above_i32_max_constraint, value); this->above_i32_max = value; }
199+ const int64_t & get_small_positive() const { return small_positive; }
200+ int64_t & get_mutable_small_positive() { return small_positive; }
201+ void set_small_positive(const int64_t & value) { CheckConstraint("small_positive", small_positive_constraint, value); this->small_positive = value; }
202202
203- const int64_t & get_below_i32_min() const { return below_i32_min; }
204- int64_t & get_mutable_below_i32_min() { return below_i32_min; }
205- void set_below_i32_min(const int64_t & value) { CheckConstraint("below_i32_min", below_i32_min_constraint, value); this->below_i32_min = value; }
203+ const int64_t & get_small_negative() const { return small_negative; }
204+ int64_t & get_mutable_small_negative() { return small_negative; }
205+ void set_small_negative(const int64_t & value) { CheckConstraint("small_negative", small_negative_constraint, value); this->small_negative = value; }
206206
207207 const int64_t & get_i32_range() const { return i32_range; }
208208 int64_t & get_mutable_i32_range() { return i32_range; }
209209 void set_i32_range(const int64_t & value) { CheckConstraint("i32_range", i32_range_constraint, value); this->i32_range = value; }
210210
211- const int64_t & get_large_bounds() const { return large_bounds; }
212- int64_t & get_mutable_large_bounds() { return large_bounds; }
213- void set_large_bounds(const int64_t & value) { CheckConstraint("large_bounds", large_bounds_constraint, value); this->large_bounds = value; }
211+ const int64_t & get_above_i32_max() const { return above_i32_max; }
212+ int64_t & get_mutable_above_i32_max() { return above_i32_max; }
213+ void set_above_i32_max(const int64_t & value) { CheckConstraint("above_i32_max", above_i32_max_constraint, value); this->above_i32_max = value; }
214214
215- const int64_t & get_only_maximum() const { return only_maximum; }
216- int64_t & get_mutable_only_maximum() { return only_maximum; }
217- void set_only_maximum(const int64_t & value) { CheckConstraint("only_maximum", only_maximum_constraint, value); this->only_maximum = value; }
215+ const int64_t & get_below_i32_min() const { return below_i32_min; }
216+ int64_t & get_mutable_below_i32_min() { return below_i32_min; }
217+ void set_below_i32_min(const int64_t & value) { CheckConstraint("below_i32_min", below_i32_min_constraint, value); this->below_i32_min = value; }
218218
219219 const int64_t & get_only_minimum() const { return only_minimum; }
220220 int64_t & get_mutable_only_minimum() { return only_minimum; }
221221 void set_only_minimum(const int64_t & value) { CheckConstraint("only_minimum", only_minimum_constraint, value); this->only_minimum = value; }
222222
223- const int64_t & get_small_negative() const { return small_negative; }
224- int64_t & get_mutable_small_negative() { return small_negative; }
225- void set_small_negative(const int64_t & value) { CheckConstraint("small_negative", small_negative_constraint, value); this->small_negative = value; }
226-
227- const int64_t & get_small_positive() const { return small_positive; }
228- int64_t & get_mutable_small_positive() { return small_positive; }
229- void set_small_positive(const int64_t & value) { CheckConstraint("small_positive", small_positive_constraint, value); this->small_positive = value; }
223+ const int64_t & get_only_maximum() const { return only_maximum; }
224+ int64_t & get_mutable_only_maximum() { return only_maximum; }
225+ void set_only_maximum(const int64_t & value) { CheckConstraint("only_maximum", only_maximum_constraint, value); this->only_maximum = value; }
230226
231227 const int64_t & get_unbounded() const { return unbounded; }
232228 int64_t & get_mutable_unbounded() { return unbounded; }
233229 void set_unbounded(const int64_t & value) { this->unbounded = value; }
230+
231+ const int64_t & get_large_bounds() const { return large_bounds; }
232+ int64_t & get_mutable_large_bounds() { return large_bounds; }
233+ void set_large_bounds(const int64_t & value) { CheckConstraint("large_bounds", large_bounds_constraint, value); this->large_bounds = value; }
234234 };
235235 }
236236
@@ -239,27 +239,27 @@ namespace quicktype {
239239 void to_json(json & j, const TopLevel & x);
240240
241241 inline void from_json(const json & j, TopLevel& x) {
242+ x.set_small_positive(j.at("small_positive").get<int64_t>());
243+ x.set_small_negative(j.at("small_negative").get<int64_t>());
244+ x.set_i32_range(j.at("i32_range").get<int64_t>());
242245 x.set_above_i32_max(j.at("above_i32_max").get<int64_t>());
243246 x.set_below_i32_min(j.at("below_i32_min").get<int64_t>());
244- x.set_i32_range(j.at("i32_range").get<int64_t>());
245- x.set_large_bounds(j.at("large_bounds").get<int64_t>());
246- x.set_only_maximum(j.at("only_maximum").get<int64_t>());
247247 x.set_only_minimum(j.at("only_minimum").get<int64_t>());
248- x.set_small_negative(j.at("small_negative").get<int64_t>());
249- x.set_small_positive(j.at("small_positive").get<int64_t>());
248+ x.set_only_maximum(j.at("only_maximum").get<int64_t>());
250249 x.set_unbounded(j.at("unbounded").get<int64_t>());
250+ x.set_large_bounds(j.at("large_bounds").get<int64_t>());
251251 }
252252
253253 inline void to_json(json & j, const TopLevel & x) {
254254 j = json::object();
255+ j["small_positive"] = x.get_small_positive();
256+ j["small_negative"] = x.get_small_negative();
257+ j["i32_range"] = x.get_i32_range();
255258 j["above_i32_max"] = x.get_above_i32_max();
256259 j["below_i32_min"] = x.get_below_i32_min();
257- j["i32_range"] = x.get_i32_range();
258- j["large_bounds"] = x.get_large_bounds();
259- j["only_maximum"] = x.get_only_maximum();
260260 j["only_minimum"] = x.get_only_minimum();
261- j["small_negative"] = x.get_small_negative();
262- j["small_positive"] = x.get_small_positive();
261+ j["only_maximum"] = x.get_only_maximum();
263262 j["unbounded"] = x.get_unbounded();
263+ j["large_bounds"] = x.get_large_bounds();
264264 }
265265 }
Mschema-cplusplus/test/inputs/schema/light.schema/default/quicktype.hpp+7 −7
@@ -37,19 +37,19 @@ namespace quicktype {
3737 virtual ~LightParams() = default;
3838
3939 private:
40- std::string app_id;
4140 std::string outlet_id;
41+ std::string app_id;
4242 std::string rgba;
4343
4444 public:
45- const std::string & get_app_id() const { return app_id; }
46- std::string & get_mutable_app_id() { return app_id; }
47- void set_app_id(const std::string & value) { this->app_id = value; }
48-
4945 const std::string & get_outlet_id() const { return outlet_id; }
5046 std::string & get_mutable_outlet_id() { return outlet_id; }
5147 void set_outlet_id(const std::string & value) { this->outlet_id = value; }
5248
49+ const std::string & get_app_id() const { return app_id; }
50+ std::string & get_mutable_app_id() { return app_id; }
51+ void set_app_id(const std::string & value) { this->app_id = value; }
52+
5353 const std::string & get_rgba() const { return rgba; }
5454 std::string & get_mutable_rgba() { return rgba; }
5555 void set_rgba(const std::string & value) { this->rgba = value; }
@@ -78,15 +78,15 @@ namespace quicktype {
7878 void to_json(json & j, const TopLevel & x);
7979
8080 inline void from_json(const json & j, LightParams& x) {
81- x.set_app_id(j.at("app_id").get<std::string>());
8281 x.set_outlet_id(j.at("outlet_id").get<std::string>());
82+ x.set_app_id(j.at("app_id").get<std::string>());
8383 x.set_rgba(j.at("rgba").get<std::string>());
8484 }
8585
8686 inline void to_json(json & j, const LightParams & x) {
8787 j = json::object();
88- j["app_id"] = x.get_app_id();
8988 j["outlet_id"] = x.get_outlet_id();
89+ j["app_id"] = x.get_app_id();
9090 j["rgba"] = x.get_rgba();
9191 }
Mschema-cplusplus/test/inputs/schema/min-max-items.schema/default/quicktype.hpp+7 −7
@@ -96,13 +96,17 @@ namespace quicktype {
9696 virtual ~TopLevel() = default;
9797
9898 private:
99+ std::vector<std::string> min_only;
99100 std::vector<int64_t> max_only;
100101 std::vector<double> min_and_max;
101- std::vector<std::string> min_only;
102102 std::vector<std::string> plain;
103103 std::vector<UnionItem> union_items;
104104
105105 public:
106+ const std::vector<std::string> & get_min_only() const { return min_only; }
107+ std::vector<std::string> & get_mutable_min_only() { return min_only; }
108+ void set_min_only(const std::vector<std::string> & value) { this->min_only = value; }
109+
106110 const std::vector<int64_t> & get_max_only() const { return max_only; }
107111 std::vector<int64_t> & get_mutable_max_only() { return max_only; }
108112 void set_max_only(const std::vector<int64_t> & value) { this->max_only = value; }
@@ -111,10 +115,6 @@ namespace quicktype {
111115 std::vector<double> & get_mutable_min_and_max() { return min_and_max; }
112116 void set_min_and_max(const std::vector<double> & value) { this->min_and_max = value; }
113117
114- const std::vector<std::string> & get_min_only() const { return min_only; }
115- std::vector<std::string> & get_mutable_min_only() { return min_only; }
116- void set_min_only(const std::vector<std::string> & value) { this->min_only = value; }
117-
118118 const std::vector<std::string> & get_plain() const { return plain; }
119119 std::vector<std::string> & get_mutable_plain() { return plain; }
120120 void set_plain(const std::vector<std::string> & value) { this->plain = value; }
@@ -138,18 +138,18 @@ struct adl_serializer<std::variant<int64_t, std::string>> {
138138 }
139139 namespace quicktype {
140140 inline void from_json(const json & j, TopLevel& x) {
141+ x.set_min_only(j.at("minOnly").get<std::vector<std::string>>());
141142 x.set_max_only(j.at("maxOnly").get<std::vector<int64_t>>());
142143 x.set_min_and_max(j.at("minAndMax").get<std::vector<double>>());
143- x.set_min_only(j.at("minOnly").get<std::vector<std::string>>());
144144 x.set_plain(j.at("plain").get<std::vector<std::string>>());
145145 x.set_union_items(j.at("unionItems").get<std::vector<UnionItem>>());
146146 }
147147
148148 inline void to_json(json & j, const TopLevel & x) {
149149 j = json::object();
150+ j["minOnly"] = x.get_min_only();
150151 j["maxOnly"] = x.get_max_only();
151152 j["minAndMax"] = x.get_min_and_max();
152- j["minOnly"] = x.get_min_only();
153153 j["plain"] = x.get_plain();
154154 j["unionItems"] = x.get_union_items();
155155 }
Mschema-cplusplus/test/inputs/schema/minmax-integer.schema/default/quicktype.hpp+32 −32
@@ -165,63 +165,63 @@ namespace quicktype {
165165 class TopLevel {
166166 public:
167167 TopLevel() :
168- intersection_constraint(4, 5, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
169- max_constraint(std::nullopt, 5, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
170168 min_constraint(3, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
169+ max_constraint(std::nullopt, 5, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
171170 minmax_constraint(3, 5, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
172- min_max_intersection_constraint(3, 5, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
173- union_constraint(3, 6, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt)
171+ union_constraint(3, 6, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
172+ intersection_constraint(4, 5, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
173+ min_max_intersection_constraint(3, 5, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt)
174174 {}
175175 virtual ~TopLevel() = default;
176176
177177 private:
178178 int64_t free;
179- int64_t intersection;
180- ClassMemberConstraints intersection_constraint;
181- int64_t max;
182- ClassMemberConstraints max_constraint;
183179 int64_t min;
184180 ClassMemberConstraints min_constraint;
181+ int64_t max;
182+ ClassMemberConstraints max_constraint;
185183 int64_t minmax;
186184 ClassMemberConstraints minmax_constraint;
187- int64_t min_max_intersection;
188- ClassMemberConstraints min_max_intersection_constraint;
189- int64_t min_max_union;
190185 int64_t top_level_union;
191186 ClassMemberConstraints union_constraint;
187+ int64_t min_max_union;
188+ int64_t intersection;
189+ ClassMemberConstraints intersection_constraint;
190+ int64_t min_max_intersection;
191+ ClassMemberConstraints min_max_intersection_constraint;
192192
193193 public:
194194 const int64_t & get_free() const { return free; }
195195 int64_t & get_mutable_free() { return free; }
196196 void set_free(const int64_t & value) { this->free = value; }
197197
198- const int64_t & get_intersection() const { return intersection; }
199- int64_t & get_mutable_intersection() { return intersection; }
200- void set_intersection(const int64_t & value) { CheckConstraint("intersection", intersection_constraint, value); this->intersection = value; }
198+ const int64_t & get_min() const { return min; }
199+ int64_t & get_mutable_min() { return min; }
200+ void set_min(const int64_t & value) { CheckConstraint("min", min_constraint, value); this->min = value; }
201201
202202 const int64_t & get_max() const { return max; }
203203 int64_t & get_mutable_max() { return max; }
204204 void set_max(const int64_t & value) { CheckConstraint("max", max_constraint, value); this->max = value; }
205205
206- const int64_t & get_min() const { return min; }
207- int64_t & get_mutable_min() { return min; }
208- void set_min(const int64_t & value) { CheckConstraint("min", min_constraint, value); this->min = value; }
209-
210206 const int64_t & get_minmax() const { return minmax; }
211207 int64_t & get_mutable_minmax() { return minmax; }
212208 void set_minmax(const int64_t & value) { CheckConstraint("minmax", minmax_constraint, value); this->minmax = value; }
213209
214- const int64_t & get_min_max_intersection() const { return min_max_intersection; }
215- int64_t & get_mutable_min_max_intersection() { return min_max_intersection; }
216- void set_min_max_intersection(const int64_t & value) { CheckConstraint("min_max_intersection", min_max_intersection_constraint, value); this->min_max_intersection = value; }
210+ const int64_t & get_top_level_union() const { return top_level_union; }
211+ int64_t & get_mutable_top_level_union() { return top_level_union; }
212+ void set_top_level_union(const int64_t & value) { CheckConstraint("top_level_union", union_constraint, value); this->top_level_union = value; }
217213
218214 const int64_t & get_min_max_union() const { return min_max_union; }
219215 int64_t & get_mutable_min_max_union() { return min_max_union; }
220216 void set_min_max_union(const int64_t & value) { this->min_max_union = value; }
221217
222- const int64_t & get_top_level_union() const { return top_level_union; }
223- int64_t & get_mutable_top_level_union() { return top_level_union; }
224- void set_top_level_union(const int64_t & value) { CheckConstraint("top_level_union", union_constraint, value); this->top_level_union = value; }
218+ const int64_t & get_intersection() const { return intersection; }
219+ int64_t & get_mutable_intersection() { return intersection; }
220+ void set_intersection(const int64_t & value) { CheckConstraint("intersection", intersection_constraint, value); this->intersection = value; }
221+
222+ const int64_t & get_min_max_intersection() const { return min_max_intersection; }
223+ int64_t & get_mutable_min_max_intersection() { return min_max_intersection; }
224+ void set_min_max_intersection(const int64_t & value) { CheckConstraint("min_max_intersection", min_max_intersection_constraint, value); this->min_max_intersection = value; }
225225 };
226226 }
227227
@@ -231,24 +231,24 @@ namespace quicktype {
231231
232232 inline void from_json(const json & j, TopLevel& x) {
233233 x.set_free(j.at("free").get<int64_t>());
234- x.set_intersection(j.at("intersection").get<int64_t>());
235- x.set_max(j.at("max").get<int64_t>());
236234 x.set_min(j.at("min").get<int64_t>());
235+ x.set_max(j.at("max").get<int64_t>());
237236 x.set_minmax(j.at("minmax").get<int64_t>());
238- x.set_min_max_intersection(j.at("minMaxIntersection").get<int64_t>());
239- x.set_min_max_union(j.at("minMaxUnion").get<int64_t>());
240237 x.set_top_level_union(j.at("union").get<int64_t>());
238+ x.set_min_max_union(j.at("minMaxUnion").get<int64_t>());
239+ x.set_intersection(j.at("intersection").get<int64_t>());
240+ x.set_min_max_intersection(j.at("minMaxIntersection").get<int64_t>());
241241 }
242242
243243 inline void to_json(json & j, const TopLevel & x) {
244244 j = json::object();
245245 j["free"] = x.get_free();
246- j["intersection"] = x.get_intersection();
247- j["max"] = x.get_max();
248246 j["min"] = x.get_min();
247+ j["max"] = x.get_max();
249248 j["minmax"] = x.get_minmax();
250- j["minMaxIntersection"] = x.get_min_max_intersection();
251- j["minMaxUnion"] = x.get_min_max_union();
252249 j["union"] = x.get_top_level_union();
250+ j["minMaxUnion"] = x.get_min_max_union();
251+ j["intersection"] = x.get_intersection();
252+ j["minMaxIntersection"] = x.get_min_max_intersection();
253253 }
254254 }
Mschema-cplusplus/test/inputs/schema/minmax.schema/default/quicktype.hpp+32 −32
@@ -165,63 +165,63 @@ namespace quicktype {
165165 class TopLevel {
166166 public:
167167 TopLevel() :
168- intersection_constraint(std::nullopt, std::nullopt, 4, 5, std::nullopt, std::nullopt, std::nullopt),
169- max_constraint(std::nullopt, std::nullopt, std::nullopt, 5, std::nullopt, std::nullopt, std::nullopt),
170168 min_constraint(std::nullopt, std::nullopt, 3, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
169+ max_constraint(std::nullopt, std::nullopt, std::nullopt, 5, std::nullopt, std::nullopt, std::nullopt),
171170 minmax_constraint(std::nullopt, std::nullopt, 3, 5, std::nullopt, std::nullopt, std::nullopt),
172- min_max_intersection_constraint(std::nullopt, std::nullopt, 3, 5, std::nullopt, std::nullopt, std::nullopt),
173- union_constraint(std::nullopt, std::nullopt, 3, 6, std::nullopt, std::nullopt, std::nullopt)
171+ union_constraint(std::nullopt, std::nullopt, 3, 6, std::nullopt, std::nullopt, std::nullopt),
172+ intersection_constraint(std::nullopt, std::nullopt, 4, 5, std::nullopt, std::nullopt, std::nullopt),
173+ min_max_intersection_constraint(std::nullopt, std::nullopt, 3, 5, std::nullopt, std::nullopt, std::nullopt)
174174 {}
175175 virtual ~TopLevel() = default;
176176
177177 private:
178178 double free;
179- double intersection;
180- ClassMemberConstraints intersection_constraint;
181- double max;
182- ClassMemberConstraints max_constraint;
183179 double min;
184180 ClassMemberConstraints min_constraint;
181+ double max;
182+ ClassMemberConstraints max_constraint;
185183 double minmax;
186184 ClassMemberConstraints minmax_constraint;
187- double min_max_intersection;
188- ClassMemberConstraints min_max_intersection_constraint;
189- double min_max_union;
190185 double top_level_union;
191186 ClassMemberConstraints union_constraint;
187+ double min_max_union;
188+ double intersection;
189+ ClassMemberConstraints intersection_constraint;
190+ double min_max_intersection;
191+ ClassMemberConstraints min_max_intersection_constraint;
192192
193193 public:
194194 const double & get_free() const { return free; }
195195 double & get_mutable_free() { return free; }
196196 void set_free(const double & value) { this->free = value; }
197197
198- const double & get_intersection() const { return intersection; }
199- double & get_mutable_intersection() { return intersection; }
200- void set_intersection(const double & value) { CheckConstraint("intersection", intersection_constraint, value); this->intersection = value; }
198+ const double & get_min() const { return min; }
199+ double & get_mutable_min() { return min; }
200+ void set_min(const double & value) { CheckConstraint("min", min_constraint, value); this->min = value; }
201201
202202 const double & get_max() const { return max; }
203203 double & get_mutable_max() { return max; }
204204 void set_max(const double & value) { CheckConstraint("max", max_constraint, value); this->max = value; }
205205
206- const double & get_min() const { return min; }
207- double & get_mutable_min() { return min; }
208- void set_min(const double & value) { CheckConstraint("min", min_constraint, value); this->min = value; }
209-
210206 const double & get_minmax() const { return minmax; }
211207 double & get_mutable_minmax() { return minmax; }
212208 void set_minmax(const double & value) { CheckConstraint("minmax", minmax_constraint, value); this->minmax = value; }
213209
214- const double & get_min_max_intersection() const { return min_max_intersection; }
215- double & get_mutable_min_max_intersection() { return min_max_intersection; }
216- void set_min_max_intersection(const double & value) { CheckConstraint("min_max_intersection", min_max_intersection_constraint, value); this->min_max_intersection = value; }
210+ const double & get_top_level_union() const { return top_level_union; }
211+ double & get_mutable_top_level_union() { return top_level_union; }
212+ void set_top_level_union(const double & value) { CheckConstraint("top_level_union", union_constraint, value); this->top_level_union = value; }
217213
218214 const double & get_min_max_union() const { return min_max_union; }
219215 double & get_mutable_min_max_union() { return min_max_union; }
220216 void set_min_max_union(const double & value) { this->min_max_union = value; }
221217
222- const double & get_top_level_union() const { return top_level_union; }
223- double & get_mutable_top_level_union() { return top_level_union; }
224- void set_top_level_union(const double & value) { CheckConstraint("top_level_union", union_constraint, value); this->top_level_union = value; }
218+ const double & get_intersection() const { return intersection; }
219+ double & get_mutable_intersection() { return intersection; }
220+ void set_intersection(const double & value) { CheckConstraint("intersection", intersection_constraint, value); this->intersection = value; }
221+
222+ const double & get_min_max_intersection() const { return min_max_intersection; }
223+ double & get_mutable_min_max_intersection() { return min_max_intersection; }
224+ void set_min_max_intersection(const double & value) { CheckConstraint("min_max_intersection", min_max_intersection_constraint, value); this->min_max_intersection = value; }
225225 };
226226 }
227227
@@ -231,24 +231,24 @@ namespace quicktype {
231231
232232 inline void from_json(const json & j, TopLevel& x) {
233233 x.set_free(j.at("free").get<double>());
234- x.set_intersection(j.at("intersection").get<double>());
235- x.set_max(j.at("max").get<double>());
236234 x.set_min(j.at("min").get<double>());
235+ x.set_max(j.at("max").get<double>());
237236 x.set_minmax(j.at("minmax").get<double>());
238- x.set_min_max_intersection(j.at("minMaxIntersection").get<double>());
239- x.set_min_max_union(j.at("minMaxUnion").get<double>());
240237 x.set_top_level_union(j.at("union").get<double>());
238+ x.set_min_max_union(j.at("minMaxUnion").get<double>());
239+ x.set_intersection(j.at("intersection").get<double>());
240+ x.set_min_max_intersection(j.at("minMaxIntersection").get<double>());
241241 }
242242
243243 inline void to_json(json & j, const TopLevel & x) {
244244 j = json::object();
245245 j["free"] = x.get_free();
246- j["intersection"] = x.get_intersection();
247- j["max"] = x.get_max();
248246 j["min"] = x.get_min();
247+ j["max"] = x.get_max();
249248 j["minmax"] = x.get_minmax();
250- j["minMaxIntersection"] = x.get_min_max_intersection();
251- j["minMaxUnion"] = x.get_min_max_union();
252249 j["union"] = x.get_top_level_union();
250+ j["minMaxUnion"] = x.get_min_max_union();
251+ j["intersection"] = x.get_intersection();
252+ j["minMaxIntersection"] = x.get_min_max_intersection();
253253 }
254254 }
Mschema-cplusplus/test/inputs/schema/minmaxlength.schema/default/quicktype.hpp+40 −40
@@ -224,63 +224,63 @@ namespace quicktype {
224224 class TopLevel {
225225 public:
226226 TopLevel() :
227- intersection_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 4, 5, std::nullopt),
228- maxlength_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, 5, std::nullopt),
229227 minlength_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 3, std::nullopt, std::nullopt),
230- min_max_intersection_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 3, 5, std::nullopt),
228+ maxlength_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, 5, std::nullopt),
231229 minmaxlength_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 3, 5, std::nullopt),
232- union_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 3, 6, std::nullopt)
230+ union_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 3, 6, std::nullopt),
231+ intersection_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 4, 5, std::nullopt),
232+ min_max_intersection_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 3, 5, std::nullopt)
233233 {}
234234 virtual ~TopLevel() = default;
235235
236236 private:
237- std::string intersection;
238- ClassMemberConstraints intersection_constraint;
239- InUnion in_union;
240- std::string maxlength;
241- ClassMemberConstraints maxlength_constraint;
242237 std::string minlength;
243238 ClassMemberConstraints minlength_constraint;
244- std::string min_max_intersection;
245- ClassMemberConstraints min_max_intersection_constraint;
239+ std::string maxlength;
240+ ClassMemberConstraints maxlength_constraint;
246241 std::string minmaxlength;
247242 ClassMemberConstraints minmaxlength_constraint;
248- std::string min_max_union;
249243 std::string top_level_union;
250244 ClassMemberConstraints union_constraint;
245+ InUnion in_union;
246+ std::string min_max_union;
247+ std::string intersection;
248+ ClassMemberConstraints intersection_constraint;
249+ std::string min_max_intersection;
250+ ClassMemberConstraints min_max_intersection_constraint;
251251
252252 public:
253- const std::string & get_intersection() const { return intersection; }
254- std::string & get_mutable_intersection() { return intersection; }
255- void set_intersection(const std::string & value) { CheckConstraint("intersection", intersection_constraint, value); this->intersection = value; }
256-
257- const InUnion & get_in_union() const { return in_union; }
258- InUnion & get_mutable_in_union() { return in_union; }
259- void set_in_union(const InUnion & value) { this->in_union = value; }
260-
261- const std::string & get_maxlength() const { return maxlength; }
262- std::string & get_mutable_maxlength() { return maxlength; }
263- void set_maxlength(const std::string & value) { CheckConstraint("maxlength", maxlength_constraint, value); this->maxlength = value; }
264-
265253 const std::string & get_minlength() const { return minlength; }
266254 std::string & get_mutable_minlength() { return minlength; }
267255 void set_minlength(const std::string & value) { CheckConstraint("minlength", minlength_constraint, value); this->minlength = value; }
268256
269- const std::string & get_min_max_intersection() const { return min_max_intersection; }
270- std::string & get_mutable_min_max_intersection() { return min_max_intersection; }
271- void set_min_max_intersection(const std::string & value) { CheckConstraint("min_max_intersection", min_max_intersection_constraint, value); this->min_max_intersection = value; }
257+ const std::string & get_maxlength() const { return maxlength; }
258+ std::string & get_mutable_maxlength() { return maxlength; }
259+ void set_maxlength(const std::string & value) { CheckConstraint("maxlength", maxlength_constraint, value); this->maxlength = value; }
272260
273261 const std::string & get_minmaxlength() const { return minmaxlength; }
274262 std::string & get_mutable_minmaxlength() { return minmaxlength; }
275263 void set_minmaxlength(const std::string & value) { CheckConstraint("minmaxlength", minmaxlength_constraint, value); this->minmaxlength = value; }
276264
265+ const std::string & get_top_level_union() const { return top_level_union; }
266+ std::string & get_mutable_top_level_union() { return top_level_union; }
267+ void set_top_level_union(const std::string & value) { CheckConstraint("top_level_union", union_constraint, value); this->top_level_union = value; }
268+
269+ const InUnion & get_in_union() const { return in_union; }
270+ InUnion & get_mutable_in_union() { return in_union; }
271+ void set_in_union(const InUnion & value) { this->in_union = value; }
272+
277273 const std::string & get_min_max_union() const { return min_max_union; }
278274 std::string & get_mutable_min_max_union() { return min_max_union; }
279275 void set_min_max_union(const std::string & value) { this->min_max_union = value; }
280276
281- const std::string & get_top_level_union() const { return top_level_union; }
282- std::string & get_mutable_top_level_union() { return top_level_union; }
283- void set_top_level_union(const std::string & value) { CheckConstraint("top_level_union", union_constraint, value); this->top_level_union = value; }
277+ const std::string & get_intersection() const { return intersection; }
278+ std::string & get_mutable_intersection() { return intersection; }
279+ void set_intersection(const std::string & value) { CheckConstraint("intersection", intersection_constraint, value); this->intersection = value; }
280+
281+ const std::string & get_min_max_intersection() const { return min_max_intersection; }
282+ std::string & get_mutable_min_max_intersection() { return min_max_intersection; }
283+ void set_min_max_intersection(const std::string & value) { CheckConstraint("min_max_intersection", min_max_intersection_constraint, value); this->min_max_intersection = value; }
284284 };
285285 }
286286
@@ -297,26 +297,26 @@ struct adl_serializer<std::variant<double, std::string>> {
297297 }
298298 namespace quicktype {
299299 inline void from_json(const json & j, TopLevel& x) {
300- x.set_intersection(j.at("intersection").get<std::string>());
301- x.set_in_union(j.at("inUnion").get<InUnion>());
302- x.set_maxlength(j.at("maxlength").get<std::string>());
303300 x.set_minlength(j.at("minlength").get<std::string>());
304- x.set_min_max_intersection(j.at("minMaxIntersection").get<std::string>());
301+ x.set_maxlength(j.at("maxlength").get<std::string>());
305302 x.set_minmaxlength(j.at("minmaxlength").get<std::string>());
306- x.set_min_max_union(j.at("minMaxUnion").get<std::string>());
307303 x.set_top_level_union(j.at("union").get<std::string>());
304+ x.set_in_union(j.at("inUnion").get<InUnion>());
305+ x.set_min_max_union(j.at("minMaxUnion").get<std::string>());
306+ x.set_intersection(j.at("intersection").get<std::string>());
307+ x.set_min_max_intersection(j.at("minMaxIntersection").get<std::string>());
308308 }
309309
310310 inline void to_json(json & j, const TopLevel & x) {
311311 j = json::object();
312- j["intersection"] = x.get_intersection();
313- j["inUnion"] = x.get_in_union();
314- j["maxlength"] = x.get_maxlength();
315312 j["minlength"] = x.get_minlength();
316- j["minMaxIntersection"] = x.get_min_max_intersection();
313+ j["maxlength"] = x.get_maxlength();
317314 j["minmaxlength"] = x.get_minmaxlength();
318- j["minMaxUnion"] = x.get_min_max_union();
319315 j["union"] = x.get_top_level_union();
316+ j["inUnion"] = x.get_in_union();
317+ j["minMaxUnion"] = x.get_min_max_union();
318+ j["intersection"] = x.get_intersection();
319+ j["minMaxIntersection"] = x.get_min_max_intersection();
320320 }
321321 }
322322 namespace nlohmann {
Mschema-cplusplus/test/inputs/schema/non-standard-ref.schema/default/quicktype.hpp+7 −7
@@ -37,19 +37,19 @@ namespace quicktype {
3737 virtual ~TopLevel() = default;
3838
3939 private:
40- int64_t bar;
4140 int64_t foo;
41+ int64_t bar;
4242 bool quux;
4343
4444 public:
45- const int64_t & get_bar() const { return bar; }
46- int64_t & get_mutable_bar() { return bar; }
47- void set_bar(const int64_t & value) { this->bar = value; }
48-
4945 const int64_t & get_foo() const { return foo; }
5046 int64_t & get_mutable_foo() { return foo; }
5147 void set_foo(const int64_t & value) { this->foo = value; }
5248
49+ const int64_t & get_bar() const { return bar; }
50+ int64_t & get_mutable_bar() { return bar; }
51+ void set_bar(const int64_t & value) { this->bar = value; }
52+
5353 const bool & get_quux() const { return quux; }
5454 bool & get_mutable_quux() { return quux; }
5555 void set_quux(const bool & value) { this->quux = value; }
@@ -61,15 +61,15 @@ namespace quicktype {
6161 void to_json(json & j, const TopLevel & x);
6262
6363 inline void from_json(const json & j, TopLevel& x) {
64- x.set_bar(j.at("bar").get<int64_t>());
6564 x.set_foo(j.at("foo").get<int64_t>());
65+ x.set_bar(j.at("bar").get<int64_t>());
6666 x.set_quux(j.at("quux").get<bool>());
6767 }
6868
6969 inline void to_json(json & j, const TopLevel & x) {
7070 j = json::object();
71- j["bar"] = x.get_bar();
7271 j["foo"] = x.get_foo();
72+ j["bar"] = x.get_bar();
7373 j["quux"] = x.get_quux();
7474 }
7575 }
Mschema-cplusplus/test/inputs/schema/nullable-optional-one-of.schema/default/quicktype.hpp+6 −6
@@ -96,16 +96,16 @@ namespace quicktype {
9696 virtual ~TopLevel() = default;
9797
9898 private:
99- std::optional<std::string> b;
10099 Kind kind;
100+ std::optional<std::string> b;
101101
102102 public:
103- std::optional<std::string> get_b() const { return b; }
104- void set_b(std::optional<std::string> value) { this->b = value; }
105-
106103 const Kind & get_kind() const { return kind; }
107104 Kind & get_mutable_kind() { return kind; }
108105 void set_kind(const Kind & value) { this->kind = value; }
106+
107+ std::optional<std::string> get_b() const { return b; }
108+ void set_b(std::optional<std::string> value) { this->b = value; }
109109 };
110110 }
111111
@@ -117,14 +117,14 @@ namespace quicktype {
117117 void to_json(json & j, const Kind & x);
118118
119119 inline void from_json(const json & j, TopLevel& x) {
120- x.set_b(get_stack_optional<std::string>(j, "b"));
121120 x.set_kind(j.at("kind").get<Kind>());
121+ x.set_b(get_stack_optional<std::string>(j, "b"));
122122 }
123123
124124 inline void to_json(json & j, const TopLevel & x) {
125125 j = json::object();
126- j["b"] = x.get_b();
127126 j["kind"] = x.get_kind();
127+ j["b"] = x.get_b();
128128 }
129129
130130 inline void from_json(const json & j, Kind & x) {
Mschema-cplusplus/test/inputs/schema/optional-any.schema/default/quicktype.hpp+7 −7
@@ -94,17 +94,17 @@ namespace quicktype {
9494 virtual ~TopLevel() = default;
9595
9696 private:
97- bool bar;
9897 nlohmann::json foo;
98+ bool bar;
9999
100100 public:
101- const bool & get_bar() const { return bar; }
102- bool & get_mutable_bar() { return bar; }
103- void set_bar(const bool & value) { this->bar = value; }
104-
105101 const nlohmann::json & get_foo() const { return foo; }
106102 nlohmann::json & get_mutable_foo() { return foo; }
107103 void set_foo(const nlohmann::json & value) { this->foo = value; }
104+
105+ const bool & get_bar() const { return bar; }
106+ bool & get_mutable_bar() { return bar; }
107+ void set_bar(const bool & value) { this->bar = value; }
108108 };
109109 }
110110
@@ -113,13 +113,13 @@ namespace quicktype {
113113 void to_json(json & j, const TopLevel & x);
114114
115115 inline void from_json(const json & j, TopLevel& x) {
116- x.set_bar(j.at("bar").get<bool>());
117116 x.set_foo(get_untyped(j, "foo"));
117+ x.set_bar(j.at("bar").get<bool>());
118118 }
119119
120120 inline void to_json(json & j, const TopLevel & x) {
121121 j = json::object();
122- j["bar"] = x.get_bar();
123122 j["foo"] = x.get_foo();
123+ j["bar"] = x.get_bar();
124124 }
125125 }
Mschema-cplusplus/test/inputs/schema/optional-any.schema/hide-null-optional-true--b100cdb5877d/quicktype.hpp+7 −7
@@ -94,17 +94,17 @@ namespace quicktype {
9494 virtual ~TopLevel() = default;
9595
9696 private:
97- bool bar;
9897 nlohmann::json foo;
98+ bool bar;
9999
100100 public:
101- const bool & get_bar() const { return bar; }
102- bool & get_mutable_bar() { return bar; }
103- void set_bar(const bool & value) { this->bar = value; }
104-
105101 const nlohmann::json & get_foo() const { return foo; }
106102 nlohmann::json & get_mutable_foo() { return foo; }
107103 void set_foo(const nlohmann::json & value) { this->foo = value; }
104+
105+ const bool & get_bar() const { return bar; }
106+ bool & get_mutable_bar() { return bar; }
107+ void set_bar(const bool & value) { this->bar = value; }
108108 };
109109 }
110110
@@ -113,15 +113,15 @@ namespace quicktype {
113113 void to_json(json & j, const TopLevel & x);
114114
115115 inline void from_json(const json & j, TopLevel& x) {
116- x.set_bar(j.at("bar").get<bool>());
117116 x.set_foo(get_untyped(j, "foo"));
117+ x.set_bar(j.at("bar").get<bool>());
118118 }
119119
120120 inline void to_json(json & j, const TopLevel & x) {
121121 j = json::object();
122- j["bar"] = x.get_bar();
123122 if (!x.get_foo().is_null()) {
124123 j["foo"] = x.get_foo();
125124 }
125+ j["bar"] = x.get_bar();
126126 }
127127 }
Mschema-cplusplus/test/inputs/schema/optional-const-ref.schema/default/quicktype.hpp+26 −26
@@ -242,55 +242,55 @@ namespace quicktype {
242242 public:
243243 TopLevel() :
244244 count_constraint(1, 100, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
245- label_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 2, 16, std::nullopt),
246245 required_count_constraint(1, 100, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
247- required_label_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 2, 16, std::nullopt),
248- weight_constraint(std::nullopt, std::nullopt, 0.5, 99.5, std::nullopt, std::nullopt, std::nullopt)
246+ weight_constraint(std::nullopt, std::nullopt, 0.5, 99.5, std::nullopt, std::nullopt, std::nullopt),
247+ label_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 2, 16, std::nullopt),
248+ required_label_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 2, 16, std::nullopt)
249249 {}
250250 virtual ~TopLevel() = default;
251251
252252 private:
253253 std::optional<std::vector<Coordinate>> coordinates;
254+ std::vector<Coordinate> required_coordinates;
254255 std::optional<int64_t> count;
255256 ClassMemberConstraints count_constraint;
256- std::optional<std::string> label;
257- ClassMemberConstraints label_constraint;
258- std::vector<Coordinate> required_coordinates;
259257 int64_t required_count;
260258 ClassMemberConstraints required_count_constraint;
261- std::string required_label;
262- ClassMemberConstraints required_label_constraint;
263259 std::optional<double> weight;
264260 ClassMemberConstraints weight_constraint;
261+ std::optional<std::string> label;
262+ ClassMemberConstraints label_constraint;
263+ std::string required_label;
264+ ClassMemberConstraints required_label_constraint;
265265
266266 public:
267267 const std::optional<std::vector<Coordinate>> & get_coordinates() const { return coordinates; }
268268 std::optional<std::vector<Coordinate>> & get_mutable_coordinates() { return coordinates; }
269269 void set_coordinates(const std::optional<std::vector<Coordinate>> & value) { this->coordinates = value; }
270270
271- const std::optional<int64_t> & get_count() const { return count; }
272- std::optional<int64_t> & get_mutable_count() { return count; }
273- void set_count(const std::optional<int64_t> & value) { CheckConstraint("count", count_constraint, value); this->count = value; }
274-
275- const std::optional<std::string> & get_label() const { return label; }
276- std::optional<std::string> & get_mutable_label() { return label; }
277- void set_label(const std::optional<std::string> & value) { CheckConstraint("label", label_constraint, value); this->label = value; }
278-
279271 const std::vector<Coordinate> & get_required_coordinates() const { return required_coordinates; }
280272 std::vector<Coordinate> & get_mutable_required_coordinates() { return required_coordinates; }
281273 void set_required_coordinates(const std::vector<Coordinate> & value) { this->required_coordinates = value; }
282274
275+ const std::optional<int64_t> & get_count() const { return count; }
276+ std::optional<int64_t> & get_mutable_count() { return count; }
277+ void set_count(const std::optional<int64_t> & value) { CheckConstraint("count", count_constraint, value); this->count = value; }
278+
283279 const int64_t & get_required_count() const { return required_count; }
284280 int64_t & get_mutable_required_count() { return required_count; }
285281 void set_required_count(const int64_t & value) { CheckConstraint("required_count", required_count_constraint, value); this->required_count = value; }
286282
287- const std::string & get_required_label() const { return required_label; }
288- std::string & get_mutable_required_label() { return required_label; }
289- void set_required_label(const std::string & value) { CheckConstraint("required_label", required_label_constraint, value); this->required_label = value; }
290-
291283 const std::optional<double> & get_weight() const { return weight; }
292284 std::optional<double> & get_mutable_weight() { return weight; }
293285 void set_weight(const std::optional<double> & value) { CheckConstraint("weight", weight_constraint, value); this->weight = value; }
286+
287+ const std::optional<std::string> & get_label() const { return label; }
288+ std::optional<std::string> & get_mutable_label() { return label; }
289+ void set_label(const std::optional<std::string> & value) { CheckConstraint("label", label_constraint, value); this->label = value; }
290+
291+ const std::string & get_required_label() const { return required_label; }
292+ std::string & get_mutable_required_label() { return required_label; }
293+ void set_required_label(const std::string & value) { CheckConstraint("required_label", required_label_constraint, value); this->required_label = value; }
294294 };
295295 }
296296
@@ -314,22 +314,22 @@ namespace quicktype {
314314
315315 inline void from_json(const json & j, TopLevel& x) {
316316 x.set_coordinates(get_stack_optional<std::vector<Coordinate>>(j, "coordinates"));
317- x.set_count(get_stack_optional<int64_t>(j, "count"));
318- x.set_label(get_stack_optional<std::string>(j, "label"));
319317 x.set_required_coordinates(j.at("requiredCoordinates").get<std::vector<Coordinate>>());
318+ x.set_count(get_stack_optional<int64_t>(j, "count"));
320319 x.set_required_count(j.at("requiredCount").get<int64_t>());
321- x.set_required_label(j.at("requiredLabel").get<std::string>());
322320 x.set_weight(get_stack_optional<double>(j, "weight"));
321+ x.set_label(get_stack_optional<std::string>(j, "label"));
322+ x.set_required_label(j.at("requiredLabel").get<std::string>());
323323 }
324324
325325 inline void to_json(json & j, const TopLevel & x) {
326326 j = json::object();
327327 j["coordinates"] = x.get_coordinates();
328- j["count"] = x.get_count();
329- j["label"] = x.get_label();
330328 j["requiredCoordinates"] = x.get_required_coordinates();
329+ j["count"] = x.get_count();
331330 j["requiredCount"] = x.get_required_count();
332- j["requiredLabel"] = x.get_required_label();
333331 j["weight"] = x.get_weight();
332+ j["label"] = x.get_label();
333+ j["requiredLabel"] = x.get_required_label();
334334 }
335335 }
Mschema-cplusplus/test/inputs/schema/optional-constraints.schema/default/quicktype.hpp+24 −24
@@ -222,46 +222,46 @@ namespace quicktype {
222222 class TopLevel {
223223 public:
224224 TopLevel() :
225- opt_double_constraint(std::nullopt, std::nullopt, 0.5, 99.5, std::nullopt, std::nullopt, std::nullopt),
225+ req_zero_min_constraint(0, 100, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
226226 opt_int_constraint(0, 100, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt),
227- opt_pattern_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::string("^[a-z]+$")),
227+ opt_double_constraint(std::nullopt, std::nullopt, 0.5, 99.5, std::nullopt, std::nullopt, std::nullopt),
228228 opt_string_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, 3, 10, std::nullopt),
229- req_zero_min_constraint(0, 100, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt)
229+ opt_pattern_constraint(std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::string("^[a-z]+$"))
230230 {}
231231 virtual ~TopLevel() = default;
232232
233233 private:
234- std::optional<double> opt_double;
235- ClassMemberConstraints opt_double_constraint;
234+ int64_t req_zero_min;
235+ ClassMemberConstraints req_zero_min_constraint;
236236 std::optional<int64_t> opt_int;
237237 ClassMemberConstraints opt_int_constraint;
238- std::optional<std::string> opt_pattern;
239- ClassMemberConstraints opt_pattern_constraint;
238+ std::optional<double> opt_double;
239+ ClassMemberConstraints opt_double_constraint;
240240 std::optional<std::string> opt_string;
241241 ClassMemberConstraints opt_string_constraint;
242- int64_t req_zero_min;
243- ClassMemberConstraints req_zero_min_constraint;
242+ std::optional<std::string> opt_pattern;
243+ ClassMemberConstraints opt_pattern_constraint;
244244
245245 public:
246- const std::optional<double> & get_opt_double() const { return opt_double; }
247- std::optional<double> & get_mutable_opt_double() { return opt_double; }
248- void set_opt_double(const std::optional<double> & value) { CheckConstraint("opt_double", opt_double_constraint, value); this->opt_double = value; }
246+ const int64_t & get_req_zero_min() const { return req_zero_min; }
247+ int64_t & get_mutable_req_zero_min() { return req_zero_min; }
248+ void set_req_zero_min(const int64_t & value) { CheckConstraint("req_zero_min", req_zero_min_constraint, value); this->req_zero_min = value; }
249249
250250 const std::optional<int64_t> & get_opt_int() const { return opt_int; }
251251 std::optional<int64_t> & get_mutable_opt_int() { return opt_int; }
252252 void set_opt_int(const std::optional<int64_t> & value) { CheckConstraint("opt_int", opt_int_constraint, value); this->opt_int = value; }
253253
254- const std::optional<std::string> & get_opt_pattern() const { return opt_pattern; }
255- std::optional<std::string> & get_mutable_opt_pattern() { return opt_pattern; }
256- void set_opt_pattern(const std::optional<std::string> & value) { CheckConstraint("opt_pattern", opt_pattern_constraint, value); this->opt_pattern = value; }
254+ const std::optional<double> & get_opt_double() const { return opt_double; }
255+ std::optional<double> & get_mutable_opt_double() { return opt_double; }
256+ void set_opt_double(const std::optional<double> & value) { CheckConstraint("opt_double", opt_double_constraint, value); this->opt_double = value; }
257257
258258 const std::optional<std::string> & get_opt_string() const { return opt_string; }
259259 std::optional<std::string> & get_mutable_opt_string() { return opt_string; }
260260 void set_opt_string(const std::optional<std::string> & value) { CheckConstraint("opt_string", opt_string_constraint, value); this->opt_string = value; }
261261
262- const int64_t & get_req_zero_min() const { return req_zero_min; }
263- int64_t & get_mutable_req_zero_min() { return req_zero_min; }
264- void set_req_zero_min(const int64_t & value) { CheckConstraint("req_zero_min", req_zero_min_constraint, value); this->req_zero_min = value; }
262+ const std::optional<std::string> & get_opt_pattern() const { return opt_pattern; }
263+ std::optional<std::string> & get_mutable_opt_pattern() { return opt_pattern; }
264+ void set_opt_pattern(const std::optional<std::string> & value) { CheckConstraint("opt_pattern", opt_pattern_constraint, value); this->opt_pattern = value; }
265265 };
266266 }
267267
@@ -270,19 +270,19 @@ namespace quicktype {
270270 void to_json(json & j, const TopLevel & x);
271271
272272 inline void from_json(const json & j, TopLevel& x) {
273- x.set_opt_double(get_stack_optional<double>(j, "optDouble"));
273+ x.set_req_zero_min(j.at("reqZeroMin").get<int64_t>());
274274 x.set_opt_int(get_stack_optional<int64_t>(j, "optInt"));
275- x.set_opt_pattern(get_stack_optional<std::string>(j, "optPattern"));
275+ x.set_opt_double(get_stack_optional<double>(j, "optDouble"));
276276 x.set_opt_string(get_stack_optional<std::string>(j, "optString"));
277- x.set_req_zero_min(j.at("reqZeroMin").get<int64_t>());
277+ x.set_opt_pattern(get_stack_optional<std::string>(j, "optPattern"));
278278 }
279279
280280 inline void to_json(json & j, const TopLevel & x) {
281281 j = json::object();
282- j["optDouble"] = x.get_opt_double();
282+ j["reqZeroMin"] = x.get_req_zero_min();
283283 j["optInt"] = x.get_opt_int();
284- j["optPattern"] = x.get_opt_pattern();
284+ j["optDouble"] = x.get_opt_double();
285285 j["optString"] = x.get_opt_string();
286- j["reqZeroMin"] = x.get_req_zero_min();
286+ j["optPattern"] = x.get_opt_pattern();
287287 }
288288 }
Mschema-cplusplus/test/inputs/schema/optional-date-time.schema/default/quicktype.hpp+27 −27
@@ -94,37 +94,37 @@ namespace quicktype {
9494 virtual ~TopLevel() = default;
9595
9696 private:
97- std::optional<std::string> optional_date;
98- std::optional<std::string> optional_date_time;
99- std::optional<std::string> optional_time;
10097 std::string required_date;
101- std::string required_date_time;
10298 std::string required_time;
99+ std::string required_date_time;
100+ std::optional<std::string> optional_date;
101+ std::optional<std::string> optional_time;
102+ std::optional<std::string> optional_date_time;
103103
104104 public:
105- const std::optional<std::string> & get_optional_date() const { return optional_date; }
106- std::optional<std::string> & get_mutable_optional_date() { return optional_date; }
107- void set_optional_date(const std::optional<std::string> & value) { this->optional_date = value; }
108-
109- const std::optional<std::string> & get_optional_date_time() const { return optional_date_time; }
110- std::optional<std::string> & get_mutable_optional_date_time() { return optional_date_time; }
111- void set_optional_date_time(const std::optional<std::string> & value) { this->optional_date_time = value; }
112-
113- const std::optional<std::string> & get_optional_time() const { return optional_time; }
114- std::optional<std::string> & get_mutable_optional_time() { return optional_time; }
115- void set_optional_time(const std::optional<std::string> & value) { this->optional_time = value; }
116-
117105 const std::string & get_required_date() const { return required_date; }
118106 std::string & get_mutable_required_date() { return required_date; }
119107 void set_required_date(const std::string & value) { this->required_date = value; }
120108
109+ const std::string & get_required_time() const { return required_time; }
110+ std::string & get_mutable_required_time() { return required_time; }
111+ void set_required_time(const std::string & value) { this->required_time = value; }
112+
121113 const std::string & get_required_date_time() const { return required_date_time; }
122114 std::string & get_mutable_required_date_time() { return required_date_time; }
123115 void set_required_date_time(const std::string & value) { this->required_date_time = value; }
124116
125- const std::string & get_required_time() const { return required_time; }
126- std::string & get_mutable_required_time() { return required_time; }
127- void set_required_time(const std::string & value) { this->required_time = value; }
117+ const std::optional<std::string> & get_optional_date() const { return optional_date; }
118+ std::optional<std::string> & get_mutable_optional_date() { return optional_date; }
119+ void set_optional_date(const std::optional<std::string> & value) { this->optional_date = value; }
120+
121+ const std::optional<std::string> & get_optional_time() const { return optional_time; }
122+ std::optional<std::string> & get_mutable_optional_time() { return optional_time; }
123+ void set_optional_time(const std::optional<std::string> & value) { this->optional_time = value; }
124+
125+ const std::optional<std::string> & get_optional_date_time() const { return optional_date_time; }
126+ std::optional<std::string> & get_mutable_optional_date_time() { return optional_date_time; }
127+ void set_optional_date_time(const std::optional<std::string> & value) { this->optional_date_time = value; }
128128 };
129129 }
130130
@@ -133,21 +133,21 @@ namespace quicktype {
133133 void to_json(json & j, const TopLevel & x);
134134
135135 inline void from_json(const json & j, TopLevel& x) {
136- x.set_optional_date(get_stack_optional<std::string>(j, "optional-date"));
137- x.set_optional_date_time(get_stack_optional<std::string>(j, "optional-date-time"));
138- x.set_optional_time(get_stack_optional<std::string>(j, "optional-time"));
139136 x.set_required_date(j.at("required-date").get<std::string>());
140- x.set_required_date_time(j.at("required-date-time").get<std::string>());
141137 x.set_required_time(j.at("required-time").get<std::string>());
138+ x.set_required_date_time(j.at("required-date-time").get<std::string>());
139+ x.set_optional_date(get_stack_optional<std::string>(j, "optional-date"));
140+ x.set_optional_time(get_stack_optional<std::string>(j, "optional-time"));
141+ x.set_optional_date_time(get_stack_optional<std::string>(j, "optional-date-time"));
142142 }
143143
144144 inline void to_json(json & j, const TopLevel & x) {
145145 j = json::object();
146- j["optional-date"] = x.get_optional_date();
147- j["optional-date-time"] = x.get_optional_date_time();
148- j["optional-time"] = x.get_optional_time();
149146 j["required-date"] = x.get_required_date();
150- j["required-date-time"] = x.get_required_date_time();
151147 j["required-time"] = x.get_required_time();
148+ j["required-date-time"] = x.get_required_date_time();
149+ j["optional-date"] = x.get_optional_date();
150+ j["optional-time"] = x.get_optional_time();
151+ j["optional-date-time"] = x.get_optional_date_time();
152152 }
153153 }
Mschema-cplusplus/test/inputs/schema/prefix-items.schema/default/quicktype.hpp+7 −7
@@ -96,17 +96,17 @@ namespace quicktype {
9696 virtual ~TopLevel() = default;
9797
9898 private:
99- std::vector<Open> open;
10099 std::vector<Open> tuple;
100+ std::vector<Open> open;
101101
102102 public:
103- const std::vector<Open> & get_open() const { return open; }
104- std::vector<Open> & get_mutable_open() { return open; }
105- void set_open(const std::vector<Open> & value) { this->open = value; }
106-
107103 const std::vector<Open> & get_tuple() const { return tuple; }
108104 std::vector<Open> & get_mutable_tuple() { return tuple; }
109105 void set_tuple(const std::vector<Open> & value) { this->tuple = value; }
106+
107+ const std::vector<Open> & get_open() const { return open; }
108+ std::vector<Open> & get_mutable_open() { return open; }
109+ void set_open(const std::vector<Open> & value) { this->open = value; }
110110 };
111111 }
112112
@@ -123,14 +123,14 @@ struct adl_serializer<std::variant<bool, int64_t>> {
123123 }
124124 namespace quicktype {
125125 inline void from_json(const json & j, TopLevel& x) {
126- x.set_open(j.at("open").get<std::vector<Open>>());
127126 x.set_tuple(j.at("tuple").get<std::vector<Open>>());
127+ x.set_open(j.at("open").get<std::vector<Open>>());
128128 }
129129
130130 inline void to_json(json & j, const TopLevel & x) {
131131 j = json::object();
132- j["open"] = x.get_open();
133132 j["tuple"] = x.get_tuple();
133+ j["open"] = x.get_open();
134134 }
135135 }
136136 namespace nlohmann {
Aschema-cplusplus/test/inputs/schema/property-order.schema/default/quicktype.hpp+136 −0
@@ -0,0 +1,136 @@
1+// To parse this JSON data, first install
2+//
3+// json.hpp https://github.com/nlohmann/json
4+//
5+// Then include this file, and then do
6+//
7+// TopLevel data = nlohmann::json::parse(jsonString);
8+
9+#pragma once
10+
11+#include "json.hpp"
12+
13+#include <optional>
14+#include <stdexcept>
15+#include <regex>
16+
17+namespace quicktype {
18+ using nlohmann::json;
19+
20+ #ifndef NLOHMANN_UNTYPED_quicktype_HELPER
21+ #define NLOHMANN_UNTYPED_quicktype_HELPER
22+ inline json get_untyped(const json & j, const char * property) {
23+ if (j.find(property) != j.end()) {
24+ return j.at(property).get<json>();
25+ }
26+ return json();
27+ }
28+
29+ inline json get_untyped(const json & j, std::string property) {
30+ return get_untyped(j, property.data());
31+ }
32+ #endif
33+
34+ class Ordered {
35+ public:
36+ Ordered() = default;
37+ virtual ~Ordered() = default;
38+
39+ private:
40+ double mango;
41+ std::string zebra;
42+ bool apple;
43+
44+ public:
45+ const double & get_mango() const { return mango; }
46+ double & get_mutable_mango() { return mango; }
47+ void set_mango(const double & value) { this->mango = value; }
48+
49+ const std::string & get_zebra() const { return zebra; }
50+ std::string & get_mutable_zebra() { return zebra; }
51+ void set_zebra(const std::string & value) { this->zebra = value; }
52+
53+ const bool & get_apple() const { return apple; }
54+ bool & get_mutable_apple() { return apple; }
55+ void set_apple(const bool & value) { this->apple = value; }
56+ };
57+
58+ class TopLevel {
59+ public:
60+ TopLevel() = default;
61+ virtual ~TopLevel() = default;
62+
63+ private:
64+ std::string zebra;
65+ double mango;
66+ bool apple;
67+ std::string delta;
68+ int64_t banana;
69+ Ordered ordered;
70+
71+ public:
72+ const std::string & get_zebra() const { return zebra; }
73+ std::string & get_mutable_zebra() { return zebra; }
74+ void set_zebra(const std::string & value) { this->zebra = value; }
75+
76+ const double & get_mango() const { return mango; }
77+ double & get_mutable_mango() { return mango; }
78+ void set_mango(const double & value) { this->mango = value; }
79+
80+ const bool & get_apple() const { return apple; }
81+ bool & get_mutable_apple() { return apple; }
82+ void set_apple(const bool & value) { this->apple = value; }
83+
84+ const std::string & get_delta() const { return delta; }
85+ std::string & get_mutable_delta() { return delta; }
86+ void set_delta(const std::string & value) { this->delta = value; }
87+
88+ const int64_t & get_banana() const { return banana; }
89+ int64_t & get_mutable_banana() { return banana; }
90+ void set_banana(const int64_t & value) { this->banana = value; }
91+
92+ const Ordered & get_ordered() const { return ordered; }
93+ Ordered & get_mutable_ordered() { return ordered; }
94+ void set_ordered(const Ordered & value) { this->ordered = value; }
95+ };
96+}
97+
98+namespace quicktype {
99+ void from_json(const json & j, Ordered & x);
100+ void to_json(json & j, const Ordered & x);
101+
102+ void from_json(const json & j, TopLevel & x);
103+ void to_json(json & j, const TopLevel & x);
104+
105+ inline void from_json(const json & j, Ordered& x) {
106+ x.set_mango(j.at("mango").get<double>());
107+ x.set_zebra(j.at("zebra").get<std::string>());
108+ x.set_apple(j.at("apple").get<bool>());
109+ }
110+
111+ inline void to_json(json & j, const Ordered & x) {
112+ j = json::object();
113+ j["mango"] = x.get_mango();
114+ j["zebra"] = x.get_zebra();
115+ j["apple"] = x.get_apple();
116+ }
117+
118+ inline void from_json(const json & j, TopLevel& x) {
119+ x.set_zebra(j.at("zebra").get<std::string>());
120+ x.set_mango(j.at("mango").get<double>());
121+ x.set_apple(j.at("apple").get<bool>());
122+ x.set_delta(j.at("delta").get<std::string>());
123+ x.set_banana(j.at("banana").get<int64_t>());
124+ x.set_ordered(j.at("ordered").get<Ordered>());
125+ }
126+
127+ inline void to_json(json & j, const TopLevel & x) {
128+ j = json::object();
129+ j["zebra"] = x.get_zebra();
130+ j["mango"] = x.get_mango();
131+ j["apple"] = x.get_apple();
132+ j["delta"] = x.get_delta();
133+ j["banana"] = x.get_banana();
134+ j["ordered"] = x.get_ordered();
135+ }
136+}
Mschema-cplusplus/test/inputs/schema/renaming-bug.schema/default/quicktype.hpp+56 −56
@@ -253,15 +253,11 @@ namespace quicktype {
253253 virtual ~Part() = default;
254254
255255 private:
256- std::optional<std::string> depth;
257256 std::optional<std::string> length;
258257 std::optional<std::string> width;
258+ std::optional<std::string> depth;
259259
260260 public:
261- const std::optional<std::string> & get_depth() const { return depth; }
262- std::optional<std::string> & get_mutable_depth() { return depth; }
263- void set_depth(const std::optional<std::string> & value) { this->depth = value; }
264-
265261 const std::optional<std::string> & get_length() const { return length; }
266262 std::optional<std::string> & get_mutable_length() { return length; }
267263 void set_length(const std::optional<std::string> & value) { this->length = value; }
@@ -269,6 +265,10 @@ namespace quicktype {
269265 const std::optional<std::string> & get_width() const { return width; }
270266 std::optional<std::string> & get_mutable_width() { return width; }
271267 void set_width(const std::optional<std::string> & value) { this->width = value; }
268+
269+ const std::optional<std::string> & get_depth() const { return depth; }
270+ std::optional<std::string> & get_mutable_depth() { return depth; }
271+ void set_depth(const std::optional<std::string> & value) { this->depth = value; }
272272 };
273273
274274 class RectShape {
@@ -324,17 +324,17 @@ namespace quicktype {
324324 virtual ~Shape() = default;
325325
326326 private:
327- std::optional<Geometry> geometry;
328327 std::optional<History> history;
328+ std::optional<Geometry> geometry;
329329
330330 public:
331- const std::optional<Geometry> & get_geometry() const { return geometry; }
332- std::optional<Geometry> & get_mutable_geometry() { return geometry; }
333- void set_geometry(const std::optional<Geometry> & value) { this->geometry = value; }
334-
335331 const std::optional<History> & get_history() const { return history; }
336332 std::optional<History> & get_mutable_history() { return history; }
337333 void set_history(const std::optional<History> & value) { this->history = value; }
334+
335+ const std::optional<Geometry> & get_geometry() const { return geometry; }
336+ std::optional<Geometry> & get_mutable_geometry() { return geometry; }
337+ void set_geometry(const std::optional<Geometry> & value) { this->geometry = value; }
338338 };
339339
340340 class Berry {
@@ -345,20 +345,20 @@ namespace quicktype {
345345 virtual ~Berry() = default;
346346
347347 private:
348- std::optional<Color> color;
349348 std::optional<std::string> name;
350349 ClassMemberConstraints name_constraint;
350+ std::optional<Color> color;
351351 std::optional<std::vector<Shape>> shapes;
352352
353353 public:
354- const std::optional<Color> & get_color() const { return color; }
355- std::optional<Color> & get_mutable_color() { return color; }
356- void set_color(const std::optional<Color> & value) { this->color = value; }
357-
358354 const std::optional<std::string> & get_name() const { return name; }
359355 std::optional<std::string> & get_mutable_name() { return name; }
360356 void set_name(const std::optional<std::string> & value) { CheckConstraint("name", name_constraint, value); this->name = value; }
361357
358+ const std::optional<Color> & get_color() const { return color; }
359+ std::optional<Color> & get_mutable_color() { return color; }
360+ void set_color(const std::optional<Color> & value) { this->color = value; }
361+
362362 const std::optional<std::vector<Shape>> & get_shapes() const { return shapes; }
363363 std::optional<std::vector<Shape>> & get_mutable_shapes() { return shapes; }
364364 void set_shapes(const std::optional<std::vector<Shape>> & value) { this->shapes = value; }
@@ -371,21 +371,21 @@ namespace quicktype {
371371
372372 private:
373373 std::optional<bool> apple;
374- std::optional<std::vector<Berry>> berries;
375374 std::optional<bool> orange;
375+ std::optional<std::vector<Berry>> berries;
376376
377377 public:
378378 const std::optional<bool> & get_apple() const { return apple; }
379379 std::optional<bool> & get_mutable_apple() { return apple; }
380380 void set_apple(const std::optional<bool> & value) { this->apple = value; }
381381
382- const std::optional<std::vector<Berry>> & get_berries() const { return berries; }
383- std::optional<std::vector<Berry>> & get_mutable_berries() { return berries; }
384- void set_berries(const std::optional<std::vector<Berry>> & value) { this->berries = value; }
385-
386382 const std::optional<bool> & get_orange() const { return orange; }
387383 std::optional<bool> & get_mutable_orange() { return orange; }
388384 void set_orange(const std::optional<bool> & value) { this->orange = value; }
385+
386+ const std::optional<std::vector<Berry>> & get_berries() const { return berries; }
387+ std::optional<std::vector<Berry>> & get_mutable_berries() { return berries; }
388+ void set_berries(const std::optional<std::vector<Berry>> & value) { this->berries = value; }
389389 };
390390
391391 class Limit {
@@ -394,17 +394,17 @@ namespace quicktype {
394394 virtual ~Limit() = default;
395395
396396 private:
397- std::optional<double> maximum;
398397 std::optional<double> minimum;
398+ std::optional<double> maximum;
399399
400400 public:
401- const std::optional<double> & get_maximum() const { return maximum; }
402- std::optional<double> & get_mutable_maximum() { return maximum; }
403- void set_maximum(const std::optional<double> & value) { this->maximum = value; }
404-
405401 const std::optional<double> & get_minimum() const { return minimum; }
406402 std::optional<double> & get_mutable_minimum() { return minimum; }
407403 void set_minimum(const std::optional<double> & value) { this->minimum = value; }
404+
405+ const std::optional<double> & get_maximum() const { return maximum; }
406+ std::optional<double> & get_mutable_maximum() { return maximum; }
407+ void set_maximum(const std::optional<double> & value) { this->maximum = value; }
408408 };
409409
410410 class Speed {
@@ -457,38 +457,38 @@ namespace quicktype {
457457 virtual ~Vehicle() = default;
458458
459459 private:
460- std::optional<std::string> brand;
461460 std::optional<std::string> id;
462461 ClassMemberConstraints id_constraint;
463- std::optional<Speed> speed;
464- std::optional<bool> sub_module;
465462 std::optional<VehicleType> type;
463+ std::optional<Speed> speed;
466464 std::optional<std::string> year;
465+ std::optional<std::string> brand;
466+ std::optional<bool> sub_module;
467467
468468 public:
469- const std::optional<std::string> & get_brand() const { return brand; }
470- std::optional<std::string> & get_mutable_brand() { return brand; }
471- void set_brand(const std::optional<std::string> & value) { this->brand = value; }
472-
473469 const std::optional<std::string> & get_id() const { return id; }
474470 std::optional<std::string> & get_mutable_id() { return id; }
475471 void set_id(const std::optional<std::string> & value) { CheckConstraint("id", id_constraint, value); this->id = value; }
476472
477- const std::optional<Speed> & get_speed() const { return speed; }
478- std::optional<Speed> & get_mutable_speed() { return speed; }
479- void set_speed(const std::optional<Speed> & value) { this->speed = value; }
480-
481- const std::optional<bool> & get_sub_module() const { return sub_module; }
482- std::optional<bool> & get_mutable_sub_module() { return sub_module; }
483- void set_sub_module(const std::optional<bool> & value) { this->sub_module = value; }
484-
485473 const std::optional<VehicleType> & get_type() const { return type; }
486474 std::optional<VehicleType> & get_mutable_type() { return type; }
487475 void set_type(const std::optional<VehicleType> & value) { this->type = value; }
488476
477+ const std::optional<Speed> & get_speed() const { return speed; }
478+ std::optional<Speed> & get_mutable_speed() { return speed; }
479+ void set_speed(const std::optional<Speed> & value) { this->speed = value; }
480+
489481 const std::optional<std::string> & get_year() const { return year; }
490482 std::optional<std::string> & get_mutable_year() { return year; }
491483 void set_year(const std::optional<std::string> & value) { this->year = value; }
484+
485+ const std::optional<std::string> & get_brand() const { return brand; }
486+ std::optional<std::string> & get_mutable_brand() { return brand; }
487+ void set_brand(const std::optional<std::string> & value) { this->brand = value; }
488+
489+ const std::optional<bool> & get_sub_module() const { return sub_module; }
490+ std::optional<bool> & get_mutable_sub_module() { return sub_module; }
491+ void set_sub_module(const std::optional<bool> & value) { this->sub_module = value; }
492492 };
493493
494494 class TopLevel {
@@ -587,16 +587,16 @@ namespace quicktype {
587587 }
588588
589589 inline void from_json(const json & j, Part& x) {
590- x.set_depth(get_stack_optional<std::string>(j, "depth"));
591590 x.set_length(get_stack_optional<std::string>(j, "length"));
592591 x.set_width(get_stack_optional<std::string>(j, "width"));
592+ x.set_depth(get_stack_optional<std::string>(j, "depth"));
593593 }
594594
595595 inline void to_json(json & j, const Part & x) {
596596 j = json::object();
597- j["depth"] = x.get_depth();
598597 j["length"] = x.get_length();
599598 j["width"] = x.get_width();
599+ j["depth"] = x.get_depth();
600600 }
601601
602602 inline void from_json(const json & j, RectShape& x) {
@@ -629,51 +629,51 @@ namespace quicktype {
629629 }
630630
631631 inline void from_json(const json & j, Shape& x) {
632- x.set_geometry(get_stack_optional<Geometry>(j, "geometry"));
633632 x.set_history(get_stack_optional<History>(j, "history"));
633+ x.set_geometry(get_stack_optional<Geometry>(j, "geometry"));
634634 }
635635
636636 inline void to_json(json & j, const Shape & x) {
637637 j = json::object();
638- j["geometry"] = x.get_geometry();
639638 j["history"] = x.get_history();
639+ j["geometry"] = x.get_geometry();
640640 }
641641
642642 inline void from_json(const json & j, Berry& x) {
643- x.set_color(get_stack_optional<Color>(j, "color"));
644643 x.set_name(get_stack_optional<std::string>(j, "name"));
644+ x.set_color(get_stack_optional<Color>(j, "color"));
645645 x.set_shapes(get_stack_optional<std::vector<Shape>>(j, "shapes"));
646646 }
647647
648648 inline void to_json(json & j, const Berry & x) {
649649 j = json::object();
650- j["color"] = x.get_color();
651650 j["name"] = x.get_name();
651+ j["color"] = x.get_color();
652652 j["shapes"] = x.get_shapes();
653653 }
654654
655655 inline void from_json(const json & j, Fruit& x) {
656656 x.set_apple(get_stack_optional<bool>(j, "apple"));
657- x.set_berries(get_stack_optional<std::vector<Berry>>(j, "berries"));
658657 x.set_orange(get_stack_optional<bool>(j, "orange"));
658+ x.set_berries(get_stack_optional<std::vector<Berry>>(j, "berries"));
659659 }
660660
661661 inline void to_json(json & j, const Fruit & x) {
662662 j = json::object();
663663 j["apple"] = x.get_apple();
664- j["berries"] = x.get_berries();
665664 j["orange"] = x.get_orange();
665+ j["berries"] = x.get_berries();
666666 }
667667
668668 inline void from_json(const json & j, Limit& x) {
669- x.set_maximum(get_stack_optional<double>(j, "maximum"));
670669 x.set_minimum(get_stack_optional<double>(j, "minimum"));
670+ x.set_maximum(get_stack_optional<double>(j, "maximum"));
671671 }
672672
673673 inline void to_json(json & j, const Limit & x) {
674674 j = json::object();
675- j["maximum"] = x.get_maximum();
676675 j["minimum"] = x.get_minimum();
676+ j["maximum"] = x.get_maximum();
677677 }
678678
679679 inline void from_json(const json & j, Speed& x) {
@@ -699,22 +699,22 @@ namespace quicktype {
699699 }
700700
701701 inline void from_json(const json & j, Vehicle& x) {
702- x.set_brand(get_stack_optional<std::string>(j, "brand"));
703702 x.set_id(get_stack_optional<std::string>(j, "id"));
704- x.set_speed(get_stack_optional<Speed>(j, "speed"));
705- x.set_sub_module(get_stack_optional<bool>(j, "subModule"));
706703 x.set_type(get_stack_optional<VehicleType>(j, "type"));
704+ x.set_speed(get_stack_optional<Speed>(j, "speed"));
707705 x.set_year(get_stack_optional<std::string>(j, "year"));
706+ x.set_brand(get_stack_optional<std::string>(j, "brand"));
707+ x.set_sub_module(get_stack_optional<bool>(j, "subModule"));
708708 }
709709
710710 inline void to_json(json & j, const Vehicle & x) {
711711 j = json::object();
712- j["brand"] = x.get_brand();
713712 j["id"] = x.get_id();
714- j["speed"] = x.get_speed();
715- j["subModule"] = x.get_sub_module();
716713 j["type"] = x.get_type();
714+ j["speed"] = x.get_speed();
717715 j["year"] = x.get_year();
716+ j["brand"] = x.get_brand();
717+ j["subModule"] = x.get_sub_module();
718718 }
719719
720720 inline void from_json(const json & j, TopLevel& x) {
Mschema-cplusplus/test/inputs/schema/rust-cycle-breaker-union.schema/default/quicktype.hpp+12 −12
@@ -99,16 +99,16 @@ namespace quicktype {
9999 virtual ~Node() = default;
100100
101101 private:
102- Next next;
103102 std::string value;
103+ Next next;
104104
105105 public:
106- Next get_next() const { return next; }
107- void set_next(Next value) { this->next = value; }
108-
109106 const std::string & get_value() const { return value; }
110107 std::string & get_mutable_value() { return value; }
111108 void set_value(const std::string & value) { this->value = value; }
109+
110+ Next get_next() const { return next; }
111+ void set_next(Next value) { this->next = value; }
112112 };
113113
114114 class TopLevel {
@@ -117,16 +117,16 @@ namespace quicktype {
117117 virtual ~TopLevel() = default;
118118
119119 private:
120- Next next;
121120 std::string value;
121+ Next next;
122122
123123 public:
124- Next get_next() const { return next; }
125- void set_next(Next value) { this->next = value; }
126-
127124 const std::string & get_value() const { return value; }
128125 std::string & get_mutable_value() { return value; }
129126 void set_value(const std::string & value) { this->value = value; }
127+
128+ Next get_next() const { return next; }
129+ void set_next(Next value) { this->next = value; }
130130 };
131131 }
132132
@@ -146,25 +146,25 @@ struct adl_serializer<std::variant<std::shared_ptr<quicktype::Node>, std::string
146146 }
147147 namespace quicktype {
148148 inline void from_json(const json & j, Node& x) {
149- x.set_next(get_heap_optional<std::variant<std::shared_ptr<Node>, std::string>>(j, "next"));
150149 x.set_value(j.at("value").get<std::string>());
150+ x.set_next(get_heap_optional<std::variant<std::shared_ptr<Node>, std::string>>(j, "next"));
151151 }
152152
153153 inline void to_json(json & j, const Node & x) {
154154 j = json::object();
155- j["next"] = x.get_next();
156155 j["value"] = x.get_value();
156+ j["next"] = x.get_next();
157157 }
158158
159159 inline void from_json(const json & j, TopLevel& x) {
160- x.set_next(get_heap_optional<std::variant<std::shared_ptr<Node>, std::string>>(j, "next"));
161160 x.set_value(j.at("value").get<std::string>());
161+ x.set_next(get_heap_optional<std::variant<std::shared_ptr<Node>, std::string>>(j, "next"));
162162 }
163163
164164 inline void to_json(json & j, const TopLevel & x) {
165165 j = json::object();
166- j["next"] = x.get_next();
167166 j["value"] = x.get_value();
167+ j["next"] = x.get_next();
168168 }
169169 }
170170 namespace nlohmann {
Mschema-cplusplus/test/inputs/schema/uuid.schema/default/quicktype.hpp+20 −20
@@ -94,25 +94,14 @@ namespace quicktype {
9494 virtual ~TopLevel() = default;
9595
9696 private:
97- std::optional<std::vector<std::optional<std::string>>> arr_nullable;
98- std::optional<std::vector<std::string>> arr_one;
99- std::optional<std::string> nullable;
10097 std::string one;
10198 std::optional<std::string> optional;
99+ std::optional<std::string> nullable;
100+ std::optional<std::vector<std::string>> arr_one;
101+ std::optional<std::vector<std::optional<std::string>>> arr_nullable;
102102 std::string union_with_enum;
103103
104104 public:
105- const std::optional<std::vector<std::optional<std::string>>> & get_arr_nullable() const { return arr_nullable; }
106- std::optional<std::vector<std::optional<std::string>>> & get_mutable_arr_nullable() { return arr_nullable; }
107- void set_arr_nullable(const std::optional<std::vector<std::optional<std::string>>> & value) { this->arr_nullable = value; }
108-
109- const std::optional<std::vector<std::string>> & get_arr_one() const { return arr_one; }
110- std::optional<std::vector<std::string>> & get_mutable_arr_one() { return arr_one; }
111- void set_arr_one(const std::optional<std::vector<std::string>> & value) { this->arr_one = value; }
112-
113- std::optional<std::string> get_nullable() const { return nullable; }
114- void set_nullable(std::optional<std::string> value) { this->nullable = value; }
115-
116105 const std::string & get_one() const { return one; }
117106 std::string & get_mutable_one() { return one; }
118107 void set_one(const std::string & value) { this->one = value; }
@@ -121,6 +110,17 @@ namespace quicktype {
121110 std::optional<std::string> & get_mutable_optional() { return optional; }
122111 void set_optional(const std::optional<std::string> & value) { this->optional = value; }
123112
113+ std::optional<std::string> get_nullable() const { return nullable; }
114+ void set_nullable(std::optional<std::string> value) { this->nullable = value; }
115+
116+ const std::optional<std::vector<std::string>> & get_arr_one() const { return arr_one; }
117+ std::optional<std::vector<std::string>> & get_mutable_arr_one() { return arr_one; }
118+ void set_arr_one(const std::optional<std::vector<std::string>> & value) { this->arr_one = value; }
119+
120+ const std::optional<std::vector<std::optional<std::string>>> & get_arr_nullable() const { return arr_nullable; }
121+ std::optional<std::vector<std::optional<std::string>>> & get_mutable_arr_nullable() { return arr_nullable; }
122+ void set_arr_nullable(const std::optional<std::vector<std::optional<std::string>>> & value) { this->arr_nullable = value; }
123+
124124 const std::string & get_union_with_enum() const { return union_with_enum; }
125125 std::string & get_mutable_union_with_enum() { return union_with_enum; }
126126 void set_union_with_enum(const std::string & value) { this->union_with_enum = value; }
@@ -132,21 +132,21 @@ namespace quicktype {
132132 void to_json(json & j, const TopLevel & x);
133133
134134 inline void from_json(const json & j, TopLevel& x) {
135- x.set_arr_nullable(get_stack_optional<std::vector<std::optional<std::string>>>(j, "arrNullable"));
136- x.set_arr_one(get_stack_optional<std::vector<std::string>>(j, "arrOne"));
137- x.set_nullable(get_stack_optional<std::string>(j, "nullable"));
138135 x.set_one(j.at("one").get<std::string>());
139136 x.set_optional(get_stack_optional<std::string>(j, "optional"));
137+ x.set_nullable(get_stack_optional<std::string>(j, "nullable"));
138+ x.set_arr_one(get_stack_optional<std::vector<std::string>>(j, "arrOne"));
139+ x.set_arr_nullable(get_stack_optional<std::vector<std::optional<std::string>>>(j, "arrNullable"));
140140 x.set_union_with_enum(j.at("unionWithEnum").get<std::string>());
141141 }
142142
143143 inline void to_json(json & j, const TopLevel & x) {
144144 j = json::object();
145- j["arrNullable"] = x.get_arr_nullable();
146- j["arrOne"] = x.get_arr_one();
147- j["nullable"] = x.get_nullable();
148145 j["one"] = x.get_one();
149146 j["optional"] = x.get_optional();
147+ j["nullable"] = x.get_nullable();
148+ j["arrOne"] = x.get_arr_one();
149+ j["arrNullable"] = x.get_arr_nullable();
150150 j["unionWithEnum"] = x.get_union_with_enum();
151151 }
152152 }
Mschema-cplusplus/test/inputs/schema/vega-lite.schema/default/quicktype.hpp+90 −90
@@ -397,9 +397,9 @@ namespace quicktype {
397397 std::optional<double> dx;
398398 std::optional<double> dy;
399399 std::optional<std::string> fill;
400- std::optional<bool> filled;
401400 std::optional<double> fill_opacity;
402401 ClassMemberConstraints fill_opacity_constraint;
402+ std::optional<bool> filled;
403403 std::optional<std::string> font;
404404 std::optional<double> font_size;
405405 ClassMemberConstraints font_size_constraint;
@@ -497,6 +497,15 @@ namespace quicktype {
497497 std::optional<std::string> & get_mutable_fill() { return fill; }
498498 void set_fill(const std::optional<std::string> & value) { this->fill = value; }
499499
500+ /**
501+ * The fill opacity (value between [0,1]).
502+ *
503+ * __Default value:__ `1`
504+ */
505+ const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
506+ std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
507+ void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
508+
500509 /**
501510 * Whether the mark's color should be used as fill color instead of stroke color.
502511 *
@@ -510,15 +519,6 @@ namespace quicktype {
510519 std::optional<bool> & get_mutable_filled() { return filled; }
511520 void set_filled(const std::optional<bool> & value) { this->filled = value; }
512521
513- /**
514- * The fill opacity (value between [0,1]).
515- *
516- * __Default value:__ `1`
517- */
518- const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
519- std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
520- void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
521-
522522 /**
523523 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
524524 */
@@ -759,11 +759,11 @@ namespace quicktype {
759759 std::optional<bool> short_time_labels;
760760 std::optional<std::string> tick_color;
761761 std::optional<bool> tick_round;
762- std::optional<bool> ticks;
763762 std::optional<double> tick_size;
764763 ClassMemberConstraints tick_size_constraint;
765764 std::optional<double> tick_width;
766765 ClassMemberConstraints tick_width_constraint;
766+ std::optional<bool> ticks;
767767 std::optional<std::string> title_align;
768768 std::optional<double> title_angle;
769769 std::optional<std::string> title_baseline;
@@ -994,13 +994,6 @@ namespace quicktype {
994994 std::optional<bool> & get_mutable_tick_round() { return tick_round; }
995995 void set_tick_round(const std::optional<bool> & value) { this->tick_round = value; }
996996
997- /**
998- * Boolean value that determines whether the axis should include ticks.
999- */
1000- const std::optional<bool> & get_ticks() const { return ticks; }
1001- std::optional<bool> & get_mutable_ticks() { return ticks; }
1002- void set_ticks(const std::optional<bool> & value) { this->ticks = value; }
1003-
1004997 /**
1005998 * The size in pixels of axis ticks.
1006999 */
@@ -1015,6 +1008,13 @@ namespace quicktype {
10151008 std::optional<double> & get_mutable_tick_width() { return tick_width; }
10161009 void set_tick_width(const std::optional<double> & value) { CheckConstraint("tick_width", tick_width_constraint, value); this->tick_width = value; }
10171010
1011+ /**
1012+ * Boolean value that determines whether the axis should include ticks.
1013+ */
1014+ const std::optional<bool> & get_ticks() const { return ticks; }
1015+ std::optional<bool> & get_mutable_ticks() { return ticks; }
1016+ void set_ticks(const std::optional<bool> & value) { this->ticks = value; }
1017+
10181018 /**
10191019 * Horizontal text alignment of axis titles.
10201020 */
@@ -1157,11 +1157,11 @@ namespace quicktype {
11571157 std::optional<double> min_extent;
11581158 std::optional<std::string> tick_color;
11591159 std::optional<bool> tick_round;
1160- std::optional<bool> ticks;
11611160 std::optional<double> tick_size;
11621161 ClassMemberConstraints tick_size_constraint;
11631162 std::optional<double> tick_width;
11641163 ClassMemberConstraints tick_width_constraint;
1164+ std::optional<bool> ticks;
11651165 std::optional<std::string> title_align;
11661166 std::optional<double> title_angle;
11671167 std::optional<std::string> title_baseline;
@@ -1383,13 +1383,6 @@ namespace quicktype {
13831383 std::optional<bool> & get_mutable_tick_round() { return tick_round; }
13841384 void set_tick_round(const std::optional<bool> & value) { this->tick_round = value; }
13851385
1386- /**
1387- * Boolean value that determines whether the axis should include ticks.
1388- */
1389- const std::optional<bool> & get_ticks() const { return ticks; }
1390- std::optional<bool> & get_mutable_ticks() { return ticks; }
1391- void set_ticks(const std::optional<bool> & value) { this->ticks = value; }
1392-
13931386 /**
13941387 * The size in pixels of axis ticks.
13951388 */
@@ -1404,6 +1397,13 @@ namespace quicktype {
14041397 std::optional<double> & get_mutable_tick_width() { return tick_width; }
14051398 void set_tick_width(const std::optional<double> & value) { CheckConstraint("tick_width", tick_width_constraint, value); this->tick_width = value; }
14061399
1400+ /**
1401+ * Boolean value that determines whether the axis should include ticks.
1402+ */
1403+ const std::optional<bool> & get_ticks() const { return ticks; }
1404+ std::optional<bool> & get_mutable_ticks() { return ticks; }
1405+ void set_ticks(const std::optional<bool> & value) { this->ticks = value; }
1406+
14071407 /**
14081408 * Horizontal text alignment of axis titles.
14091409 */
@@ -1527,9 +1527,9 @@ namespace quicktype {
15271527 std::optional<double> dx;
15281528 std::optional<double> dy;
15291529 std::optional<std::string> fill;
1530- std::optional<bool> filled;
15311530 std::optional<double> fill_opacity;
15321531 ClassMemberConstraints fill_opacity_constraint;
1532+ std::optional<bool> filled;
15331533 std::optional<std::string> font;
15341534 std::optional<double> font_size;
15351535 ClassMemberConstraints font_size_constraint;
@@ -1654,6 +1654,15 @@ namespace quicktype {
16541654 std::optional<std::string> & get_mutable_fill() { return fill; }
16551655 void set_fill(const std::optional<std::string> & value) { this->fill = value; }
16561656
1657+ /**
1658+ * The fill opacity (value between [0,1]).
1659+ *
1660+ * __Default value:__ `1`
1661+ */
1662+ const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
1663+ std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
1664+ void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
1665+
16571666 /**
16581667 * Whether the mark's color should be used as fill color instead of stroke color.
16591668 *
@@ -1667,15 +1676,6 @@ namespace quicktype {
16671676 std::optional<bool> & get_mutable_filled() { return filled; }
16681677 void set_filled(const std::optional<bool> & value) { this->filled = value; }
16691678
1670- /**
1671- * The fill opacity (value between [0,1]).
1672- *
1673- * __Default value:__ `1`
1674- */
1675- const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
1676- std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
1677- void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
1678-
16791679 /**
16801680 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
16811681 */
@@ -3488,9 +3488,9 @@ namespace quicktype {
34883488 std::optional<double> dx;
34893489 std::optional<double> dy;
34903490 std::optional<std::string> fill;
3491- std::optional<bool> filled;
34923491 std::optional<double> fill_opacity;
34933492 ClassMemberConstraints fill_opacity_constraint;
3493+ std::optional<bool> filled;
34943494 std::optional<std::string> font;
34953495 std::optional<double> font_size;
34963496 ClassMemberConstraints font_size_constraint;
@@ -3589,6 +3589,15 @@ namespace quicktype {
35893589 std::optional<std::string> & get_mutable_fill() { return fill; }
35903590 void set_fill(const std::optional<std::string> & value) { this->fill = value; }
35913591
3592+ /**
3593+ * The fill opacity (value between [0,1]).
3594+ *
3595+ * __Default value:__ `1`
3596+ */
3597+ const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
3598+ std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
3599+ void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
3600+
35923601 /**
35933602 * Whether the mark's color should be used as fill color instead of stroke color.
35943603 *
@@ -3602,15 +3611,6 @@ namespace quicktype {
36023611 std::optional<bool> & get_mutable_filled() { return filled; }
36033612 void set_filled(const std::optional<bool> & value) { this->filled = value; }
36043613
3605- /**
3606- * The fill opacity (value between [0,1]).
3607- *
3608- * __Default value:__ `1`
3609- */
3610- const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
3611- std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
3612- void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
3613-
36143614 /**
36153615 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
36163616 */
@@ -3835,9 +3835,9 @@ namespace quicktype {
38353835 std::optional<double> dx;
38363836 std::optional<double> dy;
38373837 std::optional<std::string> fill;
3838- std::optional<bool> filled;
38393838 std::optional<double> fill_opacity;
38403839 ClassMemberConstraints fill_opacity_constraint;
3840+ std::optional<bool> filled;
38413841 std::optional<std::string> font;
38423842 std::optional<double> font_size;
38433843 ClassMemberConstraints font_size_constraint;
@@ -3946,6 +3946,15 @@ namespace quicktype {
39463946 std::optional<std::string> & get_mutable_fill() { return fill; }
39473947 void set_fill(const std::optional<std::string> & value) { this->fill = value; }
39483948
3949+ /**
3950+ * The fill opacity (value between [0,1]).
3951+ *
3952+ * __Default value:__ `1`
3953+ */
3954+ const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
3955+ std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
3956+ void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
3957+
39493958 /**
39503959 * Whether the mark's color should be used as fill color instead of stroke color.
39513960 *
@@ -3959,15 +3968,6 @@ namespace quicktype {
39593968 std::optional<bool> & get_mutable_filled() { return filled; }
39603969 void set_filled(const std::optional<bool> & value) { this->filled = value; }
39613970
3962- /**
3963- * The fill opacity (value between [0,1]).
3964- *
3965- * __Default value:__ `1`
3966- */
3967- const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
3968- std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
3969- void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
3970-
39713971 /**
39723972 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
39733973 */
@@ -7021,9 +7021,9 @@ namespace quicktype {
70217021 std::optional<TitleOrient> orient;
70227022 std::optional<double> position;
70237023 std::optional<double> tick_count;
7024- std::optional<bool> ticks;
70257024 std::optional<double> tick_size;
70267025 ClassMemberConstraints tick_size_constraint;
7026+ std::optional<bool> ticks;
70277027 std::optional<std::string> title;
70287028 std::optional<double> title_max_length;
70297029 std::optional<double> title_padding;
@@ -7196,13 +7196,6 @@ namespace quicktype {
71967196 std::optional<double> & get_mutable_tick_count() { return tick_count; }
71977197 void set_tick_count(const std::optional<double> & value) { this->tick_count = value; }
71987198
7199- /**
7200- * Boolean value that determines whether the axis should include ticks.
7201- */
7202- const std::optional<bool> & get_ticks() const { return ticks; }
7203- std::optional<bool> & get_mutable_ticks() { return ticks; }
7204- void set_ticks(const std::optional<bool> & value) { this->ticks = value; }
7205-
72067199 /**
72077200 * The size in pixels of axis ticks.
72087201 */
@@ -7210,6 +7203,13 @@ namespace quicktype {
72107203 std::optional<double> & get_mutable_tick_size() { return tick_size; }
72117204 void set_tick_size(const std::optional<double> & value) { CheckConstraint("tick_size", tick_size_constraint, value); this->tick_size = value; }
72127205
7206+ /**
7207+ * Boolean value that determines whether the axis should include ticks.
7208+ */
7209+ const std::optional<bool> & get_ticks() const { return ticks; }
7210+ std::optional<bool> & get_mutable_ticks() { return ticks; }
7211+ void set_ticks(const std::optional<bool> & value) { this->ticks = value; }
7212+
72137213 /**
72147214 * A title for the field. If `null`, the title will be removed.
72157215 *
@@ -7864,9 +7864,9 @@ namespace quicktype {
78647864 std::optional<double> dx;
78657865 std::optional<double> dy;
78667866 std::optional<std::string> fill;
7867- std::optional<bool> filled;
78687867 std::optional<double> fill_opacity;
78697868 ClassMemberConstraints fill_opacity_constraint;
7869+ std::optional<bool> filled;
78707870 std::optional<std::string> font;
78717871 std::optional<double> font_size;
78727872 ClassMemberConstraints font_size_constraint;
@@ -7973,6 +7973,15 @@ namespace quicktype {
79737973 std::optional<std::string> & get_mutable_fill() { return fill; }
79747974 void set_fill(const std::optional<std::string> & value) { this->fill = value; }
79757975
7976+ /**
7977+ * The fill opacity (value between [0,1]).
7978+ *
7979+ * __Default value:__ `1`
7980+ */
7981+ const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
7982+ std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
7983+ void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
7984+
79767985 /**
79777986 * Whether the mark's color should be used as fill color instead of stroke color.
79787987 *
@@ -7986,15 +7995,6 @@ namespace quicktype {
79867995 std::optional<bool> & get_mutable_filled() { return filled; }
79877996 void set_filled(const std::optional<bool> & value) { this->filled = value; }
79887997
7989- /**
7990- * The fill opacity (value between [0,1]).
7991- *
7992- * __Default value:__ `1`
7993- */
7994- const std::optional<double> & get_fill_opacity() const { return fill_opacity; }
7995- std::optional<double> & get_mutable_fill_opacity() { return fill_opacity; }
7996- void set_fill_opacity(const std::optional<double> & value) { CheckConstraint("fill_opacity", fill_opacity_constraint, value); this->fill_opacity = value; }
7997-
79987998 /**
79997999 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
80008000 */
@@ -10074,8 +10074,8 @@ namespace quicktype {
1007410074 x.set_dx(get_stack_optional<double>(j, "dx"));
1007510075 x.set_dy(get_stack_optional<double>(j, "dy"));
1007610076 x.set_fill(get_stack_optional<std::string>(j, "fill"));
10077- x.set_filled(get_stack_optional<bool>(j, "filled"));
1007810077 x.set_fill_opacity(get_stack_optional<double>(j, "fillOpacity"));
10078+ x.set_filled(get_stack_optional<bool>(j, "filled"));
1007910079 x.set_font(get_stack_optional<std::string>(j, "font"));
1008010080 x.set_font_size(get_stack_optional<double>(j, "fontSize"));
1008110081 x.set_font_style(get_stack_optional<FontStyle>(j, "fontStyle"));
@@ -10108,8 +10108,8 @@ namespace quicktype {
1010810108 j["dx"] = x.get_dx();
1010910109 j["dy"] = x.get_dy();
1011010110 j["fill"] = x.get_fill();
10111- j["filled"] = x.get_filled();
1011210111 j["fillOpacity"] = x.get_fill_opacity();
10112+ j["filled"] = x.get_filled();
1011310113 j["font"] = x.get_font();
1011410114 j["fontSize"] = x.get_font_size();
1011510115 j["fontStyle"] = x.get_font_style();
@@ -10157,9 +10157,9 @@ namespace quicktype {
1015710157 x.set_short_time_labels(get_stack_optional<bool>(j, "shortTimeLabels"));
1015810158 x.set_tick_color(get_stack_optional<std::string>(j, "tickColor"));
1015910159 x.set_tick_round(get_stack_optional<bool>(j, "tickRound"));
10160- x.set_ticks(get_stack_optional<bool>(j, "ticks"));
1016110160 x.set_tick_size(get_stack_optional<double>(j, "tickSize"));
1016210161 x.set_tick_width(get_stack_optional<double>(j, "tickWidth"));
10162+ x.set_ticks(get_stack_optional<bool>(j, "ticks"));
1016310163 x.set_title_align(get_stack_optional<std::string>(j, "titleAlign"));
1016410164 x.set_title_angle(get_stack_optional<double>(j, "titleAngle"));
1016510165 x.set_title_baseline(get_stack_optional<std::string>(j, "titleBaseline"));
@@ -10200,9 +10200,9 @@ namespace quicktype {
1020010200 j["shortTimeLabels"] = x.get_short_time_labels();
1020110201 j["tickColor"] = x.get_tick_color();
1020210202 j["tickRound"] = x.get_tick_round();
10203- j["ticks"] = x.get_ticks();
1020410203 j["tickSize"] = x.get_tick_size();
1020510204 j["tickWidth"] = x.get_tick_width();
10205+ j["ticks"] = x.get_ticks();
1020610206 j["titleAlign"] = x.get_title_align();
1020710207 j["titleAngle"] = x.get_title_angle();
1020810208 j["titleBaseline"] = x.get_title_baseline();
@@ -10241,9 +10241,9 @@ namespace quicktype {
1024110241 x.set_min_extent(get_stack_optional<double>(j, "minExtent"));
1024210242 x.set_tick_color(get_stack_optional<std::string>(j, "tickColor"));
1024310243 x.set_tick_round(get_stack_optional<bool>(j, "tickRound"));
10244- x.set_ticks(get_stack_optional<bool>(j, "ticks"));
1024510244 x.set_tick_size(get_stack_optional<double>(j, "tickSize"));
1024610245 x.set_tick_width(get_stack_optional<double>(j, "tickWidth"));
10246+ x.set_ticks(get_stack_optional<bool>(j, "ticks"));
1024710247 x.set_title_align(get_stack_optional<std::string>(j, "titleAlign"));
1024810248 x.set_title_angle(get_stack_optional<double>(j, "titleAngle"));
1024910249 x.set_title_baseline(get_stack_optional<std::string>(j, "titleBaseline"));
@@ -10283,9 +10283,9 @@ namespace quicktype {
1028310283 j["minExtent"] = x.get_min_extent();
1028410284 j["tickColor"] = x.get_tick_color();
1028510285 j["tickRound"] = x.get_tick_round();
10286- j["ticks"] = x.get_ticks();
1028710286 j["tickSize"] = x.get_tick_size();
1028810287 j["tickWidth"] = x.get_tick_width();
10288+ j["ticks"] = x.get_ticks();
1028910289 j["titleAlign"] = x.get_title_align();
1029010290 j["titleAngle"] = x.get_title_angle();
1029110291 j["titleBaseline"] = x.get_title_baseline();
@@ -10312,8 +10312,8 @@ namespace quicktype {
1031210312 x.set_dx(get_stack_optional<double>(j, "dx"));
1031310313 x.set_dy(get_stack_optional<double>(j, "dy"));
1031410314 x.set_fill(get_stack_optional<std::string>(j, "fill"));
10315- x.set_filled(get_stack_optional<bool>(j, "filled"));
1031610315 x.set_fill_opacity(get_stack_optional<double>(j, "fillOpacity"));
10316+ x.set_filled(get_stack_optional<bool>(j, "filled"));
1031710317 x.set_font(get_stack_optional<std::string>(j, "font"));
1031810318 x.set_font_size(get_stack_optional<double>(j, "fontSize"));
1031910319 x.set_font_style(get_stack_optional<FontStyle>(j, "fontStyle"));
@@ -10349,8 +10349,8 @@ namespace quicktype {
1034910349 j["dx"] = x.get_dx();
1035010350 j["dy"] = x.get_dy();
1035110351 j["fill"] = x.get_fill();
10352- j["filled"] = x.get_filled();
1035310352 j["fillOpacity"] = x.get_fill_opacity();
10353+ j["filled"] = x.get_filled();
1035410354 j["font"] = x.get_font();
1035510355 j["fontSize"] = x.get_font_size();
1035610356 j["fontStyle"] = x.get_font_style();
@@ -10756,8 +10756,8 @@ namespace quicktype {
1075610756 x.set_dx(get_stack_optional<double>(j, "dx"));
1075710757 x.set_dy(get_stack_optional<double>(j, "dy"));
1075810758 x.set_fill(get_stack_optional<std::string>(j, "fill"));
10759- x.set_filled(get_stack_optional<bool>(j, "filled"));
1076010759 x.set_fill_opacity(get_stack_optional<double>(j, "fillOpacity"));
10760+ x.set_filled(get_stack_optional<bool>(j, "filled"));
1076110761 x.set_font(get_stack_optional<std::string>(j, "font"));
1076210762 x.set_font_size(get_stack_optional<double>(j, "fontSize"));
1076310763 x.set_font_style(get_stack_optional<FontStyle>(j, "fontStyle"));
@@ -10791,8 +10791,8 @@ namespace quicktype {
1079110791 j["dx"] = x.get_dx();
1079210792 j["dy"] = x.get_dy();
1079310793 j["fill"] = x.get_fill();
10794- j["filled"] = x.get_filled();
1079510794 j["fillOpacity"] = x.get_fill_opacity();
10795+ j["filled"] = x.get_filled();
1079610796 j["font"] = x.get_font();
1079710797 j["fontSize"] = x.get_font_size();
1079810798 j["fontStyle"] = x.get_font_style();
@@ -10826,8 +10826,8 @@ namespace quicktype {
1082610826 x.set_dx(get_stack_optional<double>(j, "dx"));
1082710827 x.set_dy(get_stack_optional<double>(j, "dy"));
1082810828 x.set_fill(get_stack_optional<std::string>(j, "fill"));
10829- x.set_filled(get_stack_optional<bool>(j, "filled"));
1083010829 x.set_fill_opacity(get_stack_optional<double>(j, "fillOpacity"));
10830+ x.set_filled(get_stack_optional<bool>(j, "filled"));
1083110831 x.set_font(get_stack_optional<std::string>(j, "font"));
1083210832 x.set_font_size(get_stack_optional<double>(j, "fontSize"));
1083310833 x.set_font_style(get_stack_optional<FontStyle>(j, "fontStyle"));
@@ -10862,8 +10862,8 @@ namespace quicktype {
1086210862 j["dx"] = x.get_dx();
1086310863 j["dy"] = x.get_dy();
1086410864 j["fill"] = x.get_fill();
10865- j["filled"] = x.get_filled();
1086610865 j["fillOpacity"] = x.get_fill_opacity();
10866+ j["filled"] = x.get_filled();
1086710867 j["font"] = x.get_font();
1086810868 j["fontSize"] = x.get_font_size();
1086910869 j["fontStyle"] = x.get_font_style();
@@ -11521,8 +11521,8 @@ namespace quicktype {
1152111521 x.set_orient(get_stack_optional<TitleOrient>(j, "orient"));
1152211522 x.set_position(get_stack_optional<double>(j, "position"));
1152311523 x.set_tick_count(get_stack_optional<double>(j, "tickCount"));
11524- x.set_ticks(get_stack_optional<bool>(j, "ticks"));
1152511524 x.set_tick_size(get_stack_optional<double>(j, "tickSize"));
11525+ x.set_ticks(get_stack_optional<bool>(j, "ticks"));
1152611526 x.set_title(get_stack_optional<std::string>(j, "title"));
1152711527 x.set_title_max_length(get_stack_optional<double>(j, "titleMaxLength"));
1152811528 x.set_title_padding(get_stack_optional<double>(j, "titlePadding"));
@@ -11547,8 +11547,8 @@ namespace quicktype {
1154711547 j["orient"] = x.get_orient();
1154811548 j["position"] = x.get_position();
1154911549 j["tickCount"] = x.get_tick_count();
11550- j["ticks"] = x.get_ticks();
1155111550 j["tickSize"] = x.get_tick_size();
11551+ j["ticks"] = x.get_ticks();
1155211552 j["title"] = x.get_title();
1155311553 j["titleMaxLength"] = x.get_title_max_length();
1155411554 j["titlePadding"] = x.get_title_padding();
@@ -11693,8 +11693,8 @@ namespace quicktype {
1169311693 x.set_dx(get_stack_optional<double>(j, "dx"));
1169411694 x.set_dy(get_stack_optional<double>(j, "dy"));
1169511695 x.set_fill(get_stack_optional<std::string>(j, "fill"));
11696- x.set_filled(get_stack_optional<bool>(j, "filled"));
1169711696 x.set_fill_opacity(get_stack_optional<double>(j, "fillOpacity"));
11697+ x.set_filled(get_stack_optional<bool>(j, "filled"));
1169811698 x.set_font(get_stack_optional<std::string>(j, "font"));
1169911699 x.set_font_size(get_stack_optional<double>(j, "fontSize"));
1170011700 x.set_font_style(get_stack_optional<FontStyle>(j, "fontStyle"));
@@ -11730,8 +11730,8 @@ namespace quicktype {
1173011730 j["dx"] = x.get_dx();
1173111731 j["dy"] = x.get_dy();
1173211732 j["fill"] = x.get_fill();
11733- j["filled"] = x.get_filled();
1173411733 j["fillOpacity"] = x.get_fill_opacity();
11734+ j["filled"] = x.get_filled();
1173511735 j["font"] = x.get_font();
1173611736 j["fontSize"] = x.get_font_size();
1173711737 j["fontStyle"] = x.get_font_style();
Mschema-csharp-SystemTextJson/test/inputs/schema/accessors.schema/default/QuickType.cs+4 −4
@@ -25,8 +25,8 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("bar", Required = Required.Always)]
29- public string Barre { get; set; }
28+ [JsonProperty("union", Required = Required.Always)]
29+ public Union Unionization { get; set; }
3030
3131 [JsonProperty("enum", Required = Required.Always)]
3232 public Enum Enumerification { get; set; }
@@ -34,8 +34,8 @@ namespace QuickType
3434 [JsonProperty("foo", Required = Required.Always)]
3535 public string Fu_uu { get; set; }
3636
37- [JsonProperty("union", Required = Required.Always)]
38- public Union Unionization { get; set; }
37+ [JsonProperty("bar", Required = Required.Always)]
38+ public string Barre { get; set; }
3939 }
4040
4141 public enum Enum { Fire, Grass, Blue };
Mschema-csharp-SystemTextJson/test/inputs/schema/all-of-additional-properties-false.schema/default/QuickType.cs+3 −3
@@ -31,11 +31,11 @@ namespace QuickType
3131 [JsonProperty("frequency", Required = Required.Always)]
3232 public Frequency Frequency { get; set; }
3333
34- [JsonProperty("description", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
35- public string? Description { get; set; }
36-
3734 [JsonProperty("type", Required = Required.Always)]
3835 public TypeEnum Type { get; set; }
36+
37+ [JsonProperty("description", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
38+ public string? Description { get; set; }
3939 }
4040
4141 public enum Frequency { Weekly, Monthly, Annually };
Mschema-csharp-SystemTextJson/test/inputs/schema/bool-string.schema/default/QuickType.cs+12 −12
@@ -25,18 +25,6 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("arrNullable", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
29- [JsonConverter(typeof(PurpleDecodeArrayConverter))]
30- public bool?[]? ArrNullable { get; set; }
31-
32- [JsonProperty("arrOne", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
33- [JsonConverter(typeof(FluffyDecodeArrayConverter))]
34- public bool[]? ArrOne { get; set; }
35-
36- [JsonProperty("nullable", Required = Required.AllowNull)]
37- [JsonConverter(typeof(ParseStringConverter))]
38- public bool? Nullable { get; set; }
39-
4028 [JsonProperty("one", Required = Required.Always)]
4129 [JsonConverter(typeof(ParseStringConverter))]
4230 public bool One { get; set; }
@@ -45,6 +33,18 @@ namespace QuickType
4533 [JsonConverter(typeof(ParseStringConverter))]
4634 public bool? Optional { get; set; }
4735
36+ [JsonProperty("nullable", Required = Required.AllowNull)]
37+ [JsonConverter(typeof(ParseStringConverter))]
38+ public bool? Nullable { get; set; }
39+
40+ [JsonProperty("arrOne", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
41+ [JsonConverter(typeof(FluffyDecodeArrayConverter))]
42+ public bool[]? ArrOne { get; set; }
43+
44+ [JsonProperty("arrNullable", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
45+ [JsonConverter(typeof(PurpleDecodeArrayConverter))]
46+ public bool?[]? ArrNullable { get; set; }
47+
4848 [JsonProperty("unionWithBool", Required = Required.Always)]
4949 [JsonConverter(typeof(DecodingChoiceConverter))]
5050 public bool UnionWithBool { get; set; }
Mschema-csharp-SystemTextJson/test/inputs/schema/boolean-subschema.schema/default/QuickType.cs+3 −3
@@ -25,15 +25,15 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28+ [JsonProperty("foo", Required = Required.Always)]
29+ public string Foo { get; set; }
30+
2831 [JsonProperty("disallowed")]
2932 public object? Disallowed { get; set; }
3033
3134 [JsonProperty("empty", Required = Required.Always)]
3235 public object[] Empty { get; set; }
3336
34- [JsonProperty("foo", Required = Required.Always)]
35- public string Foo { get; set; }
36-
3737 [JsonProperty("impossible")]
3838 public object? Impossible { get; set; }
3939 }
Mschema-csharp-SystemTextJson/test/inputs/schema/comment-injection.schema/default/QuickType.cs+17 −17
@@ -39,6 +39,23 @@ namespace QuickType
3939 /// </summary>
4040 public partial class TopLevel
4141 {
42+ /// <summary>
43+ /// Property delimiters:
44+ /// */
45+ /// /*
46+ /// {-
47+ /// -}
48+ /// """
49+ /// &lt;/summary&gt; &amp; &lt;br&gt;
50+ /// }
51+ /// }
52+ /// }
53+ /// }
54+ /// }
55+ /// </summary>
56+ [JsonProperty("value", Required = Required.Always)]
57+ public string Value { get; set; }
58+
4259 /// <summary>
4360 /// Ends with a backslash \
4461 /// </summary>
@@ -56,23 +73,6 @@ namespace QuickType
5673 /// </summary>
5774 [JsonProperty("trailingTripleQuote", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
5875 public string? TrailingTripleQuote { get; set; }
59-
60- /// <summary>
61- /// Property delimiters:
62- /// */
63- /// /*
64- /// {-
65- /// -}
66- /// """
67- /// &lt;/summary&gt; &amp; &lt;br&gt;
68- /// }
69- /// }
70- /// }
71- /// }
72- /// }
73- /// </summary>
74- [JsonProperty("value", Required = Required.Always)]
75- public string Value { get; set; }
7676 }
7777
7878 public partial class TopLevel
Mschema-csharp-SystemTextJson/test/inputs/schema/const-non-string.schema/default/QuickType.cs+6 −6
@@ -25,20 +25,20 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28+ [JsonProperty("version", Required = Required.Always)]
29+ public double Version { get; set; }
30+
2831 [JsonProperty("amount", Required = Required.Always)]
2932 public long Amount { get; set; }
3033
34+ [JsonProperty("ratio", Required = Required.Always)]
35+ public double Ratio { get; set; }
36+
3137 [JsonProperty("enabled", Required = Required.Always)]
3238 public bool Enabled { get; set; }
3339
3440 [JsonProperty("kind", Required = Required.Always)]
3541 public Kind Kind { get; set; }
36-
37- [JsonProperty("ratio", Required = Required.Always)]
38- public double Ratio { get; set; }
39-
40- [JsonProperty("version", Required = Required.Always)]
41- public double Version { get; set; }
4242 }
4343
4444 public enum Kind { Widget };
Mschema-csharp-SystemTextJson/test/inputs/schema/date-time-or-string.schema/default/QuickType.cs+3 −3
@@ -25,11 +25,11 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("bar", Required = Required.Always)]
29- public BarUnion Bar { get; set; }
30-
3128 [JsonProperty("foo", Required = Required.Always)]
3229 public string Foo { get; set; }
30+
31+ [JsonProperty("bar", Required = Required.Always)]
32+ public BarUnion Bar { get; set; }
3333 }
3434
3535 public enum BarEnum { Quux };
Mschema-csharp-SystemTextJson/test/inputs/schema/date-time.schema/default/QuickType.cs+6 −6
@@ -25,20 +25,20 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("complex-union-array", Required = Required.Always)]
29- public ComplexUnionArrayElement[] ComplexUnionArray { get; set; }
30-
3128 [JsonProperty("date", Required = Required.Always)]
3229 public DateTimeOffset Date { get; set; }
3330
34- [JsonProperty("date-time", Required = Required.Always)]
35- public DateTimeOffset DateTime { get; set; }
36-
3731 [JsonProperty("time", Required = Required.Always)]
3832 public DateTimeOffset Time { get; set; }
3933
34+ [JsonProperty("date-time", Required = Required.Always)]
35+ public DateTimeOffset DateTime { get; set; }
36+
4037 [JsonProperty("union-array", Required = Required.Always)]
4138 public DateTimeOffset[] UnionArray { get; set; }
39+
40+ [JsonProperty("complex-union-array", Required = Required.Always)]
41+ public ComplexUnionArrayElement[] ComplexUnionArray { get; set; }
4242 }
4343
4444 public enum ComplexUnionArrayEnum { Foo, Bar };
Mschema-csharp-SystemTextJson/test/inputs/schema/description.schema/default/QuickType.cs+9 −9
@@ -30,10 +30,10 @@ namespace QuickType
3030 public partial class TopLevel
3131 {
3232 /// <summary>
33- /// A pretty boolean
33+ /// Either a number or a string
3434 /// </summary>
35- [JsonProperty("bar", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
36- public bool? Bar { get; set; }
35+ [JsonProperty("union", Required = Required.Always)]
36+ public Union Union { get; set; }
3737
3838 /// <summary>
3939 /// An enumeration
@@ -44,14 +44,14 @@ namespace QuickType
4444 [JsonProperty("foo", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
4545 public double? Foo { get; set; }
4646
47- [JsonProperty("object-or-string", Required = Required.Always)]
48- public ObjectOrStringUnion ObjectOrString { get; set; }
49-
5047 /// <summary>
51- /// Either a number or a string
48+ /// A pretty boolean
5249 /// </summary>
53- [JsonProperty("union", Required = Required.Always)]
54- public Union Union { get; set; }
50+ [JsonProperty("bar", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
51+ public bool? Bar { get; set; }
52+
53+ [JsonProperty("object-or-string", Required = Required.Always)]
54+ public ObjectOrStringUnion ObjectOrString { get; set; }
5555 }
5656
5757 public partial class ObjectOrStringClass
Mschema-csharp-SystemTextJson/test/inputs/schema/direct-union.schema/default/QuickType.cs+3 −3
@@ -31,11 +31,11 @@ namespace QuickType
3131
3232 public partial class Thing
3333 {
34- [JsonProperty("optional")]
35- public Anything? Optional { get; set; }
36-
3734 [JsonProperty("required", Required = Required.AllowNull)]
3835 public Anything ThingRequired { get; set; }
36+
37+ [JsonProperty("optional")]
38+ public Anything? Optional { get; set; }
3939 }
4040
4141 public partial struct Anything
Mschema-csharp-SystemTextJson/test/inputs/schema/enum.schema/default/QuickType.cs+7 −7
@@ -25,20 +25,20 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("arr", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
29- public Arr[]? Arr { get; set; }
30-
31- [JsonProperty("for", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
32- public string? For { get; set; }
28+ [JsonProperty("lvc", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
29+ public Lvc? Lvc { get; set; }
3330
3431 [JsonProperty("gve", Required = Required.Always)]
3532 public Gve Gve { get; set; }
3633
37- [JsonProperty("lvc", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
38- public Lvc? Lvc { get; set; }
34+ [JsonProperty("arr", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
35+ public Arr[]? Arr { get; set; }
3936
4037 [JsonProperty("otherArr", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
4138 public OtherArr[]? OtherArr { get; set; }
39+
40+ [JsonProperty("for", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
41+ public string? For { get; set; }
4242 }
4343
4444 public enum OtherArr { Foo, Bar, If };
Mschema-csharp-SystemTextJson/test/inputs/schema/integer-string.schema/default/QuickType.cs+12 −12
@@ -25,18 +25,6 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("arrNullable", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
29- [JsonConverter(typeof(PurpleDecodeArrayConverter))]
30- public long?[]? ArrNullable { get; set; }
31-
32- [JsonProperty("arrOne", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
33- [JsonConverter(typeof(FluffyDecodeArrayConverter))]
34- public long[]? ArrOne { get; set; }
35-
36- [JsonProperty("nullable", Required = Required.AllowNull)]
37- [JsonConverter(typeof(ParseStringConverter))]
38- public long? Nullable { get; set; }
39-
4028 [JsonProperty("one", Required = Required.Always)]
4129 [JsonConverter(typeof(ParseStringConverter))]
4230 public long One { get; set; }
@@ -45,6 +33,18 @@ namespace QuickType
4533 [JsonConverter(typeof(ParseStringConverter))]
4634 public long? Optional { get; set; }
4735
36+ [JsonProperty("nullable", Required = Required.AllowNull)]
37+ [JsonConverter(typeof(ParseStringConverter))]
38+ public long? Nullable { get; set; }
39+
40+ [JsonProperty("arrOne", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
41+ [JsonConverter(typeof(FluffyDecodeArrayConverter))]
42+ public long[]? ArrOne { get; set; }
43+
44+ [JsonProperty("arrNullable", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
45+ [JsonConverter(typeof(PurpleDecodeArrayConverter))]
46+ public long?[]? ArrNullable { get; set; }
47+
4848 [JsonProperty("unionWithInt", Required = Required.Always)]
4949 [JsonConverter(typeof(DecodingChoiceConverter))]
5050 public long UnionWithInt { get; set; }
Mschema-csharp-SystemTextJson/test/inputs/schema/integer-type.schema/default/QuickType.cs+13 −13
@@ -25,32 +25,32 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("above_i32_max", Required = Required.Always)]
29- public long AboveI32Max { get; set; }
28+ [JsonProperty("small_positive", Required = Required.Always)]
29+ public long SmallPositive { get; set; }
3030
31- [JsonProperty("below_i32_min", Required = Required.Always)]
32- public long BelowI32Min { get; set; }
31+ [JsonProperty("small_negative", Required = Required.Always)]
32+ public long SmallNegative { get; set; }
3333
3434 [JsonProperty("i32_range", Required = Required.Always)]
3535 public long I32Range { get; set; }
3636
37- [JsonProperty("large_bounds", Required = Required.Always)]
38- public long LargeBounds { get; set; }
37+ [JsonProperty("above_i32_max", Required = Required.Always)]
38+ public long AboveI32Max { get; set; }
3939
40- [JsonProperty("only_maximum", Required = Required.Always)]
41- public long OnlyMaximum { get; set; }
40+ [JsonProperty("below_i32_min", Required = Required.Always)]
41+ public long BelowI32Min { get; set; }
4242
4343 [JsonProperty("only_minimum", Required = Required.Always)]
4444 public long OnlyMinimum { get; set; }
4545
46- [JsonProperty("small_negative", Required = Required.Always)]
47- public long SmallNegative { get; set; }
48-
49- [JsonProperty("small_positive", Required = Required.Always)]
50- public long SmallPositive { get; set; }
46+ [JsonProperty("only_maximum", Required = Required.Always)]
47+ public long OnlyMaximum { get; set; }
5148
5249 [JsonProperty("unbounded", Required = Required.Always)]
5350 public long Unbounded { get; set; }
51+
52+ [JsonProperty("large_bounds", Required = Required.Always)]
53+ public long LargeBounds { get; set; }
5454 }
5555
5656 public partial class TopLevel
Mschema-csharp-SystemTextJson/test/inputs/schema/light.schema/default/QuickType.cs+6 −6
@@ -253,9 +253,6 @@ namespace QuickType
253253 [JsonProperty("double", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
254254 public UnionDouble? Double { get; set; }
255255
256- [JsonProperty("dummy", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
257- public double? Dummy { get; set; }
258-
259256 [JsonProperty("dynamic", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
260257 public UnionDynamic? Dynamic { get; set; }
261258
@@ -412,12 +409,12 @@ namespace QuickType
412409 [JsonProperty("internal", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
413410 public UnionInternal? Internal { get; set; }
414411
415- [JsonProperty("is", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
416- public UnionIs? Is { get; set; }
417-
418412 [JsonProperty("iterable", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
419413 public UnionIterable? Iterable { get; set; }
420414
415+ [JsonProperty("is", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
416+ public UnionIs? Is { get; set; }
417+
421418 [JsonProperty("jdec", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
422419 public UnionJdec? Jdec { get; set; }
423420
@@ -855,6 +852,9 @@ namespace QuickType
855852
856853 [JsonProperty("yield", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
857854 public UnionYield? Yield { get; set; }
855+
856+ [JsonProperty("dummy", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
857+ public double? Dummy { get; set; }
858858 }
859859
860860 public partial class Abstract
Mschema-csharp-SystemTextJson/test/inputs/schema/min-max-items.schema/default/QuickType.cs+3 −3
@@ -31,12 +31,12 @@ namespace QuickType
3131
3232 public partial class LightParams
3333 {
34- [JsonProperty("app_id", Required = Required.Always)]
35- public string AppId { get; set; }
36-
3734 [JsonProperty("outlet_id", Required = Required.Always)]
3835 public string OutletId { get; set; }
3936
37+ [JsonProperty("app_id", Required = Required.Always)]
38+ public string AppId { get; set; }
39+
4040 [JsonProperty("rgba", Required = Required.Always)]
4141 public string Rgba { get; set; }
4242 }
Mschema-csharp-SystemTextJson/test/inputs/schema/minmax-integer.schema/default/QuickType.cs+3 −3
@@ -25,15 +25,15 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28+ [JsonProperty("minOnly", Required = Required.Always)]
29+ public string[] MinOnly { get; set; }
30+
2831 [JsonProperty("maxOnly", Required = Required.Always)]
2932 public long[] MaxOnly { get; set; }
3033
3134 [JsonProperty("minAndMax", Required = Required.Always)]
3235 public double[] MinAndMax { get; set; }
3336
34- [JsonProperty("minOnly", Required = Required.Always)]
35- public string[] MinOnly { get; set; }
36-
3737 [JsonProperty("plain", Required = Required.Always)]
3838 public string[] Plain { get; set; }
Mschema-csharp-SystemTextJson/test/inputs/schema/minmax.schema/default/QuickType.cs+9 −9
@@ -28,26 +28,26 @@ namespace QuickType
2828 [JsonProperty("free", Required = Required.Always)]
2929 public long Free { get; set; }
3030
31- [JsonProperty("intersection", Required = Required.Always)]
32- public long Intersection { get; set; }
31+ [JsonProperty("min", Required = Required.Always)]
32+ public long Min { get; set; }
3333
3434 [JsonProperty("max", Required = Required.Always)]
3535 public long Max { get; set; }
3636
37- [JsonProperty("min", Required = Required.Always)]
38- public long Min { get; set; }
39-
4037 [JsonProperty("minmax", Required = Required.Always)]
4138 public long Minmax { get; set; }
4239
43- [JsonProperty("minMaxIntersection", Required = Required.Always)]
44- public long MinMaxIntersection { get; set; }
40+ [JsonProperty("union", Required = Required.Always)]
41+ public long Union { get; set; }
4542
4643 [JsonProperty("minMaxUnion", Required = Required.Always)]
4744 public long MinMaxUnion { get; set; }
4845
49- [JsonProperty("union", Required = Required.Always)]
50- public long Union { get; set; }
46+ [JsonProperty("intersection", Required = Required.Always)]
47+ public long Intersection { get; set; }
48+
49+ [JsonProperty("minMaxIntersection", Required = Required.Always)]
50+ public long MinMaxIntersection { get; set; }
5151 }
5252
5353 public partial class TopLevel
Mschema-csharp-SystemTextJson/test/inputs/schema/minmaxlength.schema/default/QuickType.cs+13 −13
@@ -28,32 +28,32 @@ namespace QuickType
2828 [JsonProperty("free", Required = Required.Always)]
2929 public double Free { get; set; }
3030
31- [JsonProperty("intersection", Required = Required.Always)]
32- [JsonConverter(typeof(PurpleMinMaxValueCheckConverter))]
33- public double Intersection { get; set; }
31+ [JsonProperty("min", Required = Required.Always)]
32+ [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
33+ public double Min { get; set; }
3434
3535 [JsonProperty("max", Required = Required.Always)]
3636 [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
3737 public double Max { get; set; }
3838
39- [JsonProperty("min", Required = Required.Always)]
40- [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
41- public double Min { get; set; }
42-
4339 [JsonProperty("minmax", Required = Required.Always)]
4440 [JsonConverter(typeof(StickyMinMaxValueCheckConverter))]
4541 public double Minmax { get; set; }
4642
47- [JsonProperty("minMaxIntersection", Required = Required.Always)]
48- [JsonConverter(typeof(StickyMinMaxValueCheckConverter))]
49- public double MinMaxIntersection { get; set; }
43+ [JsonProperty("union", Required = Required.Always)]
44+ [JsonConverter(typeof(IndigoMinMaxValueCheckConverter))]
45+ public double Union { get; set; }
5046
5147 [JsonProperty("minMaxUnion", Required = Required.Always)]
5248 public double MinMaxUnion { get; set; }
5349
54- [JsonProperty("union", Required = Required.Always)]
55- [JsonConverter(typeof(IndigoMinMaxValueCheckConverter))]
56- public double Union { get; set; }
50+ [JsonProperty("intersection", Required = Required.Always)]
51+ [JsonConverter(typeof(PurpleMinMaxValueCheckConverter))]
52+ public double Intersection { get; set; }
53+
54+ [JsonProperty("minMaxIntersection", Required = Required.Always)]
55+ [JsonConverter(typeof(StickyMinMaxValueCheckConverter))]
56+ public double MinMaxIntersection { get; set; }
5757 }
5858
5959 public partial class TopLevel
Mschema-csharp-SystemTextJson/test/inputs/schema/non-standard-ref.schema/default/QuickType.cs+17 −17
@@ -25,35 +25,35 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("intersection", Required = Required.Always)]
29- [JsonConverter(typeof(FluffyMinMaxLengthCheckConverter))]
30- public string Intersection { get; set; }
31-
32- [JsonProperty("inUnion", Required = Required.Always)]
33- public InUnion InUnion { get; set; }
34-
35- [JsonProperty("maxlength", Required = Required.Always)]
36- [JsonConverter(typeof(TentacledMinMaxLengthCheckConverter))]
37- public string Maxlength { get; set; }
38-
3928 [JsonProperty("minlength", Required = Required.Always)]
4029 [JsonConverter(typeof(StickyMinMaxLengthCheckConverter))]
4130 public string Minlength { get; set; }
4231
43- [JsonProperty("minMaxIntersection", Required = Required.Always)]
44- [JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
45- public string MinMaxIntersection { get; set; }
32+ [JsonProperty("maxlength", Required = Required.Always)]
33+ [JsonConverter(typeof(TentacledMinMaxLengthCheckConverter))]
34+ public string Maxlength { get; set; }
4635
4736 [JsonProperty("minmaxlength", Required = Required.Always)]
4837 [JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
4938 public string Minmaxlength { get; set; }
5039
51- [JsonProperty("minMaxUnion", Required = Required.Always)]
52- public string MinMaxUnion { get; set; }
53-
5440 [JsonProperty("union", Required = Required.Always)]
5541 [JsonConverter(typeof(IndigoMinMaxLengthCheckConverter))]
5642 public string Union { get; set; }
43+
44+ [JsonProperty("inUnion", Required = Required.Always)]
45+ public InUnion InUnion { get; set; }
46+
47+ [JsonProperty("minMaxUnion", Required = Required.Always)]
48+ public string MinMaxUnion { get; set; }
49+
50+ [JsonProperty("intersection", Required = Required.Always)]
51+ [JsonConverter(typeof(FluffyMinMaxLengthCheckConverter))]
52+ public string Intersection { get; set; }
53+
54+ [JsonProperty("minMaxIntersection", Required = Required.Always)]
55+ [JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
56+ public string MinMaxIntersection { get; set; }
5757 }
5858
5959 public partial struct InUnion
Mschema-csharp-SystemTextJson/test/inputs/schema/nullable-optional-one-of.schema/default/QuickType.cs+3 −3
@@ -25,12 +25,12 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("bar", Required = Required.Always)]
29- public long Bar { get; set; }
30-
3128 [JsonProperty("foo", Required = Required.Always)]
3229 public long Foo { get; set; }
3330
31+ [JsonProperty("bar", Required = Required.Always)]
32+ public long Bar { get; set; }
33+
3434 [JsonProperty("quux", Required = Required.Always)]
3535 public bool Quux { get; set; }
3636 }
Mschema-csharp-SystemTextJson/test/inputs/schema/optional-any.schema/default/QuickType.cs+3 −3
@@ -25,11 +25,11 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("b")]
29- public string? B { get; set; }
30-
3128 [JsonProperty("kind", Required = Required.Always)]
3229 public Kind Kind { get; set; }
30+
31+ [JsonProperty("b")]
32+ public string? B { get; set; }
3333 }
3434
3535 public enum Kind { One, Two };
Mschema-csharp-SystemTextJson/test/inputs/schema/optional-const-ref.schema/default/QuickType.cs+3 −3
@@ -25,11 +25,11 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("bar", Required = Required.Always)]
29- public bool Bar { get; set; }
30-
3128 [JsonProperty("foo")]
3229 public object? Foo { get; set; }
30+
31+ [JsonProperty("bar", Required = Required.Always)]
32+ public bool Bar { get; set; }
3333 }
3434
3535 public partial class TopLevel
Mschema-csharp-SystemTextJson/test/inputs/schema/optional-constraints.schema/default/QuickType.cs+10 −10
@@ -28,26 +28,26 @@ namespace QuickType
2828 [JsonProperty("coordinates", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
2929 public Coordinate[]? Coordinates { get; set; }
3030
31+ [JsonProperty("requiredCoordinates", Required = Required.Always)]
32+ public Coordinate[] RequiredCoordinates { get; set; }
33+
3134 [JsonProperty("count", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3235 public long? Count { get; set; }
3336
37+ [JsonProperty("requiredCount", Required = Required.Always)]
38+ public long RequiredCount { get; set; }
39+
40+ [JsonProperty("weight", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
41+ [JsonConverter(typeof(MinMaxValueCheckConverter))]
42+ public double? Weight { get; set; }
43+
3444 [JsonProperty("label", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3545 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
3646 public string? Label { get; set; }
3747
38- [JsonProperty("requiredCoordinates", Required = Required.Always)]
39- public Coordinate[] RequiredCoordinates { get; set; }
40-
41- [JsonProperty("requiredCount", Required = Required.Always)]
42- public long RequiredCount { get; set; }
43-
4448 [JsonProperty("requiredLabel", Required = Required.Always)]
4549 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
4650 public string RequiredLabel { get; set; }
47-
48- [JsonProperty("weight", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
49- [JsonConverter(typeof(MinMaxValueCheckConverter))]
50- public double? Weight { get; set; }
5151 }
5252
5353 public partial class Coordinate
Mschema-csharp-SystemTextJson/test/inputs/schema/optional-date-time.schema/default/QuickType.cs+7 −7
@@ -25,22 +25,22 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("optDouble", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
29- [JsonConverter(typeof(MinMaxValueCheckConverter))]
30- public double? OptDouble { get; set; }
28+ [JsonProperty("reqZeroMin", Required = Required.Always)]
29+ public long ReqZeroMin { get; set; }
3130
3231 [JsonProperty("optInt", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3332 public long? OptInt { get; set; }
3433
35- [JsonProperty("optPattern", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
36- public string? OptPattern { get; set; }
34+ [JsonProperty("optDouble", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
35+ [JsonConverter(typeof(MinMaxValueCheckConverter))]
36+ public double? OptDouble { get; set; }
3737
3838 [JsonProperty("optString", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3939 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
4040 public string? OptString { get; set; }
4141
42- [JsonProperty("reqZeroMin", Required = Required.Always)]
43- public long ReqZeroMin { get; set; }
42+ [JsonProperty("optPattern", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
43+ public string? OptPattern { get; set; }
4444 }
4545
4646 public partial class TopLevel
Mschema-csharp-SystemTextJson/test/inputs/schema/prefix-items.schema/default/QuickType.cs+11 −11
@@ -25,23 +25,23 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("optional-date", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
29- public DateTimeOffset? OptionalDate { get; set; }
30-
31- [JsonProperty("optional-date-time", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
32- public DateTimeOffset? OptionalDateTime { get; set; }
33-
34- [JsonProperty("optional-time", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
35- public DateTimeOffset? OptionalTime { get; set; }
36-
3728 [JsonProperty("required-date", Required = Required.Always)]
3829 public DateTimeOffset RequiredDate { get; set; }
3930
31+ [JsonProperty("required-time", Required = Required.Always)]
32+ public DateTimeOffset RequiredTime { get; set; }
33+
4034 [JsonProperty("required-date-time", Required = Required.Always)]
4135 public DateTimeOffset RequiredDateTime { get; set; }
4236
43- [JsonProperty("required-time", Required = Required.Always)]
44- public DateTimeOffset RequiredTime { get; set; }
37+ [JsonProperty("optional-date", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
38+ public DateTimeOffset? OptionalDate { get; set; }
39+
40+ [JsonProperty("optional-time", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
41+ public DateTimeOffset? OptionalTime { get; set; }
42+
43+ [JsonProperty("optional-date-time", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
44+ public DateTimeOffset? OptionalDateTime { get; set; }
4545 }
4646
4747 public partial class TopLevel
Aschema-csharp-SystemTextJson/test/inputs/schema/property-order.schema/default/QuickType.cs+3 −3
@@ -25,11 +25,11 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("open", Required = Required.Always)]
29- public Open[] Open { get; set; }
30-
3128 [JsonProperty("tuple", Required = Required.Always)]
3229 public Open[] Tuple { get; set; }
30+
31+ [JsonProperty("open", Required = Required.Always)]
32+ public Open[] Open { get; set; }
3333 }
3434
3535 public partial struct Open
Mschema-csharp-SystemTextJson/test/inputs/schema/renaming-bug.schema/default/QuickType.cs+88 −0
@@ -0,0 +1,88 @@
1+// <auto-generated />
2+//
3+// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
4+//
5+// using QuickType;
6+//
7+// var topLevel = TopLevel.FromJson(jsonString);
8+#nullable enable
9+#pragma warning disable CS8618
10+#pragma warning disable CS8601
11+#pragma warning disable CS8602
12+#pragma warning disable CS8603
13+#pragma warning disable CS8604
14+#pragma warning disable CS8625
15+#pragma warning disable CS8765
16+
17+namespace QuickType
18+{
19+ using System;
20+ using System.Collections.Generic;
21+
22+ using System.Globalization;
23+ using Newtonsoft.Json;
24+ using Newtonsoft.Json.Converters;
25+
26+ public partial class TopLevel
27+ {
28+ [JsonProperty("zebra", Required = Required.Always)]
29+ public string Zebra { get; set; }
30+
31+ [JsonProperty("mango", Required = Required.Always)]
32+ public double Mango { get; set; }
33+
34+ [JsonProperty("apple", Required = Required.Always)]
35+ public bool Apple { get; set; }
36+
37+ [JsonProperty("delta", Required = Required.Always)]
38+ public string Delta { get; set; }
39+
40+ [JsonProperty("banana", Required = Required.Always)]
41+ public long Banana { get; set; }
42+
43+ [JsonProperty("ordered", Required = Required.Always)]
44+ public Ordered Ordered { get; set; }
45+ }
46+
47+ public partial class Ordered
48+ {
49+ [JsonProperty("mango", Required = Required.Always)]
50+ public double Mango { get; set; }
51+
52+ [JsonProperty("zebra", Required = Required.Always)]
53+ public string Zebra { get; set; }
54+
55+ [JsonProperty("apple", Required = Required.Always)]
56+ public bool Apple { get; set; }
57+ }
58+
59+ public partial class TopLevel
60+ {
61+ public static TopLevel FromJson(string json) => JsonConvert.DeserializeObject<TopLevel>(json, QuickType.Converter.Settings);
62+ }
63+
64+ public static partial class Serialize
65+ {
66+ public static string ToJson(this TopLevel self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
67+ }
68+
69+ internal static partial class Converter
70+ {
71+ public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
72+ {
73+ MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
74+ DateParseHandling = DateParseHandling.None,
75+ Converters =
76+ {
77+ new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
78+ },
79+ };
80+ }
81+}
82+#pragma warning restore CS8618
83+#pragma warning restore CS8601
84+#pragma warning restore CS8602
85+#pragma warning restore CS8603
86+#pragma warning restore CS8604
87+#pragma warning restore CS8625
88+#pragma warning restore CS8765
Mschema-csharp-SystemTextJson/test/inputs/schema/rust-cycle-breaker-union.schema/default/QuickType.cs+24 −24
@@ -40,22 +40,22 @@ namespace QuickType
4040 [JsonProperty("apple", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
4141 public bool? Apple { get; set; }
4242
43- [JsonProperty("berries", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
44- public Berry[]? Berries { get; set; }
45-
4643 [JsonProperty("orange", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
4744 public bool? Orange { get; set; }
45+
46+ [JsonProperty("berries", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
47+ public Berry[]? Berries { get; set; }
4848 }
4949
5050 public partial class Berry
5151 {
52- [JsonProperty("color", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
53- public Color? Color { get; set; }
54-
5552 [JsonProperty("name", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
5653 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
5754 public string? Name { get; set; }
5855
56+ [JsonProperty("color", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
57+ public Color? Color { get; set; }
58+
5959 [JsonProperty("shapes", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
6060 public Shape[]? Shapes { get; set; }
6161 }
@@ -68,11 +68,11 @@ namespace QuickType
6868
6969 public partial class Shape
7070 {
71- [JsonProperty("geometry", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
72- public Geometry? Geometry { get; set; }
73-
7471 [JsonProperty("history", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
7572 public History? History { get; set; }
73+
74+ [JsonProperty("geometry", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
75+ public Geometry? Geometry { get; set; }
7676 }
7777
7878 public partial class Geometry
@@ -98,14 +98,14 @@ namespace QuickType
9898
9999 public partial class Part
100100 {
101- [JsonProperty("depth", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
102- public string? Depth { get; set; }
103-
104101 [JsonProperty("length", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
105102 public string? Length { get; set; }
106103
107104 [JsonProperty("width", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
108105 public string? Width { get; set; }
106+
107+ [JsonProperty("depth", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
108+ public string? Depth { get; set; }
109109 }
110110
111111 public partial class History
@@ -116,24 +116,24 @@ namespace QuickType
116116
117117 public partial class Vehicle
118118 {
119- [JsonProperty("brand", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
120- public string? Brand { get; set; }
121-
122119 [JsonProperty("id", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
123120 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
124121 public string? Id { get; set; }
125122
126- [JsonProperty("speed", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
127- public Speed? Speed { get; set; }
128-
129- [JsonProperty("subModule", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
130- public bool? SubModule { get; set; }
131-
132123 [JsonProperty("type", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
133124 public VehicleType? Type { get; set; }
134125
126+ [JsonProperty("speed", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
127+ public Speed? Speed { get; set; }
128+
135129 [JsonProperty("year", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
136130 public string? Year { get; set; }
131+
132+ [JsonProperty("brand", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
133+ public string? Brand { get; set; }
134+
135+ [JsonProperty("subModule", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
136+ public bool? SubModule { get; set; }
137137 }
138138
139139 public partial class Speed
@@ -144,11 +144,11 @@ namespace QuickType
144144
145145 public partial class Limit
146146 {
147- [JsonProperty("maximum", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
148- public double? Maximum { get; set; }
149-
150147 [JsonProperty("minimum", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
151148 public double? Minimum { get; set; }
149+
150+ [JsonProperty("maximum", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
151+ public double? Maximum { get; set; }
152152 }
153153
154154 public partial class VehicleType
Mschema-csharp-SystemTextJson/test/inputs/schema/uuid.schema/default/QuickType.cs+6 −6
@@ -25,20 +25,20 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("next")]
29- public Next? Next { get; set; }
30-
3128 [JsonProperty("value", Required = Required.Always)]
3229 public string Value { get; set; }
33- }
3430
35- public partial class Node
36- {
3731 [JsonProperty("next")]
3832 public Next? Next { get; set; }
33+ }
3934
35+ public partial class Node
36+ {
4037 [JsonProperty("value", Required = Required.Always)]
4138 public string Value { get; set; }
39+
40+ [JsonProperty("next")]
41+ public Next? Next { get; set; }
4242 }
4343
4444 public partial struct Next
Mschema-csharp-SystemTextJson/test/inputs/schema/vega-lite.schema/default/QuickType.cs+8 −8
@@ -25,20 +25,20 @@ namespace QuickType
2525
2626 public partial class TopLevel
2727 {
28- [JsonProperty("arrNullable", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
29- public Guid?[]? ArrNullable { get; set; }
28+ [JsonProperty("one", Required = Required.Always)]
29+ public Guid One { get; set; }
3030
31- [JsonProperty("arrOne", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
32- public Guid[]? ArrOne { get; set; }
31+ [JsonProperty("optional", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
32+ public Guid? Optional { get; set; }
3333
3434 [JsonProperty("nullable", Required = Required.AllowNull)]
3535 public Guid? Nullable { get; set; }
3636
37- [JsonProperty("one", Required = Required.Always)]
38- public Guid One { get; set; }
37+ [JsonProperty("arrOne", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
38+ public Guid[]? ArrOne { get; set; }
3939
40- [JsonProperty("optional", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
41- public Guid? Optional { get; set; }
40+ [JsonProperty("arrNullable", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
41+ public Guid?[]? ArrNullable { get; set; }
4242
4343 [JsonProperty("unionWithEnum", Required = Required.Always)]
4444 public UnionWithEnumUnion UnionWithEnum { get; set; }
Mschema-csharp/test/inputs/schema/accessors.schema/default/QuickType.cs+63 −63
@@ -625,6 +625,15 @@ namespace QuickType
625625 [JsonProperty("fill", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
626626 public string? Fill { get; set; }
627627
628+ /// <summary>
629+ /// The fill opacity (value between [0,1]).
630+ ///
631+ /// __Default value:__ `1`
632+ /// </summary>
633+ [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
634+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
635+ public double? FillOpacity { get; set; }
636+
628637 /// <summary>
629638 /// Whether the mark's color should be used as fill color instead of stroke color.
630639 ///
@@ -637,15 +646,6 @@ namespace QuickType
637646 [JsonProperty("filled", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
638647 public bool? Filled { get; set; }
639648
640- /// <summary>
641- /// The fill opacity (value between [0,1]).
642- ///
643- /// __Default value:__ `1`
644- /// </summary>
645- [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
646- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
647- public double? FillOpacity { get; set; }
648-
649649 /// <summary>
650650 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
651651 /// </summary>
@@ -1020,12 +1020,6 @@ namespace QuickType
10201020 [JsonProperty("tickRound", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
10211021 public bool? TickRound { get; set; }
10221022
1023- /// <summary>
1024- /// Boolean value that determines whether the axis should include ticks.
1025- /// </summary>
1026- [JsonProperty("ticks", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
1027- public bool? Ticks { get; set; }
1028-
10291023 /// <summary>
10301024 /// The size in pixels of axis ticks.
10311025 /// </summary>
@@ -1040,6 +1034,12 @@ namespace QuickType
10401034 [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
10411035 public double? TickWidth { get; set; }
10421036
1037+ /// <summary>
1038+ /// Boolean value that determines whether the axis should include ticks.
1039+ /// </summary>
1040+ [JsonProperty("ticks", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
1041+ public bool? Ticks { get; set; }
1042+
10431043 /// <summary>
10441044 /// Horizontal text alignment of axis titles.
10451045 /// </summary>
@@ -1319,12 +1319,6 @@ namespace QuickType
13191319 [JsonProperty("tickRound", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
13201320 public bool? TickRound { get; set; }
13211321
1322- /// <summary>
1323- /// Boolean value that determines whether the axis should include ticks.
1324- /// </summary>
1325- [JsonProperty("ticks", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
1326- public bool? Ticks { get; set; }
1327-
13281322 /// <summary>
13291323 /// The size in pixels of axis ticks.
13301324 /// </summary>
@@ -1339,6 +1333,12 @@ namespace QuickType
13391333 [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
13401334 public double? TickWidth { get; set; }
13411335
1336+ /// <summary>
1337+ /// Boolean value that determines whether the axis should include ticks.
1338+ /// </summary>
1339+ [JsonProperty("ticks", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
1340+ public bool? Ticks { get; set; }
1341+
13421342 /// <summary>
13431343 /// Horizontal text alignment of axis titles.
13441344 /// </summary>
@@ -1507,6 +1507,15 @@ namespace QuickType
15071507 [JsonProperty("fill", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
15081508 public string? Fill { get; set; }
15091509
1510+ /// <summary>
1511+ /// The fill opacity (value between [0,1]).
1512+ ///
1513+ /// __Default value:__ `1`
1514+ /// </summary>
1515+ [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
1516+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
1517+ public double? FillOpacity { get; set; }
1518+
15101519 /// <summary>
15111520 /// Whether the mark's color should be used as fill color instead of stroke color.
15121521 ///
@@ -1519,15 +1528,6 @@ namespace QuickType
15191528 [JsonProperty("filled", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
15201529 public bool? Filled { get; set; }
15211530
1522- /// <summary>
1523- /// The fill opacity (value between [0,1]).
1524- ///
1525- /// __Default value:__ `1`
1526- /// </summary>
1527- [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
1528- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
1529- public double? FillOpacity { get; set; }
1530-
15311531 /// <summary>
15321532 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
15331533 /// </summary>
@@ -2899,6 +2899,15 @@ namespace QuickType
28992899 [JsonProperty("fill", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
29002900 public string? Fill { get; set; }
29012901
2902+ /// <summary>
2903+ /// The fill opacity (value between [0,1]).
2904+ ///
2905+ /// __Default value:__ `1`
2906+ /// </summary>
2907+ [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
2908+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
2909+ public double? FillOpacity { get; set; }
2910+
29022911 /// <summary>
29032912 /// Whether the mark's color should be used as fill color instead of stroke color.
29042913 ///
@@ -2911,15 +2920,6 @@ namespace QuickType
29112920 [JsonProperty("filled", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
29122921 public bool? Filled { get; set; }
29132922
2914- /// <summary>
2915- /// The fill opacity (value between [0,1]).
2916- ///
2917- /// __Default value:__ `1`
2918- /// </summary>
2919- [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
2920- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
2921- public double? FillOpacity { get; set; }
2922-
29232923 /// <summary>
29242924 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
29252925 /// </summary>
@@ -3173,6 +3173,15 @@ namespace QuickType
31733173 [JsonProperty("fill", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
31743174 public string? Fill { get; set; }
31753175
3176+ /// <summary>
3177+ /// The fill opacity (value between [0,1]).
3178+ ///
3179+ /// __Default value:__ `1`
3180+ /// </summary>
3181+ [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3182+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
3183+ public double? FillOpacity { get; set; }
3184+
31763185 /// <summary>
31773186 /// Whether the mark's color should be used as fill color instead of stroke color.
31783187 ///
@@ -3185,15 +3194,6 @@ namespace QuickType
31853194 [JsonProperty("filled", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
31863195 public bool? Filled { get; set; }
31873196
3188- /// <summary>
3189- /// The fill opacity (value between [0,1]).
3190- ///
3191- /// __Default value:__ `1`
3192- /// </summary>
3193- [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
3194- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
3195- public double? FillOpacity { get; set; }
3196-
31973197 /// <summary>
31983198 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
31993199 /// </summary>
@@ -5556,12 +5556,6 @@ namespace QuickType
55565556 [JsonProperty("tickCount", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
55575557 public double? TickCount { get; set; }
55585558
5559- /// <summary>
5560- /// Boolean value that determines whether the axis should include ticks.
5561- /// </summary>
5562- [JsonProperty("ticks", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
5563- public bool? Ticks { get; set; }
5564-
55655559 /// <summary>
55665560 /// The size in pixels of axis ticks.
55675561 /// </summary>
@@ -5569,6 +5563,12 @@ namespace QuickType
55695563 [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
55705564 public double? TickSize { get; set; }
55715565
5566+ /// <summary>
5567+ /// Boolean value that determines whether the axis should include ticks.
5568+ /// </summary>
5569+ [JsonProperty("ticks", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
5570+ public bool? Ticks { get; set; }
5571+
55725572 /// <summary>
55735573 /// A title for the field. If `null`, the title will be removed.
55745574 ///
@@ -6183,6 +6183,15 @@ namespace QuickType
61836183 [JsonProperty("fill", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
61846184 public string? Fill { get; set; }
61856185
6186+ /// <summary>
6187+ /// The fill opacity (value between [0,1]).
6188+ ///
6189+ /// __Default value:__ `1`
6190+ /// </summary>
6191+ [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
6192+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
6193+ public double? FillOpacity { get; set; }
6194+
61866195 /// <summary>
61876196 /// Whether the mark's color should be used as fill color instead of stroke color.
61886197 ///
@@ -6195,15 +6204,6 @@ namespace QuickType
61956204 [JsonProperty("filled", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
61966205 public bool? Filled { get; set; }
61976206
6198- /// <summary>
6199- /// The fill opacity (value between [0,1]).
6200- ///
6201- /// __Default value:__ `1`
6202- /// </summary>
6203- [JsonProperty("fillOpacity", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
6204- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
6205- public double? FillOpacity { get; set; }
6206-
62076207 /// <summary>
62086208 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
62096209 /// </summary>
Mschema-csharp/test/inputs/schema/all-of-additional-properties-false.schema/default/QuickType.cs+4 −4
@@ -23,8 +23,8 @@ namespace QuickType
2323 public partial class TopLevel
2424 {
2525 [JsonRequired]
26- [JsonPropertyName("bar")]
27- public string Barre { get; set; }
26+ [JsonPropertyName("union")]
27+ public Union Unionization { get; set; }
2828
2929 [JsonRequired]
3030 [JsonPropertyName("enum")]
@@ -35,8 +35,8 @@ namespace QuickType
3535 public string Fu_uu { get; set; }
3636
3737 [JsonRequired]
38- [JsonPropertyName("union")]
39- public Union Unionization { get; set; }
38+ [JsonPropertyName("bar")]
39+ public string Barre { get; set; }
4040 }
4141
4242 public enum Enum { Fire, Grass, Blue };
Mschema-csharp/test/inputs/schema/bool-string.schema/default/QuickType.cs+4 −4
@@ -30,13 +30,13 @@ namespace QuickType
3030 [JsonPropertyName("frequency")]
3131 public Frequency Frequency { get; set; }
3232
33- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
34- [JsonPropertyName("description")]
35- public string? Description { get; set; }
36-
3733 [JsonRequired]
3834 [JsonPropertyName("type")]
3935 public TypeEnum Type { get; set; }
36+
37+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
38+ [JsonPropertyName("description")]
39+ public string? Description { get; set; }
4040 }
4141
4242 public enum Frequency { Weekly, Monthly, Annually };
Mschema-csharp/test/inputs/schema/boolean-subschema.schema/default/QuickType.cs+14 −14
@@ -22,30 +22,30 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
26- [JsonPropertyName("arrNullable")]
27- [JsonConverter(typeof(PurpleDecodeArrayConverter))]
28- public bool?[]? ArrNullable { get; set; }
25+ [JsonRequired]
26+ [JsonPropertyName("one")]
27+ [JsonConverter(typeof(ParseStringConverter))]
28+ public bool One { get; set; }
2929
3030 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
31- [JsonPropertyName("arrOne")]
32- [JsonConverter(typeof(FluffyDecodeArrayConverter))]
33- public bool[]? ArrOne { get; set; }
31+ [JsonPropertyName("optional")]
32+ [JsonConverter(typeof(ParseStringConverter))]
33+ public bool? Optional { get; set; }
3434
3535 [JsonRequired]
3636 [JsonPropertyName("nullable")]
3737 [JsonConverter(typeof(ParseStringConverter))]
3838 public bool? Nullable { get; set; }
3939
40- [JsonRequired]
41- [JsonPropertyName("one")]
42- [JsonConverter(typeof(ParseStringConverter))]
43- public bool One { get; set; }
40+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
41+ [JsonPropertyName("arrOne")]
42+ [JsonConverter(typeof(FluffyDecodeArrayConverter))]
43+ public bool[]? ArrOne { get; set; }
4444
4545 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
46- [JsonPropertyName("optional")]
47- [JsonConverter(typeof(ParseStringConverter))]
48- public bool? Optional { get; set; }
46+ [JsonPropertyName("arrNullable")]
47+ [JsonConverter(typeof(PurpleDecodeArrayConverter))]
48+ public bool?[]? ArrNullable { get; set; }
4949
5050 [JsonRequired]
5151 [JsonPropertyName("unionWithBool")]
Mschema-csharp/test/inputs/schema/comment-injection.schema/default/QuickType.cs+4 −4
@@ -22,6 +22,10 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25+ [JsonRequired]
26+ [JsonPropertyName("foo")]
27+ public string Foo { get; set; }
28+
2529 [JsonPropertyName("disallowed")]
2630 public object? Disallowed { get; set; }
2731
@@ -29,10 +33,6 @@ namespace QuickType
2933 [JsonPropertyName("empty")]
3034 public object[] Empty { get; set; }
3135
32- [JsonRequired]
33- [JsonPropertyName("foo")]
34- public string Foo { get; set; }
35-
3636 [JsonPropertyName("impossible")]
3737 public object? Impossible { get; set; }
3838 }
Mschema-csharp/test/inputs/schema/const-non-string.schema/default/QuickType.cs+18 −18
@@ -36,6 +36,24 @@ namespace QuickType
3636 /// </summary>
3737 public partial class TopLevel
3838 {
39+ /// <summary>
40+ /// Property delimiters:
41+ /// */
42+ /// /*
43+ /// {-
44+ /// -}
45+ /// """
46+ /// &lt;/summary&gt; &amp; &lt;br&gt;
47+ /// }
48+ /// }
49+ /// }
50+ /// }
51+ /// }
52+ /// </summary>
53+ [JsonRequired]
54+ [JsonPropertyName("value")]
55+ public string Value { get; set; }
56+
3957 /// <summary>
4058 /// Ends with a backslash \
4159 /// </summary>
@@ -56,24 +74,6 @@ namespace QuickType
5674 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
5775 [JsonPropertyName("trailingTripleQuote")]
5876 public string? TrailingTripleQuote { get; set; }
59-
60- /// <summary>
61- /// Property delimiters:
62- /// */
63- /// /*
64- /// {-
65- /// -}
66- /// """
67- /// &lt;/summary&gt; &amp; &lt;br&gt;
68- /// }
69- /// }
70- /// }
71- /// }
72- /// }
73- /// </summary>
74- [JsonRequired]
75- [JsonPropertyName("value")]
76- public string Value { get; set; }
7777 }
7878
7979 public partial class TopLevel
Mschema-csharp/test/inputs/schema/date-time-or-string.schema/default/QuickType.cs+8 −8
@@ -22,10 +22,18 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25+ [JsonRequired]
26+ [JsonPropertyName("version")]
27+ public double Version { get; set; }
28+
2529 [JsonRequired]
2630 [JsonPropertyName("amount")]
2731 public long Amount { get; set; }
2832
33+ [JsonRequired]
34+ [JsonPropertyName("ratio")]
35+ public double Ratio { get; set; }
36+
2937 [JsonRequired]
3038 [JsonPropertyName("enabled")]
3139 public bool Enabled { get; set; }
@@ -33,14 +41,6 @@ namespace QuickType
3341 [JsonRequired]
3442 [JsonPropertyName("kind")]
3543 public Kind Kind { get; set; }
36-
37- [JsonRequired]
38- [JsonPropertyName("ratio")]
39- public double Ratio { get; set; }
40-
41- [JsonRequired]
42- [JsonPropertyName("version")]
43- public double Version { get; set; }
4444 }
4545
4646 public enum Kind { Widget };
Mschema-csharp/test/inputs/schema/date-time.schema/default/QuickType.cs+4 −4
@@ -22,13 +22,13 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonRequired]
26- [JsonPropertyName("bar")]
27- public BarUnion Bar { get; set; }
28-
2925 [JsonRequired]
3026 [JsonPropertyName("foo")]
3127 public string Foo { get; set; }
28+
29+ [JsonRequired]
30+ [JsonPropertyName("bar")]
31+ public BarUnion Bar { get; set; }
3232 }
3333
3434 public enum BarEnum { Quux };
Mschema-csharp/test/inputs/schema/description.schema/default/QuickType.cs+8 −8
@@ -22,25 +22,25 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonRequired]
26- [JsonPropertyName("complex-union-array")]
27- public ComplexUnionArrayElement[] ComplexUnionArray { get; set; }
28-
2925 [JsonRequired]
3026 [JsonPropertyName("date")]
3127 public DateTimeOffset Date { get; set; }
3228
33- [JsonRequired]
34- [JsonPropertyName("date-time")]
35- public DateTimeOffset DateTime { get; set; }
36-
3729 [JsonRequired]
3830 [JsonPropertyName("time")]
3931 public DateTimeOffset Time { get; set; }
4032
33+ [JsonRequired]
34+ [JsonPropertyName("date-time")]
35+ public DateTimeOffset DateTime { get; set; }
36+
4137 [JsonRequired]
4238 [JsonPropertyName("union-array")]
4339 public DateTimeOffset[] UnionArray { get; set; }
40+
41+ [JsonRequired]
42+ [JsonPropertyName("complex-union-array")]
43+ public ComplexUnionArrayElement[] ComplexUnionArray { get; set; }
4444 }
4545
4646 public enum ComplexUnionArrayEnum { Foo, Bar };
Mschema-csharp/test/inputs/schema/direct-union.schema/default/QuickType.cs+11 −11
@@ -27,11 +27,11 @@ namespace QuickType
2727 public partial class TopLevel
2828 {
2929 /// <summary>
30- /// A pretty boolean
30+ /// Either a number or a string
3131 /// </summary>
32- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
33- [JsonPropertyName("bar")]
34- public bool? Bar { get; set; }
32+ [JsonRequired]
33+ [JsonPropertyName("union")]
34+ public Union Union { get; set; }
3535
3636 /// <summary>
3737 /// An enumeration
@@ -44,16 +44,16 @@ namespace QuickType
4444 [JsonPropertyName("foo")]
4545 public double? Foo { get; set; }
4646
47- [JsonRequired]
48- [JsonPropertyName("object-or-string")]
49- public ObjectOrStringUnion ObjectOrString { get; set; }
50-
5147 /// <summary>
52- /// Either a number or a string
48+ /// A pretty boolean
5349 /// </summary>
50+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
51+ [JsonPropertyName("bar")]
52+ public bool? Bar { get; set; }
53+
5454 [JsonRequired]
55- [JsonPropertyName("union")]
56- public Union Union { get; set; }
55+ [JsonPropertyName("object-or-string")]
56+ public ObjectOrStringUnion ObjectOrString { get; set; }
5757 }
5858
5959 public partial class ObjectOrStringClass
Mschema-csharp/test/inputs/schema/enum.schema/default/QuickType.cs+3 −3
@@ -29,12 +29,12 @@ namespace QuickType
2929
3030 public partial class Thing
3131 {
32- [JsonPropertyName("optional")]
33- public Anything? Optional { get; set; }
34-
3532 [JsonRequired]
3633 [JsonPropertyName("required")]
3734 public Anything ThingRequired { get; set; }
35+
36+ [JsonPropertyName("optional")]
37+ public Anything? Optional { get; set; }
3838 }
3939
4040 public partial struct Anything
Mschema-csharp/test/inputs/schema/integer-string.schema/default/QuickType.cs+8 −8
@@ -23,24 +23,24 @@ namespace QuickType
2323 public partial class TopLevel
2424 {
2525 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
26- [JsonPropertyName("arr")]
27- public Arr[]? Arr { get; set; }
28-
29- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
30- [JsonPropertyName("for")]
31- public string? For { get; set; }
26+ [JsonPropertyName("lvc")]
27+ public Lvc? Lvc { get; set; }
3228
3329 [JsonRequired]
3430 [JsonPropertyName("gve")]
3531 public Gve Gve { get; set; }
3632
3733 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
38- [JsonPropertyName("lvc")]
39- public Lvc? Lvc { get; set; }
34+ [JsonPropertyName("arr")]
35+ public Arr[]? Arr { get; set; }
4036
4137 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4238 [JsonPropertyName("otherArr")]
4339 public OtherArr[]? OtherArr { get; set; }
40+
41+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
42+ [JsonPropertyName("for")]
43+ public string? For { get; set; }
4444 }
4545
4646 public enum OtherArr { Foo, Bar, If };
Mschema-csharp/test/inputs/schema/integer-type.schema/default/QuickType.cs+14 −14
@@ -22,30 +22,30 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
26- [JsonPropertyName("arrNullable")]
27- [JsonConverter(typeof(PurpleDecodeArrayConverter))]
28- public long?[]? ArrNullable { get; set; }
25+ [JsonRequired]
26+ [JsonPropertyName("one")]
27+ [JsonConverter(typeof(ParseStringConverter))]
28+ public long One { get; set; }
2929
3030 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
31- [JsonPropertyName("arrOne")]
32- [JsonConverter(typeof(FluffyDecodeArrayConverter))]
33- public long[]? ArrOne { get; set; }
31+ [JsonPropertyName("optional")]
32+ [JsonConverter(typeof(ParseStringConverter))]
33+ public long? Optional { get; set; }
3434
3535 [JsonRequired]
3636 [JsonPropertyName("nullable")]
3737 [JsonConverter(typeof(ParseStringConverter))]
3838 public long? Nullable { get; set; }
3939
40- [JsonRequired]
41- [JsonPropertyName("one")]
42- [JsonConverter(typeof(ParseStringConverter))]
43- public long One { get; set; }
40+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
41+ [JsonPropertyName("arrOne")]
42+ [JsonConverter(typeof(FluffyDecodeArrayConverter))]
43+ public long[]? ArrOne { get; set; }
4444
4545 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
46- [JsonPropertyName("optional")]
47- [JsonConverter(typeof(ParseStringConverter))]
48- public long? Optional { get; set; }
46+ [JsonPropertyName("arrNullable")]
47+ [JsonConverter(typeof(PurpleDecodeArrayConverter))]
48+ public long?[]? ArrNullable { get; set; }
4949
5050 [JsonRequired]
5151 [JsonPropertyName("unionWithInt")]
Mschema-csharp/test/inputs/schema/keyword-unions.schema/default/QuickType.cs+14 −14
@@ -23,40 +23,40 @@ namespace QuickType
2323 public partial class TopLevel
2424 {
2525 [JsonRequired]
26- [JsonPropertyName("above_i32_max")]
27- public long AboveI32Max { get; set; }
26+ [JsonPropertyName("small_positive")]
27+ public long SmallPositive { get; set; }
2828
2929 [JsonRequired]
30- [JsonPropertyName("below_i32_min")]
31- public long BelowI32Min { get; set; }
30+ [JsonPropertyName("small_negative")]
31+ public long SmallNegative { get; set; }
3232
3333 [JsonRequired]
3434 [JsonPropertyName("i32_range")]
3535 public long I32Range { get; set; }
3636
3737 [JsonRequired]
38- [JsonPropertyName("large_bounds")]
39- public long LargeBounds { get; set; }
38+ [JsonPropertyName("above_i32_max")]
39+ public long AboveI32Max { get; set; }
4040
4141 [JsonRequired]
42- [JsonPropertyName("only_maximum")]
43- public long OnlyMaximum { get; set; }
42+ [JsonPropertyName("below_i32_min")]
43+ public long BelowI32Min { get; set; }
4444
4545 [JsonRequired]
4646 [JsonPropertyName("only_minimum")]
4747 public long OnlyMinimum { get; set; }
4848
4949 [JsonRequired]
50- [JsonPropertyName("small_negative")]
51- public long SmallNegative { get; set; }
52-
53- [JsonRequired]
54- [JsonPropertyName("small_positive")]
55- public long SmallPositive { get; set; }
50+ [JsonPropertyName("only_maximum")]
51+ public long OnlyMaximum { get; set; }
5652
5753 [JsonRequired]
5854 [JsonPropertyName("unbounded")]
5955 public long Unbounded { get; set; }
56+
57+ [JsonRequired]
58+ [JsonPropertyName("large_bounds")]
59+ public long LargeBounds { get; set; }
6060 }
6161
6262 public partial class TopLevel
Mschema-csharp/test/inputs/schema/light.schema/default/QuickType.cs+4 −4
@@ -29,14 +29,14 @@ namespace QuickType
2929
3030 public partial class LightParams
3131 {
32- [JsonRequired]
33- [JsonPropertyName("app_id")]
34- public string AppId { get; set; }
35-
3632 [JsonRequired]
3733 [JsonPropertyName("outlet_id")]
3834 public string OutletId { get; set; }
3935
36+ [JsonRequired]
37+ [JsonPropertyName("app_id")]
38+ public string AppId { get; set; }
39+
4040 [JsonRequired]
4141 [JsonPropertyName("rgba")]
4242 public string Rgba { get; set; }
Mschema-csharp/test/inputs/schema/min-max-items.schema/default/QuickType.cs+4 −4
@@ -22,6 +22,10 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25+ [JsonRequired]
26+ [JsonPropertyName("minOnly")]
27+ public string[] MinOnly { get; set; }
28+
2529 [JsonRequired]
2630 [JsonPropertyName("maxOnly")]
2731 public long[] MaxOnly { get; set; }
@@ -30,10 +34,6 @@ namespace QuickType
3034 [JsonPropertyName("minAndMax")]
3135 public double[] MinAndMax { get; set; }
3236
33- [JsonRequired]
34- [JsonPropertyName("minOnly")]
35- public string[] MinOnly { get; set; }
36-
3737 [JsonRequired]
3838 [JsonPropertyName("plain")]
3939 public string[] Plain { get; set; }
Mschema-csharp/test/inputs/schema/minmax-integer.schema/default/QuickType.cs+10 −10
@@ -27,32 +27,32 @@ namespace QuickType
2727 public long Free { get; set; }
2828
2929 [JsonRequired]
30- [JsonPropertyName("intersection")]
31- public long Intersection { get; set; }
30+ [JsonPropertyName("min")]
31+ public long Min { get; set; }
3232
3333 [JsonRequired]
3434 [JsonPropertyName("max")]
3535 public long Max { get; set; }
3636
37- [JsonRequired]
38- [JsonPropertyName("min")]
39- public long Min { get; set; }
40-
4137 [JsonRequired]
4238 [JsonPropertyName("minmax")]
4339 public long Minmax { get; set; }
4440
4541 [JsonRequired]
46- [JsonPropertyName("minMaxIntersection")]
47- public long MinMaxIntersection { get; set; }
42+ [JsonPropertyName("union")]
43+ public long Union { get; set; }
4844
4945 [JsonRequired]
5046 [JsonPropertyName("minMaxUnion")]
5147 public long MinMaxUnion { get; set; }
5248
5349 [JsonRequired]
54- [JsonPropertyName("union")]
55- public long Union { get; set; }
50+ [JsonPropertyName("intersection")]
51+ public long Intersection { get; set; }
52+
53+ [JsonRequired]
54+ [JsonPropertyName("minMaxIntersection")]
55+ public long MinMaxIntersection { get; set; }
5656 }
5757
5858 public partial class TopLevel
Mschema-csharp/test/inputs/schema/minmax.schema/default/QuickType.cs+14 −14
@@ -27,38 +27,38 @@ namespace QuickType
2727 public double Free { get; set; }
2828
2929 [JsonRequired]
30- [JsonPropertyName("intersection")]
31- [JsonConverter(typeof(PurpleMinMaxValueCheckConverter))]
32- public double Intersection { get; set; }
30+ [JsonPropertyName("min")]
31+ [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
32+ public double Min { get; set; }
3333
3434 [JsonRequired]
3535 [JsonPropertyName("max")]
3636 [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
3737 public double Max { get; set; }
3838
39- [JsonRequired]
40- [JsonPropertyName("min")]
41- [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
42- public double Min { get; set; }
43-
4439 [JsonRequired]
4540 [JsonPropertyName("minmax")]
4641 [JsonConverter(typeof(StickyMinMaxValueCheckConverter))]
4742 public double Minmax { get; set; }
4843
4944 [JsonRequired]
50- [JsonPropertyName("minMaxIntersection")]
51- [JsonConverter(typeof(StickyMinMaxValueCheckConverter))]
52- public double MinMaxIntersection { get; set; }
45+ [JsonPropertyName("union")]
46+ [JsonConverter(typeof(IndigoMinMaxValueCheckConverter))]
47+ public double Union { get; set; }
5348
5449 [JsonRequired]
5550 [JsonPropertyName("minMaxUnion")]
5651 public double MinMaxUnion { get; set; }
5752
5853 [JsonRequired]
59- [JsonPropertyName("union")]
60- [JsonConverter(typeof(IndigoMinMaxValueCheckConverter))]
61- public double Union { get; set; }
54+ [JsonPropertyName("intersection")]
55+ [JsonConverter(typeof(PurpleMinMaxValueCheckConverter))]
56+ public double Intersection { get; set; }
57+
58+ [JsonRequired]
59+ [JsonPropertyName("minMaxIntersection")]
60+ [JsonConverter(typeof(StickyMinMaxValueCheckConverter))]
61+ public double MinMaxIntersection { get; set; }
6262 }
6363
6464 public partial class TopLevel
Mschema-csharp/test/inputs/schema/minmaxlength.schema/default/QuickType.cs+19 −19
@@ -23,13 +23,9 @@ namespace QuickType
2323 public partial class TopLevel
2424 {
2525 [JsonRequired]
26- [JsonPropertyName("intersection")]
27- [JsonConverter(typeof(FluffyMinMaxLengthCheckConverter))]
28- public string Intersection { get; set; }
29-
30- [JsonRequired]
31- [JsonPropertyName("inUnion")]
32- public InUnion InUnion { get; set; }
26+ [JsonPropertyName("minlength")]
27+ [JsonConverter(typeof(StickyMinMaxLengthCheckConverter))]
28+ public string Minlength { get; set; }
3329
3430 [JsonRequired]
3531 [JsonPropertyName("maxlength")]
@@ -37,28 +33,32 @@ namespace QuickType
3733 public string Maxlength { get; set; }
3834
3935 [JsonRequired]
40- [JsonPropertyName("minlength")]
41- [JsonConverter(typeof(StickyMinMaxLengthCheckConverter))]
42- public string Minlength { get; set; }
36+ [JsonPropertyName("minmaxlength")]
37+ [JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
38+ public string Minmaxlength { get; set; }
4339
4440 [JsonRequired]
45- [JsonPropertyName("minMaxIntersection")]
46- [JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
47- public string MinMaxIntersection { get; set; }
41+ [JsonPropertyName("union")]
42+ [JsonConverter(typeof(IndigoMinMaxLengthCheckConverter))]
43+ public string Union { get; set; }
4844
4945 [JsonRequired]
50- [JsonPropertyName("minmaxlength")]
51- [JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
52- public string Minmaxlength { get; set; }
46+ [JsonPropertyName("inUnion")]
47+ public InUnion InUnion { get; set; }
5348
5449 [JsonRequired]
5550 [JsonPropertyName("minMaxUnion")]
5651 public string MinMaxUnion { get; set; }
5752
5853 [JsonRequired]
59- [JsonPropertyName("union")]
60- [JsonConverter(typeof(IndigoMinMaxLengthCheckConverter))]
61- public string Union { get; set; }
54+ [JsonPropertyName("intersection")]
55+ [JsonConverter(typeof(FluffyMinMaxLengthCheckConverter))]
56+ public string Intersection { get; set; }
57+
58+ [JsonRequired]
59+ [JsonPropertyName("minMaxIntersection")]
60+ [JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
61+ public string MinMaxIntersection { get; set; }
6262 }
6363
6464 public partial struct InUnion
Mschema-csharp/test/inputs/schema/non-standard-ref.schema/default/QuickType.cs+4 −4
@@ -22,14 +22,14 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonRequired]
26- [JsonPropertyName("bar")]
27- public long Bar { get; set; }
28-
2925 [JsonRequired]
3026 [JsonPropertyName("foo")]
3127 public long Foo { get; set; }
3228
29+ [JsonRequired]
30+ [JsonPropertyName("bar")]
31+ public long Bar { get; set; }
32+
3333 [JsonRequired]
3434 [JsonPropertyName("quux")]
3535 public bool Quux { get; set; }
Mschema-csharp/test/inputs/schema/nullable-optional-one-of.schema/default/QuickType.cs+3 −3
@@ -22,12 +22,12 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonPropertyName("b")]
26- public string? B { get; set; }
27-
2825 [JsonRequired]
2926 [JsonPropertyName("kind")]
3027 public Kind Kind { get; set; }
28+
29+ [JsonPropertyName("b")]
30+ public string? B { get; set; }
3131 }
3232
3333 public enum Kind { One, Two };
Mschema-csharp/test/inputs/schema/optional-any.schema/default/QuickType.cs+3 −3
@@ -22,12 +22,12 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25+ [JsonPropertyName("foo")]
26+ public object? Foo { get; set; }
27+
2528 [JsonRequired]
2629 [JsonPropertyName("bar")]
2730 public bool Bar { get; set; }
28-
29- [JsonPropertyName("foo")]
30- public object? Foo { get; set; }
3131 }
3232
3333 public partial class TopLevel
Mschema-csharp/test/inputs/schema/optional-const-ref.schema/default/QuickType.cs+13 −13
@@ -26,32 +26,32 @@ namespace QuickType
2626 [JsonPropertyName("coordinates")]
2727 public Coordinate[]? Coordinates { get; set; }
2828
29+ [JsonRequired]
30+ [JsonPropertyName("requiredCoordinates")]
31+ public Coordinate[] RequiredCoordinates { get; set; }
32+
2933 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3034 [JsonPropertyName("count")]
3135 public long? Count { get; set; }
3236
37+ [JsonRequired]
38+ [JsonPropertyName("requiredCount")]
39+ public long RequiredCount { get; set; }
40+
41+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
42+ [JsonPropertyName("weight")]
43+ [JsonConverter(typeof(MinMaxValueCheckConverter))]
44+ public double? Weight { get; set; }
45+
3346 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3447 [JsonPropertyName("label")]
3548 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
3649 public string? Label { get; set; }
3750
38- [JsonRequired]
39- [JsonPropertyName("requiredCoordinates")]
40- public Coordinate[] RequiredCoordinates { get; set; }
41-
42- [JsonRequired]
43- [JsonPropertyName("requiredCount")]
44- public long RequiredCount { get; set; }
45-
4651 [JsonRequired]
4752 [JsonPropertyName("requiredLabel")]
4853 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
4954 public string RequiredLabel { get; set; }
50-
51- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
52- [JsonPropertyName("weight")]
53- [JsonConverter(typeof(MinMaxValueCheckConverter))]
54- public double? Weight { get; set; }
5555 }
5656
5757 public partial class Coordinate
Mschema-csharp/test/inputs/schema/optional-constraints.schema/default/QuickType.cs+9 −9
@@ -22,27 +22,27 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
26- [JsonPropertyName("optDouble")]
27- [JsonConverter(typeof(MinMaxValueCheckConverter))]
28- public double? OptDouble { get; set; }
25+ [JsonRequired]
26+ [JsonPropertyName("reqZeroMin")]
27+ public long ReqZeroMin { get; set; }
2928
3029 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3130 [JsonPropertyName("optInt")]
3231 public long? OptInt { get; set; }
3332
3433 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
35- [JsonPropertyName("optPattern")]
36- public string? OptPattern { get; set; }
34+ [JsonPropertyName("optDouble")]
35+ [JsonConverter(typeof(MinMaxValueCheckConverter))]
36+ public double? OptDouble { get; set; }
3737
3838 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3939 [JsonPropertyName("optString")]
4040 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
4141 public string? OptString { get; set; }
4242
43- [JsonRequired]
44- [JsonPropertyName("reqZeroMin")]
45- public long ReqZeroMin { get; set; }
43+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
44+ [JsonPropertyName("optPattern")]
45+ public string? OptPattern { get; set; }
4646 }
4747
4848 public partial class TopLevel
Mschema-csharp/test/inputs/schema/optional-date-time.schema/default/QuickType.cs+15 −15
@@ -22,29 +22,29 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
26- [JsonPropertyName("optional-date")]
27- public DateTimeOffset? OptionalDate { get; set; }
28-
29- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
30- [JsonPropertyName("optional-date-time")]
31- public DateTimeOffset? OptionalDateTime { get; set; }
32-
33- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
34- [JsonPropertyName("optional-time")]
35- public DateTimeOffset? OptionalTime { get; set; }
36-
3725 [JsonRequired]
3826 [JsonPropertyName("required-date")]
3927 public DateTimeOffset RequiredDate { get; set; }
4028
29+ [JsonRequired]
30+ [JsonPropertyName("required-time")]
31+ public DateTimeOffset RequiredTime { get; set; }
32+
4133 [JsonRequired]
4234 [JsonPropertyName("required-date-time")]
4335 public DateTimeOffset RequiredDateTime { get; set; }
4436
45- [JsonRequired]
46- [JsonPropertyName("required-time")]
47- public DateTimeOffset RequiredTime { get; set; }
37+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
38+ [JsonPropertyName("optional-date")]
39+ public DateTimeOffset? OptionalDate { get; set; }
40+
41+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
42+ [JsonPropertyName("optional-time")]
43+ public DateTimeOffset? OptionalTime { get; set; }
44+
45+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
46+ [JsonPropertyName("optional-date-time")]
47+ public DateTimeOffset? OptionalDateTime { get; set; }
4848 }
4949
5050 public partial class TopLevel
Mschema-csharp/test/inputs/schema/prefix-items.schema/default/QuickType.cs+4 −4
@@ -22,13 +22,13 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonRequired]
26- [JsonPropertyName("open")]
27- public Open[] Open { get; set; }
28-
2925 [JsonRequired]
3026 [JsonPropertyName("tuple")]
3127 public Open[] Tuple { get; set; }
28+
29+ [JsonRequired]
30+ [JsonPropertyName("open")]
31+ public Open[] Open { get; set; }
3232 }
3333
3434 public partial struct Open
Aschema-csharp/test/inputs/schema/property-order.schema/default/QuickType.cs+201 −0
@@ -0,0 +1,201 @@
1+// <auto-generated />
2+//
3+// To parse this JSON data, add NuGet 'System.Text.Json' then do:
4+//
5+// using QuickType;
6+//
7+// var topLevel = TopLevel.FromJson(jsonString);
8+#nullable enable
9+#pragma warning disable CS8618
10+#pragma warning disable CS8601
11+#pragma warning disable CS8602
12+#pragma warning disable CS8603
13+
14+namespace QuickType
15+{
16+ using System;
17+ using System.Collections.Generic;
18+
19+ using System.Text.Json;
20+ using System.Text.Json.Serialization;
21+ using System.Globalization;
22+
23+ public partial class TopLevel
24+ {
25+ [JsonRequired]
26+ [JsonPropertyName("zebra")]
27+ public string Zebra { get; set; }
28+
29+ [JsonRequired]
30+ [JsonPropertyName("mango")]
31+ public double Mango { get; set; }
32+
33+ [JsonRequired]
34+ [JsonPropertyName("apple")]
35+ public bool Apple { get; set; }
36+
37+ [JsonRequired]
38+ [JsonPropertyName("delta")]
39+ public string Delta { get; set; }
40+
41+ [JsonRequired]
42+ [JsonPropertyName("banana")]
43+ public long Banana { get; set; }
44+
45+ [JsonRequired]
46+ [JsonPropertyName("ordered")]
47+ public Ordered Ordered { get; set; }
48+ }
49+
50+ public partial class Ordered
51+ {
52+ [JsonRequired]
53+ [JsonPropertyName("mango")]
54+ public double Mango { get; set; }
55+
56+ [JsonRequired]
57+ [JsonPropertyName("zebra")]
58+ public string Zebra { get; set; }
59+
60+ [JsonRequired]
61+ [JsonPropertyName("apple")]
62+ public bool Apple { get; set; }
63+ }
64+
65+ public partial class TopLevel
66+ {
67+ public static TopLevel FromJson(string json) => JsonSerializer.Deserialize<TopLevel>(json, QuickType.Converter.Settings);
68+ }
69+
70+ public static partial class Serialize
71+ {
72+ public static string ToJson(this TopLevel self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
73+ }
74+
75+ internal static partial class Converter
76+ {
77+ public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
78+ {
79+ Converters =
80+ {
81+ new DateOnlyConverter(),
82+ new TimeOnlyConverter(),
83+ IsoDateTimeOffsetConverter.Singleton
84+ },
85+ };
86+ }
87+
88+ public class DateOnlyConverter : JsonConverter<DateOnly>
89+ {
90+ private readonly string serializationFormat;
91+ public DateOnlyConverter() : this(null) { }
92+
93+ public DateOnlyConverter(string? serializationFormat)
94+ {
95+ this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
96+ }
97+
98+ public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
99+ {
100+ var value = reader.GetString();
101+ return DateOnly.Parse(value!);
102+ }
103+
104+ public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
105+ => writer.WriteStringValue(value.ToString(serializationFormat));
106+ }
107+
108+ public class TimeOnlyConverter : JsonConverter<TimeOnly>
109+ {
110+ private readonly string serializationFormat;
111+
112+ public TimeOnlyConverter() : this(null) { }
113+
114+ public TimeOnlyConverter(string? serializationFormat)
115+ {
116+ this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
117+ }
118+
119+ public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
120+ {
121+ var value = reader.GetString();
122+ return TimeOnly.Parse(value!);
123+ }
124+
125+ public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
126+ => writer.WriteStringValue(value.ToString(serializationFormat));
127+ }
128+
129+ internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
130+ {
131+ public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);
132+
133+ private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
134+
135+ private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
136+ private string? _dateTimeFormat;
137+ private CultureInfo? _culture;
138+
139+ public DateTimeStyles DateTimeStyles
140+ {
141+ get => _dateTimeStyles;
142+ set => _dateTimeStyles = value;
143+ }
144+
145+ public string? DateTimeFormat
146+ {
147+ get => _dateTimeFormat ?? string.Empty;
148+ set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
149+ }
150+
151+ public CultureInfo Culture
152+ {
153+ get => _culture ?? CultureInfo.CurrentCulture;
154+ set => _culture = value;
155+ }
156+
157+ public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
158+ {
159+ string text;
160+
161+
162+ if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
163+ || (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
164+ {
165+ value = value.ToUniversalTime();
166+ }
167+
168+ text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
169+
170+ writer.WriteStringValue(text);
171+ }
172+
173+ public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
174+ {
175+ string? dateText = reader.GetString();
176+
177+ if (string.IsNullOrEmpty(dateText) == false)
178+ {
179+ if (!string.IsNullOrEmpty(_dateTimeFormat))
180+ {
181+ return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
182+ }
183+ else
184+ {
185+ return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
186+ }
187+ }
188+ else
189+ {
190+ return default(DateTimeOffset);
191+ }
192+ }
193+
194+
195+ public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
196+ }
197+}
198+#pragma warning restore CS8618
199+#pragma warning restore CS8601
200+#pragma warning restore CS8602
201+#pragma warning restore CS8603
Mschema-csharp/test/inputs/schema/renaming-bug.schema/default/QuickType.cs+30 −30
@@ -41,26 +41,26 @@ namespace QuickType
4141 [JsonPropertyName("apple")]
4242 public bool? Apple { get; set; }
4343
44- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
45- [JsonPropertyName("berries")]
46- public Berry[]? Berries { get; set; }
47-
4844 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4945 [JsonPropertyName("orange")]
5046 public bool? Orange { get; set; }
47+
48+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
49+ [JsonPropertyName("berries")]
50+ public Berry[]? Berries { get; set; }
5151 }
5252
5353 public partial class Berry
5454 {
55- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
56- [JsonPropertyName("color")]
57- public Color? Color { get; set; }
58-
5955 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
6056 [JsonPropertyName("name")]
6157 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
6258 public string? Name { get; set; }
6359
60+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
61+ [JsonPropertyName("color")]
62+ public Color? Color { get; set; }
63+
6464 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
6565 [JsonPropertyName("shapes")]
6666 public Shape[]? Shapes { get; set; }
@@ -75,13 +75,13 @@ namespace QuickType
7575
7676 public partial class Shape
7777 {
78- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
79- [JsonPropertyName("geometry")]
80- public Geometry? Geometry { get; set; }
81-
8278 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
8379 [JsonPropertyName("history")]
8480 public History? History { get; set; }
81+
82+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
83+ [JsonPropertyName("geometry")]
84+ public Geometry? Geometry { get; set; }
8585 }
8686
8787 public partial class Geometry
@@ -111,10 +111,6 @@ namespace QuickType
111111
112112 public partial class Part
113113 {
114- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
115- [JsonPropertyName("depth")]
116- public string? Depth { get; set; }
117-
118114 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
119115 [JsonPropertyName("length")]
120116 public string? Length { get; set; }
@@ -122,6 +118,10 @@ namespace QuickType
122118 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
123119 [JsonPropertyName("width")]
124120 public string? Width { get; set; }
121+
122+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
123+ [JsonPropertyName("depth")]
124+ public string? Depth { get; set; }
125125 }
126126
127127 public partial class History
@@ -133,30 +133,30 @@ namespace QuickType
133133
134134 public partial class Vehicle
135135 {
136- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
137- [JsonPropertyName("brand")]
138- public string? Brand { get; set; }
139-
140136 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
141137 [JsonPropertyName("id")]
142138 [JsonConverter(typeof(MinMaxLengthCheckConverter))]
143139 public string? Id { get; set; }
144140
141+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
142+ [JsonPropertyName("type")]
143+ public VehicleType? Type { get; set; }
144+
145145 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
146146 [JsonPropertyName("speed")]
147147 public Speed? Speed { get; set; }
148148
149149 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
150- [JsonPropertyName("subModule")]
151- public bool? SubModule { get; set; }
150+ [JsonPropertyName("year")]
151+ public string? Year { get; set; }
152152
153153 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
154- [JsonPropertyName("type")]
155- public VehicleType? Type { get; set; }
154+ [JsonPropertyName("brand")]
155+ public string? Brand { get; set; }
156156
157157 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
158- [JsonPropertyName("year")]
159- public string? Year { get; set; }
158+ [JsonPropertyName("subModule")]
159+ public bool? SubModule { get; set; }
160160 }
161161
162162 public partial class Speed
@@ -168,13 +168,13 @@ namespace QuickType
168168
169169 public partial class Limit
170170 {
171- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
172- [JsonPropertyName("maximum")]
173- public double? Maximum { get; set; }
174-
175171 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
176172 [JsonPropertyName("minimum")]
177173 public double? Minimum { get; set; }
174+
175+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
176+ [JsonPropertyName("maximum")]
177+ public double? Maximum { get; set; }
178178 }
179179
180180 public partial class VehicleType
Mschema-csharp/test/inputs/schema/rust-cycle-breaker-union.schema/default/QuickType.cs+6 −6
@@ -22,22 +22,22 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonPropertyName("next")]
26- public Next? Next { get; set; }
27-
2825 [JsonRequired]
2926 [JsonPropertyName("value")]
3027 public string Value { get; set; }
31- }
3228
33- public partial class Node
34- {
3529 [JsonPropertyName("next")]
3630 public Next? Next { get; set; }
31+ }
3732
33+ public partial class Node
34+ {
3835 [JsonRequired]
3936 [JsonPropertyName("value")]
4037 public string Value { get; set; }
38+
39+ [JsonPropertyName("next")]
40+ public Next? Next { get; set; }
4141 }
4242
4343 public partial struct Next
Mschema-csharp/test/inputs/schema/uuid.schema/default/QuickType.cs+10 −10
@@ -22,25 +22,25 @@ namespace QuickType
2222
2323 public partial class TopLevel
2424 {
25- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
26- [JsonPropertyName("arrNullable")]
27- public Guid?[]? ArrNullable { get; set; }
25+ [JsonRequired]
26+ [JsonPropertyName("one")]
27+ public Guid One { get; set; }
2828
2929 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
30- [JsonPropertyName("arrOne")]
31- public Guid[]? ArrOne { get; set; }
30+ [JsonPropertyName("optional")]
31+ public Guid? Optional { get; set; }
3232
3333 [JsonRequired]
3434 [JsonPropertyName("nullable")]
3535 public Guid? Nullable { get; set; }
3636
37- [JsonRequired]
38- [JsonPropertyName("one")]
39- public Guid One { get; set; }
37+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
38+ [JsonPropertyName("arrOne")]
39+ public Guid[]? ArrOne { get; set; }
4040
4141 [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
42- [JsonPropertyName("optional")]
43- public Guid? Optional { get; set; }
42+ [JsonPropertyName("arrNullable")]
43+ public Guid?[]? ArrNullable { get; set; }
4444
4545 [JsonRequired]
4646 [JsonPropertyName("unionWithEnum")]
Mschema-csharp/test/inputs/schema/vega-lite.schema/default/QuickType.cs+71 −71
@@ -693,6 +693,16 @@ namespace QuickType
693693 [JsonPropertyName("fill")]
694694 public string? Fill { get; set; }
695695
696+ /// <summary>
697+ /// The fill opacity (value between [0,1]).
698+ ///
699+ /// __Default value:__ `1`
700+ /// </summary>
701+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
702+ [JsonPropertyName("fillOpacity")]
703+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
704+ public double? FillOpacity { get; set; }
705+
696706 /// <summary>
697707 /// Whether the mark's color should be used as fill color instead of stroke color.
698708 ///
@@ -706,16 +716,6 @@ namespace QuickType
706716 [JsonPropertyName("filled")]
707717 public bool? Filled { get; set; }
708718
709- /// <summary>
710- /// The fill opacity (value between [0,1]).
711- ///
712- /// __Default value:__ `1`
713- /// </summary>
714- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
715- [JsonPropertyName("fillOpacity")]
716- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
717- public double? FillOpacity { get; set; }
718-
719719 /// <summary>
720720 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
721721 /// </summary>
@@ -1134,13 +1134,6 @@ namespace QuickType
11341134 [JsonPropertyName("tickRound")]
11351135 public bool? TickRound { get; set; }
11361136
1137- /// <summary>
1138- /// Boolean value that determines whether the axis should include ticks.
1139- /// </summary>
1140- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1141- [JsonPropertyName("ticks")]
1142- public bool? Ticks { get; set; }
1143-
11441137 /// <summary>
11451138 /// The size in pixels of axis ticks.
11461139 /// </summary>
@@ -1157,6 +1150,13 @@ namespace QuickType
11571150 [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
11581151 public double? TickWidth { get; set; }
11591152
1153+ /// <summary>
1154+ /// Boolean value that determines whether the axis should include ticks.
1155+ /// </summary>
1156+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1157+ [JsonPropertyName("ticks")]
1158+ public bool? Ticks { get; set; }
1159+
11601160 /// <summary>
11611161 /// Horizontal text alignment of axis titles.
11621162 /// </summary>
@@ -1471,13 +1471,6 @@ namespace QuickType
14711471 [JsonPropertyName("tickRound")]
14721472 public bool? TickRound { get; set; }
14731473
1474- /// <summary>
1475- /// Boolean value that determines whether the axis should include ticks.
1476- /// </summary>
1477- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1478- [JsonPropertyName("ticks")]
1479- public bool? Ticks { get; set; }
1480-
14811474 /// <summary>
14821475 /// The size in pixels of axis ticks.
14831476 /// </summary>
@@ -1494,6 +1487,13 @@ namespace QuickType
14941487 [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
14951488 public double? TickWidth { get; set; }
14961489
1490+ /// <summary>
1491+ /// Boolean value that determines whether the axis should include ticks.
1492+ /// </summary>
1493+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1494+ [JsonPropertyName("ticks")]
1495+ public bool? Ticks { get; set; }
1496+
14971497 /// <summary>
14981498 /// Horizontal text alignment of axis titles.
14991499 /// </summary>
@@ -1685,6 +1685,16 @@ namespace QuickType
16851685 [JsonPropertyName("fill")]
16861686 public string? Fill { get; set; }
16871687
1688+ /// <summary>
1689+ /// The fill opacity (value between [0,1]).
1690+ ///
1691+ /// __Default value:__ `1`
1692+ /// </summary>
1693+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1694+ [JsonPropertyName("fillOpacity")]
1695+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
1696+ public double? FillOpacity { get; set; }
1697+
16881698 /// <summary>
16891699 /// Whether the mark's color should be used as fill color instead of stroke color.
16901700 ///
@@ -1698,16 +1708,6 @@ namespace QuickType
16981708 [JsonPropertyName("filled")]
16991709 public bool? Filled { get; set; }
17001710
1701- /// <summary>
1702- /// The fill opacity (value between [0,1]).
1703- ///
1704- /// __Default value:__ `1`
1705- /// </summary>
1706- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1707- [JsonPropertyName("fillOpacity")]
1708- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
1709- public double? FillOpacity { get; set; }
1710-
17111711 /// <summary>
17121712 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
17131713 /// </summary>
@@ -3248,6 +3248,16 @@ namespace QuickType
32483248 [JsonPropertyName("fill")]
32493249 public string? Fill { get; set; }
32503250
3251+ /// <summary>
3252+ /// The fill opacity (value between [0,1]).
3253+ ///
3254+ /// __Default value:__ `1`
3255+ /// </summary>
3256+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3257+ [JsonPropertyName("fillOpacity")]
3258+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
3259+ public double? FillOpacity { get; set; }
3260+
32513261 /// <summary>
32523262 /// Whether the mark's color should be used as fill color instead of stroke color.
32533263 ///
@@ -3261,16 +3271,6 @@ namespace QuickType
32613271 [JsonPropertyName("filled")]
32623272 public bool? Filled { get; set; }
32633273
3264- /// <summary>
3265- /// The fill opacity (value between [0,1]).
3266- ///
3267- /// __Default value:__ `1`
3268- /// </summary>
3269- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3270- [JsonPropertyName("fillOpacity")]
3271- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
3272- public double? FillOpacity { get; set; }
3273-
32743274 /// <summary>
32753275 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
32763276 /// </summary>
@@ -3554,6 +3554,16 @@ namespace QuickType
35543554 [JsonPropertyName("fill")]
35553555 public string? Fill { get; set; }
35563556
3557+ /// <summary>
3558+ /// The fill opacity (value between [0,1]).
3559+ ///
3560+ /// __Default value:__ `1`
3561+ /// </summary>
3562+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3563+ [JsonPropertyName("fillOpacity")]
3564+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
3565+ public double? FillOpacity { get; set; }
3566+
35573567 /// <summary>
35583568 /// Whether the mark's color should be used as fill color instead of stroke color.
35593569 ///
@@ -3567,16 +3577,6 @@ namespace QuickType
35673577 [JsonPropertyName("filled")]
35683578 public bool? Filled { get; set; }
35693579
3570- /// <summary>
3571- /// The fill opacity (value between [0,1]).
3572- ///
3573- /// __Default value:__ `1`
3574- /// </summary>
3575- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3576- [JsonPropertyName("fillOpacity")]
3577- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
3578- public double? FillOpacity { get; set; }
3579-
35803580 /// <summary>
35813581 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
35823582 /// </summary>
@@ -6161,13 +6161,6 @@ namespace QuickType
61616161 [JsonPropertyName("tickCount")]
61626162 public double? TickCount { get; set; }
61636163
6164- /// <summary>
6165- /// Boolean value that determines whether the axis should include ticks.
6166- /// </summary>
6167- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
6168- [JsonPropertyName("ticks")]
6169- public bool? Ticks { get; set; }
6170-
61716164 /// <summary>
61726165 /// The size in pixels of axis ticks.
61736166 /// </summary>
@@ -6176,6 +6169,13 @@ namespace QuickType
61766169 [JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
61776170 public double? TickSize { get; set; }
61786171
6172+ /// <summary>
6173+ /// Boolean value that determines whether the axis should include ticks.
6174+ /// </summary>
6175+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
6176+ [JsonPropertyName("ticks")]
6177+ public bool? Ticks { get; set; }
6178+
61796179 /// <summary>
61806180 /// A title for the field. If `null`, the title will be removed.
61816181 ///
@@ -6855,6 +6855,16 @@ namespace QuickType
68556855 [JsonPropertyName("fill")]
68566856 public string? Fill { get; set; }
68576857
6858+ /// <summary>
6859+ /// The fill opacity (value between [0,1]).
6860+ ///
6861+ /// __Default value:__ `1`
6862+ /// </summary>
6863+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
6864+ [JsonPropertyName("fillOpacity")]
6865+ [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
6866+ public double? FillOpacity { get; set; }
6867+
68586868 /// <summary>
68596869 /// Whether the mark's color should be used as fill color instead of stroke color.
68606870 ///
@@ -6868,16 +6878,6 @@ namespace QuickType
68686878 [JsonPropertyName("filled")]
68696879 public bool? Filled { get; set; }
68706880
6871- /// <summary>
6872- /// The fill opacity (value between [0,1]).
6873- ///
6874- /// __Default value:__ `1`
6875- /// </summary>
6876- [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
6877- [JsonPropertyName("fillOpacity")]
6878- [JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
6879- public double? FillOpacity { get; set; }
6880-
68816881 /// <summary>
68826882 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
68836883 /// </summary>
Mschema-dart/test/inputs/schema/accessors.schema/default/TopLevel.dart+8 −8
@@ -9,30 +9,30 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final String barre;
12+ final dynamic unionization;
1313 final Enum enumerification;
1414 final String foo;
15- final dynamic unionization;
15+ final String barre;
1616
1717 TopLevel({
18- required this.barre,
18+ required this.unionization,
1919 required this.enumerification,
2020 required this.foo,
21- required this.unionization,
21+ required this.barre,
2222 });
2323
2424 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
25- barre: json["bar"],
25+ unionization: json["union"],
2626 enumerification: enumValues.map[json["enum"]]!,
2727 foo: json["foo"],
28- unionization: json["union"],
28+ barre: json["bar"],
2929 );
3030
3131 Map<String, dynamic> toJson() => {
32- "bar": barre,
32+ "union": unionization,
3333 "enum": enumValues.reverse[enumerification],
3434 "foo": foo,
35- "union": unionization,
35+ "bar": barre,
3636 };
3737 }
Mschema-dart/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.dart+4 −4
@@ -11,28 +11,28 @@ String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1111 class TopLevel {
1212 final double amount;
1313 final Frequency frequency;
14- final String? description;
1514 final Type type;
15+ final String? description;
1616
1717 TopLevel({
1818 required this.amount,
1919 required this.frequency,
20- this.description,
2120 required this.type,
21+ this.description,
2222 });
2323
2424 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
2525 amount: json["amount"]?.toDouble(),
2626 frequency: frequencyValues.map[json["frequency"]]!,
27- description: json["description"],
2827 type: typeValues.map[json["type"]]!,
28+ description: json["description"],
2929 );
3030
3131 Map<String, dynamic> toJson() => {
3232 "amount": amount,
3333 "frequency": frequencyValues.reverse[frequency],
34- "description": description,
3534 "type": typeValues.reverse[type],
35+ "description": description,
3636 };
3737 }
Mschema-dart/test/inputs/schema/boolean-subschema.schema/default/TopLevel.dart+4 −4
@@ -9,29 +9,29 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12+ final String foo;
1213 final dynamic disallowed;
1314 final List<dynamic> empty;
14- final String foo;
1515 final dynamic impossible;
1616
1717 TopLevel({
18+ required this.foo,
1819 this.disallowed,
1920 required this.empty,
20- required this.foo,
2121 this.impossible,
2222 });
2323
2424 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
25+ foo: json["foo"],
2526 disallowed: json["disallowed"],
2627 empty: List<dynamic>.from(json["empty"].map((x) => x)),
27- foo: json["foo"],
2828 impossible: json["impossible"],
2929 );
3030
3131 Map<String, dynamic> toJson() => {
32+ "foo": foo,
3233 "disallowed": disallowed,
3334 "empty": List<dynamic>.from(empty.map((x) => x)),
34- "foo": foo,
3535 "impossible": impossible,
3636 };
3737 }
Mschema-dart/test/inputs/schema/comment-injection.schema/default/TopLevel.dart+12 −12
@@ -23,15 +23,6 @@ String topLevelToJson(TopLevel data) => json.encode(data.toJson());
2323 ///}
2424 class TopLevel {
2525
26- ///Ends with a backslash \
27- final String? trailingBackslash;
28-
29- ///Ends with a quote "
30- final String? trailingQuote;
31-
32- ///Ends with a triple quote """
33- final String? trailingTripleQuote;
34-
3526 ///Property delimiters:
3627 ///*/
3728 ////*
@@ -45,25 +36,34 @@ class TopLevel {
4536 ///}
4637 ///}
4738 final String value;
39+
40+ ///Ends with a backslash \
41+ final String? trailingBackslash;
42+
43+ ///Ends with a quote "
44+ final String? trailingQuote;
45+
46+ ///Ends with a triple quote """
47+ final String? trailingTripleQuote;
4848
4949 TopLevel({
50+ required this.value,
5051 this.trailingBackslash,
5152 this.trailingQuote,
5253 this.trailingTripleQuote,
53- required this.value,
5454 });
5555
5656 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
57+ value: json["value"],
5758 trailingBackslash: json["trailingBackslash"],
5859 trailingQuote: json["trailingQuote"],
5960 trailingTripleQuote: json["trailingTripleQuote"],
60- value: json["value"],
6161 );
6262
6363 Map<String, dynamic> toJson() => {
64+ "value": value,
6465 "trailingBackslash": trailingBackslash,
6566 "trailingQuote": trailingQuote,
6667 "trailingTripleQuote": trailingTripleQuote,
67- "value": value,
6868 };
6969 }
Mschema-dart/test/inputs/schema/date-time-or-string.schema/default/TopLevel.dart+4 −4
@@ -9,22 +9,22 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final dynamic bar;
1312 final String foo;
13+ final dynamic bar;
1414
1515 TopLevel({
16- required this.bar,
1716 required this.foo,
17+ required this.bar,
1818 });
1919
2020 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
21- bar: json["bar"],
2221 foo: json["foo"],
22+ bar: json["bar"],
2323 );
2424
2525 Map<String, dynamic> toJson() => {
26- "bar": bar,
2726 "foo": foo,
27+ "bar": bar,
2828 };
2929 }
Mschema-dart/test/inputs/schema/date-time.schema/default/TopLevel.dart+8 −8
@@ -9,34 +9,34 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final List<dynamic> complexUnionArray;
1312 final DateTime date;
14- final DateTime dateTime;
1513 final String time;
14+ final DateTime dateTime;
1615 final List<String> unionArray;
16+ final List<dynamic> complexUnionArray;
1717
1818 TopLevel({
19- required this.complexUnionArray,
2019 required this.date,
21- required this.dateTime,
2220 required this.time,
21+ required this.dateTime,
2322 required this.unionArray,
23+ required this.complexUnionArray,
2424 });
2525
2626 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
27- complexUnionArray: List<dynamic>.from(json["complex-union-array"].map((x) => x)),
2827 date: DateTime.parse(json["date"]),
29- dateTime: DateTime.parse(json["date-time"]),
3028 time: json["time"],
29+ dateTime: DateTime.parse(json["date-time"]),
3130 unionArray: List<String>.from(json["union-array"].map((x) => x)),
31+ complexUnionArray: List<dynamic>.from(json["complex-union-array"].map((x) => x)),
3232 );
3333
3434 Map<String, dynamic> toJson() => {
35- "complex-union-array": List<dynamic>.from(complexUnionArray.map((x) => x)),
3635 "date": "${date.year.toString().padLeft(4, '0')}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}",
37- "date-time": dateTime.toIso8601String(),
3836 "time": time,
37+ "date-time": dateTime.toIso8601String(),
3938 "union-array": List<dynamic>.from(unionArray.map((x) => x)),
39+ "complex-union-array": List<dynamic>.from(complexUnionArray.map((x) => x)),
4040 };
4141 }
Mschema-dart/test/inputs/schema/description.schema/default/TopLevel.dart+11 −11
@@ -13,39 +13,39 @@ String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1313 ///Its description has two lines.
1414 class TopLevel {
1515
16- ///A pretty boolean
17- final bool? bar;
16+ ///Either a number or a string
17+ final dynamic union;
1818
1919 ///An enumeration
2020 final Enum topLevelEnum;
2121 final double? foo;
22- final dynamic objectOrString;
2322
24- ///Either a number or a string
25- final dynamic union;
23+ ///A pretty boolean
24+ final bool? bar;
25+ final dynamic objectOrString;
2626
2727 TopLevel({
28- this.bar,
28+ required this.union,
2929 required this.topLevelEnum,
3030 this.foo,
31+ this.bar,
3132 required this.objectOrString,
32- required this.union,
3333 });
3434
3535 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
36- bar: json["bar"],
36+ union: json["union"],
3737 topLevelEnum: enumValues.map[json["enum"]]!,
3838 foo: json["foo"]?.toDouble(),
39+ bar: json["bar"],
3940 objectOrString: json["object-or-string"],
40- union: json["union"],
4141 );
4242
4343 Map<String, dynamic> toJson() => {
44- "bar": bar,
44+ "union": union,
4545 "enum": enumValues.reverse[topLevelEnum],
4646 "foo": foo,
47+ "bar": bar,
4748 "object-or-string": objectOrString,
48- "union": union,
4949 };
5050 }
Mschema-dart/test/inputs/schema/direct-union.schema/default/TopLevel.dart+4 −4
@@ -25,21 +25,21 @@ class TopLevel {
2525 }
2626
2727 class Thing {
28- final dynamic optional;
2928 final dynamic required;
29+ final dynamic optional;
3030
3131 Thing({
32- this.optional,
3332 required this.required,
33+ this.optional,
3434 });
3535
3636 factory Thing.fromJson(Map<String, dynamic> json) => Thing(
37- optional: json["optional"],
3837 required: json["required"],
38+ optional: json["optional"],
3939 );
4040
4141 Map<String, dynamic> toJson() => {
42- "optional": optional,
4342 "required": required,
43+ "optional": optional,
4444 };
4545 }
Mschema-dart/test/inputs/schema/integer-type.schema/default/TopLevel.dart+20 −20
@@ -9,49 +9,49 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12+ final int smallPositive;
13+ final int smallNegative;
14+ final int i32Range;
1215 final int aboveI32Max;
1316 final int belowI32Min;
14- final int i32Range;
15- final int largeBounds;
16- final int onlyMaximum;
1717 final int onlyMinimum;
18- final int smallNegative;
19- final int smallPositive;
18+ final int onlyMaximum;
2019 final int unbounded;
20+ final int largeBounds;
2121
2222 TopLevel({
23+ required this.smallPositive,
24+ required this.smallNegative,
25+ required this.i32Range,
2326 required this.aboveI32Max,
2427 required this.belowI32Min,
25- required this.i32Range,
26- required this.largeBounds,
27- required this.onlyMaximum,
2828 required this.onlyMinimum,
29- required this.smallNegative,
30- required this.smallPositive,
29+ required this.onlyMaximum,
3130 required this.unbounded,
31+ required this.largeBounds,
3232 });
3333
3434 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
35+ smallPositive: json["small_positive"],
36+ smallNegative: json["small_negative"],
37+ i32Range: json["i32_range"],
3538 aboveI32Max: json["above_i32_max"],
3639 belowI32Min: json["below_i32_min"],
37- i32Range: json["i32_range"],
38- largeBounds: json["large_bounds"],
39- onlyMaximum: json["only_maximum"],
4040 onlyMinimum: json["only_minimum"],
41- smallNegative: json["small_negative"],
42- smallPositive: json["small_positive"],
41+ onlyMaximum: json["only_maximum"],
4342 unbounded: json["unbounded"],
43+ largeBounds: json["large_bounds"],
4444 );
4545
4646 Map<String, dynamic> toJson() => {
47+ "small_positive": smallPositive,
48+ "small_negative": smallNegative,
49+ "i32_range": i32Range,
4750 "above_i32_max": aboveI32Max,
4851 "below_i32_min": belowI32Min,
49- "i32_range": i32Range,
50- "large_bounds": largeBounds,
51- "only_maximum": onlyMaximum,
5252 "only_minimum": onlyMinimum,
53- "small_negative": smallNegative,
54- "small_positive": smallPositive,
53+ "only_maximum": onlyMaximum,
5554 "unbounded": unbounded,
55+ "large_bounds": largeBounds,
5656 };
5757 }
Mschema-dart/test/inputs/schema/light.schema/default/TopLevel.dart+4 −4
@@ -25,25 +25,25 @@ class TopLevel {
2525 }
2626
2727 class LightParams {
28- final String appId;
2928 final String outletId;
29+ final String appId;
3030 final String rgba;
3131
3232 LightParams({
33- required this.appId,
3433 required this.outletId,
34+ required this.appId,
3535 required this.rgba,
3636 });
3737
3838 factory LightParams.fromJson(Map<String, dynamic> json) => LightParams(
39- appId: json["app_id"],
4039 outletId: json["outlet_id"],
40+ appId: json["app_id"],
4141 rgba: json["rgba"],
4242 );
4343
4444 Map<String, dynamic> toJson() => {
45- "app_id": appId,
4645 "outlet_id": outletId,
46+ "app_id": appId,
4747 "rgba": rgba,
4848 };
4949 }
Mschema-dart/test/inputs/schema/min-max-items.schema/default/TopLevel.dart+4 −4
@@ -9,32 +9,32 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12+ final List<String> minOnly;
1213 final List<int> maxOnly;
1314 final List<double> minAndMax;
14- final List<String> minOnly;
1515 final List<String> plain;
1616 final List<dynamic> unionItems;
1717
1818 TopLevel({
19+ required this.minOnly,
1920 required this.maxOnly,
2021 required this.minAndMax,
21- required this.minOnly,
2222 required this.plain,
2323 required this.unionItems,
2424 });
2525
2626 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
27+ minOnly: List<String>.from(json["minOnly"].map((x) => x)),
2728 maxOnly: List<int>.from(json["maxOnly"].map((x) => x)),
2829 minAndMax: List<double>.from(json["minAndMax"].map((x) => x?.toDouble())),
29- minOnly: List<String>.from(json["minOnly"].map((x) => x)),
3030 plain: List<String>.from(json["plain"].map((x) => x)),
3131 unionItems: List<dynamic>.from(json["unionItems"].map((x) => x)),
3232 );
3333
3434 Map<String, dynamic> toJson() => {
35+ "minOnly": List<dynamic>.from(minOnly.map((x) => x)),
3536 "maxOnly": List<dynamic>.from(maxOnly.map((x) => x)),
3637 "minAndMax": List<dynamic>.from(minAndMax.map((x) => x)),
37- "minOnly": List<dynamic>.from(minOnly.map((x) => x)),
3838 "plain": List<dynamic>.from(plain.map((x) => x)),
3939 "unionItems": List<dynamic>.from(unionItems.map((x) => x)),
4040 };
Mschema-dart/test/inputs/schema/minmax-integer.schema/default/TopLevel.dart+16 −16
@@ -10,44 +10,44 @@ String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
1212 final int free;
13- final int intersection;
14- final int max;
1513 final int min;
14+ final int max;
1615 final int minmax;
17- final int minMaxIntersection;
18- final int minMaxUnion;
1916 final int union;
17+ final int minMaxUnion;
18+ final int intersection;
19+ final int minMaxIntersection;
2020
2121 TopLevel({
2222 required this.free,
23- required this.intersection,
24- required this.max,
2523 required this.min,
24+ required this.max,
2625 required this.minmax,
27- required this.minMaxIntersection,
28- required this.minMaxUnion,
2926 required this.union,
27+ required this.minMaxUnion,
28+ required this.intersection,
29+ required this.minMaxIntersection,
3030 });
3131
3232 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
3333 free: json["free"],
34- intersection: json["intersection"],
35- max: json["max"],
3634 min: json["min"],
35+ max: json["max"],
3736 minmax: json["minmax"],
38- minMaxIntersection: json["minMaxIntersection"],
39- minMaxUnion: json["minMaxUnion"],
4037 union: json["union"],
38+ minMaxUnion: json["minMaxUnion"],
39+ intersection: json["intersection"],
40+ minMaxIntersection: json["minMaxIntersection"],
4141 );
4242
4343 Map<String, dynamic> toJson() => {
4444 "free": free,
45- "intersection": intersection,
46- "max": max,
4745 "min": min,
46+ "max": max,
4847 "minmax": minmax,
49- "minMaxIntersection": minMaxIntersection,
50- "minMaxUnion": minMaxUnion,
5148 "union": union,
49+ "minMaxUnion": minMaxUnion,
50+ "intersection": intersection,
51+ "minMaxIntersection": minMaxIntersection,
5252 };
5353 }
Mschema-dart/test/inputs/schema/minmax.schema/default/TopLevel.dart+16 −16
@@ -10,44 +10,44 @@ String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
1212 final double free;
13- final double intersection;
14- final double max;
1513 final double min;
14+ final double max;
1615 final double minmax;
17- final double minMaxIntersection;
18- final double minMaxUnion;
1916 final double union;
17+ final double minMaxUnion;
18+ final double intersection;
19+ final double minMaxIntersection;
2020
2121 TopLevel({
2222 required this.free,
23- required this.intersection,
24- required this.max,
2523 required this.min,
24+ required this.max,
2625 required this.minmax,
27- required this.minMaxIntersection,
28- required this.minMaxUnion,
2926 required this.union,
27+ required this.minMaxUnion,
28+ required this.intersection,
29+ required this.minMaxIntersection,
3030 });
3131
3232 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
3333 free: json["free"]?.toDouble(),
34- intersection: json["intersection"]?.toDouble(),
35- max: json["max"]?.toDouble(),
3634 min: json["min"]?.toDouble(),
35+ max: json["max"]?.toDouble(),
3736 minmax: json["minmax"]?.toDouble(),
38- minMaxIntersection: json["minMaxIntersection"]?.toDouble(),
39- minMaxUnion: json["minMaxUnion"]?.toDouble(),
4037 union: json["union"]?.toDouble(),
38+ minMaxUnion: json["minMaxUnion"]?.toDouble(),
39+ intersection: json["intersection"]?.toDouble(),
40+ minMaxIntersection: json["minMaxIntersection"]?.toDouble(),
4141 );
4242
4343 Map<String, dynamic> toJson() => {
4444 "free": free,
45- "intersection": intersection,
46- "max": max,
4745 "min": min,
46+ "max": max,
4847 "minmax": minmax,
49- "minMaxIntersection": minMaxIntersection,
50- "minMaxUnion": minMaxUnion,
5148 "union": union,
49+ "minMaxUnion": minMaxUnion,
50+ "intersection": intersection,
51+ "minMaxIntersection": minMaxIntersection,
5252 };
5353 }
Mschema-dart/test/inputs/schema/minmaxlength.schema/default/TopLevel.dart+20 −20
@@ -9,45 +9,45 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final String intersection;
13- final dynamic inUnion;
14- final String maxlength;
1512 final String minlength;
16- final String minMaxIntersection;
13+ final String maxlength;
1714 final String minmaxlength;
18- final String minMaxUnion;
1915 final String union;
16+ final dynamic inUnion;
17+ final String minMaxUnion;
18+ final String intersection;
19+ final String minMaxIntersection;
2020
2121 TopLevel({
22- required this.intersection,
23- required this.inUnion,
24- required this.maxlength,
2522 required this.minlength,
26- required this.minMaxIntersection,
23+ required this.maxlength,
2724 required this.minmaxlength,
28- required this.minMaxUnion,
2925 required this.union,
26+ required this.inUnion,
27+ required this.minMaxUnion,
28+ required this.intersection,
29+ required this.minMaxIntersection,
3030 });
3131
3232 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
33- intersection: json["intersection"],
34- inUnion: json["inUnion"],
35- maxlength: json["maxlength"],
3633 minlength: json["minlength"],
37- minMaxIntersection: json["minMaxIntersection"],
34+ maxlength: json["maxlength"],
3835 minmaxlength: json["minmaxlength"],
39- minMaxUnion: json["minMaxUnion"],
4036 union: json["union"],
37+ inUnion: json["inUnion"],
38+ minMaxUnion: json["minMaxUnion"],
39+ intersection: json["intersection"],
40+ minMaxIntersection: json["minMaxIntersection"],
4141 );
4242
4343 Map<String, dynamic> toJson() => {
44- "intersection": intersection,
45- "inUnion": inUnion,
46- "maxlength": maxlength,
4744 "minlength": minlength,
48- "minMaxIntersection": minMaxIntersection,
45+ "maxlength": maxlength,
4946 "minmaxlength": minmaxlength,
50- "minMaxUnion": minMaxUnion,
5147 "union": union,
48+ "inUnion": inUnion,
49+ "minMaxUnion": minMaxUnion,
50+ "intersection": intersection,
51+ "minMaxIntersection": minMaxIntersection,
5252 };
5353 }
Mschema-dart/test/inputs/schema/non-standard-ref.schema/default/TopLevel.dart+4 −4
@@ -9,25 +9,25 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final int bar;
1312 final int foo;
13+ final int bar;
1414 final bool quux;
1515
1616 TopLevel({
17- required this.bar,
1817 required this.foo,
18+ required this.bar,
1919 required this.quux,
2020 });
2121
2222 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
23- bar: json["bar"],
2423 foo: json["foo"],
24+ bar: json["bar"],
2525 quux: json["quux"],
2626 );
2727
2828 Map<String, dynamic> toJson() => {
29- "bar": bar,
3029 "foo": foo,
30+ "bar": bar,
3131 "quux": quux,
3232 };
3333 }
Mschema-dart/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.dart+4 −4
@@ -9,22 +9,22 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final String? b;
1312 final Kind kind;
13+ final String? b;
1414
1515 TopLevel({
16- this.b,
1716 required this.kind,
17+ this.b,
1818 });
1919
2020 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
21- b: json["b"],
2221 kind: kindValues.map[json["kind"]]!,
22+ b: json["b"],
2323 );
2424
2525 Map<String, dynamic> toJson() => {
26- "b": b,
2726 "kind": kindValues.reverse[kind],
27+ "b": b,
2828 };
2929 }
Mschema-dart/test/inputs/schema/optional-any.schema/default/TopLevel.dart+4 −4
@@ -9,21 +9,21 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final bool bar;
1312 final dynamic foo;
13+ final bool bar;
1414
1515 TopLevel({
16- required this.bar,
1716 this.foo,
17+ required this.bar,
1818 });
1919
2020 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
21- bar: json["bar"],
2221 foo: json["foo"],
22+ bar: json["bar"],
2323 );
2424
2525 Map<String, dynamic> toJson() => {
26- "bar": bar,
2726 "foo": foo,
27+ "bar": bar,
2828 };
2929 }
Mschema-dart/test/inputs/schema/optional-const-ref.schema/default/TopLevel.dart+12 −12
@@ -10,41 +10,41 @@ String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
1212 final List<Coordinate>? coordinates;
13- final int? count;
14- final String? label;
1513 final List<Coordinate> requiredCoordinates;
14+ final int? count;
1615 final int requiredCount;
17- final String requiredLabel;
1816 final double? weight;
17+ final String? label;
18+ final String requiredLabel;
1919
2020 TopLevel({
2121 this.coordinates,
22- this.count,
23- this.label,
2422 required this.requiredCoordinates,
23+ this.count,
2524 required this.requiredCount,
26- required this.requiredLabel,
2725 this.weight,
26+ this.label,
27+ required this.requiredLabel,
2828 });
2929
3030 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
3131 coordinates: json["coordinates"] == null ? null : List<Coordinate>.from(json["coordinates"]!.map((x) => Coordinate.fromJson(x))),
32- count: json["count"],
33- label: json["label"],
3432 requiredCoordinates: List<Coordinate>.from(json["requiredCoordinates"].map((x) => Coordinate.fromJson(x))),
33+ count: json["count"],
3534 requiredCount: json["requiredCount"],
36- requiredLabel: json["requiredLabel"],
3735 weight: json["weight"]?.toDouble(),
36+ label: json["label"],
37+ requiredLabel: json["requiredLabel"],
3838 );
3939
4040 Map<String, dynamic> toJson() => {
4141 "coordinates": coordinates == null ? null : List<dynamic>.from(coordinates!.map((x) => x.toJson())),
42- "count": count,
43- "label": label,
4442 "requiredCoordinates": List<dynamic>.from(requiredCoordinates.map((x) => x.toJson())),
43+ "count": count,
4544 "requiredCount": requiredCount,
46- "requiredLabel": requiredLabel,
4745 "weight": weight,
46+ "label": label,
47+ "requiredLabel": requiredLabel,
4848 };
4949 }
Mschema-dart/test/inputs/schema/optional-constraints.schema/default/TopLevel.dart+12 −12
@@ -9,33 +9,33 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final double? optDouble;
12+ final int reqZeroMin;
1313 final int? optInt;
14- final String? optPattern;
14+ final double? optDouble;
1515 final String? optString;
16- final int reqZeroMin;
16+ final String? optPattern;
1717
1818 TopLevel({
19- this.optDouble,
19+ required this.reqZeroMin,
2020 this.optInt,
21- this.optPattern,
21+ this.optDouble,
2222 this.optString,
23- required this.reqZeroMin,
23+ this.optPattern,
2424 });
2525
2626 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
27- optDouble: json["optDouble"]?.toDouble(),
27+ reqZeroMin: json["reqZeroMin"],
2828 optInt: json["optInt"],
29- optPattern: json["optPattern"],
29+ optDouble: json["optDouble"]?.toDouble(),
3030 optString: json["optString"],
31- reqZeroMin: json["reqZeroMin"],
31+ optPattern: json["optPattern"],
3232 );
3333
3434 Map<String, dynamic> toJson() => {
35- "optDouble": optDouble,
35+ "reqZeroMin": reqZeroMin,
3636 "optInt": optInt,
37- "optPattern": optPattern,
37+ "optDouble": optDouble,
3838 "optString": optString,
39- "reqZeroMin": reqZeroMin,
39+ "optPattern": optPattern,
4040 };
4141 }
Mschema-dart/test/inputs/schema/optional-date-time.schema/default/TopLevel.dart+16 −16
@@ -9,37 +9,37 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final DateTime? optionalDate;
13- final DateTime? optionalDateTime;
14- final String? optionalTime;
1512 final DateTime requiredDate;
16- final DateTime requiredDateTime;
1713 final String requiredTime;
14+ final DateTime requiredDateTime;
15+ final DateTime? optionalDate;
16+ final String? optionalTime;
17+ final DateTime? optionalDateTime;
1818
1919 TopLevel({
20- this.optionalDate,
21- this.optionalDateTime,
22- this.optionalTime,
2320 required this.requiredDate,
24- required this.requiredDateTime,
2521 required this.requiredTime,
22+ required this.requiredDateTime,
23+ this.optionalDate,
24+ this.optionalTime,
25+ this.optionalDateTime,
2626 });
2727
2828 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
29- optionalDate: json["optional-date"] == null ? null : DateTime.parse(json["optional-date"]),
30- optionalDateTime: json["optional-date-time"] == null ? null : DateTime.parse(json["optional-date-time"]),
31- optionalTime: json["optional-time"],
3229 requiredDate: DateTime.parse(json["required-date"]),
33- requiredDateTime: DateTime.parse(json["required-date-time"]),
3430 requiredTime: json["required-time"],
31+ requiredDateTime: DateTime.parse(json["required-date-time"]),
32+ optionalDate: json["optional-date"] == null ? null : DateTime.parse(json["optional-date"]),
33+ optionalTime: json["optional-time"],
34+ optionalDateTime: json["optional-date-time"] == null ? null : DateTime.parse(json["optional-date-time"]),
3535 );
3636
3737 Map<String, dynamic> toJson() => {
38- "optional-date": optionalDate == null ? null : "${optionalDate!.year.toString().padLeft(4, '0')}-${optionalDate!.month.toString().padLeft(2, '0')}-${optionalDate!.day.toString().padLeft(2, '0')}",
39- "optional-date-time": optionalDateTime?.toIso8601String(),
40- "optional-time": optionalTime,
4138 "required-date": "${requiredDate.year.toString().padLeft(4, '0')}-${requiredDate.month.toString().padLeft(2, '0')}-${requiredDate.day.toString().padLeft(2, '0')}",
42- "required-date-time": requiredDateTime.toIso8601String(),
4339 "required-time": requiredTime,
40+ "required-date-time": requiredDateTime.toIso8601String(),
41+ "optional-date": optionalDate == null ? null : "${optionalDate!.year.toString().padLeft(4, '0')}-${optionalDate!.month.toString().padLeft(2, '0')}-${optionalDate!.day.toString().padLeft(2, '0')}",
42+ "optional-time": optionalTime,
43+ "optional-date-time": optionalDateTime?.toIso8601String(),
4444 };
4545 }
Mschema-dart/test/inputs/schema/prefix-items.schema/default/TopLevel.dart+4 −4
@@ -9,21 +9,21 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final List<dynamic> open;
1312 final List<dynamic> tuple;
13+ final List<dynamic> open;
1414
1515 TopLevel({
16- required this.open,
1716 required this.tuple,
17+ required this.open,
1818 });
1919
2020 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
21- open: List<dynamic>.from(json["open"].map((x) => x)),
2221 tuple: List<dynamic>.from(json["tuple"].map((x) => x)),
22+ open: List<dynamic>.from(json["open"].map((x) => x)),
2323 );
2424
2525 Map<String, dynamic> toJson() => {
26- "open": List<dynamic>.from(open.map((x) => x)),
2726 "tuple": List<dynamic>.from(tuple.map((x) => x)),
27+ "open": List<dynamic>.from(open.map((x) => x)),
2828 };
2929 }
Aschema-dart/test/inputs/schema/property-order.schema/default/TopLevel.dart+69 −0
@@ -0,0 +1,69 @@
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 zebra;
13+ final double mango;
14+ final bool apple;
15+ final String delta;
16+ final int banana;
17+ final Ordered ordered;
18+
19+ TopLevel({
20+ required this.zebra,
21+ required this.mango,
22+ required this.apple,
23+ required this.delta,
24+ required this.banana,
25+ required this.ordered,
26+ });
27+
28+ factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
29+ zebra: json["zebra"],
30+ mango: json["mango"]?.toDouble(),
31+ apple: json["apple"],
32+ delta: json["delta"],
33+ banana: json["banana"],
34+ ordered: Ordered.fromJson(json["ordered"]),
35+ );
36+
37+ Map<String, dynamic> toJson() => {
38+ "zebra": zebra,
39+ "mango": mango,
40+ "apple": apple,
41+ "delta": delta,
42+ "banana": banana,
43+ "ordered": ordered.toJson(),
44+ };
45+}
46+
47+class Ordered {
48+ final double mango;
49+ final String zebra;
50+ final bool apple;
51+
52+ Ordered({
53+ required this.mango,
54+ required this.zebra,
55+ required this.apple,
56+ });
57+
58+ factory Ordered.fromJson(Map<String, dynamic> json) => Ordered(
59+ mango: json["mango"]?.toDouble(),
60+ zebra: json["zebra"],
61+ apple: json["apple"],
62+ );
63+
64+ Map<String, dynamic> toJson() => {
65+ "mango": mango,
66+ "zebra": zebra,
67+ "apple": apple,
68+ };
69+}
Mschema-dart/test/inputs/schema/renaming-bug.schema/default/TopLevel.dart+32 −32
@@ -34,48 +34,48 @@ class TopLevel {
3434
3535 class Fruit {
3636 final bool? apple;
37- final List<Berry>? berries;
3837 final bool? orange;
38+ final List<Berry>? berries;
3939
4040 Fruit({
4141 this.apple,
42- this.berries,
4342 this.orange,
43+ this.berries,
4444 });
4545
4646 factory Fruit.fromJson(Map<String, dynamic> json) => Fruit(
4747 apple: json["apple"],
48- berries: json["berries"] == null ? null : List<Berry>.from(json["berries"]!.map((x) => Berry.fromJson(x))),
4948 orange: json["orange"],
49+ berries: json["berries"] == null ? null : List<Berry>.from(json["berries"]!.map((x) => Berry.fromJson(x))),
5050 );
5151
5252 Map<String, dynamic> toJson() => {
5353 "apple": apple,
54- "berries": berries == null ? null : List<dynamic>.from(berries!.map((x) => x.toJson())),
5554 "orange": orange,
55+ "berries": berries == null ? null : List<dynamic>.from(berries!.map((x) => x.toJson())),
5656 };
5757 }
5858
5959 class Berry {
60- final Color? color;
6160 final String? name;
61+ final Color? color;
6262 final List<Shape>? shapes;
6363
6464 Berry({
65- this.color,
6665 this.name,
66+ this.color,
6767 this.shapes,
6868 });
6969
7070 factory Berry.fromJson(Map<String, dynamic> json) => Berry(
71- color: json["color"] == null ? null : Color.fromJson(json["color"]),
7271 name: json["name"],
72+ color: json["color"] == null ? null : Color.fromJson(json["color"]),
7373 shapes: json["shapes"] == null ? null : List<Shape>.from(json["shapes"]!.map((x) => Shape.fromJson(x))),
7474 );
7575
7676 Map<String, dynamic> toJson() => {
77- "color": color?.toJson(),
7877 "name": name,
78+ "color": color?.toJson(),
7979 "shapes": shapes == null ? null : List<dynamic>.from(shapes!.map((x) => x.toJson())),
8080 };
8181 }
@@ -97,22 +97,22 @@ class Color {
9797 }
9898
9999 class Shape {
100- final Geometry? geometry;
101100 final History? history;
101+ final Geometry? geometry;
102102
103103 Shape({
104- this.geometry,
105104 this.history,
105+ this.geometry,
106106 });
107107
108108 factory Shape.fromJson(Map<String, dynamic> json) => Shape(
109- geometry: json["geometry"] == null ? null : Geometry.fromJson(json["geometry"]),
110109 history: json["history"] == null ? null : History.fromJson(json["history"]),
110+ geometry: json["geometry"] == null ? null : Geometry.fromJson(json["geometry"]),
111111 );
112112
113113 Map<String, dynamic> toJson() => {
114- "geometry": geometry?.toJson(),
115114 "history": history?.toJson(),
115+ "geometry": geometry?.toJson(),
116116 };
117117 }
118118
@@ -169,26 +169,26 @@ class RectShape {
169169 }
170170
171171 class Part {
172- final String? depth;
173172 final String? length;
174173 final String? width;
174+ final String? depth;
175175
176176 Part({
177- this.depth,
178177 this.length,
179178 this.width,
179+ this.depth,
180180 });
181181
182182 factory Part.fromJson(Map<String, dynamic> json) => Part(
183- depth: json["depth"],
184183 length: json["length"],
185184 width: json["width"],
185+ depth: json["depth"],
186186 );
187187
188188 Map<String, dynamic> toJson() => {
189- "depth": depth,
190189 "length": length,
191190 "width": width,
191+ "depth": depth,
192192 };
193193 }
194194
@@ -209,38 +209,38 @@ class History {
209209 }
210210
211211 class Vehicle {
212- final String? brand;
213212 final String? id;
214- final Speed? speed;
215- final bool? subModule;
216213 final VehicleType? type;
214+ final Speed? speed;
217215 final String? year;
216+ final String? brand;
217+ final bool? subModule;
218218
219219 Vehicle({
220- this.brand,
221220 this.id,
222- this.speed,
223- this.subModule,
224221 this.type,
222+ this.speed,
225223 this.year,
224+ this.brand,
225+ this.subModule,
226226 });
227227
228228 factory Vehicle.fromJson(Map<String, dynamic> json) => Vehicle(
229- brand: json["brand"],
230229 id: json["id"],
231- speed: json["speed"] == null ? null : Speed.fromJson(json["speed"]),
232- subModule: json["subModule"],
233230 type: json["type"] == null ? null : VehicleType.fromJson(json["type"]),
231+ speed: json["speed"] == null ? null : Speed.fromJson(json["speed"]),
234232 year: json["year"],
233+ brand: json["brand"],
234+ subModule: json["subModule"],
235235 );
236236
237237 Map<String, dynamic> toJson() => {
238- "brand": brand,
239238 "id": id,
240- "speed": speed?.toJson(),
241- "subModule": subModule,
242239 "type": type?.toJson(),
240+ "speed": speed?.toJson(),
243241 "year": year,
242+ "brand": brand,
243+ "subModule": subModule,
244244 };
245245 }
246246
@@ -261,22 +261,22 @@ class Speed {
261261 }
262262
263263 class Limit {
264- final double? maximum;
265264 final double? minimum;
265+ final double? maximum;
266266
267267 Limit({
268- this.maximum,
269268 this.minimum,
269+ this.maximum,
270270 });
271271
272272 factory Limit.fromJson(Map<String, dynamic> json) => Limit(
273- maximum: json["maximum"]?.toDouble(),
274273 minimum: json["minimum"]?.toDouble(),
274+ maximum: json["maximum"]?.toDouble(),
275275 );
276276
277277 Map<String, dynamic> toJson() => {
278- "maximum": maximum,
279278 "minimum": minimum,
279+ "maximum": maximum,
280280 };
281281 }
Mschema-dart/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.dart+8 −8
@@ -9,41 +9,41 @@ TopLevel topLevelFromJson(String str) => TopLevel.fromJson(json.decode(str));
99 String topLevelToJson(TopLevel data) => json.encode(data.toJson());
1010
1111 class TopLevel {
12- final dynamic next;
1312 final String value;
13+ final dynamic next;
1414
1515 TopLevel({
16- this.next,
1716 required this.value,
17+ this.next,
1818 });
1919
2020 factory TopLevel.fromJson(Map<String, dynamic> json) => TopLevel(
21- next: json["next"],
2221 value: json["value"],
22+ next: json["next"],
2323 );
2424
2525 Map<String, dynamic> toJson() => {
26- "next": next,
2726 "value": value,
27+ "next": next,
2828 };
2929 }
3030
3131 class Node {
32- final dynamic next;
3332 final String value;
33+ final dynamic next;
3434
3535 Node({
36- this.next,
3736 required this.value,
37+ this.next,
3838 });
3939
4040 factory Node.fromJson(Map<String, dynamic> json) => Node(
41- next: json["next"],
4241 value: json["value"],
42+ next: json["next"],
4343 );
4444
4545 Map<String, dynamic> toJson() => {
46- "next": next,
4746 "value": value,
47+ "next": next,
4848 };
4949 }
Mschema-dart/test/inputs/schema/vega-lite.schema/default/TopLevel.dart+58 −58
@@ -646,6 +646,11 @@ class MarkConfig {
646646 ///__Default value:__ (None)
647647 final String? fill;
648648
649+ ///The fill opacity (value between [0,1]).
650+ ///
651+ ///__Default value:__ `1`
652+ final double? fillOpacity;
653+
649654 ///Whether the mark's color should be used as fill color instead of stroke color.
650655 ///
651656 ///__Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -655,11 +660,6 @@ class MarkConfig {
655660 ///__Note:__ This property cannot be used in a [style config](mark.html#style-config).
656661 final bool? filled;
657662
658- ///The fill opacity (value between [0,1]).
659- ///
660- ///__Default value:__ `1`
661- final double? fillOpacity;
662-
663663 ///The typeface to set the text in (e.g., `"Helvetica Neue"`).
664664 final String? font;
665665
@@ -773,8 +773,8 @@ class MarkConfig {
773773 this.dx,
774774 this.dy,
775775 this.fill,
776- this.filled,
777776 this.fillOpacity,
777+ this.filled,
778778 this.font,
779779 this.fontSize,
780780 this.fontStyle,
@@ -806,8 +806,8 @@ class MarkConfig {
806806 dx: json["dx"]?.toDouble(),
807807 dy: json["dy"]?.toDouble(),
808808 fill: json["fill"],
809- filled: json["filled"],
810809 fillOpacity: json["fillOpacity"]?.toDouble(),
810+ filled: json["filled"],
811811 font: json["font"],
812812 fontSize: json["fontSize"]?.toDouble(),
813813 fontStyle: fontStyleValues.map[json["fontStyle"]],
@@ -839,8 +839,8 @@ class MarkConfig {
839839 "dx": dx,
840840 "dy": dy,
841841 "fill": fill,
842- "filled": filled,
843842 "fillOpacity": fillOpacity,
843+ "filled": filled,
844844 "font": font,
845845 "fontSize": fontSize,
846846 "fontStyle": fontStyleValues.reverse[fontStyle],
@@ -1195,15 +1195,15 @@ class AxisConfig {
11951195 ///Boolean flag indicating if pixel position values should be rounded to the nearest integer.
11961196 final bool? tickRound;
11971197
1198- ///Boolean value that determines whether the axis should include ticks.
1199- final bool? ticks;
1200-
12011198 ///The size in pixels of axis ticks.
12021199 final double? tickSize;
12031200
12041201 ///The width, in pixels, of ticks.
12051202 final double? tickWidth;
12061203
1204+ ///Boolean value that determines whether the axis should include ticks.
1205+ final bool? ticks;
1206+
12071207 ///Horizontal text alignment of axis titles.
12081208 final String? titleAlign;
12091209
@@ -1266,9 +1266,9 @@ class AxisConfig {
12661266 this.shortTimeLabels,
12671267 this.tickColor,
12681268 this.tickRound,
1269- this.ticks,
12701269 this.tickSize,
12711270 this.tickWidth,
1271+ this.ticks,
12721272 this.titleAlign,
12731273 this.titleAngle,
12741274 this.titleBaseline,
@@ -1308,9 +1308,9 @@ class AxisConfig {
13081308 shortTimeLabels: json["shortTimeLabels"],
13091309 tickColor: json["tickColor"],
13101310 tickRound: json["tickRound"],
1311- ticks: json["ticks"],
13121311 tickSize: json["tickSize"]?.toDouble(),
13131312 tickWidth: json["tickWidth"]?.toDouble(),
1313+ ticks: json["ticks"],
13141314 titleAlign: json["titleAlign"],
13151315 titleAngle: json["titleAngle"]?.toDouble(),
13161316 titleBaseline: json["titleBaseline"],
@@ -1350,9 +1350,9 @@ class AxisConfig {
13501350 "shortTimeLabels": shortTimeLabels,
13511351 "tickColor": tickColor,
13521352 "tickRound": tickRound,
1353- "ticks": ticks,
13541353 "tickSize": tickSize,
13551354 "tickWidth": tickWidth,
1355+ "ticks": ticks,
13561356 "titleAlign": titleAlign,
13571357 "titleAngle": titleAngle,
13581358 "titleBaseline": titleBaseline,
@@ -1508,15 +1508,15 @@ class VgAxisConfig {
15081508 ///Boolean flag indicating if pixel position values should be rounded to the nearest integer.
15091509 final bool? tickRound;
15101510
1511- ///Boolean value that determines whether the axis should include ticks.
1512- final bool? ticks;
1513-
15141511 ///The size in pixels of axis ticks.
15151512 final double? tickSize;
15161513
15171514 ///The width, in pixels, of ticks.
15181515 final double? tickWidth;
15191516
1517+ ///Boolean value that determines whether the axis should include ticks.
1518+ final bool? ticks;
1519+
15201520 ///Horizontal text alignment of axis titles.
15211521 final String? titleAlign;
15221522
@@ -1578,9 +1578,9 @@ class VgAxisConfig {
15781578 this.minExtent,
15791579 this.tickColor,
15801580 this.tickRound,
1581- this.ticks,
15821581 this.tickSize,
15831582 this.tickWidth,
1583+ this.ticks,
15841584 this.titleAlign,
15851585 this.titleAngle,
15861586 this.titleBaseline,
@@ -1619,9 +1619,9 @@ class VgAxisConfig {
16191619 minExtent: json["minExtent"]?.toDouble(),
16201620 tickColor: json["tickColor"],
16211621 tickRound: json["tickRound"],
1622- ticks: json["ticks"],
16231622 tickSize: json["tickSize"]?.toDouble(),
16241623 tickWidth: json["tickWidth"]?.toDouble(),
1624+ ticks: json["ticks"],
16251625 titleAlign: json["titleAlign"],
16261626 titleAngle: json["titleAngle"]?.toDouble(),
16271627 titleBaseline: json["titleBaseline"],
@@ -1660,9 +1660,9 @@ class VgAxisConfig {
16601660 "minExtent": minExtent,
16611661 "tickColor": tickColor,
16621662 "tickRound": tickRound,
1663- "ticks": ticks,
16641663 "tickSize": tickSize,
16651664 "tickWidth": tickWidth,
1665+ "ticks": ticks,
16661666 "titleAlign": titleAlign,
16671667 "titleAngle": titleAngle,
16681668 "titleBaseline": titleBaseline,
@@ -1733,6 +1733,11 @@ class BarConfig {
17331733 ///__Default value:__ (None)
17341734 final String? fill;
17351735
1736+ ///The fill opacity (value between [0,1]).
1737+ ///
1738+ ///__Default value:__ `1`
1739+ final double? fillOpacity;
1740+
17361741 ///Whether the mark's color should be used as fill color instead of stroke color.
17371742 ///
17381743 ///__Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -1742,11 +1747,6 @@ class BarConfig {
17421747 ///__Note:__ This property cannot be used in a [style config](mark.html#style-config).
17431748 final bool? filled;
17441749
1745- ///The fill opacity (value between [0,1]).
1746- ///
1747- ///__Default value:__ `1`
1748- final double? fillOpacity;
1749-
17501750 ///The typeface to set the text in (e.g., `"Helvetica Neue"`).
17511751 final String? font;
17521752
@@ -1863,8 +1863,8 @@ class BarConfig {
18631863 this.dx,
18641864 this.dy,
18651865 this.fill,
1866- this.filled,
18671866 this.fillOpacity,
1867+ this.filled,
18681868 this.font,
18691869 this.fontSize,
18701870 this.fontStyle,
@@ -1899,8 +1899,8 @@ class BarConfig {
18991899 dx: json["dx"]?.toDouble(),
19001900 dy: json["dy"]?.toDouble(),
19011901 fill: json["fill"],
1902- filled: json["filled"],
19031902 fillOpacity: json["fillOpacity"]?.toDouble(),
1903+ filled: json["filled"],
19041904 font: json["font"],
19051905 fontSize: json["fontSize"]?.toDouble(),
19061906 fontStyle: fontStyleValues.map[json["fontStyle"]],
@@ -1935,8 +1935,8 @@ class BarConfig {
19351935 "dx": dx,
19361936 "dy": dy,
19371937 "fill": fill,
1938- "filled": filled,
19391938 "fillOpacity": fillOpacity,
1939+ "filled": filled,
19401940 "font": font,
19411941 "fontSize": fontSize,
19421942 "fontStyle": fontStyleValues.reverse[fontStyle],
@@ -3410,6 +3410,11 @@ class TextConfig {
34103410 ///__Default value:__ (None)
34113411 final String? fill;
34123412
3413+ ///The fill opacity (value between [0,1]).
3414+ ///
3415+ ///__Default value:__ `1`
3416+ final double? fillOpacity;
3417+
34133418 ///Whether the mark's color should be used as fill color instead of stroke color.
34143419 ///
34153420 ///__Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -3419,11 +3424,6 @@ class TextConfig {
34193424 ///__Note:__ This property cannot be used in a [style config](mark.html#style-config).
34203425 final bool? filled;
34213426
3422- ///The fill opacity (value between [0,1]).
3423- ///
3424- ///__Default value:__ `1`
3425- final double? fillOpacity;
3426-
34273427 ///The typeface to set the text in (e.g., `"Helvetica Neue"`).
34283428 final String? font;
34293429
@@ -3540,8 +3540,8 @@ class TextConfig {
35403540 this.dx,
35413541 this.dy,
35423542 this.fill,
3543- this.filled,
35443543 this.fillOpacity,
3544+ this.filled,
35453545 this.font,
35463546 this.fontSize,
35473547 this.fontStyle,
@@ -3574,8 +3574,8 @@ class TextConfig {
35743574 dx: json["dx"]?.toDouble(),
35753575 dy: json["dy"]?.toDouble(),
35763576 fill: json["fill"],
3577- filled: json["filled"],
35783577 fillOpacity: json["fillOpacity"]?.toDouble(),
3578+ filled: json["filled"],
35793579 font: json["font"],
35803580 fontSize: json["fontSize"]?.toDouble(),
35813581 fontStyle: fontStyleValues.map[json["fontStyle"]],
@@ -3608,8 +3608,8 @@ class TextConfig {
36083608 "dx": dx,
36093609 "dy": dy,
36103610 "fill": fill,
3611- "filled": filled,
36123611 "fillOpacity": fillOpacity,
3612+ "filled": filled,
36133613 "font": font,
36143614 "fontSize": fontSize,
36153615 "fontStyle": fontStyleValues.reverse[fontStyle],
@@ -3679,6 +3679,11 @@ class TickConfig {
36793679 ///__Default value:__ (None)
36803680 final String? fill;
36813681
3682+ ///The fill opacity (value between [0,1]).
3683+ ///
3684+ ///__Default value:__ `1`
3685+ final double? fillOpacity;
3686+
36823687 ///Whether the mark's color should be used as fill color instead of stroke color.
36833688 ///
36843689 ///__Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -3688,11 +3693,6 @@ class TickConfig {
36883693 ///__Note:__ This property cannot be used in a [style config](mark.html#style-config).
36893694 final bool? filled;
36903695
3691- ///The fill opacity (value between [0,1]).
3692- ///
3693- ///__Default value:__ `1`
3694- final double? fillOpacity;
3695-
36963696 ///The typeface to set the text in (e.g., `"Helvetica Neue"`).
36973697 final String? font;
36983698
@@ -3812,8 +3812,8 @@ class TickConfig {
38123812 this.dx,
38133813 this.dy,
38143814 this.fill,
3815- this.filled,
38163815 this.fillOpacity,
3816+ this.filled,
38173817 this.font,
38183818 this.fontSize,
38193819 this.fontStyle,
@@ -3847,8 +3847,8 @@ class TickConfig {
38473847 dx: json["dx"]?.toDouble(),
38483848 dy: json["dy"]?.toDouble(),
38493849 fill: json["fill"],
3850- filled: json["filled"],
38513850 fillOpacity: json["fillOpacity"]?.toDouble(),
3851+ filled: json["filled"],
38523852 font: json["font"],
38533853 fontSize: json["fontSize"]?.toDouble(),
38543854 fontStyle: fontStyleValues.map[json["fontStyle"]],
@@ -3882,8 +3882,8 @@ class TickConfig {
38823882 "dx": dx,
38833883 "dy": dy,
38843884 "fill": fill,
3885- "filled": filled,
38863885 "fillOpacity": fillOpacity,
3886+ "filled": filled,
38873887 "font": font,
38883888 "fontSize": fontSize,
38893889 "fontStyle": fontStyleValues.reverse[fontStyle],
@@ -6684,12 +6684,12 @@ class Axis {
66846684 ///underlying scale's range.
66856685 final double? tickCount;
66866686
6687- ///Boolean value that determines whether the axis should include ticks.
6688- final bool? ticks;
6689-
66906687 ///The size in pixels of axis ticks.
66916688 final double? tickSize;
66926689
6690+ ///Boolean value that determines whether the axis should include ticks.
6691+ final bool? ticks;
6692+
66936693 ///A title for the field. If `null`, the title will be removed.
66946694 ///
66956695 ///__Default value:__ derived from the field's name and transformation function
@@ -6738,8 +6738,8 @@ class Axis {
67386738 this.orient,
67396739 this.position,
67406740 this.tickCount,
6741- this.ticks,
67426741 this.tickSize,
6742+ this.ticks,
67436743 this.title,
67446744 this.titleMaxLength,
67456745 this.titlePadding,
@@ -6763,8 +6763,8 @@ class Axis {
67636763 orient: titleOrientValues.map[json["orient"]],
67646764 position: json["position"]?.toDouble(),
67656765 tickCount: json["tickCount"]?.toDouble(),
6766- ticks: json["ticks"],
67676766 tickSize: json["tickSize"]?.toDouble(),
6767+ ticks: json["ticks"],
67686768 title: json["title"],
67696769 titleMaxLength: json["titleMaxLength"]?.toDouble(),
67706770 titlePadding: json["titlePadding"]?.toDouble(),
@@ -6788,8 +6788,8 @@ class Axis {
67886788 "orient": titleOrientValues.reverse[orient],
67896789 "position": position,
67906790 "tickCount": tickCount,
6791- "ticks": ticks,
67926791 "tickSize": tickSize,
6792+ "ticks": ticks,
67936793 "title": title,
67946794 "titleMaxLength": titleMaxLength,
67956795 "titlePadding": titlePadding,
@@ -7375,6 +7375,11 @@ class MarkDef {
73757375 ///__Default value:__ (None)
73767376 final String? fill;
73777377
7378+ ///The fill opacity (value between [0,1]).
7379+ ///
7380+ ///__Default value:__ `1`
7381+ final double? fillOpacity;
7382+
73787383 ///Whether the mark's color should be used as fill color instead of stroke color.
73797384 ///
73807385 ///__Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -7384,11 +7389,6 @@ class MarkDef {
73847389 ///__Note:__ This property cannot be used in a [style config](mark.html#style-config).
73857390 final bool? filled;
73867391
7387- ///The fill opacity (value between [0,1]).
7388- ///
7389- ///__Default value:__ `1`
7390- final double? fillOpacity;
7391-
73927392 ///The typeface to set the text in (e.g., `"Helvetica Neue"`).
73937393 final String? font;
73947394
@@ -7521,8 +7521,8 @@ class MarkDef {
75217521 this.dx,
75227522 this.dy,
75237523 this.fill,
7524- this.filled,
75257524 this.fillOpacity,
7525+ this.filled,
75267526 this.font,
75277527 this.fontSize,
75287528 this.fontStyle,
@@ -7557,8 +7557,8 @@ class MarkDef {
75577557 dx: json["dx"]?.toDouble(),
75587558 dy: json["dy"]?.toDouble(),
75597559 fill: json["fill"],
7560- filled: json["filled"],
75617560 fillOpacity: json["fillOpacity"]?.toDouble(),
7561+ filled: json["filled"],
75627562 font: json["font"],
75637563 fontSize: json["fontSize"]?.toDouble(),
75647564 fontStyle: fontStyleValues.map[json["fontStyle"]],
@@ -7593,8 +7593,8 @@ class MarkDef {
75937593 "dx": dx,
75947594 "dy": dy,
75957595 "fill": fill,
7596- "filled": filled,
75977596 "fillOpacity": fillOpacity,
7597+ "filled": filled,
75987598 "font": font,
75997599 "fontSize": fontSize,
76007600 "fontStyle": fontStyleValues.reverse[fontStyle],
Mschema-elixir/test/inputs/schema/accessors.schema/default/QuickType.ex+8 −8
@@ -53,22 +53,22 @@ defmodule EnumEnum do
5353 end
5454
5555 defmodule TopLevel do
56- @enforce_keys [:barre, :enumerification, :foo, :unionization]
57- defstruct [:barre, :enumerification, :foo, :unionization]
56+ @enforce_keys [:unionization, :enumerification, :foo, :barre]
57+ defstruct [:unionization, :enumerification, :foo, :barre]
5858
5959 @type t :: %__MODULE__{
60- barre: String.t(),
60+ unionization: boolean() | float(),
6161 enumerification: EnumEnum.t(),
6262 foo: String.t(),
63- unionization: boolean() | float()
63+ barre: String.t()
6464 }
6565
6666 def from_map(m) do
6767 %TopLevel{
68- barre: m["bar"],
68+ unionization: m["union"],
6969 enumerification: EnumEnum.decode(m["enum"]),
7070 foo: m["foo"],
71- unionization: m["union"],
71+ barre: m["bar"],
7272 }
7373 end
7474
@@ -80,10 +80,10 @@ defmodule TopLevel do
8080
8181 def to_map(struct) do
8282 %{
83- "bar" => struct.barre,
83+ "union" => struct.unionization,
8484 "enum" => EnumEnum.encode(struct.enumerification),
8585 "foo" => struct.foo,
86- "union" => struct.unionization,
86+ "bar" => struct.barre,
8787 }
8888 end
Mschema-elixir/test/inputs/schema/all-of-additional-properties-false.schema/default/QuickType.ex+5 −5
@@ -100,21 +100,21 @@ end
100100
101101 defmodule TopLevel do
102102 @enforce_keys [:amount, :frequency, :type]
103- defstruct [:amount, :frequency, :description, :type]
103+ defstruct [:amount, :frequency, :type, :description]
104104
105105 @type t :: %__MODULE__{
106106 amount: float(),
107107 frequency: Frequency.t(),
108- description: String.t() | nil,
109- type: Type.t()
108+ type: Type.t(),
109+ description: String.t() | nil
110110 }
111111
112112 def from_map(m) do
113113 %TopLevel{
114114 amount: m["amount"],
115115 frequency: Frequency.decode(m["frequency"]),
116- description: m["description"],
117116 type: Type.decode(m["type"]),
117+ description: m["description"],
118118 }
119119 end
120120
@@ -128,8 +128,8 @@ defmodule TopLevel do
128128 %{
129129 "amount" => struct.amount,
130130 "frequency" => Frequency.encode(struct.frequency),
131- "description" => struct.description,
132131 "type" => Type.encode(struct.type),
132+ "description" => struct.description,
133133 }
134134 end
Mschema-elixir/test/inputs/schema/bool-string.schema/default/QuickType.ex+11 −11
@@ -6,15 +6,15 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:nullable, :one, :union_with_bool, :union_with_bool_and_enum]
10- defstruct [:arr_nullable, :arr_one, :nullable, :one, :optional, :union_with_bool, :union_with_bool_and_enum]
9+ @enforce_keys [:one, :nullable, :union_with_bool, :union_with_bool_and_enum]
10+ defstruct [:one, :optional, :nullable, :arr_one, :arr_nullable, :union_with_bool, :union_with_bool_and_enum]
1111
1212 @type t :: %__MODULE__{
13- arr_nullable: [nil | String.t()] | nil,
14- arr_one: [String.t()] | nil,
15- nullable: nil | String.t(),
1613 one: String.t(),
1714 optional: String.t() | nil,
15+ nullable: nil | String.t(),
16+ arr_one: [String.t()] | nil,
17+ arr_nullable: [nil | String.t()] | nil,
1818 union_with_bool: boolean() | String.t(),
1919 union_with_bool_and_enum: boolean() | String.t()
2020 }
@@ -29,11 +29,11 @@ defmodule TopLevel do
2929
3030 def from_map(m) do
3131 %TopLevel{
32- arr_nullable: m["arrNullable"] && Enum.map(m["arrNullable"], &decode_arr_nullable_element/1),
33- arr_one: m["arrOne"],
34- nullable: m["nullable"],
3532 one: m["one"],
3633 optional: m["optional"],
34+ nullable: m["nullable"],
35+ arr_one: m["arrOne"],
36+ arr_nullable: m["arrNullable"] && Enum.map(m["arrNullable"], &decode_arr_nullable_element/1),
3737 union_with_bool: m["unionWithBool"],
3838 union_with_bool_and_enum: m["unionWithBoolAndEnum"],
3939 }
@@ -47,11 +47,11 @@ defmodule TopLevel do
4747
4848 def to_map(struct) do
4949 %{
50- "arrNullable" => struct.arr_nullable && Enum.map(struct.arr_nullable, &encode_arr_nullable_element/1),
51- "arrOne" => struct.arr_one,
52- "nullable" => struct.nullable,
5350 "one" => struct.one,
5451 "optional" => struct.optional,
52+ "nullable" => struct.nullable,
53+ "arrOne" => struct.arr_one,
54+ "arrNullable" => struct.arr_nullable && Enum.map(struct.arr_nullable, &encode_arr_nullable_element/1),
5555 "unionWithBool" => struct.union_with_bool,
5656 "unionWithBoolAndEnum" => struct.union_with_bool_and_enum,
5757 }
Mschema-elixir/test/inputs/schema/comment-injection.schema/default/QuickType.ex+6 −6
@@ -19,28 +19,28 @@ defmodule TopLevel do
1919 }
2020 }
2121 }
22+ - `:value` - Property delimiters:*//*{--}\"\"\"</summary> & <br>}}}}}
2223 - `:trailing_backslash` - Ends with a backslash \\
2324 - `:trailing_quote` - Ends with a quote "
2425 - `:trailing_triple_quote` - Ends with a triple quote \"\"\"
25- - `:value` - Property delimiters:*//*{--}\"\"\"</summary> & <br>}}}}}
2626 """
2727
2828 @enforce_keys [:value]
29- defstruct [:trailing_backslash, :trailing_quote, :trailing_triple_quote, :value]
29+ defstruct [:value, :trailing_backslash, :trailing_quote, :trailing_triple_quote]
3030
3131 @type t :: %__MODULE__{
32+ value: String.t(),
3233 trailing_backslash: String.t() | nil,
3334 trailing_quote: String.t() | nil,
34- trailing_triple_quote: String.t() | nil,
35- value: String.t()
35+ trailing_triple_quote: String.t() | nil
3636 }
3737
3838 def from_map(m) do
3939 %TopLevel{
40+ value: m["value"],
4041 trailing_backslash: m["trailingBackslash"],
4142 trailing_quote: m["trailingQuote"],
4243 trailing_triple_quote: m["trailingTripleQuote"],
43- value: m["value"],
4444 }
4545 end
4646
@@ -52,10 +52,10 @@ defmodule TopLevel do
5252
5353 def to_map(struct) do
5454 %{
55+ "value" => struct.value,
5556 "trailingBackslash" => struct.trailing_backslash,
5657 "trailingQuote" => struct.trailing_quote,
5758 "trailingTripleQuote" => struct.trailing_triple_quote,
58- "value" => struct.value,
5959 }
6060 end
Mschema-elixir/test/inputs/schema/const-non-string.schema/default/QuickType.ex+9 −9
@@ -51,24 +51,24 @@ defmodule Kind do
5151 end
5252
5353 defmodule TopLevel do
54- @enforce_keys [:amount, :enabled, :kind, :ratio, :version]
55- defstruct [:amount, :enabled, :kind, :ratio, :version]
54+ @enforce_keys [:version, :amount, :ratio, :enabled, :kind]
55+ defstruct [:version, :amount, :ratio, :enabled, :kind]
5656
5757 @type t :: %__MODULE__{
58+ version: float(),
5859 amount: integer(),
59- enabled: boolean(),
60- kind: Kind.t(),
6160 ratio: float(),
62- version: float()
61+ enabled: boolean(),
62+ kind: Kind.t()
6363 }
6464
6565 def from_map(m) do
6666 %TopLevel{
67+ version: m["version"],
6768 amount: m["amount"],
69+ ratio: m["ratio"],
6870 enabled: m["enabled"],
6971 kind: Kind.decode(m["kind"]),
70- ratio: m["ratio"],
71- version: m["version"],
7272 }
7373 end
7474
@@ -80,11 +80,11 @@ defmodule TopLevel do
8080
8181 def to_map(struct) do
8282 %{
83+ "version" => struct.version,
8384 "amount" => struct.amount,
85+ "ratio" => struct.ratio,
8486 "enabled" => struct.enabled,
8587 "kind" => Kind.encode(struct.kind),
86- "ratio" => struct.ratio,
87- "version" => struct.version,
8888 }
8989 end
Mschema-elixir/test/inputs/schema/date-time-or-string.schema/default/QuickType.ex+6 −6
@@ -6,18 +6,18 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:bar, :foo]
10- defstruct [:bar, :foo]
9+ @enforce_keys [:foo, :bar]
10+ defstruct [:foo, :bar]
1111
1212 @type t :: %__MODULE__{
13- bar: String.t(),
14- foo: String.t()
13+ foo: String.t(),
14+ bar: String.t()
1515 }
1616
1717 def from_map(m) do
1818 %TopLevel{
19- bar: m["bar"],
2019 foo: m["foo"],
20+ bar: m["bar"],
2121 }
2222 end
2323
@@ -29,8 +29,8 @@ defmodule TopLevel do
2929
3030 def to_map(struct) do
3131 %{
32- "bar" => struct.bar,
3332 "foo" => struct.foo,
33+ "bar" => struct.bar,
3434 }
3535 end
Mschema-elixir/test/inputs/schema/date-time.schema/default/QuickType.ex+9 −9
@@ -6,15 +6,15 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:complex_union_array, :date, :date_time, :time, :union_array]
10- defstruct [:complex_union_array, :date, :date_time, :time, :union_array]
9+ @enforce_keys [:date, :time, :date_time, :union_array, :complex_union_array]
10+ defstruct [:date, :time, :date_time, :union_array, :complex_union_array]
1111
1212 @type t :: %__MODULE__{
13- complex_union_array: [integer() | String.t()],
1413 date: String.t(),
15- date_time: String.t(),
1614 time: String.t(),
17- union_array: [String.t()]
15+ date_time: String.t(),
16+ union_array: [String.t()],
17+ complex_union_array: [integer() | String.t()]
1818 }
1919
2020 def decode_complex_union_array_element(value) when is_integer(value), do: value
@@ -27,11 +27,11 @@ defmodule TopLevel do
2727
2828 def from_map(m) do
2929 %TopLevel{
30- complex_union_array: Enum.map(m["complex-union-array"], &decode_complex_union_array_element/1),
3130 date: m["date"],
32- date_time: m["date-time"],
3331 time: m["time"],
32+ date_time: m["date-time"],
3433 union_array: m["union-array"],
34+ complex_union_array: Enum.map(m["complex-union-array"], &decode_complex_union_array_element/1),
3535 }
3636 end
3737
@@ -43,11 +43,11 @@ defmodule TopLevel do
4343
4444 def to_map(struct) do
4545 %{
46- "complex-union-array" => struct.complex_union_array && Enum.map(struct.complex_union_array, &encode_complex_union_array_element/1),
4746 "date" => struct.date,
48- "date-time" => struct.date_time,
4947 "time" => struct.time,
48+ "date-time" => struct.date_time,
5049 "union-array" => struct.union_array,
50+ "complex-union-array" => struct.complex_union_array && Enum.map(struct.complex_union_array, &encode_complex_union_array_element/1),
5151 }
5252 end
Mschema-elixir/test/inputs/schema/description.schema/default/QuickType.ex+11 −11
@@ -95,20 +95,20 @@ defmodule TopLevel do
9595 @moduledoc """
9696 The top-level class.
9797 Its description has two lines.
98- - `:bar` - A pretty boolean
99- - `:enum` - An enumeration
10098 - `:union` - Either a number or a string
99+ - `:enum` - An enumeration
100+ - `:bar` - A pretty boolean
101101 """
102102
103- @enforce_keys [:enum, :object_or_string, :union]
104- defstruct [:bar, :enum, :foo, :object_or_string, :union]
103+ @enforce_keys [:union, :enum, :object_or_string]
104+ defstruct [:union, :enum, :foo, :bar, :object_or_string]
105105
106106 @type t :: %__MODULE__{
107- bar: boolean() | nil,
107+ union: float() | String.t(),
108108 enum: EnumEnum.t(),
109109 foo: float() | nil,
110- object_or_string: ObjectOrStringClass.t() | String.t(),
111- union: float() | String.t()
110+ bar: boolean() | nil,
111+ object_or_string: ObjectOrStringClass.t() | String.t()
112112 }
113113
114114 def decode_object_or_string(%{"prop" => _,} = value), do: ObjectOrStringClass.from_map(value)
@@ -121,11 +121,11 @@ defmodule TopLevel do
121121
122122 def from_map(m) do
123123 %TopLevel{
124- bar: m["bar"],
124+ union: m["union"],
125125 enum: EnumEnum.decode(m["enum"]),
126126 foo: m["foo"],
127+ bar: m["bar"],
127128 object_or_string: decode_object_or_string(m["object-or-string"]),
128- union: m["union"],
129129 }
130130 end
131131
@@ -137,11 +137,11 @@ defmodule TopLevel do
137137
138138 def to_map(struct) do
139139 %{
140- "bar" => struct.bar,
140+ "union" => struct.union,
141141 "enum" => EnumEnum.encode(struct.enum),
142142 "foo" => struct.foo,
143+ "bar" => struct.bar,
143144 "object-or-string" => encode_object_or_string(struct.object_or_string),
144- "union" => struct.union,
145145 }
146146 end
Mschema-elixir/test/inputs/schema/direct-union.schema/default/QuickType.ex+23 −23
@@ -7,31 +7,13 @@
77
88 defmodule Thing do
99 @enforce_keys [:required]
10- defstruct [:optional, :required]
10+ defstruct [:required, :optional]
1111
1212 @type t :: %__MODULE__{
13- optional: [any()] | boolean() | float() | integer() | %{String.t() => any()} | nil | String.t() | nil,
14- required: [any()] | boolean() | float() | integer() | %{String.t() => any()} | nil | String.t()
13+ required: [any()] | boolean() | float() | integer() | %{String.t() => any()} | nil | String.t(),
14+ optional: [any()] | boolean() | float() | integer() | %{String.t() => any()} | nil | String.t() | nil
1515 }
1616
17- def decode_optional(value) when is_boolean(value), do: value
18- def decode_optional(value) when is_float(value), do: value
19- def decode_optional(value) when is_integer(value), do: value
20- def decode_optional(value) when is_nil(value), do: value
21- def decode_optional(value) when is_binary(value), do: value
22- def decode_optional(value) when is_list(value), do: value
23- def decode_optional(value) when is_map(value), do: value
24- def decode_optional(_), do: {:error, "Unexpected type when decoding Thing.optional"}
25-
26- def encode_optional(value) when is_boolean(value), do: value
27- def encode_optional(value) when is_float(value), do: value
28- def encode_optional(value) when is_integer(value), do: value
29- def encode_optional(value) when is_nil(value), do: value
30- def encode_optional(value) when is_binary(value), do: value
31- def encode_optional(value) when is_list(value), do: value
32- def encode_optional(value) when is_map(value), do: value
33- def encode_optional(_), do: {:error, "Unexpected type when encoding Thing.optional"}
34-
3517 def decode_required(value) when is_boolean(value), do: value
3618 def decode_required(value) when is_float(value), do: value
3719 def decode_required(value) when is_integer(value), do: value
@@ -50,10 +32,28 @@ defmodule Thing do
5032 def encode_required(value) when is_map(value), do: value
5133 def encode_required(_), do: {:error, "Unexpected type when encoding Thing.required"}
5234
35+ def decode_optional(value) when is_boolean(value), do: value
36+ def decode_optional(value) when is_float(value), do: value
37+ def decode_optional(value) when is_integer(value), do: value
38+ def decode_optional(value) when is_nil(value), do: value
39+ def decode_optional(value) when is_binary(value), do: value
40+ def decode_optional(value) when is_list(value), do: value
41+ def decode_optional(value) when is_map(value), do: value
42+ def decode_optional(_), do: {:error, "Unexpected type when decoding Thing.optional"}
43+
44+ def encode_optional(value) when is_boolean(value), do: value
45+ def encode_optional(value) when is_float(value), do: value
46+ def encode_optional(value) when is_integer(value), do: value
47+ def encode_optional(value) when is_nil(value), do: value
48+ def encode_optional(value) when is_binary(value), do: value
49+ def encode_optional(value) when is_list(value), do: value
50+ def encode_optional(value) when is_map(value), do: value
51+ def encode_optional(_), do: {:error, "Unexpected type when encoding Thing.optional"}
52+
5353 def from_map(m) do
5454 %Thing{
55- optional: decode_optional(m["optional"]),
5655 required: decode_required(m["required"]),
56+ optional: decode_optional(m["optional"]),
5757 }
5858 end
5959
@@ -65,8 +65,8 @@ defmodule Thing do
6565
6666 def to_map(struct) do
6767 %{
68- "optional" => encode_optional(struct.optional),
6968 "required" => encode_required(struct.required),
69+ "optional" => encode_optional(struct.optional),
7070 }
7171 end
Mschema-elixir/test/inputs/schema/enum.schema/default/QuickType.ex+11 −11
@@ -148,14 +148,14 @@ end
148148
149149 defmodule TopLevel do
150150 @enforce_keys [:gve]
151- defstruct [:arr, :for, :gve, :lvc, :other_arr]
151+ defstruct [:lvc, :gve, :arr, :other_arr, :for]
152152
153153 @type t :: %__MODULE__{
154- arr: [OtherArr.t() | integer()] | nil,
155- for: String.t() | nil,
156- gve: Gve.t(),
157154 lvc: Lvc.t() | nil,
158- other_arr: [OtherArr.t()] | nil
155+ gve: Gve.t(),
156+ arr: [OtherArr.t() | integer()] | nil,
157+ other_arr: [OtherArr.t()] | nil,
158+ for: String.t() | nil
159159 }
160160
161161 def decode_arr_element(value) when is_binary(value), do: OtherArr.decode(value)
@@ -168,11 +168,11 @@ defmodule TopLevel do
168168
169169 def from_map(m) do
170170 %TopLevel{
171- arr: m["arr"] && Enum.map(m["arr"], &decode_arr_element/1),
172- for: m["for"],
173- gve: Gve.decode(m["gve"]),
174171 lvc: m["lvc"] && Lvc.decode(m["lvc"]),
172+ gve: Gve.decode(m["gve"]),
173+ arr: m["arr"] && Enum.map(m["arr"], &decode_arr_element/1),
175174 other_arr: m["otherArr"] && Enum.map(m["otherArr"], &OtherArr.decode/1),
175+ for: m["for"],
176176 }
177177 end
178178
@@ -184,11 +184,11 @@ defmodule TopLevel do
184184
185185 def to_map(struct) do
186186 %{
187- "arr" => struct.arr && Enum.map(struct.arr, &encode_arr_element/1),
188- "for" => struct.for,
189- "gve" => Gve.encode(struct.gve),
190187 "lvc" => struct.lvc && Lvc.encode(struct.lvc),
188+ "gve" => Gve.encode(struct.gve),
189+ "arr" => struct.arr && Enum.map(struct.arr, &encode_arr_element/1),
191190 "otherArr" => struct.other_arr && Enum.map(struct.other_arr, &OtherArr.encode/1),
191+ "for" => struct.for,
192192 }
193193 end
Mschema-elixir/test/inputs/schema/integer-string.schema/default/QuickType.ex+11 −11
@@ -6,15 +6,15 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:nullable, :one, :union_with_int, :union_with_int_and_enum]
10- defstruct [:arr_nullable, :arr_one, :nullable, :one, :optional, :union_with_int, :union_with_int_and_enum]
9+ @enforce_keys [:one, :nullable, :union_with_int, :union_with_int_and_enum]
10+ defstruct [:one, :optional, :nullable, :arr_one, :arr_nullable, :union_with_int, :union_with_int_and_enum]
1111
1212 @type t :: %__MODULE__{
13- arr_nullable: [nil | String.t()] | nil,
14- arr_one: [String.t()] | nil,
15- nullable: nil | String.t(),
1613 one: String.t(),
1714 optional: String.t() | nil,
15+ nullable: nil | String.t(),
16+ arr_one: [String.t()] | nil,
17+ arr_nullable: [nil | String.t()] | nil,
1818 union_with_int: integer() | String.t(),
1919 union_with_int_and_enum: integer() | String.t()
2020 }
@@ -29,11 +29,11 @@ defmodule TopLevel do
2929
3030 def from_map(m) do
3131 %TopLevel{
32- arr_nullable: m["arrNullable"] && Enum.map(m["arrNullable"], &decode_arr_nullable_element/1),
33- arr_one: m["arrOne"],
34- nullable: m["nullable"],
3532 one: m["one"],
3633 optional: m["optional"],
34+ nullable: m["nullable"],
35+ arr_one: m["arrOne"],
36+ arr_nullable: m["arrNullable"] && Enum.map(m["arrNullable"], &decode_arr_nullable_element/1),
3737 union_with_int: m["unionWithInt"],
3838 union_with_int_and_enum: m["unionWithIntAndEnum"],
3939 }
@@ -47,11 +47,11 @@ defmodule TopLevel do
4747
4848 def to_map(struct) do
4949 %{
50- "arrNullable" => struct.arr_nullable && Enum.map(struct.arr_nullable, &encode_arr_nullable_element/1),
51- "arrOne" => struct.arr_one,
52- "nullable" => struct.nullable,
5350 "one" => struct.one,
5451 "optional" => struct.optional,
52+ "nullable" => struct.nullable,
53+ "arrOne" => struct.arr_one,
54+ "arrNullable" => struct.arr_nullable && Enum.map(struct.arr_nullable, &encode_arr_nullable_element/1),
5555 "unionWithInt" => struct.union_with_int,
5656 "unionWithIntAndEnum" => struct.union_with_int_and_enum,
5757 }
Mschema-elixir/test/inputs/schema/integer-type.schema/default/QuickType.ex+18 −18
@@ -6,32 +6,32 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:above_i32_max, :below_i32_min, :i32_range, :large_bounds, :only_maximum, :only_minimum, :small_negative, :small_positive, :unbounded]
10- defstruct [:above_i32_max, :below_i32_min, :i32_range, :large_bounds, :only_maximum, :only_minimum, :small_negative, :small_positive, :unbounded]
9+ @enforce_keys [:small_positive, :small_negative, :i32_range, :above_i32_max, :below_i32_min, :only_minimum, :only_maximum, :unbounded, :large_bounds]
10+ defstruct [:small_positive, :small_negative, :i32_range, :above_i32_max, :below_i32_min, :only_minimum, :only_maximum, :unbounded, :large_bounds]
1111
1212 @type t :: %__MODULE__{
13+ small_positive: integer(),
14+ small_negative: integer(),
15+ i32_range: integer(),
1316 above_i32_max: integer(),
1417 below_i32_min: integer(),
15- i32_range: integer(),
16- large_bounds: integer(),
17- only_maximum: integer(),
1818 only_minimum: integer(),
19- small_negative: integer(),
20- small_positive: integer(),
21- unbounded: integer()
19+ only_maximum: integer(),
20+ unbounded: integer(),
21+ large_bounds: integer()
2222 }
2323
2424 def from_map(m) do
2525 %TopLevel{
26+ small_positive: m["small_positive"],
27+ small_negative: m["small_negative"],
28+ i32_range: m["i32_range"],
2629 above_i32_max: m["above_i32_max"],
2730 below_i32_min: m["below_i32_min"],
28- i32_range: m["i32_range"],
29- large_bounds: m["large_bounds"],
30- only_maximum: m["only_maximum"],
3131 only_minimum: m["only_minimum"],
32- small_negative: m["small_negative"],
33- small_positive: m["small_positive"],
32+ only_maximum: m["only_maximum"],
3433 unbounded: m["unbounded"],
34+ large_bounds: m["large_bounds"],
3535 }
3636 end
3737
@@ -43,15 +43,15 @@ defmodule TopLevel do
4343
4444 def to_map(struct) do
4545 %{
46+ "small_positive" => struct.small_positive,
47+ "small_negative" => struct.small_negative,
48+ "i32_range" => struct.i32_range,
4649 "above_i32_max" => struct.above_i32_max,
4750 "below_i32_min" => struct.below_i32_min,
48- "i32_range" => struct.i32_range,
49- "large_bounds" => struct.large_bounds,
50- "only_maximum" => struct.only_maximum,
5151 "only_minimum" => struct.only_minimum,
52- "small_negative" => struct.small_negative,
53- "small_positive" => struct.small_positive,
52+ "only_maximum" => struct.only_maximum,
5453 "unbounded" => struct.unbounded,
54+ "large_bounds" => struct.large_bounds,
5555 }
5656 end
Mschema-elixir/test/inputs/schema/keyword-unions.schema/default/QuickType.ex+20 −20
@@ -8010,7 +8010,7 @@ defmodule Yield do
80108010 end
80118011
80128012 defmodule TopLevel do
8013- defstruct [:empty, :top_level_bool, :complex, :imaginery, :abstract, :alignas, :alignof, :top_level_and, :and_eq, :top_level_any, :any, :array, :as, :asm, :assert, :associatedtype, :associativity, :async, :atomic, :atomic_cancel, :atomic_commit, :atomic_noexcept, :auto, :await, :base, :bitand, :bitor, :bool, :bool_1, :boolean, :break, :bycopy, :byref, :byte, :case, :top_level_catch, :chan, :char, :char16_t, :char32_t, :checked, :top_level_class, :class, :co_await, :co_return, :co_yield, :compl, :concept, :console, :const, :const_cast, :constexpr, :constructor, :continue, :convenience, :convert, :converter, :date, :date_parse_handling, :debugger, :decimal, :declare, :decltype, :decode_string, :top_level_def, :default, :defer, :deinit, :del, :delegate, :delete, :dict, :dictionary, :did_set, :top_level_do, :double, :dummy, :dynamic, :dynamic_cast, :elif, :top_level_else, :encode_quick_type, :enum, :event, :except, :exception, :explicit, :export, :exposing, :extends, :extension, :extern, :fallthrough, :false_1, :top_level_false, :fileprivate, :final, :finally, :fixed, :float, :for, :foreach, :friend, :from, :from_json, :func, :function, :get, :global, :go, :goto, :guard, :has_own_property, :id, :if, :imp, :implements, :implicit, :top_level_import, :top_level_in, :indirect, :infix, :init, :inline, :inout, :instanceof, :int, :interface, :internal, :is, :iterable, :jdec, :jenc, :jpipe, :json, :json_converter, :json_serializer, :json_token, :json_writer, :lambda, :lazy, :left, :let, :list, :lock, :long, :map, :metadata_property_handling, :module, :mutable, :mutating, :namespace, :native, :new, :newtonsoft, :top_level_nil, :no, :noexcept, :nonatomic, :top_level_none, :none, :nonlocal, :nonmutating, :top_level_not, :not_eq, :ns_string, :null, :top_level_null, :nullptr, :number, :object, :of, :oneway, :open, :operator, :optional, :top_level_or, :or_eq, :out, :override, :package, :params, :pass, :port, :postfix, :precedence, :prefix, :print, :printf, :private, :protected, :protocol, :top_level_protocol, :public, :quicktype, :raise, :range, :readonly, :ref, :register, :reinterpret_cast, :repeat, :require, :required, :requires, :restrict, :retain, :rethrows, :return, :right, :sbyte, :sealed, :sel, :select, :self, :top_level_self, :serialize, :set, :short, :signed, :sizeof, :stackalloc, :static, :static_assert, :static_cast, :strictfp, :string, :struct, :subscript, :super, :switch, :symbol, :synchronized, :system, :template, :then, :this, :thread_local, :throw, :throws, :to_json, :top_level, :transient, :top_level_true, :true_1, :try, :type, :top_level_type, :typealias, :typedef, :typeid, :typename, :typeof, :uint, :ulong, :unchecked, :undefined, :union, :unowned, :unsafe, :unsigned, :ushort, :using, :var, :virtual, :void, :volatile, :wchar_t, :weak, :where, :while, :will_set, :with, :xor, :xor_eq, :yes, :yield]
8013+ defstruct [:empty, :top_level_bool, :complex, :imaginery, :abstract, :alignas, :alignof, :top_level_and, :and_eq, :top_level_any, :any, :array, :as, :asm, :assert, :associatedtype, :associativity, :async, :atomic, :atomic_cancel, :atomic_commit, :atomic_noexcept, :auto, :await, :base, :bitand, :bitor, :bool, :bool_1, :boolean, :break, :bycopy, :byref, :byte, :case, :top_level_catch, :chan, :char, :char16_t, :char32_t, :checked, :top_level_class, :class, :co_await, :co_return, :co_yield, :compl, :concept, :console, :const, :const_cast, :constexpr, :constructor, :continue, :convenience, :convert, :converter, :date, :date_parse_handling, :debugger, :decimal, :declare, :decltype, :decode_string, :top_level_def, :default, :defer, :deinit, :del, :delegate, :delete, :dict, :dictionary, :did_set, :top_level_do, :double, :dynamic, :dynamic_cast, :elif, :top_level_else, :encode_quick_type, :enum, :event, :except, :exception, :explicit, :export, :exposing, :extends, :extension, :extern, :fallthrough, :false_1, :top_level_false, :fileprivate, :final, :finally, :fixed, :float, :for, :foreach, :friend, :from, :from_json, :func, :function, :get, :global, :go, :goto, :guard, :has_own_property, :id, :if, :imp, :implements, :implicit, :top_level_import, :top_level_in, :indirect, :infix, :init, :inline, :inout, :instanceof, :int, :interface, :internal, :iterable, :is, :jdec, :jenc, :jpipe, :json, :json_converter, :json_serializer, :json_token, :json_writer, :lambda, :lazy, :left, :let, :list, :lock, :long, :map, :metadata_property_handling, :module, :mutable, :mutating, :namespace, :native, :new, :newtonsoft, :top_level_nil, :no, :noexcept, :nonatomic, :top_level_none, :none, :nonlocal, :nonmutating, :top_level_not, :not_eq, :ns_string, :null, :top_level_null, :nullptr, :number, :object, :of, :oneway, :open, :operator, :optional, :top_level_or, :or_eq, :out, :override, :package, :params, :pass, :port, :postfix, :precedence, :prefix, :print, :printf, :private, :protected, :protocol, :top_level_protocol, :public, :quicktype, :raise, :range, :readonly, :ref, :register, :reinterpret_cast, :repeat, :require, :required, :requires, :restrict, :retain, :rethrows, :return, :right, :sbyte, :sealed, :sel, :select, :self, :top_level_self, :serialize, :set, :short, :signed, :sizeof, :stackalloc, :static, :static_assert, :static_cast, :strictfp, :string, :struct, :subscript, :super, :switch, :symbol, :synchronized, :system, :template, :then, :this, :thread_local, :throw, :throws, :to_json, :top_level, :transient, :top_level_true, :true_1, :try, :type, :top_level_type, :typealias, :typedef, :typeid, :typename, :typeof, :uint, :ulong, :unchecked, :undefined, :union, :unowned, :unsafe, :unsigned, :ushort, :using, :var, :virtual, :void, :volatile, :wchar_t, :weak, :where, :while, :will_set, :with, :xor, :xor_eq, :yes, :yield, :dummy]
80148014
80158015 @type t :: %__MODULE__{
80168016 empty: Empty.t() | float() | nil,
@@ -8089,7 +8089,6 @@ defmodule TopLevel do
80898089 did_set: DidSet.t() | float() | nil,
80908090 top_level_do: DoClass.t() | float() | nil,
80918091 double: Double.t() | float() | nil,
8092- dummy: float() | nil,
80938092 dynamic: Dynamic.t() | float() | nil,
80948093 dynamic_cast: DynamicCast.t() | float() | nil,
80958094 elif: Elif.t() | float() | nil,
@@ -8142,8 +8141,8 @@ defmodule TopLevel do
81428141 int: Int.t() | float() | nil,
81438142 interface: Interface.t() | float() | nil,
81448143 internal: Internal.t() | float() | nil,
8145- is: Is.t() | float() | nil,
81468144 iterable: Iterable.t() | float() | nil,
8145+ is: Is.t() | float() | nil,
81478146 jdec: Jdec.t() | float() | nil,
81488147 jenc: Jenc.t() | float() | nil,
81498148 jpipe: Jpipe.t() | float() | nil,
@@ -8289,7 +8288,8 @@ defmodule TopLevel do
82898288 xor: Xor.t() | float() | nil,
82908289 xor_eq: XorEq.t() | float() | nil,
82918290 yes: Yes.t() | float() | nil,
8292- yield: Yield.t() | float() | nil
8291+ yield: Yield.t() | float() | nil,
8292+ dummy: float() | nil
82938293 }
82948294
82958295 def decode_empty(%{} = value), do: Empty.from_map(value)
@@ -9828,18 +9828,6 @@ defmodule TopLevel do
98289828 def encode_internal(value) when is_nil(value), do: value
98299829 def encode_internal(_), do: {:error, "Unexpected type when encoding TopLevel.internal"}
98309830
9831- def decode_is(%{} = value), do: Is.from_map(value)
9832- def decode_is(value) when is_float(value), do: value
9833- def decode_is(value) when is_integer(value), do: value
9834- def decode_is(value) when is_nil(value), do: value
9835- def decode_is(_), do: {:error, "Unexpected type when decoding TopLevel.is"}
9836-
9837- def encode_is(%Is{} = value), do: Is.to_map(value)
9838- def encode_is(value) when is_float(value), do: value
9839- def encode_is(value) when is_integer(value), do: value
9840- def encode_is(value) when is_nil(value), do: value
9841- def encode_is(_), do: {:error, "Unexpected type when encoding TopLevel.is"}
9842-
98439831 def decode_iterable(%{} = value), do: Iterable.from_map(value)
98449832 def decode_iterable(value) when is_float(value), do: value
98459833 def decode_iterable(value) when is_integer(value), do: value
@@ -9852,6 +9840,18 @@ defmodule TopLevel do
98529840 def encode_iterable(value) when is_nil(value), do: value
98539841 def encode_iterable(_), do: {:error, "Unexpected type when encoding TopLevel.iterable"}
98549842
9843+ def decode_is(%{} = value), do: Is.from_map(value)
9844+ def decode_is(value) when is_float(value), do: value
9845+ def decode_is(value) when is_integer(value), do: value
9846+ def decode_is(value) when is_nil(value), do: value
9847+ def decode_is(_), do: {:error, "Unexpected type when decoding TopLevel.is"}
9848+
9849+ def encode_is(%Is{} = value), do: Is.to_map(value)
9850+ def encode_is(value) when is_float(value), do: value
9851+ def encode_is(value) when is_integer(value), do: value
9852+ def encode_is(value) when is_nil(value), do: value
9853+ def encode_is(_), do: {:error, "Unexpected type when encoding TopLevel.is"}
9854+
98559855 def decode_jdec(%{} = value), do: Jdec.from_map(value)
98569856 def decode_jdec(value) when is_float(value), do: value
98579857 def decode_jdec(value) when is_integer(value), do: value
@@ -11682,7 +11682,6 @@ defmodule TopLevel do
1168211682 did_set: decode_did_set(m["didSet"]),
1168311683 top_level_do: decode_top_level_do(m["do"]),
1168411684 double: decode_double(m["double"]),
11685- dummy: m["dummy"],
1168611685 dynamic: decode_dynamic(m["dynamic"]),
1168711686 dynamic_cast: decode_dynamic_cast(m["dynamic_cast"]),
1168811687 elif: decode_elif(m["elif"]),
@@ -11735,8 +11734,8 @@ defmodule TopLevel do
1173511734 int: decode_int(m["int"]),
1173611735 interface: decode_interface(m["interface"]),
1173711736 internal: decode_internal(m["internal"]),
11738- is: decode_is(m["is"]),
1173911737 iterable: decode_iterable(m["iterable"]),
11738+ is: decode_is(m["is"]),
1174011739 jdec: decode_jdec(m["jdec"]),
1174111740 jenc: decode_jenc(m["jenc"]),
1174211741 jpipe: decode_jpipe(m["jpipe"]),
@@ -11883,6 +11882,7 @@ defmodule TopLevel do
1188311882 xor_eq: decode_xor_eq(m["xor_eq"]),
1188411883 yes: decode_yes(m["YES"]),
1188511884 yield: decode_yield(m["yield"]),
11885+ dummy: m["dummy"],
1188611886 }
1188711887 end
1188811888
@@ -11970,7 +11970,6 @@ defmodule TopLevel do
1197011970 "didSet" => encode_did_set(struct.did_set),
1197111971 "do" => encode_top_level_do(struct.top_level_do),
1197211972 "double" => encode_double(struct.double),
11973- "dummy" => struct.dummy,
1197411973 "dynamic" => encode_dynamic(struct.dynamic),
1197511974 "dynamic_cast" => encode_dynamic_cast(struct.dynamic_cast),
1197611975 "elif" => encode_elif(struct.elif),
@@ -12023,8 +12022,8 @@ defmodule TopLevel do
1202312022 "int" => encode_int(struct.int),
1202412023 "interface" => encode_interface(struct.interface),
1202512024 "internal" => encode_internal(struct.internal),
12026- "is" => encode_is(struct.is),
1202712025 "iterable" => encode_iterable(struct.iterable),
12026+ "is" => encode_is(struct.is),
1202812027 "jdec" => encode_jdec(struct.jdec),
1202912028 "jenc" => encode_jenc(struct.jenc),
1203012029 "jpipe" => encode_jpipe(struct.jpipe),
@@ -12171,6 +12170,7 @@ defmodule TopLevel do
1217112170 "xor_eq" => encode_xor_eq(struct.xor_eq),
1217212171 "YES" => encode_yes(struct.yes),
1217312172 "yield" => encode_yield(struct.yield),
12173+ "dummy" => struct.dummy,
1217412174 }
1217512175 end
Mschema-elixir/test/inputs/schema/light.schema/default/QuickType.ex+5 −5
@@ -6,19 +6,19 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule LightParams do
9- @enforce_keys [:app_id, :outlet_id, :rgba]
10- defstruct [:app_id, :outlet_id, :rgba]
9+ @enforce_keys [:outlet_id, :app_id, :rgba]
10+ defstruct [:outlet_id, :app_id, :rgba]
1111
1212 @type t :: %__MODULE__{
13- app_id: String.t(),
1413 outlet_id: String.t(),
14+ app_id: String.t(),
1515 rgba: String.t()
1616 }
1717
1818 def from_map(m) do
1919 %LightParams{
20- app_id: m["app_id"],
2120 outlet_id: m["outlet_id"],
21+ app_id: m["app_id"],
2222 rgba: m["rgba"],
2323 }
2424 end
@@ -31,8 +31,8 @@ defmodule LightParams do
3131
3232 def to_map(struct) do
3333 %{
34- "app_id" => struct.app_id,
3534 "outlet_id" => struct.outlet_id,
35+ "app_id" => struct.app_id,
3636 "rgba" => struct.rgba,
3737 }
3838 end
Mschema-elixir/test/inputs/schema/min-max-items.schema/default/QuickType.ex+5 −5
@@ -6,13 +6,13 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:max_only, :min_and_max, :min_only, :plain, :union_items]
10- defstruct [:max_only, :min_and_max, :min_only, :plain, :union_items]
9+ @enforce_keys [:min_only, :max_only, :min_and_max, :plain, :union_items]
10+ defstruct [:min_only, :max_only, :min_and_max, :plain, :union_items]
1111
1212 @type t :: %__MODULE__{
13+ min_only: [String.t()],
1314 max_only: [integer()],
1415 min_and_max: [float()],
15- min_only: [String.t()],
1616 plain: [String.t()],
1717 union_items: [integer() | String.t()]
1818 }
@@ -27,9 +27,9 @@ defmodule TopLevel do
2727
2828 def from_map(m) do
2929 %TopLevel{
30+ min_only: m["minOnly"],
3031 max_only: m["maxOnly"],
3132 min_and_max: m["minAndMax"],
32- min_only: m["minOnly"],
3333 plain: m["plain"],
3434 union_items: Enum.map(m["unionItems"], &decode_union_items_element/1),
3535 }
@@ -43,9 +43,9 @@ defmodule TopLevel do
4343
4444 def to_map(struct) do
4545 %{
46+ "minOnly" => struct.min_only,
4647 "maxOnly" => struct.max_only,
4748 "minAndMax" => struct.min_and_max,
48- "minOnly" => struct.min_only,
4949 "plain" => struct.plain,
5050 "unionItems" => struct.union_items && Enum.map(struct.union_items, &encode_union_items_element/1),
5151 }
Mschema-elixir/test/inputs/schema/minmax-integer.schema/default/QuickType.ex+14 −14
@@ -6,30 +6,30 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:free, :intersection, :max, :min, :minmax, :min_max_intersection, :min_max_union, :union]
10- defstruct [:free, :intersection, :max, :min, :minmax, :min_max_intersection, :min_max_union, :union]
9+ @enforce_keys [:free, :min, :max, :minmax, :union, :min_max_union, :intersection, :min_max_intersection]
10+ defstruct [:free, :min, :max, :minmax, :union, :min_max_union, :intersection, :min_max_intersection]
1111
1212 @type t :: %__MODULE__{
1313 free: integer(),
14- intersection: integer(),
15- max: integer(),
1614 min: integer(),
15+ max: integer(),
1716 minmax: integer(),
18- min_max_intersection: integer(),
17+ union: integer(),
1918 min_max_union: integer(),
20- union: integer()
19+ intersection: integer(),
20+ min_max_intersection: integer()
2121 }
2222
2323 def from_map(m) do
2424 %TopLevel{
2525 free: m["free"],
26- intersection: m["intersection"],
27- max: m["max"],
2826 min: m["min"],
27+ max: m["max"],
2928 minmax: m["minmax"],
30- min_max_intersection: m["minMaxIntersection"],
31- min_max_union: m["minMaxUnion"],
3229 union: m["union"],
30+ min_max_union: m["minMaxUnion"],
31+ intersection: m["intersection"],
32+ min_max_intersection: m["minMaxIntersection"],
3333 }
3434 end
3535
@@ -42,13 +42,13 @@ defmodule TopLevel do
4242 def to_map(struct) do
4343 %{
4444 "free" => struct.free,
45- "intersection" => struct.intersection,
46- "max" => struct.max,
4745 "min" => struct.min,
46+ "max" => struct.max,
4847 "minmax" => struct.minmax,
49- "minMaxIntersection" => struct.min_max_intersection,
50- "minMaxUnion" => struct.min_max_union,
5148 "union" => struct.union,
49+ "minMaxUnion" => struct.min_max_union,
50+ "intersection" => struct.intersection,
51+ "minMaxIntersection" => struct.min_max_intersection,
5252 }
5353 end
Mschema-elixir/test/inputs/schema/minmax.schema/default/QuickType.ex+14 −14
@@ -6,30 +6,30 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:free, :intersection, :max, :min, :minmax, :min_max_intersection, :min_max_union, :union]
10- defstruct [:free, :intersection, :max, :min, :minmax, :min_max_intersection, :min_max_union, :union]
9+ @enforce_keys [:free, :min, :max, :minmax, :union, :min_max_union, :intersection, :min_max_intersection]
10+ defstruct [:free, :min, :max, :minmax, :union, :min_max_union, :intersection, :min_max_intersection]
1111
1212 @type t :: %__MODULE__{
1313 free: float(),
14- intersection: float(),
15- max: float(),
1614 min: float(),
15+ max: float(),
1716 minmax: float(),
18- min_max_intersection: float(),
17+ union: float(),
1918 min_max_union: float(),
20- union: float()
19+ intersection: float(),
20+ min_max_intersection: float()
2121 }
2222
2323 def from_map(m) do
2424 %TopLevel{
2525 free: m["free"],
26- intersection: m["intersection"],
27- max: m["max"],
2826 min: m["min"],
27+ max: m["max"],
2928 minmax: m["minmax"],
30- min_max_intersection: m["minMaxIntersection"],
31- min_max_union: m["minMaxUnion"],
3229 union: m["union"],
30+ min_max_union: m["minMaxUnion"],
31+ intersection: m["intersection"],
32+ min_max_intersection: m["minMaxIntersection"],
3333 }
3434 end
3535
@@ -42,13 +42,13 @@ defmodule TopLevel do
4242 def to_map(struct) do
4343 %{
4444 "free" => struct.free,
45- "intersection" => struct.intersection,
46- "max" => struct.max,
4745 "min" => struct.min,
46+ "max" => struct.max,
4847 "minmax" => struct.minmax,
49- "minMaxIntersection" => struct.min_max_intersection,
50- "minMaxUnion" => struct.min_max_union,
5148 "union" => struct.union,
49+ "minMaxUnion" => struct.min_max_union,
50+ "intersection" => struct.intersection,
51+ "minMaxIntersection" => struct.min_max_intersection,
5252 }
5353 end
Mschema-elixir/test/inputs/schema/minmaxlength.schema/default/QuickType.ex+17 −17
@@ -6,30 +6,30 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:intersection, :in_union, :maxlength, :minlength, :min_max_intersection, :minmaxlength, :min_max_union, :union]
10- defstruct [:intersection, :in_union, :maxlength, :minlength, :min_max_intersection, :minmaxlength, :min_max_union, :union]
9+ @enforce_keys [:minlength, :maxlength, :minmaxlength, :union, :in_union, :min_max_union, :intersection, :min_max_intersection]
10+ defstruct [:minlength, :maxlength, :minmaxlength, :union, :in_union, :min_max_union, :intersection, :min_max_intersection]
1111
1212 @type t :: %__MODULE__{
13- intersection: String.t(),
14- in_union: float() | String.t(),
15- maxlength: String.t(),
1613 minlength: String.t(),
17- min_max_intersection: String.t(),
14+ maxlength: String.t(),
1815 minmaxlength: String.t(),
16+ union: String.t(),
17+ in_union: float() | String.t(),
1918 min_max_union: String.t(),
20- union: String.t()
19+ intersection: String.t(),
20+ min_max_intersection: String.t()
2121 }
2222
2323 def from_map(m) do
2424 %TopLevel{
25- intersection: m["intersection"],
26- in_union: m["inUnion"],
27- maxlength: m["maxlength"],
2825 minlength: m["minlength"],
29- min_max_intersection: m["minMaxIntersection"],
26+ maxlength: m["maxlength"],
3027 minmaxlength: m["minmaxlength"],
31- min_max_union: m["minMaxUnion"],
3228 union: m["union"],
29+ in_union: m["inUnion"],
30+ min_max_union: m["minMaxUnion"],
31+ intersection: m["intersection"],
32+ min_max_intersection: m["minMaxIntersection"],
3333 }
3434 end
3535
@@ -41,14 +41,14 @@ defmodule TopLevel do
4141
4242 def to_map(struct) do
4343 %{
44- "intersection" => struct.intersection,
45- "inUnion" => struct.in_union,
46- "maxlength" => struct.maxlength,
4744 "minlength" => struct.minlength,
48- "minMaxIntersection" => struct.min_max_intersection,
45+ "maxlength" => struct.maxlength,
4946 "minmaxlength" => struct.minmaxlength,
50- "minMaxUnion" => struct.min_max_union,
5147 "union" => struct.union,
48+ "inUnion" => struct.in_union,
49+ "minMaxUnion" => struct.min_max_union,
50+ "intersection" => struct.intersection,
51+ "minMaxIntersection" => struct.min_max_intersection,
5252 }
5353 end
Mschema-elixir/test/inputs/schema/non-standard-ref.schema/default/QuickType.ex+5 −5
@@ -6,19 +6,19 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:bar, :foo, :quux]
10- defstruct [:bar, :foo, :quux]
9+ @enforce_keys [:foo, :bar, :quux]
10+ defstruct [:foo, :bar, :quux]
1111
1212 @type t :: %__MODULE__{
13- bar: integer(),
1413 foo: integer(),
14+ bar: integer(),
1515 quux: boolean()
1616 }
1717
1818 def from_map(m) do
1919 %TopLevel{
20- bar: m["bar"],
2120 foo: m["foo"],
21+ bar: m["bar"],
2222 quux: m["quux"],
2323 }
2424 end
@@ -31,8 +31,8 @@ defmodule TopLevel do
3131
3232 def to_map(struct) do
3333 %{
34- "bar" => struct.bar,
3534 "foo" => struct.foo,
35+ "bar" => struct.bar,
3636 "quux" => struct.quux,
3737 }
3838 end
Mschema-elixir/test/inputs/schema/nullable-optional-one-of.schema/default/QuickType.ex+5 −5
@@ -53,17 +53,17 @@ end
5353
5454 defmodule TopLevel do
5555 @enforce_keys [:kind]
56- defstruct [:b, :kind]
56+ defstruct [:kind, :b]
5757
5858 @type t :: %__MODULE__{
59- b: nil | String.t() | nil,
60- kind: Kind.t()
59+ kind: Kind.t(),
60+ b: nil | String.t() | nil
6161 }
6262
6363 def from_map(m) do
6464 %TopLevel{
65- b: m["b"],
6665 kind: Kind.decode(m["kind"]),
66+ b: m["b"],
6767 }
6868 end
6969
@@ -75,8 +75,8 @@ defmodule TopLevel do
7575
7676 def to_map(struct) do
7777 %{
78- "b" => struct.b,
7978 "kind" => Kind.encode(struct.kind),
79+ "b" => struct.b,
8080 }
8181 end
Mschema-elixir/test/inputs/schema/optional-const-ref.schema/default/QuickType.ex+11 −11
@@ -43,27 +43,27 @@ end
4343
4444 defmodule TopLevel do
4545 @enforce_keys [:required_coordinates, :required_count, :required_label]
46- defstruct [:coordinates, :count, :label, :required_coordinates, :required_count, :required_label, :weight]
46+ defstruct [:coordinates, :required_coordinates, :count, :required_count, :weight, :label, :required_label]
4747
4848 @type t :: %__MODULE__{
4949 coordinates: [Coordinate.t()] | nil,
50- count: integer() | nil,
51- label: String.t() | nil,
5250 required_coordinates: [Coordinate.t()],
51+ count: integer() | nil,
5352 required_count: integer(),
54- required_label: String.t(),
55- weight: float() | nil
53+ weight: float() | nil,
54+ label: String.t() | nil,
55+ required_label: String.t()
5656 }
5757
5858 def from_map(m) do
5959 %TopLevel{
6060 coordinates: m["coordinates"] && Enum.map(m["coordinates"], &Coordinate.from_map/1),
61- count: m["count"],
62- label: m["label"],
6361 required_coordinates: Enum.map(m["requiredCoordinates"], &Coordinate.from_map/1),
62+ count: m["count"],
6463 required_count: m["requiredCount"],
65- required_label: m["requiredLabel"],
6664 weight: m["weight"],
65+ label: m["label"],
66+ required_label: m["requiredLabel"],
6767 }
6868 end
6969
@@ -76,12 +76,12 @@ defmodule TopLevel do
7676 def to_map(struct) do
7777 %{
7878 "coordinates" => struct.coordinates && Enum.map(struct.coordinates, &Coordinate.to_map/1),
79- "count" => struct.count,
80- "label" => struct.label,
8179 "requiredCoordinates" => struct.required_coordinates && Enum.map(struct.required_coordinates, &Coordinate.to_map/1),
80+ "count" => struct.count,
8281 "requiredCount" => struct.required_count,
83- "requiredLabel" => struct.required_label,
8482 "weight" => struct.weight,
83+ "label" => struct.label,
84+ "requiredLabel" => struct.required_label,
8585 }
8686 end
Mschema-elixir/test/inputs/schema/optional-constraints.schema/default/QuickType.ex+10 −10
@@ -7,23 +7,23 @@
77
88 defmodule TopLevel do
99 @enforce_keys [:req_zero_min]
10- defstruct [:opt_double, :opt_int, :opt_pattern, :opt_string, :req_zero_min]
10+ defstruct [:req_zero_min, :opt_int, :opt_double, :opt_string, :opt_pattern]
1111
1212 @type t :: %__MODULE__{
13- opt_double: float() | nil,
13+ req_zero_min: integer(),
1414 opt_int: integer() | nil,
15- opt_pattern: String.t() | nil,
15+ opt_double: float() | nil,
1616 opt_string: String.t() | nil,
17- req_zero_min: integer()
17+ opt_pattern: String.t() | nil
1818 }
1919
2020 def from_map(m) do
2121 %TopLevel{
22- opt_double: m["optDouble"],
22+ req_zero_min: m["reqZeroMin"],
2323 opt_int: m["optInt"],
24- opt_pattern: m["optPattern"],
24+ opt_double: m["optDouble"],
2525 opt_string: m["optString"],
26- req_zero_min: m["reqZeroMin"],
26+ opt_pattern: m["optPattern"],
2727 }
2828 end
2929
@@ -35,11 +35,11 @@ defmodule TopLevel do
3535
3636 def to_map(struct) do
3737 %{
38- "optDouble" => struct.opt_double,
38+ "reqZeroMin" => struct.req_zero_min,
3939 "optInt" => struct.opt_int,
40- "optPattern" => struct.opt_pattern,
40+ "optDouble" => struct.opt_double,
4141 "optString" => struct.opt_string,
42- "reqZeroMin" => struct.req_zero_min,
42+ "optPattern" => struct.opt_pattern,
4343 }
4444 end
Mschema-elixir/test/inputs/schema/optional-date-time.schema/default/QuickType.ex+14 −14
@@ -6,26 +6,26 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:required_date, :required_date_time, :required_time]
10- defstruct [:optional_date, :optional_date_time, :optional_time, :required_date, :required_date_time, :required_time]
9+ @enforce_keys [:required_date, :required_time, :required_date_time]
10+ defstruct [:required_date, :required_time, :required_date_time, :optional_date, :optional_time, :optional_date_time]
1111
1212 @type t :: %__MODULE__{
13- optional_date: String.t() | nil,
14- optional_date_time: String.t() | nil,
15- optional_time: String.t() | nil,
1613 required_date: String.t(),
14+ required_time: String.t(),
1715 required_date_time: String.t(),
18- required_time: String.t()
16+ optional_date: String.t() | nil,
17+ optional_time: String.t() | nil,
18+ optional_date_time: String.t() | nil
1919 }
2020
2121 def from_map(m) do
2222 %TopLevel{
23- optional_date: m["optional-date"],
24- optional_date_time: m["optional-date-time"],
25- optional_time: m["optional-time"],
2623 required_date: m["required-date"],
27- required_date_time: m["required-date-time"],
2824 required_time: m["required-time"],
25+ required_date_time: m["required-date-time"],
26+ optional_date: m["optional-date"],
27+ optional_time: m["optional-time"],
28+ optional_date_time: m["optional-date-time"],
2929 }
3030 end
3131
@@ -37,12 +37,12 @@ defmodule TopLevel do
3737
3838 def to_map(struct) do
3939 %{
40- "optional-date" => struct.optional_date,
41- "optional-date-time" => struct.optional_date_time,
42- "optional-time" => struct.optional_time,
4340 "required-date" => struct.required_date,
44- "required-date-time" => struct.required_date_time,
4541 "required-time" => struct.required_time,
42+ "required-date-time" => struct.required_date_time,
43+ "optional-date" => struct.optional_date,
44+ "optional-time" => struct.optional_time,
45+ "optional-date-time" => struct.optional_date_time,
4646 }
4747 end
Mschema-elixir/test/inputs/schema/prefix-items.schema/default/QuickType.ex+14 −14
@@ -6,22 +6,14 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:open, :tuple]
10- defstruct [:open, :tuple]
9+ @enforce_keys [:tuple, :open]
10+ defstruct [:tuple, :open]
1111
1212 @type t :: %__MODULE__{
13- open: [boolean() | integer()],
14- tuple: [boolean() | integer()]
13+ tuple: [boolean() | integer()],
14+ open: [boolean() | integer()]
1515 }
1616
17- def decode_open_element(value) when is_boolean(value), do: value
18- def decode_open_element(value) when is_integer(value), do: value
19- def decode_open_element(_), do: {:error, "Unexpected type when decoding TopLevel.open"}
20-
21- def encode_open_element(value) when is_boolean(value), do: value
22- def encode_open_element(value) when is_integer(value), do: value
23- def encode_open_element(_), do: {:error, "Unexpected type when encoding TopLevel.open"}
24-
2517 def decode_tuple_element(value) when is_boolean(value), do: value
2618 def decode_tuple_element(value) when is_integer(value), do: value
2719 def decode_tuple_element(_), do: {:error, "Unexpected type when decoding TopLevel.tuple"}
@@ -30,10 +22,18 @@ defmodule TopLevel do
3022 def encode_tuple_element(value) when is_integer(value), do: value
3123 def encode_tuple_element(_), do: {:error, "Unexpected type when encoding TopLevel.tuple"}
3224
25+ def decode_open_element(value) when is_boolean(value), do: value
26+ def decode_open_element(value) when is_integer(value), do: value
27+ def decode_open_element(_), do: {:error, "Unexpected type when decoding TopLevel.open"}
28+
29+ def encode_open_element(value) when is_boolean(value), do: value
30+ def encode_open_element(value) when is_integer(value), do: value
31+ def encode_open_element(_), do: {:error, "Unexpected type when encoding TopLevel.open"}
32+
3333 def from_map(m) do
3434 %TopLevel{
35- open: Enum.map(m["open"], &decode_open_element/1),
3635 tuple: Enum.map(m["tuple"], &decode_tuple_element/1),
36+ open: Enum.map(m["open"], &decode_open_element/1),
3737 }
3838 end
3939
@@ -45,8 +45,8 @@ defmodule TopLevel do
4545
4646 def to_map(struct) do
4747 %{
48- "open" => struct.open && Enum.map(struct.open, &encode_open_element/1),
4948 "tuple" => struct.tuple && Enum.map(struct.tuple, &encode_tuple_element/1),
49+ "open" => struct.open && Enum.map(struct.open, &encode_open_element/1),
5050 }
5151 end
Mschema-elixir/test/inputs/schema/renaming-bug.schema/default/QuickType.ex+35 −35
@@ -70,19 +70,19 @@ defmodule CircularShape do
7070 end
7171
7272 defmodule Part do
73- defstruct [:depth, :length, :width]
73+ defstruct [:length, :width, :depth]
7474
7575 @type t :: %__MODULE__{
76- depth: String.t() | nil,
7776 length: String.t() | nil,
78- width: String.t() | nil
77+ width: String.t() | nil,
78+ depth: String.t() | nil
7979 }
8080
8181 def from_map(m) do
8282 %Part{
83- depth: m["depth"],
8483 length: m["length"],
8584 width: m["width"],
85+ depth: m["depth"],
8686 }
8787 end
8888
@@ -94,9 +94,9 @@ defmodule Part do
9494
9595 def to_map(struct) do
9696 %{
97- "depth" => struct.depth,
9897 "length" => struct.length,
9998 "width" => struct.width,
99+ "depth" => struct.depth,
100100 }
101101 end
102102
@@ -207,17 +207,17 @@ defmodule History do
207207 end
208208
209209 defmodule Shape do
210- defstruct [:geometry, :history]
210+ defstruct [:history, :geometry]
211211
212212 @type t :: %__MODULE__{
213- geometry: Geometry.t() | nil,
214- history: History.t() | nil
213+ history: History.t() | nil,
214+ geometry: Geometry.t() | nil
215215 }
216216
217217 def from_map(m) do
218218 %Shape{
219- geometry: m["geometry"] && Geometry.from_map(m["geometry"]),
220219 history: m["history"] && History.from_map(m["history"]),
220+ geometry: m["geometry"] && Geometry.from_map(m["geometry"]),
221221 }
222222 end
223223
@@ -229,8 +229,8 @@ defmodule Shape do
229229
230230 def to_map(struct) do
231231 %{
232- "geometry" => struct.geometry && Geometry.to_map(struct.geometry),
233232 "history" => struct.history && History.to_map(struct.history),
233+ "geometry" => struct.geometry && Geometry.to_map(struct.geometry),
234234 }
235235 end
236236
@@ -242,18 +242,18 @@ defmodule Shape do
242242 end
243243
244244 defmodule Berry do
245- defstruct [:color, :name, :shapes]
245+ defstruct [:name, :color, :shapes]
246246
247247 @type t :: %__MODULE__{
248- color: Color.t() | nil,
249248 name: String.t() | nil,
249+ color: Color.t() | nil,
250250 shapes: [Shape.t()] | nil
251251 }
252252
253253 def from_map(m) do
254254 %Berry{
255- color: m["color"] && Color.from_map(m["color"]),
256255 name: m["name"],
256+ color: m["color"] && Color.from_map(m["color"]),
257257 shapes: m["shapes"] && Enum.map(m["shapes"], &Shape.from_map/1),
258258 }
259259 end
@@ -266,8 +266,8 @@ defmodule Berry do
266266
267267 def to_map(struct) do
268268 %{
269- "color" => struct.color && Color.to_map(struct.color),
270269 "name" => struct.name,
270+ "color" => struct.color && Color.to_map(struct.color),
271271 "shapes" => struct.shapes && Enum.map(struct.shapes, &Shape.to_map/1),
272272 }
273273 end
@@ -280,19 +280,19 @@ defmodule Berry do
280280 end
281281
282282 defmodule Fruit do
283- defstruct [:apple, :berries, :orange]
283+ defstruct [:apple, :orange, :berries]
284284
285285 @type t :: %__MODULE__{
286286 apple: boolean() | nil,
287- berries: [Berry.t()] | nil,
288- orange: boolean() | nil
287+ orange: boolean() | nil,
288+ berries: [Berry.t()] | nil
289289 }
290290
291291 def from_map(m) do
292292 %Fruit{
293293 apple: m["apple"],
294- berries: m["berries"] && Enum.map(m["berries"], &Berry.from_map/1),
295294 orange: m["orange"],
295+ berries: m["berries"] && Enum.map(m["berries"], &Berry.from_map/1),
296296 }
297297 end
298298
@@ -305,8 +305,8 @@ defmodule Fruit do
305305 def to_map(struct) do
306306 %{
307307 "apple" => struct.apple,
308- "berries" => struct.berries && Enum.map(struct.berries, &Berry.to_map/1),
309308 "orange" => struct.orange,
309+ "berries" => struct.berries && Enum.map(struct.berries, &Berry.to_map/1),
310310 }
311311 end
312312
@@ -318,17 +318,17 @@ defmodule Fruit do
318318 end
319319
320320 defmodule Limit do
321- defstruct [:maximum, :minimum]
321+ defstruct [:minimum, :maximum]
322322
323323 @type t :: %__MODULE__{
324- maximum: float() | nil,
325- minimum: float() | nil
324+ minimum: float() | nil,
325+ maximum: float() | nil
326326 }
327327
328328 def from_map(m) do
329329 %Limit{
330- maximum: m["maximum"],
331330 minimum: m["minimum"],
331+ maximum: m["maximum"],
332332 }
333333 end
334334
@@ -340,8 +340,8 @@ defmodule Limit do
340340
341341 def to_map(struct) do
342342 %{
343- "maximum" => struct.maximum,
344343 "minimum" => struct.minimum,
344+ "maximum" => struct.maximum,
345345 }
346346 end
347347
@@ -526,25 +526,25 @@ defmodule VehicleType do
526526 end
527527
528528 defmodule Vehicle do
529- defstruct [:brand, :id, :speed, :sub_module, :type, :year]
529+ defstruct [:id, :type, :speed, :year, :brand, :sub_module]
530530
531531 @type t :: %__MODULE__{
532- brand: String.t() | nil,
533532 id: String.t() | nil,
534- speed: Speed.t() | nil,
535- sub_module: boolean() | nil,
536533 type: VehicleType.t() | nil,
537- year: String.t() | nil
534+ speed: Speed.t() | nil,
535+ year: String.t() | nil,
536+ brand: String.t() | nil,
537+ sub_module: boolean() | nil
538538 }
539539
540540 def from_map(m) do
541541 %Vehicle{
542- brand: m["brand"],
543542 id: m["id"],
544- speed: m["speed"] && Speed.from_map(m["speed"]),
545- sub_module: m["subModule"],
546543 type: m["type"] && VehicleType.from_map(m["type"]),
544+ speed: m["speed"] && Speed.from_map(m["speed"]),
547545 year: m["year"],
546+ brand: m["brand"],
547+ sub_module: m["subModule"],
548548 }
549549 end
550550
@@ -556,12 +556,12 @@ defmodule Vehicle do
556556
557557 def to_map(struct) do
558558 %{
559- "brand" => struct.brand,
560559 "id" => struct.id,
561- "speed" => struct.speed && Speed.to_map(struct.speed),
562- "subModule" => struct.sub_module,
563560 "type" => struct.type && VehicleType.to_map(struct.type),
561+ "speed" => struct.speed && Speed.to_map(struct.speed),
564562 "year" => struct.year,
563+ "brand" => struct.brand,
564+ "subModule" => struct.sub_module,
565565 }
566566 end
Mschema-elixir/test/inputs/schema/rust-cycle-breaker-union.schema/default/QuickType.ex+10 −10
@@ -7,11 +7,11 @@
77
88 defmodule NodeClass do
99 @enforce_keys [:value]
10- defstruct [:next, :value]
10+ defstruct [:value, :next]
1111
1212 @type t :: %__MODULE__{
13- next: NodeClass.t() | nil | String.t() | nil,
14- value: String.t()
13+ value: String.t(),
14+ next: NodeClass.t() | nil | String.t() | nil
1515 }
1616
1717 def decode_next(%{"value" => _,} = value), do: NodeClass.from_map(value)
@@ -26,8 +26,8 @@ defmodule NodeClass do
2626
2727 def from_map(m) do
2828 %NodeClass{
29- next: decode_next(m["next"]),
3029 value: m["value"],
30+ next: decode_next(m["next"]),
3131 }
3232 end
3333
@@ -39,8 +39,8 @@ defmodule NodeClass do
3939
4040 def to_map(struct) do
4141 %{
42- "next" => encode_next(struct.next),
4342 "value" => struct.value,
43+ "next" => encode_next(struct.next),
4444 }
4545 end
4646
@@ -53,11 +53,11 @@ end
5353
5454 defmodule TopLevel do
5555 @enforce_keys [:value]
56- defstruct [:next, :value]
56+ defstruct [:value, :next]
5757
5858 @type t :: %__MODULE__{
59- next: NodeClass.t() | nil | String.t() | nil,
60- value: String.t()
59+ value: String.t(),
60+ next: NodeClass.t() | nil | String.t() | nil
6161 }
6262
6363 def decode_next(%{"value" => _,} = value), do: NodeClass.from_map(value)
@@ -72,8 +72,8 @@ defmodule TopLevel do
7272
7373 def from_map(m) do
7474 %TopLevel{
75- next: decode_next(m["next"]),
7675 value: m["value"],
76+ next: decode_next(m["next"]),
7777 }
7878 end
7979
@@ -85,8 +85,8 @@ defmodule TopLevel do
8585
8686 def to_map(struct) do
8787 %{
88- "next" => encode_next(struct.next),
8988 "value" => struct.value,
89+ "next" => encode_next(struct.next),
9090 }
9191 end
Mschema-elixir/test/inputs/schema/uuid.schema/default/QuickType.ex+11 −11
@@ -6,15 +6,15 @@
66 # Encode into a JSON string: TopLevel.to_json(struct)
77
88 defmodule TopLevel do
9- @enforce_keys [:nullable, :one, :union_with_enum]
10- defstruct [:arr_nullable, :arr_one, :nullable, :one, :optional, :union_with_enum]
9+ @enforce_keys [:one, :nullable, :union_with_enum]
10+ defstruct [:one, :optional, :nullable, :arr_one, :arr_nullable, :union_with_enum]
1111
1212 @type t :: %__MODULE__{
13- arr_nullable: [nil | String.t()] | nil,
14- arr_one: [String.t()] | nil,
15- nullable: nil | String.t(),
1613 one: String.t(),
1714 optional: String.t() | nil,
15+ nullable: nil | String.t(),
16+ arr_one: [String.t()] | nil,
17+ arr_nullable: [nil | String.t()] | nil,
1818 union_with_enum: String.t()
1919 }
2020
@@ -28,11 +28,11 @@ defmodule TopLevel do
2828
2929 def from_map(m) do
3030 %TopLevel{
31- arr_nullable: m["arrNullable"] && Enum.map(m["arrNullable"], &decode_arr_nullable_element/1),
32- arr_one: m["arrOne"],
33- nullable: m["nullable"],
3431 one: m["one"],
3532 optional: m["optional"],
33+ nullable: m["nullable"],
34+ arr_one: m["arrOne"],
35+ arr_nullable: m["arrNullable"] && Enum.map(m["arrNullable"], &decode_arr_nullable_element/1),
3636 union_with_enum: m["unionWithEnum"],
3737 }
3838 end
@@ -45,11 +45,11 @@ defmodule TopLevel do
4545
4646 def to_map(struct) do
4747 %{
48- "arrNullable" => struct.arr_nullable && Enum.map(struct.arr_nullable, &encode_arr_nullable_element/1),
49- "arrOne" => struct.arr_one,
50- "nullable" => struct.nullable,
5148 "one" => struct.one,
5249 "optional" => struct.optional,
50+ "nullable" => struct.nullable,
51+ "arrOne" => struct.arr_one,
52+ "arrNullable" => struct.arr_nullable && Enum.map(struct.arr_nullable, &encode_arr_nullable_element/1),
5353 "unionWithEnum" => struct.union_with_enum,
5454 }
5555 end
Mschema-elixir/test/inputs/schema/vega-lite.schema/default/QuickType.ex+40 −40
@@ -602,8 +602,8 @@ defmodule MarkConfig do
602602 - `:dx` - The horizontal offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
603603 - `:dy` - The vertical offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
604604 - `:fill` - Default Fill Color. This has higher precedence than config.color__Default value:__ (None)
605- - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
606605 - `:fill_opacity` - The fill opacity (value between [0,1]).__Default value:__ `1`
606+ - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
607607 - `:font` - The typeface to set the text in (e.g., `"Helvetica Neue"`).
608608 - `:font_size` - The font size, in pixels.
609609 - `:font_style` - The font style (e.g., `"italic"`).
@@ -626,7 +626,7 @@ defmodule MarkConfig do
626626 - `:theta` - Polar coordinate angle, in radians, of the text label from the origin determined by the`x` and `y` properties. Values for `theta` follow the same convention of `arc` mark`startAngle` and `endAngle` properties: angles are measured in radians, with `0`indicating "north".
627627 """
628628
629- defstruct [:align, :angle, :baseline, :color, :cursor, :dx, :dy, :fill, :filled, :fill_opacity, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :tension, :text, :theta]
629+ defstruct [:align, :angle, :baseline, :color, :cursor, :dx, :dy, :fill, :fill_opacity, :filled, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :tension, :text, :theta]
630630
631631 @type t :: %__MODULE__{
632632 align: HorizontalAlign.t() | nil,
@@ -637,8 +637,8 @@ defmodule MarkConfig do
637637 dx: float() | nil,
638638 dy: float() | nil,
639639 fill: String.t() | nil,
640- filled: boolean() | nil,
641640 fill_opacity: float() | nil,
641+ filled: boolean() | nil,
642642 font: String.t() | nil,
643643 font_size: float() | nil,
644644 font_style: FontStyle.t() | nil,
@@ -683,8 +683,8 @@ defmodule MarkConfig do
683683 dx: m["dx"],
684684 dy: m["dy"],
685685 fill: m["fill"],
686- filled: m["filled"],
687686 fill_opacity: m["fillOpacity"],
687+ filled: m["filled"],
688688 font: m["font"],
689689 font_size: m["fontSize"],
690690 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
@@ -724,8 +724,8 @@ defmodule MarkConfig do
724724 "dx" => struct.dx,
725725 "dy" => struct.dy,
726726 "fill" => struct.fill,
727- "filled" => struct.filled,
728727 "fillOpacity" => struct.fill_opacity,
728+ "filled" => struct.filled,
729729 "font" => struct.font,
730730 "fontSize" => struct.font_size,
731731 "fontStyle" => struct.font_style && FontStyle.encode(struct.font_style),
@@ -831,9 +831,9 @@ defmodule AxisConfig do
831831 - `:short_time_labels` - Whether month names and weekday names should be abbreviated.__Default value:__ `false`
832832 - `:tick_color` - The color of the axis's tick.
833833 - `:tick_round` - Boolean flag indicating if pixel position values should be rounded to the nearest integer.
834- - `:ticks` - Boolean value that determines whether the axis should include ticks.
835834 - `:tick_size` - The size in pixels of axis ticks.
836835 - `:tick_width` - The width, in pixels, of ticks.
836+ - `:ticks` - Boolean value that determines whether the axis should include ticks.
837837 - `:title_align` - Horizontal text alignment of axis titles.
838838 - `:title_angle` - Angle in degrees of axis titles.
839839 - `:title_baseline` - Vertical text baseline for axis titles.
@@ -848,7 +848,7 @@ defmodule AxisConfig do
848848 - `:title_y` - Y-coordinate of the axis title relative to the axis group.
849849 """
850850
851- defstruct [:band_position, :domain, :domain_color, :domain_width, :grid, :grid_color, :grid_dash, :grid_opacity, :grid_width, :label_angle, :label_bound, :label_color, :label_flush, :label_font, :label_font_size, :label_limit, :label_overlap, :label_padding, :labels, :max_extent, :min_extent, :short_time_labels, :tick_color, :tick_round, :ticks, :tick_size, :tick_width, :title_align, :title_angle, :title_baseline, :title_color, :title_font, :title_font_size, :title_font_weight, :title_limit, :title_max_length, :title_padding, :title_x, :title_y]
851+ defstruct [:band_position, :domain, :domain_color, :domain_width, :grid, :grid_color, :grid_dash, :grid_opacity, :grid_width, :label_angle, :label_bound, :label_color, :label_flush, :label_font, :label_font_size, :label_limit, :label_overlap, :label_padding, :labels, :max_extent, :min_extent, :short_time_labels, :tick_color, :tick_round, :tick_size, :tick_width, :ticks, :title_align, :title_angle, :title_baseline, :title_color, :title_font, :title_font_size, :title_font_weight, :title_limit, :title_max_length, :title_padding, :title_x, :title_y]
852852
853853 @type t :: %__MODULE__{
854854 band_position: float() | nil,
@@ -875,9 +875,9 @@ defmodule AxisConfig do
875875 short_time_labels: boolean() | nil,
876876 tick_color: String.t() | nil,
877877 tick_round: boolean() | nil,
878- ticks: boolean() | nil,
879878 tick_size: float() | nil,
880879 tick_width: float() | nil,
880+ ticks: boolean() | nil,
881881 title_align: String.t() | nil,
882882 title_angle: float() | nil,
883883 title_baseline: String.t() | nil,
@@ -928,9 +928,9 @@ defmodule AxisConfig do
928928 short_time_labels: m["shortTimeLabels"],
929929 tick_color: m["tickColor"],
930930 tick_round: m["tickRound"],
931- ticks: m["ticks"],
932931 tick_size: m["tickSize"],
933932 tick_width: m["tickWidth"],
933+ ticks: m["ticks"],
934934 title_align: m["titleAlign"],
935935 title_angle: m["titleAngle"],
936936 title_baseline: m["titleBaseline"],
@@ -978,9 +978,9 @@ defmodule AxisConfig do
978978 "shortTimeLabels" => struct.short_time_labels,
979979 "tickColor" => struct.tick_color,
980980 "tickRound" => struct.tick_round,
981- "ticks" => struct.ticks,
982981 "tickSize" => struct.tick_size,
983982 "tickWidth" => struct.tick_width,
983+ "ticks" => struct.ticks,
984984 "titleAlign" => struct.title_align,
985985 "titleAngle" => struct.title_angle,
986986 "titleBaseline" => struct.title_baseline,
@@ -1041,9 +1041,9 @@ defmodule VGAxisConfig do
10411041 - `:min_extent` - The minimum extent in pixels that axis ticks and labels should use. This determines aminimum offset value for axis titles.__Default value:__ `30` for y-axis; `undefined` for x-axis.
10421042 - `:tick_color` - The color of the axis's tick.
10431043 - `:tick_round` - Boolean flag indicating if pixel position values should be rounded to the nearest integer.
1044- - `:ticks` - Boolean value that determines whether the axis should include ticks.
10451044 - `:tick_size` - The size in pixels of axis ticks.
10461045 - `:tick_width` - The width, in pixels, of ticks.
1046+ - `:ticks` - Boolean value that determines whether the axis should include ticks.
10471047 - `:title_align` - Horizontal text alignment of axis titles.
10481048 - `:title_angle` - Angle in degrees of axis titles.
10491049 - `:title_baseline` - Vertical text baseline for axis titles.
@@ -1058,7 +1058,7 @@ defmodule VGAxisConfig do
10581058 - `:title_y` - Y-coordinate of the axis title relative to the axis group.
10591059 """
10601060
1061- defstruct [:band_position, :domain, :domain_color, :domain_width, :grid, :grid_color, :grid_dash, :grid_opacity, :grid_width, :label_angle, :label_bound, :label_color, :label_flush, :label_font, :label_font_size, :label_limit, :label_overlap, :label_padding, :labels, :max_extent, :min_extent, :tick_color, :tick_round, :ticks, :tick_size, :tick_width, :title_align, :title_angle, :title_baseline, :title_color, :title_font, :title_font_size, :title_font_weight, :title_limit, :title_max_length, :title_padding, :title_x, :title_y]
1061+ defstruct [:band_position, :domain, :domain_color, :domain_width, :grid, :grid_color, :grid_dash, :grid_opacity, :grid_width, :label_angle, :label_bound, :label_color, :label_flush, :label_font, :label_font_size, :label_limit, :label_overlap, :label_padding, :labels, :max_extent, :min_extent, :tick_color, :tick_round, :tick_size, :tick_width, :ticks, :title_align, :title_angle, :title_baseline, :title_color, :title_font, :title_font_size, :title_font_weight, :title_limit, :title_max_length, :title_padding, :title_x, :title_y]
10621062
10631063 @type t :: %__MODULE__{
10641064 band_position: float() | nil,
@@ -1084,9 +1084,9 @@ defmodule VGAxisConfig do
10841084 min_extent: float() | nil,
10851085 tick_color: String.t() | nil,
10861086 tick_round: boolean() | nil,
1087- ticks: boolean() | nil,
10881087 tick_size: float() | nil,
10891088 tick_width: float() | nil,
1089+ ticks: boolean() | nil,
10901090 title_align: String.t() | nil,
10911091 title_angle: float() | nil,
10921092 title_baseline: String.t() | nil,
@@ -1136,9 +1136,9 @@ defmodule VGAxisConfig do
11361136 min_extent: m["minExtent"],
11371137 tick_color: m["tickColor"],
11381138 tick_round: m["tickRound"],
1139- ticks: m["ticks"],
11401139 tick_size: m["tickSize"],
11411140 tick_width: m["tickWidth"],
1141+ ticks: m["ticks"],
11421142 title_align: m["titleAlign"],
11431143 title_angle: m["titleAngle"],
11441144 title_baseline: m["titleBaseline"],
@@ -1185,9 +1185,9 @@ defmodule VGAxisConfig do
11851185 "minExtent" => struct.min_extent,
11861186 "tickColor" => struct.tick_color,
11871187 "tickRound" => struct.tick_round,
1188- "ticks" => struct.ticks,
11891188 "tickSize" => struct.tick_size,
11901189 "tickWidth" => struct.tick_width,
1190+ "ticks" => struct.ticks,
11911191 "titleAlign" => struct.title_align,
11921192 "titleAngle" => struct.title_angle,
11931193 "titleBaseline" => struct.title_baseline,
@@ -1224,8 +1224,8 @@ defmodule BarConfig do
12241224 - `:dx` - The horizontal offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
12251225 - `:dy` - The vertical offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
12261226 - `:fill` - Default Fill Color. This has higher precedence than config.color__Default value:__ (None)
1227- - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
12281227 - `:fill_opacity` - The fill opacity (value between [0,1]).__Default value:__ `1`
1228+ - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
12291229 - `:font` - The typeface to set the text in (e.g., `"Helvetica Neue"`).
12301230 - `:font_size` - The font size, in pixels.
12311231 - `:font_style` - The font style (e.g., `"italic"`).
@@ -1248,7 +1248,7 @@ defmodule BarConfig do
12481248 - `:theta` - Polar coordinate angle, in radians, of the text label from the origin determined by the`x` and `y` properties. Values for `theta` follow the same convention of `arc` mark`startAngle` and `endAngle` properties: angles are measured in radians, with `0`indicating "north".
12491249 """
12501250
1251- defstruct [:align, :angle, :baseline, :bin_spacing, :color, :continuous_band_size, :cursor, :discrete_band_size, :dx, :dy, :fill, :filled, :fill_opacity, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :tension, :text, :theta]
1251+ defstruct [:align, :angle, :baseline, :bin_spacing, :color, :continuous_band_size, :cursor, :discrete_band_size, :dx, :dy, :fill, :fill_opacity, :filled, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :tension, :text, :theta]
12521252
12531253 @type t :: %__MODULE__{
12541254 align: HorizontalAlign.t() | nil,
@@ -1262,8 +1262,8 @@ defmodule BarConfig do
12621262 dx: float() | nil,
12631263 dy: float() | nil,
12641264 fill: String.t() | nil,
1265- filled: boolean() | nil,
12661265 fill_opacity: float() | nil,
1266+ filled: boolean() | nil,
12671267 font: String.t() | nil,
12681268 font_size: float() | nil,
12691269 font_style: FontStyle.t() | nil,
@@ -1311,8 +1311,8 @@ defmodule BarConfig do
13111311 dx: m["dx"],
13121312 dy: m["dy"],
13131313 fill: m["fill"],
1314- filled: m["filled"],
13151314 fill_opacity: m["fillOpacity"],
1315+ filled: m["filled"],
13161316 font: m["font"],
13171317 font_size: m["fontSize"],
13181318 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
@@ -1355,8 +1355,8 @@ defmodule BarConfig do
13551355 "dx" => struct.dx,
13561356 "dy" => struct.dy,
13571357 "fill" => struct.fill,
1358- "filled" => struct.filled,
13591358 "fillOpacity" => struct.fill_opacity,
1359+ "filled" => struct.filled,
13601360 "font" => struct.font,
13611361 "fontSize" => struct.font_size,
13621362 "fontStyle" => struct.font_style && FontStyle.encode(struct.font_style),
@@ -2879,8 +2879,8 @@ defmodule TextConfig do
28792879 - `:dx` - The horizontal offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
28802880 - `:dy` - The vertical offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
28812881 - `:fill` - Default Fill Color. This has higher precedence than config.color__Default value:__ (None)
2882- - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
28832882 - `:fill_opacity` - The fill opacity (value between [0,1]).__Default value:__ `1`
2883+ - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
28842884 - `:font` - The typeface to set the text in (e.g., `"Helvetica Neue"`).
28852885 - `:font_size` - The font size, in pixels.
28862886 - `:font_style` - The font style (e.g., `"italic"`).
@@ -2904,7 +2904,7 @@ defmodule TextConfig do
29042904 - `:theta` - Polar coordinate angle, in radians, of the text label from the origin determined by the`x` and `y` properties. Values for `theta` follow the same convention of `arc` mark`startAngle` and `endAngle` properties: angles are measured in radians, with `0`indicating "north".
29052905 """
29062906
2907- defstruct [:align, :angle, :baseline, :color, :cursor, :dx, :dy, :fill, :filled, :fill_opacity, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :short_time_labels, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :tension, :text, :theta]
2907+ defstruct [:align, :angle, :baseline, :color, :cursor, :dx, :dy, :fill, :fill_opacity, :filled, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :short_time_labels, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :tension, :text, :theta]
29082908
29092909 @type t :: %__MODULE__{
29102910 align: HorizontalAlign.t() | nil,
@@ -2915,8 +2915,8 @@ defmodule TextConfig do
29152915 dx: float() | nil,
29162916 dy: float() | nil,
29172917 fill: String.t() | nil,
2918- filled: boolean() | nil,
29192918 fill_opacity: float() | nil,
2919+ filled: boolean() | nil,
29202920 font: String.t() | nil,
29212921 font_size: float() | nil,
29222922 font_style: FontStyle.t() | nil,
@@ -2962,8 +2962,8 @@ defmodule TextConfig do
29622962 dx: m["dx"],
29632963 dy: m["dy"],
29642964 fill: m["fill"],
2965- filled: m["filled"],
29662965 fill_opacity: m["fillOpacity"],
2966+ filled: m["filled"],
29672967 font: m["font"],
29682968 font_size: m["fontSize"],
29692969 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
@@ -3004,8 +3004,8 @@ defmodule TextConfig do
30043004 "dx" => struct.dx,
30053005 "dy" => struct.dy,
30063006 "fill" => struct.fill,
3007- "filled" => struct.filled,
30083007 "fillOpacity" => struct.fill_opacity,
3008+ "filled" => struct.filled,
30093009 "font" => struct.font,
30103010 "fontSize" => struct.font_size,
30113011 "fontStyle" => struct.font_style && FontStyle.encode(struct.font_style),
@@ -3049,8 +3049,8 @@ defmodule TickConfig do
30493049 - `:dx` - The horizontal offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
30503050 - `:dy` - The vertical offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
30513051 - `:fill` - Default Fill Color. This has higher precedence than config.color__Default value:__ (None)
3052- - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
30533052 - `:fill_opacity` - The fill opacity (value between [0,1]).__Default value:__ `1`
3053+ - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
30543054 - `:font` - The typeface to set the text in (e.g., `"Helvetica Neue"`).
30553055 - `:font_size` - The font size, in pixels.
30563056 - `:font_style` - The font style (e.g., `"italic"`).
@@ -3074,7 +3074,7 @@ defmodule TickConfig do
30743074 - `:thickness` - Thickness of the tick mark.__Default value:__ `1`
30753075 """
30763076
3077- defstruct [:align, :angle, :band_size, :baseline, :color, :cursor, :dx, :dy, :fill, :filled, :fill_opacity, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :tension, :text, :theta, :thickness]
3077+ defstruct [:align, :angle, :band_size, :baseline, :color, :cursor, :dx, :dy, :fill, :fill_opacity, :filled, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :tension, :text, :theta, :thickness]
30783078
30793079 @type t :: %__MODULE__{
30803080 align: HorizontalAlign.t() | nil,
@@ -3086,8 +3086,8 @@ defmodule TickConfig do
30863086 dx: float() | nil,
30873087 dy: float() | nil,
30883088 fill: String.t() | nil,
3089- filled: boolean() | nil,
30903089 fill_opacity: float() | nil,
3090+ filled: boolean() | nil,
30913091 font: String.t() | nil,
30923092 font_size: float() | nil,
30933093 font_style: FontStyle.t() | nil,
@@ -3134,8 +3134,8 @@ defmodule TickConfig do
31343134 dx: m["dx"],
31353135 dy: m["dy"],
31363136 fill: m["fill"],
3137- filled: m["filled"],
31383137 fill_opacity: m["fillOpacity"],
3138+ filled: m["filled"],
31393139 font: m["font"],
31403140 font_size: m["fontSize"],
31413141 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
@@ -3177,8 +3177,8 @@ defmodule TickConfig do
31773177 "dx" => struct.dx,
31783178 "dy" => struct.dy,
31793179 "fill" => struct.fill,
3180- "filled" => struct.filled,
31813180 "fillOpacity" => struct.fill_opacity,
3181+ "filled" => struct.filled,
31823182 "font" => struct.font,
31833183 "fontSize" => struct.font_size,
31843184 "fontStyle" => struct.font_style && FontStyle.encode(struct.font_style),
@@ -6443,8 +6443,8 @@ defmodule Axis do
64436443 - `:orient` - The orientation of the axis. One of `"top"`, `"bottom"`, `"left"` or `"right"`. Theorientation can be used to further specialize the axis type (e.g., a y axis oriented forthe right edge of the chart).__Default value:__ `"bottom"` for x-axes and `"left"` for y-axes.
64446444 - `:position` - The anchor position of the axis in pixels. For x-axis with top or bottom orientation,this sets the axis group x coordinate. For y-axis with left or right orientation, thissets the axis group y coordinate.__Default value__: `0`
64456445 - `:tick_count` - A desired number of ticks, for axes visualizing quantitative scales. The resulting numbermay be different so that values are "nice" (multiples of 2, 5, 10) and lie within theunderlying scale's range.
6446- - `:ticks` - Boolean value that determines whether the axis should include ticks.
64476446 - `:tick_size` - The size in pixels of axis ticks.
6447+ - `:ticks` - Boolean value that determines whether the axis should include ticks.
64486448 - `:title` - A title for the field. If `null`, the title will be removed.__Default value:__ derived from the field's name and transformation function(`aggregate`, `bin` and `timeUnit`). If the field has an aggregate function, thefunction is displayed as a part of the title (e.g., `"Sum of Profit"`). If the field isbinned or has a time unit applied, the applied function will be denoted in parentheses(e.g., `"Profit (binned)"`, `"Transaction Date (year-month)"`). Otherwise, the title issimply the field name.__Note__: You can customize the default field title format by providing the [`fieldTitle`property in the [config](config.html) or [`fieldTitle` function via the `compile`function's options](compile.html#field-title).
64496449 - `:title_max_length` - Max length for axis title if the title is automatically generated from the field'sdescription.
64506450 - `:title_padding` - The padding, in pixels, between title and axis.
@@ -6452,7 +6452,7 @@ defmodule Axis do
64526452 - `:zindex` - A non-positive integer indicating z-index of the axis.If zindex is 0, axes should be drawn behind all chart elements.To put them in front, use `"zindex = 1"`.__Default value:__ `1` (in front of the marks) for actual axis and `0` (behind the marks)for grids.
64536453 """
64546454
6455- defstruct [:domain, :format, :grid, :label_angle, :label_bound, :label_flush, :label_overlap, :label_padding, :labels, :max_extent, :min_extent, :offset, :orient, :position, :tick_count, :ticks, :tick_size, :title, :title_max_length, :title_padding, :values, :zindex]
6455+ defstruct [:domain, :format, :grid, :label_angle, :label_bound, :label_flush, :label_overlap, :label_padding, :labels, :max_extent, :min_extent, :offset, :orient, :position, :tick_count, :tick_size, :ticks, :title, :title_max_length, :title_padding, :values, :zindex]
64566456
64576457 @type t :: %__MODULE__{
64586458 domain: boolean() | nil,
@@ -6470,8 +6470,8 @@ defmodule Axis do
64706470 orient: TitleOrient.t() | nil,
64716471 position: float() | nil,
64726472 tick_count: float() | nil,
6473- ticks: boolean() | nil,
64746473 tick_size: float() | nil,
6474+ ticks: boolean() | nil,
64756475 title: nil | String.t() | nil,
64766476 title_max_length: float() | nil,
64776477 title_padding: float() | nil,
@@ -6516,8 +6516,8 @@ defmodule Axis do
65166516 orient: m["orient"] && TitleOrient.decode(m["orient"]),
65176517 position: m["position"],
65186518 tick_count: m["tickCount"],
6519- ticks: m["ticks"],
65206519 tick_size: m["tickSize"],
6520+ ticks: m["ticks"],
65216521 title: m["title"],
65226522 title_max_length: m["titleMaxLength"],
65236523 title_padding: m["titlePadding"],
@@ -6549,8 +6549,8 @@ defmodule Axis do
65496549 "orient" => struct.orient && TitleOrient.encode(struct.orient),
65506550 "position" => struct.position,
65516551 "tickCount" => struct.tick_count,
6552- "ticks" => struct.ticks,
65536552 "tickSize" => struct.tick_size,
6553+ "ticks" => struct.ticks,
65546554 "title" => struct.title,
65556555 "titleMaxLength" => struct.title_max_length,
65566556 "titlePadding" => struct.title_padding,
@@ -7089,8 +7089,8 @@ defmodule MarkDef do
70897089 - `:dx` - The horizontal offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
70907090 - `:dy` - The vertical offset, in pixels, between the text label and its anchor point. The offsetis applied after rotation by the _angle_ property.
70917091 - `:fill` - Default Fill Color. This has higher precedence than config.color__Default value:__ (None)
7092- - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
70937092 - `:fill_opacity` - The fill opacity (value between [0,1]).__Default value:__ `1`
7093+ - `:filled` - Whether the mark's color should be used as fill color instead of stroke color.__Default value:__ `true` for all marks except `point` and `false` for `point`.__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.__Note:__ This property cannot be used in a [style config](mark.html#style-config).
70947094 - `:font` - The typeface to set the text in (e.g., `"Helvetica Neue"`).
70957095 - `:font_size` - The font size, in pixels.
70967096 - `:font_style` - The font style (e.g., `"italic"`).
@@ -7116,7 +7116,7 @@ defmodule MarkDef do
71167116 """
71177117
71187118 @enforce_keys [:type]
7119- defstruct [:align, :angle, :baseline, :clip, :color, :cursor, :dx, :dy, :fill, :filled, :fill_opacity, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :style, :tension, :text, :theta, :type]
7119+ defstruct [:align, :angle, :baseline, :clip, :color, :cursor, :dx, :dy, :fill, :fill_opacity, :filled, :font, :font_size, :font_style, :font_weight, :href, :interpolate, :limit, :opacity, :orient, :radius, :shape, :size, :stroke, :stroke_dash, :stroke_dash_offset, :stroke_opacity, :stroke_width, :style, :tension, :text, :theta, :type]
71207120
71217121 @type t :: %__MODULE__{
71227122 align: HorizontalAlign.t() | nil,
@@ -7128,8 +7128,8 @@ defmodule MarkDef do
71287128 dx: float() | nil,
71297129 dy: float() | nil,
71307130 fill: String.t() | nil,
7131- filled: boolean() | nil,
71327131 fill_opacity: float() | nil,
7132+ filled: boolean() | nil,
71337133 font: String.t() | nil,
71347134 font_size: float() | nil,
71357135 font_style: FontStyle.t() | nil,
@@ -7187,8 +7187,8 @@ defmodule MarkDef do
71877187 dx: m["dx"],
71887188 dy: m["dy"],
71897189 fill: m["fill"],
7190- filled: m["filled"],
71917190 fill_opacity: m["fillOpacity"],
7191+ filled: m["filled"],
71927192 font: m["font"],
71937193 font_size: m["fontSize"],
71947194 font_style: m["fontStyle"] && FontStyle.decode(m["fontStyle"]),
@@ -7231,8 +7231,8 @@ defmodule MarkDef do
72317231 "dx" => struct.dx,
72327232 "dy" => struct.dy,
72337233 "fill" => struct.fill,
7234- "filled" => struct.filled,
72357234 "fillOpacity" => struct.fill_opacity,
7235+ "filled" => struct.filled,
72367236 "font" => struct.font,
72377237 "fontSize" => struct.font_size,
72387238 "fontStyle" => struct.font_style && FontStyle.encode(struct.font_style),
Mschema-elm/test/inputs/schema/accessors.schema/default/QuickType.elm+6 −6
@@ -25,10 +25,10 @@ import Json.Encode as Jenc
2525 import Dict exposing (Dict)
2626
2727 type alias QuickType =
28- { barre : String
28+ { unionization : Union
2929 , enumerification : Enum
3030 , foo : String
31- , unionization : Union
31+ , barre : String
3232 }
3333
3434 type Enum
@@ -48,18 +48,18 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4848 quickType : Jdec.Decoder QuickType
4949 quickType =
5050 Jdec.succeed QuickType
51- |> Jpipe.required "bar" Jdec.string
51+ |> Jpipe.required "union" union
5252 |> Jpipe.required "enum" enum
5353 |> Jpipe.required "foo" Jdec.string
54- |> Jpipe.required "union" union
54+ |> Jpipe.required "bar" Jdec.string
5555
5656 encodeQuickType : QuickType -> Jenc.Value
5757 encodeQuickType x =
5858 Jenc.object
59- [ ("bar", Jenc.string x.barre)
59+ [ ("union", encodeUnion x.unionization)
6060 , ("enum", encodeEnum x.enumerification)
6161 , ("foo", Jenc.string x.foo)
62- , ("union", encodeUnion x.unionization)
62+ , ("bar", Jenc.string x.barre)
6363 ]
6464
6565 enum : Jdec.Decoder Enum
Mschema-elm/test/inputs/schema/all-of-additional-properties-false.schema/default/QuickType.elm+3 −3
@@ -27,8 +27,8 @@ import Dict exposing (Dict)
2727 type alias QuickType =
2828 { amount : Float
2929 , frequency : Frequency
30- , description : Maybe String
3130 , quickTypeType : Type
31+ , description : Maybe String
3232 }
3333
3434 type Frequency
@@ -50,16 +50,16 @@ quickType =
5050 Jdec.succeed QuickType
5151 |> Jpipe.required "amount" Jdec.float
5252 |> Jpipe.required "frequency" frequency
53- |> Jpipe.optional "description" (Jdec.nullable Jdec.string) Nothing
5453 |> Jpipe.required "type" purpleType
54+ |> Jpipe.optional "description" (Jdec.nullable Jdec.string) Nothing
5555
5656 encodeQuickType : QuickType -> Jenc.Value
5757 encodeQuickType x =
5858 Jenc.object
5959 [ ("amount", Jenc.float x.amount)
6060 , ("frequency", encodeFrequency x.frequency)
61- , ("description", makeNullableEncoder Jenc.string x.description)
6261 , ("type", encodeType x.quickTypeType)
62+ , ("description", makeNullableEncoder Jenc.string x.description)
6363 ]
6464
6565 frequency : Jdec.Decoder Frequency
Mschema-elm/test/inputs/schema/bool-string.schema/default/QuickType.elm+11 −11
@@ -24,11 +24,11 @@ import Json.Encode as Jenc
2424 import Dict exposing (Dict)
2525
2626 type alias QuickType =
27- { arrNullable : Maybe (List (Maybe String))
28- , arrOne : Maybe (List String)
29- , nullable : Maybe String
30- , one : String
27+ { one : String
3128 , optional : Maybe String
29+ , nullable : Maybe String
30+ , arrOne : Maybe (List String)
31+ , arrNullable : Maybe (List (Maybe String))
3232 , unionWithBool : UnionWithBool
3333 , unionWithBoolAndEnum : UnionWithBool
3434 }
@@ -45,22 +45,22 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4545 quickType : Jdec.Decoder QuickType
4646 quickType =
4747 Jdec.succeed QuickType
48- |> Jpipe.optional "arrNullable" (Jdec.nullable (Jdec.list (Jdec.nullable Jdec.string))) Nothing
49- |> Jpipe.optional "arrOne" (Jdec.nullable (Jdec.list Jdec.string)) Nothing
50- |> Jpipe.optional "nullable" (Jdec.nullable Jdec.string) Nothing
5148 |> Jpipe.required "one" Jdec.string
5249 |> Jpipe.optional "optional" (Jdec.nullable Jdec.string) Nothing
50+ |> Jpipe.optional "nullable" (Jdec.nullable Jdec.string) Nothing
51+ |> Jpipe.optional "arrOne" (Jdec.nullable (Jdec.list Jdec.string)) Nothing
52+ |> Jpipe.optional "arrNullable" (Jdec.nullable (Jdec.list (Jdec.nullable Jdec.string))) Nothing
5353 |> Jpipe.required "unionWithBool" unionWithBool
5454 |> Jpipe.required "unionWithBoolAndEnum" unionWithBool
5555
5656 encodeQuickType : QuickType -> Jenc.Value
5757 encodeQuickType x =
5858 Jenc.object
59- [ ("arrNullable", makeNullableEncoder (Jenc.list (makeNullableEncoder Jenc.string)) x.arrNullable)
60- , ("arrOne", makeNullableEncoder (Jenc.list Jenc.string) x.arrOne)
61- , ("nullable", makeNullableEncoder Jenc.string x.nullable)
62- , ("one", Jenc.string x.one)
59+ [ ("one", Jenc.string x.one)
6360 , ("optional", makeNullableEncoder Jenc.string x.optional)
61+ , ("nullable", makeNullableEncoder Jenc.string x.nullable)
62+ , ("arrOne", makeNullableEncoder (Jenc.list Jenc.string) x.arrOne)
63+ , ("arrNullable", makeNullableEncoder (Jenc.list (makeNullableEncoder Jenc.string)) x.arrNullable)
6464 , ("unionWithBool", encodeUnionWithBool x.unionWithBool)
6565 , ("unionWithBoolAndEnum", encodeUnionWithBool x.unionWithBoolAndEnum)
6666 ]
Mschema-elm/test/inputs/schema/boolean-subschema.schema/default/QuickType.elm+5 −5
@@ -23,9 +23,9 @@ import Json.Encode as Jenc
2323 import Dict exposing (Dict)
2424
2525 type alias QuickType =
26- { disallowed : Maybe Jdec.Value
26+ { foo : String
27+ , disallowed : Maybe Jdec.Value
2728 , empty : List Jdec.Value
28- , foo : String
2929 , impossible : Maybe Jdec.Value
3030 }
3131
@@ -37,17 +37,17 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
3737 quickType : Jdec.Decoder QuickType
3838 quickType =
3939 Jdec.succeed QuickType
40+ |> Jpipe.required "foo" Jdec.string
4041 |> Jpipe.optional "disallowed" (Jdec.nullable Jdec.value) Nothing
4142 |> Jpipe.required "empty" (Jdec.list Jdec.value)
42- |> Jpipe.required "foo" Jdec.string
4343 |> Jpipe.optional "impossible" (Jdec.nullable Jdec.value) Nothing
4444
4545 encodeQuickType : QuickType -> Jenc.Value
4646 encodeQuickType x =
4747 Jenc.object
48- [ ("disallowed", makeNullableEncoder identity x.disallowed)
48+ [ ("foo", Jenc.string x.foo)
49+ , ("disallowed", makeNullableEncoder identity x.disallowed)
4950 , ("empty", Jenc.list identity x.empty)
50- , ("foo", Jenc.string x.foo)
5151 , ("impossible", makeNullableEncoder identity x.impossible)
5252 ]
Mschema-elm/test/inputs/schema/comment-injection.schema/default/QuickType.elm+14 −14
@@ -35,15 +35,6 @@ import Dict exposing (Dict)
3535 }
3636 }
3737
38-trailingBackslash:
39-Ends with a backslash \
40-
41-trailingQuote:
42-Ends with a quote "
43-
44-trailingTripleQuote:
45-Ends with a triple quote """
46-
4738 value:
4839 Property delimiters:
4940 */
@@ -57,12 +48,21 @@ Property delimiters:
5748 }
5849 }
5950 }
51+
52+trailingBackslash:
53+Ends with a backslash \
54+
55+trailingQuote:
56+Ends with a quote "
57+
58+trailingTripleQuote:
59+Ends with a triple quote """
6060 -}
6161 type alias QuickType =
62- { trailingBackslash : Maybe String
62+ { value : String
63+ , trailingBackslash : Maybe String
6364 , trailingQuote : Maybe String
6465 , trailingTripleQuote : Maybe String
65- , value : String
6666 }
6767
6868 -- decoders and encoders
@@ -73,18 +73,18 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
7373 quickType : Jdec.Decoder QuickType
7474 quickType =
7575 Jdec.succeed QuickType
76+ |> Jpipe.required "value" Jdec.string
7677 |> Jpipe.optional "trailingBackslash" (Jdec.nullable Jdec.string) Nothing
7778 |> Jpipe.optional "trailingQuote" (Jdec.nullable Jdec.string) Nothing
7879 |> Jpipe.optional "trailingTripleQuote" (Jdec.nullable Jdec.string) Nothing
79- |> Jpipe.required "value" Jdec.string
8080
8181 encodeQuickType : QuickType -> Jenc.Value
8282 encodeQuickType x =
8383 Jenc.object
84- [ ("trailingBackslash", makeNullableEncoder Jenc.string x.trailingBackslash)
84+ [ ("value", Jenc.string x.value)
85+ , ("trailingBackslash", makeNullableEncoder Jenc.string x.trailingBackslash)
8586 , ("trailingQuote", makeNullableEncoder Jenc.string x.trailingQuote)
8687 , ("trailingTripleQuote", makeNullableEncoder Jenc.string x.trailingTripleQuote)
87- , ("value", Jenc.string x.value)
8888 ]
8989
9090 --- encoder helpers
Mschema-elm/test/inputs/schema/const-non-string.schema/default/QuickType.elm+8 −8
@@ -24,11 +24,11 @@ import Json.Encode as Jenc
2424 import Dict exposing (Dict)
2525
2626 type alias QuickType =
27- { amount : Int
27+ { version : Float
28+ , amount : Int
29+ , ratio : Float
2830 , enabled : Bool
2931 , kind : Kind
30- , ratio : Float
31- , version : Float
3232 }
3333
3434 type Kind
@@ -42,20 +42,20 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4242 quickType : Jdec.Decoder QuickType
4343 quickType =
4444 Jdec.succeed QuickType
45+ |> Jpipe.required "version" Jdec.float
4546 |> Jpipe.required "amount" Jdec.int
47+ |> Jpipe.required "ratio" Jdec.float
4648 |> Jpipe.required "enabled" Jdec.bool
4749 |> Jpipe.required "kind" kind
48- |> Jpipe.required "ratio" Jdec.float
49- |> Jpipe.required "version" Jdec.float
5050
5151 encodeQuickType : QuickType -> Jenc.Value
5252 encodeQuickType x =
5353 Jenc.object
54- [ ("amount", Jenc.int x.amount)
54+ [ ("version", Jenc.float x.version)
55+ , ("amount", Jenc.int x.amount)
56+ , ("ratio", Jenc.float x.ratio)
5557 , ("enabled", Jenc.bool x.enabled)
5658 , ("kind", encodeKind x.kind)
57- , ("ratio", Jenc.float x.ratio)
58- , ("version", Jenc.float x.version)
5959 ]
6060
6161 kind : Jdec.Decoder Kind
Mschema-elm/test/inputs/schema/date-time-or-string.schema/default/QuickType.elm+5 −5
@@ -23,8 +23,8 @@ import Json.Encode as Jenc
2323 import Dict exposing (Dict)
2424
2525 type alias QuickType =
26- { bar : String
27- , foo : String
26+ { foo : String
27+ , bar : String
2828 }
2929
3030 -- decoders and encoders
@@ -35,14 +35,14 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
3535 quickType : Jdec.Decoder QuickType
3636 quickType =
3737 Jdec.succeed QuickType
38- |> Jpipe.required "bar" Jdec.string
3938 |> Jpipe.required "foo" Jdec.string
39+ |> Jpipe.required "bar" Jdec.string
4040
4141 encodeQuickType : QuickType -> Jenc.Value
4242 encodeQuickType x =
4343 Jenc.object
44- [ ("bar", Jenc.string x.bar)
45- , ("foo", Jenc.string x.foo)
44+ [ ("foo", Jenc.string x.foo)
45+ , ("bar", Jenc.string x.bar)
4646 ]
4747
4848 --- encoder helpers
Mschema-elm/test/inputs/schema/date-time.schema/default/QuickType.elm+8 −8
@@ -24,11 +24,11 @@ import Json.Encode as Jenc
2424 import Dict exposing (Dict)
2525
2626 type alias QuickType =
27- { complexUnionArray : List ComplexUnionArray
28- , date : String
29- , dateTime : String
27+ { date : String
3028 , time : String
29+ , dateTime : String
3130 , unionArray : List String
31+ , complexUnionArray : List ComplexUnionArray
3232 }
3333
3434 type ComplexUnionArray
@@ -43,20 +43,20 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4343 quickType : Jdec.Decoder QuickType
4444 quickType =
4545 Jdec.succeed QuickType
46- |> Jpipe.required "complex-union-array" (Jdec.list complexUnionArray)
4746 |> Jpipe.required "date" Jdec.string
48- |> Jpipe.required "date-time" Jdec.string
4947 |> Jpipe.required "time" Jdec.string
48+ |> Jpipe.required "date-time" Jdec.string
5049 |> Jpipe.required "union-array" (Jdec.list Jdec.string)
50+ |> Jpipe.required "complex-union-array" (Jdec.list complexUnionArray)
5151
5252 encodeQuickType : QuickType -> Jenc.Value
5353 encodeQuickType x =
5454 Jenc.object
55- [ ("complex-union-array", Jenc.list encodeComplexUnionArray x.complexUnionArray)
56- , ("date", Jenc.string x.date)
57- , ("date-time", Jenc.string x.dateTime)
55+ [ ("date", Jenc.string x.date)
5856 , ("time", Jenc.string x.time)
57+ , ("date-time", Jenc.string x.dateTime)
5958 , ("union-array", Jenc.list Jenc.string x.unionArray)
59+ , ("complex-union-array", Jenc.list encodeComplexUnionArray x.complexUnionArray)
6060 ]
6161
6262 complexUnionArray : Jdec.Decoder ComplexUnionArray
Mschema-elm/test/inputs/schema/description.schema/default/QuickType.elm+10 −10
@@ -29,21 +29,21 @@ import Dict exposing (Dict)
2929 {-| The top-level class.
3030 Its description has two lines.
3131
32-bar:
33-A pretty boolean
32+union:
33+Either a number or a string
3434
3535 enum:
3636 An enumeration
3737
38-union:
39-Either a number or a string
38+bar:
39+A pretty boolean
4040 -}
4141 type alias QuickType =
42- { bar : Maybe Bool
42+ { union : Union
4343 , enum : Enum
4444 , foo : Maybe Float
45+ , bar : Maybe Bool
4546 , objectOrString : ObjectOrStringUnion
46- , union : Union
4747 }
4848
4949 {-| An enumeration -}
@@ -77,20 +77,20 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
7777 quickType : Jdec.Decoder QuickType
7878 quickType =
7979 Jdec.succeed QuickType
80- |> Jpipe.optional "bar" (Jdec.nullable Jdec.bool) Nothing
80+ |> Jpipe.required "union" union
8181 |> Jpipe.required "enum" enum
8282 |> Jpipe.optional "foo" (Jdec.nullable Jdec.float) Nothing
83+ |> Jpipe.optional "bar" (Jdec.nullable Jdec.bool) Nothing
8384 |> Jpipe.required "object-or-string" objectOrStringUnion
84- |> Jpipe.required "union" union
8585
8686 encodeQuickType : QuickType -> Jenc.Value
8787 encodeQuickType x =
8888 Jenc.object
89- [ ("bar", makeNullableEncoder Jenc.bool x.bar)
89+ [ ("union", encodeUnion x.union)
9090 , ("enum", encodeEnum x.enum)
9191 , ("foo", makeNullableEncoder Jenc.float x.foo)
92+ , ("bar", makeNullableEncoder Jenc.bool x.bar)
9293 , ("object-or-string", encodeObjectOrStringUnion x.objectOrString)
93- , ("union", encodeUnion x.union)
9494 ]
9595
9696 enum : Jdec.Decoder Enum
Mschema-elm/test/inputs/schema/direct-union.schema/default/QuickType.elm+5 −5
@@ -29,8 +29,8 @@ type alias QuickType =
2929 }
3030
3131 type alias Thing =
32- { optional : Maybe Anything
33- , required : Anything
32+ { required : Anything
33+ , optional : Maybe Anything
3434 }
3535
3636 type Anything
@@ -61,14 +61,14 @@ encodeQuickType x =
6161 thing : Jdec.Decoder Thing
6262 thing =
6363 Jdec.succeed Thing
64- |> Jpipe.optional "optional" (Jdec.nullable anything) Nothing
6564 |> Jpipe.required "required" anything
65+ |> Jpipe.optional "optional" (Jdec.nullable anything) Nothing
6666
6767 encodeThing : Thing -> Jenc.Value
6868 encodeThing x =
6969 Jenc.object
70- [ ("optional", makeNullableEncoder encodeAnything x.optional)
71- , ("required", encodeAnything x.required)
70+ [ ("required", encodeAnything x.required)
71+ , ("optional", makeNullableEncoder encodeAnything x.optional)
7272 ]
7373
7474 anything : Jdec.Decoder Anything
Mschema-elm/test/inputs/schema/enum.schema/default/QuickType.elm+9 −9
@@ -27,11 +27,11 @@ import Json.Encode as Jenc
2727 import Dict exposing (Dict)
2828
2929 type alias QuickType =
30- { arr : Maybe (List Arr)
31- , for : Maybe String
30+ { lvc : Maybe Lvc
3231 , gve : Gve
33- , lvc : Maybe Lvc
32+ , arr : Maybe (List Arr)
3433 , otherArr : Maybe (List OtherArr)
34+ , for : Maybe String
3535 }
3636
3737 type Arr
@@ -61,20 +61,20 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
6161 quickType : Jdec.Decoder QuickType
6262 quickType =
6363 Jdec.succeed QuickType
64- |> Jpipe.optional "arr" (Jdec.nullable (Jdec.list arr)) Nothing
65- |> Jpipe.optional "for" (Jdec.nullable Jdec.string) Nothing
66- |> Jpipe.required "gve" gve
6764 |> Jpipe.optional "lvc" (Jdec.nullable lvc) Nothing
65+ |> Jpipe.required "gve" gve
66+ |> Jpipe.optional "arr" (Jdec.nullable (Jdec.list arr)) Nothing
6867 |> Jpipe.optional "otherArr" (Jdec.nullable (Jdec.list otherArr)) Nothing
68+ |> Jpipe.optional "for" (Jdec.nullable Jdec.string) Nothing
6969
7070 encodeQuickType : QuickType -> Jenc.Value
7171 encodeQuickType x =
7272 Jenc.object
73- [ ("arr", makeNullableEncoder (Jenc.list encodeArr) x.arr)
74- , ("for", makeNullableEncoder Jenc.string x.for)
73+ [ ("lvc", makeNullableEncoder encodeLvc x.lvc)
7574 , ("gve", encodeGve x.gve)
76- , ("lvc", makeNullableEncoder encodeLvc x.lvc)
75+ , ("arr", makeNullableEncoder (Jenc.list encodeArr) x.arr)
7776 , ("otherArr", makeNullableEncoder (Jenc.list encodeOtherArr) x.otherArr)
77+ , ("for", makeNullableEncoder Jenc.string x.for)
7878 ]
7979
8080 arr : Jdec.Decoder Arr
Mschema-elm/test/inputs/schema/integer-string.schema/default/QuickType.elm+11 −11
@@ -24,11 +24,11 @@ import Json.Encode as Jenc
2424 import Dict exposing (Dict)
2525
2626 type alias QuickType =
27- { arrNullable : Maybe (List (Maybe String))
28- , arrOne : Maybe (List String)
29- , nullable : Maybe String
30- , one : String
27+ { one : String
3128 , optional : Maybe String
29+ , nullable : Maybe String
30+ , arrOne : Maybe (List String)
31+ , arrNullable : Maybe (List (Maybe String))
3232 , unionWithInt : UnionWithInt
3333 , unionWithIntAndEnum : UnionWithInt
3434 }
@@ -45,22 +45,22 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4545 quickType : Jdec.Decoder QuickType
4646 quickType =
4747 Jdec.succeed QuickType
48- |> Jpipe.optional "arrNullable" (Jdec.nullable (Jdec.list (Jdec.nullable Jdec.string))) Nothing
49- |> Jpipe.optional "arrOne" (Jdec.nullable (Jdec.list Jdec.string)) Nothing
50- |> Jpipe.optional "nullable" (Jdec.nullable Jdec.string) Nothing
5148 |> Jpipe.required "one" Jdec.string
5249 |> Jpipe.optional "optional" (Jdec.nullable Jdec.string) Nothing
50+ |> Jpipe.optional "nullable" (Jdec.nullable Jdec.string) Nothing
51+ |> Jpipe.optional "arrOne" (Jdec.nullable (Jdec.list Jdec.string)) Nothing
52+ |> Jpipe.optional "arrNullable" (Jdec.nullable (Jdec.list (Jdec.nullable Jdec.string))) Nothing
5353 |> Jpipe.required "unionWithInt" unionWithInt
5454 |> Jpipe.required "unionWithIntAndEnum" unionWithInt
5555
5656 encodeQuickType : QuickType -> Jenc.Value
5757 encodeQuickType x =
5858 Jenc.object
59- [ ("arrNullable", makeNullableEncoder (Jenc.list (makeNullableEncoder Jenc.string)) x.arrNullable)
60- , ("arrOne", makeNullableEncoder (Jenc.list Jenc.string) x.arrOne)
61- , ("nullable", makeNullableEncoder Jenc.string x.nullable)
62- , ("one", Jenc.string x.one)
59+ [ ("one", Jenc.string x.one)
6360 , ("optional", makeNullableEncoder Jenc.string x.optional)
61+ , ("nullable", makeNullableEncoder Jenc.string x.nullable)
62+ , ("arrOne", makeNullableEncoder (Jenc.list Jenc.string) x.arrOne)
63+ , ("arrNullable", makeNullableEncoder (Jenc.list (makeNullableEncoder Jenc.string)) x.arrNullable)
6464 , ("unionWithInt", encodeUnionWithInt x.unionWithInt)
6565 , ("unionWithIntAndEnum", encodeUnionWithInt x.unionWithIntAndEnum)
6666 ]
Mschema-elm/test/inputs/schema/integer-type.schema/default/QuickType.elm+17 −17
@@ -23,15 +23,15 @@ import Json.Encode as Jenc
2323 import Dict exposing (Dict)
2424
2525 type alias QuickType =
26- { aboveI32Max : Int
27- , belowI32Min : Int
26+ { smallPositive : Int
27+ , smallNegative : Int
2828 , i32Range : Int
29- , largeBounds : Int
30- , onlyMaximum : Int
29+ , aboveI32Max : Int
30+ , belowI32Min : Int
3131 , onlyMinimum : Int
32- , smallNegative : Int
33- , smallPositive : Int
32+ , onlyMaximum : Int
3433 , unbounded : Int
34+ , largeBounds : Int
3535 }
3636
3737 -- decoders and encoders
@@ -42,28 +42,28 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4242 quickType : Jdec.Decoder QuickType
4343 quickType =
4444 Jdec.succeed QuickType
45+ |> Jpipe.required "small_positive" Jdec.int
46+ |> Jpipe.required "small_negative" Jdec.int
47+ |> Jpipe.required "i32_range" Jdec.int
4548 |> Jpipe.required "above_i32_max" Jdec.int
4649 |> Jpipe.required "below_i32_min" Jdec.int
47- |> Jpipe.required "i32_range" Jdec.int
48- |> Jpipe.required "large_bounds" Jdec.int
49- |> Jpipe.required "only_maximum" Jdec.int
5050 |> Jpipe.required "only_minimum" Jdec.int
51- |> Jpipe.required "small_negative" Jdec.int
52- |> Jpipe.required "small_positive" Jdec.int
51+ |> Jpipe.required "only_maximum" Jdec.int
5352 |> Jpipe.required "unbounded" Jdec.int
53+ |> Jpipe.required "large_bounds" Jdec.int
5454
5555 encodeQuickType : QuickType -> Jenc.Value
5656 encodeQuickType x =
5757 Jenc.object
58- [ ("above_i32_max", Jenc.int x.aboveI32Max)
59- , ("below_i32_min", Jenc.int x.belowI32Min)
58+ [ ("small_positive", Jenc.int x.smallPositive)
59+ , ("small_negative", Jenc.int x.smallNegative)
6060 , ("i32_range", Jenc.int x.i32Range)
61- , ("large_bounds", Jenc.int x.largeBounds)
62- , ("only_maximum", Jenc.int x.onlyMaximum)
61+ , ("above_i32_max", Jenc.int x.aboveI32Max)
62+ , ("below_i32_min", Jenc.int x.belowI32Min)
6363 , ("only_minimum", Jenc.int x.onlyMinimum)
64- , ("small_negative", Jenc.int x.smallNegative)
65- , ("small_positive", Jenc.int x.smallPositive)
64+ , ("only_maximum", Jenc.int x.onlyMaximum)
6665 , ("unbounded", Jenc.int x.unbounded)
66+ , ("large_bounds", Jenc.int x.largeBounds)
6767 ]
6868
6969 --- encoder helpers
Mschema-elm/test/inputs/schema/light.schema/default/QuickType.elm+5 −5
@@ -28,8 +28,8 @@ type alias QuickType =
2828 }
2929
3030 type alias LightParams =
31- { appID : String
32- , outletID : String
31+ { outletID : String
32+ , appID : String
3333 , rgba : String
3434 }
3535
@@ -52,15 +52,15 @@ encodeQuickType x =
5252 lightParams : Jdec.Decoder LightParams
5353 lightParams =
5454 Jdec.succeed LightParams
55- |> Jpipe.required "app_id" Jdec.string
5655 |> Jpipe.required "outlet_id" Jdec.string
56+ |> Jpipe.required "app_id" Jdec.string
5757 |> Jpipe.required "rgba" Jdec.string
5858
5959 encodeLightParams : LightParams -> Jenc.Value
6060 encodeLightParams x =
6161 Jenc.object
62- [ ("app_id", Jenc.string x.appID)
63- , ("outlet_id", Jenc.string x.outletID)
62+ [ ("outlet_id", Jenc.string x.outletID)
63+ , ("app_id", Jenc.string x.appID)
6464 , ("rgba", Jenc.string x.rgba)
6565 ]
Mschema-elm/test/inputs/schema/min-max-items.schema/default/QuickType.elm+5 −5
@@ -24,9 +24,9 @@ import Json.Encode as Jenc
2424 import Dict exposing (Dict)
2525
2626 type alias QuickType =
27- { maxOnly : List Int
27+ { minOnly : List String
28+ , maxOnly : List Int
2829 , minAndMax : List Float
29- , minOnly : List String
3030 , plain : List String
3131 , unionItems : List UnionItem
3232 }
@@ -43,18 +43,18 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4343 quickType : Jdec.Decoder QuickType
4444 quickType =
4545 Jdec.succeed QuickType
46+ |> Jpipe.required "minOnly" (Jdec.list Jdec.string)
4647 |> Jpipe.required "maxOnly" (Jdec.list Jdec.int)
4748 |> Jpipe.required "minAndMax" (Jdec.list Jdec.float)
48- |> Jpipe.required "minOnly" (Jdec.list Jdec.string)
4949 |> Jpipe.required "plain" (Jdec.list Jdec.string)
5050 |> Jpipe.required "unionItems" (Jdec.list unionItem)
5151
5252 encodeQuickType : QuickType -> Jenc.Value
5353 encodeQuickType x =
5454 Jenc.object
55- [ ("maxOnly", Jenc.list Jenc.int x.maxOnly)
55+ [ ("minOnly", Jenc.list Jenc.string x.minOnly)
56+ , ("maxOnly", Jenc.list Jenc.int x.maxOnly)
5657 , ("minAndMax", Jenc.list Jenc.float x.minAndMax)
57- , ("minOnly", Jenc.list Jenc.string x.minOnly)
5858 , ("plain", Jenc.list Jenc.string x.plain)
5959 , ("unionItems", Jenc.list encodeUnionItem x.unionItems)
6060 ]
Mschema-elm/test/inputs/schema/minmax-integer.schema/default/QuickType.elm+12 −12
@@ -24,13 +24,13 @@ import Dict exposing (Dict)
2424
2525 type alias QuickType =
2626 { free : Int
27- , intersection : Int
28- , max : Int
2927 , min : Int
28+ , max : Int
3029 , minmax : Int
31- , minMaxIntersection : Int
32- , minMaxUnion : Int
3330 , union : Int
31+ , minMaxUnion : Int
32+ , intersection : Int
33+ , minMaxIntersection : Int
3434 }
3535
3636 -- decoders and encoders
@@ -42,25 +42,25 @@ quickType : Jdec.Decoder QuickType
4242 quickType =
4343 Jdec.succeed QuickType
4444 |> Jpipe.required "free" Jdec.int
45- |> Jpipe.required "intersection" Jdec.int
46- |> Jpipe.required "max" Jdec.int
4745 |> Jpipe.required "min" Jdec.int
46+ |> Jpipe.required "max" Jdec.int
4847 |> Jpipe.required "minmax" Jdec.int
49- |> Jpipe.required "minMaxIntersection" Jdec.int
50- |> Jpipe.required "minMaxUnion" Jdec.int
5148 |> Jpipe.required "union" Jdec.int
49+ |> Jpipe.required "minMaxUnion" Jdec.int
50+ |> Jpipe.required "intersection" Jdec.int
51+ |> Jpipe.required "minMaxIntersection" Jdec.int
5252
5353 encodeQuickType : QuickType -> Jenc.Value
5454 encodeQuickType x =
5555 Jenc.object
5656 [ ("free", Jenc.int x.free)
57- , ("intersection", Jenc.int x.intersection)
58- , ("max", Jenc.int x.max)
5957 , ("min", Jenc.int x.min)
58+ , ("max", Jenc.int x.max)
6059 , ("minmax", Jenc.int x.minmax)
61- , ("minMaxIntersection", Jenc.int x.minMaxIntersection)
62- , ("minMaxUnion", Jenc.int x.minMaxUnion)
6360 , ("union", Jenc.int x.union)
61+ , ("minMaxUnion", Jenc.int x.minMaxUnion)
62+ , ("intersection", Jenc.int x.intersection)
63+ , ("minMaxIntersection", Jenc.int x.minMaxIntersection)
6464 ]
6565
6666 --- encoder helpers
Mschema-elm/test/inputs/schema/minmax.schema/default/QuickType.elm+12 −12
@@ -24,13 +24,13 @@ import Dict exposing (Dict)
2424
2525 type alias QuickType =
2626 { free : Float
27- , intersection : Float
28- , max : Float
2927 , min : Float
28+ , max : Float
3029 , minmax : Float
31- , minMaxIntersection : Float
32- , minMaxUnion : Float
3330 , union : Float
31+ , minMaxUnion : Float
32+ , intersection : Float
33+ , minMaxIntersection : Float
3434 }
3535
3636 -- decoders and encoders
@@ -42,25 +42,25 @@ quickType : Jdec.Decoder QuickType
4242 quickType =
4343 Jdec.succeed QuickType
4444 |> Jpipe.required "free" Jdec.float
45- |> Jpipe.required "intersection" Jdec.float
46- |> Jpipe.required "max" Jdec.float
4745 |> Jpipe.required "min" Jdec.float
46+ |> Jpipe.required "max" Jdec.float
4847 |> Jpipe.required "minmax" Jdec.float
49- |> Jpipe.required "minMaxIntersection" Jdec.float
50- |> Jpipe.required "minMaxUnion" Jdec.float
5148 |> Jpipe.required "union" Jdec.float
49+ |> Jpipe.required "minMaxUnion" Jdec.float
50+ |> Jpipe.required "intersection" Jdec.float
51+ |> Jpipe.required "minMaxIntersection" Jdec.float
5252
5353 encodeQuickType : QuickType -> Jenc.Value
5454 encodeQuickType x =
5555 Jenc.object
5656 [ ("free", Jenc.float x.free)
57- , ("intersection", Jenc.float x.intersection)
58- , ("max", Jenc.float x.max)
5957 , ("min", Jenc.float x.min)
58+ , ("max", Jenc.float x.max)
6059 , ("minmax", Jenc.float x.minmax)
61- , ("minMaxIntersection", Jenc.float x.minMaxIntersection)
62- , ("minMaxUnion", Jenc.float x.minMaxUnion)
6360 , ("union", Jenc.float x.union)
61+ , ("minMaxUnion", Jenc.float x.minMaxUnion)
62+ , ("intersection", Jenc.float x.intersection)
63+ , ("minMaxIntersection", Jenc.float x.minMaxIntersection)
6464 ]
6565
6666 --- encoder helpers
Mschema-elm/test/inputs/schema/minmaxlength.schema/default/QuickType.elm+15 −15
@@ -24,14 +24,14 @@ import Json.Encode as Jenc
2424 import Dict exposing (Dict)
2525
2626 type alias QuickType =
27- { intersection : String
28- , inUnion : InUnion
27+ { minlength : String
2928 , maxlength : String
30- , minlength : String
31- , minMaxIntersection : String
3229 , minmaxlength : String
33- , minMaxUnion : String
3430 , union : String
31+ , inUnion : InUnion
32+ , minMaxUnion : String
33+ , intersection : String
34+ , minMaxIntersection : String
3535 }
3636
3737 type InUnion
@@ -46,26 +46,26 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4646 quickType : Jdec.Decoder QuickType
4747 quickType =
4848 Jdec.succeed QuickType
49- |> Jpipe.required "intersection" Jdec.string
50- |> Jpipe.required "inUnion" inUnion
51- |> Jpipe.required "maxlength" Jdec.string
5249 |> Jpipe.required "minlength" Jdec.string
53- |> Jpipe.required "minMaxIntersection" Jdec.string
50+ |> Jpipe.required "maxlength" Jdec.string
5451 |> Jpipe.required "minmaxlength" Jdec.string
55- |> Jpipe.required "minMaxUnion" Jdec.string
5652 |> Jpipe.required "union" Jdec.string
53+ |> Jpipe.required "inUnion" inUnion
54+ |> Jpipe.required "minMaxUnion" Jdec.string
55+ |> Jpipe.required "intersection" Jdec.string
56+ |> Jpipe.required "minMaxIntersection" Jdec.string
5757
5858 encodeQuickType : QuickType -> Jenc.Value
5959 encodeQuickType x =
6060 Jenc.object
61- [ ("intersection", Jenc.string x.intersection)
62- , ("inUnion", encodeInUnion x.inUnion)
61+ [ ("minlength", Jenc.string x.minlength)
6362 , ("maxlength", Jenc.string x.maxlength)
64- , ("minlength", Jenc.string x.minlength)
65- , ("minMaxIntersection", Jenc.string x.minMaxIntersection)
6663 , ("minmaxlength", Jenc.string x.minmaxlength)
67- , ("minMaxUnion", Jenc.string x.minMaxUnion)
6864 , ("union", Jenc.string x.union)
65+ , ("inUnion", encodeInUnion x.inUnion)
66+ , ("minMaxUnion", Jenc.string x.minMaxUnion)
67+ , ("intersection", Jenc.string x.intersection)
68+ , ("minMaxIntersection", Jenc.string x.minMaxIntersection)
6969 ]
7070
7171 inUnion : Jdec.Decoder InUnion
Mschema-elm/test/inputs/schema/non-standard-ref.schema/default/QuickType.elm+5 −5
@@ -23,8 +23,8 @@ import Json.Encode as Jenc
2323 import Dict exposing (Dict)
2424
2525 type alias QuickType =
26- { bar : Int
27- , foo : Int
26+ { foo : Int
27+ , bar : Int
2828 , quux : Bool
2929 }
3030
@@ -36,15 +36,15 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
3636 quickType : Jdec.Decoder QuickType
3737 quickType =
3838 Jdec.succeed QuickType
39- |> Jpipe.required "bar" Jdec.int
4039 |> Jpipe.required "foo" Jdec.int
40+ |> Jpipe.required "bar" Jdec.int
4141 |> Jpipe.required "quux" Jdec.bool
4242
4343 encodeQuickType : QuickType -> Jenc.Value
4444 encodeQuickType x =
4545 Jenc.object
46- [ ("bar", Jenc.int x.bar)
47- , ("foo", Jenc.int x.foo)
46+ [ ("foo", Jenc.int x.foo)
47+ , ("bar", Jenc.int x.bar)
4848 , ("quux", Jenc.bool x.quux)
4949 ]
Mschema-elm/test/inputs/schema/nullable-optional-one-of.schema/default/QuickType.elm+5 −5
@@ -24,8 +24,8 @@ import Json.Encode as Jenc
2424 import Dict exposing (Dict)
2525
2626 type alias QuickType =
27- { b : Maybe String
28- , kind : Kind
27+ { kind : Kind
28+ , b : Maybe String
2929 }
3030
3131 type Kind
@@ -40,14 +40,14 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4040 quickType : Jdec.Decoder QuickType
4141 quickType =
4242 Jdec.succeed QuickType
43- |> Jpipe.optional "b" (Jdec.nullable Jdec.string) Nothing
4443 |> Jpipe.required "kind" kind
44+ |> Jpipe.optional "b" (Jdec.nullable Jdec.string) Nothing
4545
4646 encodeQuickType : QuickType -> Jenc.Value
4747 encodeQuickType x =
4848 Jenc.object
49- [ ("b", makeNullableEncoder Jenc.string x.b)
50- , ("kind", encodeKind x.kind)
49+ [ ("kind", encodeKind x.kind)
50+ , ("b", makeNullableEncoder Jenc.string x.b)
5151 ]
5252
5353 kind : Jdec.Decoder Kind
Mschema-elm/test/inputs/schema/optional-any.schema/default/QuickType.elm+5 −5
@@ -23,8 +23,8 @@ import Json.Encode as Jenc
2323 import Dict exposing (Dict)
2424
2525 type alias QuickType =
26- { bar : Bool
27- , foo : Maybe Jdec.Value
26+ { foo : Maybe Jdec.Value
27+ , bar : Bool
2828 }
2929
3030 -- decoders and encoders
@@ -35,14 +35,14 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
3535 quickType : Jdec.Decoder QuickType
3636 quickType =
3737 Jdec.succeed QuickType
38- |> Jpipe.required "bar" Jdec.bool
3938 |> Jpipe.optional "foo" (Jdec.nullable Jdec.value) Nothing
39+ |> Jpipe.required "bar" Jdec.bool
4040
4141 encodeQuickType : QuickType -> Jenc.Value
4242 encodeQuickType x =
4343 Jenc.object
44- [ ("bar", Jenc.bool x.bar)
45- , ("foo", makeNullableEncoder identity x.foo)
44+ [ ("foo", makeNullableEncoder identity x.foo)
45+ , ("bar", Jenc.bool x.bar)
4646 ]
4747
4848 --- encoder helpers
Mschema-elm/test/inputs/schema/optional-const-ref.schema/default/QuickType.elm+9 −9
@@ -25,12 +25,12 @@ import Dict exposing (Dict)
2525
2626 type alias QuickType =
2727 { coordinates : Maybe (List Coordinate)
28- , count : Maybe Int
29- , label : Maybe String
3028 , requiredCoordinates : List Coordinate
29+ , count : Maybe Int
3130 , requiredCount : Int
32- , requiredLabel : String
3331 , weight : Maybe Float
32+ , label : Maybe String
33+ , requiredLabel : String
3434 }
3535
3636 type alias Coordinate =
@@ -47,23 +47,23 @@ quickType : Jdec.Decoder QuickType
4747 quickType =
4848 Jdec.succeed QuickType
4949 |> Jpipe.optional "coordinates" (Jdec.nullable (Jdec.list coordinate)) Nothing
50- |> Jpipe.optional "count" (Jdec.nullable Jdec.int) Nothing
51- |> Jpipe.optional "label" (Jdec.nullable Jdec.string) Nothing
5250 |> Jpipe.required "requiredCoordinates" (Jdec.list coordinate)
51+ |> Jpipe.optional "count" (Jdec.nullable Jdec.int) Nothing
5352 |> Jpipe.required "requiredCount" Jdec.int
54- |> Jpipe.required "requiredLabel" Jdec.string
5553 |> Jpipe.optional "weight" (Jdec.nullable Jdec.float) Nothing
54+ |> Jpipe.optional "label" (Jdec.nullable Jdec.string) Nothing
55+ |> Jpipe.required "requiredLabel" Jdec.string
5656
5757 encodeQuickType : QuickType -> Jenc.Value
5858 encodeQuickType x =
5959 Jenc.object
6060 [ ("coordinates", makeNullableEncoder (Jenc.list encodeCoordinate) x.coordinates)
61- , ("count", makeNullableEncoder Jenc.int x.count)
62- , ("label", makeNullableEncoder Jenc.string x.label)
6361 , ("requiredCoordinates", Jenc.list encodeCoordinate x.requiredCoordinates)
62+ , ("count", makeNullableEncoder Jenc.int x.count)
6463 , ("requiredCount", Jenc.int x.requiredCount)
65- , ("requiredLabel", Jenc.string x.requiredLabel)
6664 , ("weight", makeNullableEncoder Jenc.float x.weight)
65+ , ("label", makeNullableEncoder Jenc.string x.label)
66+ , ("requiredLabel", Jenc.string x.requiredLabel)
6767 ]
6868
6969 coordinate : Jdec.Decoder Coordinate
Mschema-elm/test/inputs/schema/optional-constraints.schema/default/QuickType.elm+9 −9
@@ -23,11 +23,11 @@ import Json.Encode as Jenc
2323 import Dict exposing (Dict)
2424
2525 type alias QuickType =
26- { optDouble : Maybe Float
26+ { reqZeroMin : Int
2727 , optInt : Maybe Int
28- , optPattern : Maybe String
28+ , optDouble : Maybe Float
2929 , optString : Maybe String
30- , reqZeroMin : Int
30+ , optPattern : Maybe String
3131 }
3232
3333 -- decoders and encoders
@@ -38,20 +38,20 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
3838 quickType : Jdec.Decoder QuickType
3939 quickType =
4040 Jdec.succeed QuickType
41- |> Jpipe.optional "optDouble" (Jdec.nullable Jdec.float) Nothing
41+ |> Jpipe.required "reqZeroMin" Jdec.int
4242 |> Jpipe.optional "optInt" (Jdec.nullable Jdec.int) Nothing
43- |> Jpipe.optional "optPattern" (Jdec.nullable Jdec.string) Nothing
43+ |> Jpipe.optional "optDouble" (Jdec.nullable Jdec.float) Nothing
4444 |> Jpipe.optional "optString" (Jdec.nullable Jdec.string) Nothing
45- |> Jpipe.required "reqZeroMin" Jdec.int
45+ |> Jpipe.optional "optPattern" (Jdec.nullable Jdec.string) Nothing
4646
4747 encodeQuickType : QuickType -> Jenc.Value
4848 encodeQuickType x =
4949 Jenc.object
50- [ ("optDouble", makeNullableEncoder Jenc.float x.optDouble)
50+ [ ("reqZeroMin", Jenc.int x.reqZeroMin)
5151 , ("optInt", makeNullableEncoder Jenc.int x.optInt)
52- , ("optPattern", makeNullableEncoder Jenc.string x.optPattern)
52+ , ("optDouble", makeNullableEncoder Jenc.float x.optDouble)
5353 , ("optString", makeNullableEncoder Jenc.string x.optString)
54- , ("reqZeroMin", Jenc.int x.reqZeroMin)
54+ , ("optPattern", makeNullableEncoder Jenc.string x.optPattern)
5555 ]
5656
5757 --- encoder helpers
Mschema-elm/test/inputs/schema/optional-date-time.schema/default/QuickType.elm+14 −14
@@ -23,12 +23,12 @@ import Json.Encode as Jenc
2323 import Dict exposing (Dict)
2424
2525 type alias QuickType =
26- { optionalDate : Maybe String
27- , optionalDateTime : Maybe String
28- , optionalTime : Maybe String
29- , requiredDate : String
30- , requiredDateTime : String
26+ { requiredDate : String
3127 , requiredTime : String
28+ , requiredDateTime : String
29+ , optionalDate : Maybe String
30+ , optionalTime : Maybe String
31+ , optionalDateTime : Maybe String
3232 }
3333
3434 -- decoders and encoders
@@ -39,22 +39,22 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
3939 quickType : Jdec.Decoder QuickType
4040 quickType =
4141 Jdec.succeed QuickType
42- |> Jpipe.optional "optional-date" (Jdec.nullable Jdec.string) Nothing
43- |> Jpipe.optional "optional-date-time" (Jdec.nullable Jdec.string) Nothing
44- |> Jpipe.optional "optional-time" (Jdec.nullable Jdec.string) Nothing
4542 |> Jpipe.required "required-date" Jdec.string
46- |> Jpipe.required "required-date-time" Jdec.string
4743 |> Jpipe.required "required-time" Jdec.string
44+ |> Jpipe.required "required-date-time" Jdec.string
45+ |> Jpipe.optional "optional-date" (Jdec.nullable Jdec.string) Nothing
46+ |> Jpipe.optional "optional-time" (Jdec.nullable Jdec.string) Nothing
47+ |> Jpipe.optional "optional-date-time" (Jdec.nullable Jdec.string) Nothing
4848
4949 encodeQuickType : QuickType -> Jenc.Value
5050 encodeQuickType x =
5151 Jenc.object
52- [ ("optional-date", makeNullableEncoder Jenc.string x.optionalDate)
53- , ("optional-date-time", makeNullableEncoder Jenc.string x.optionalDateTime)
54- , ("optional-time", makeNullableEncoder Jenc.string x.optionalTime)
55- , ("required-date", Jenc.string x.requiredDate)
56- , ("required-date-time", Jenc.string x.requiredDateTime)
52+ [ ("required-date", Jenc.string x.requiredDate)
5753 , ("required-time", Jenc.string x.requiredTime)
54+ , ("required-date-time", Jenc.string x.requiredDateTime)
55+ , ("optional-date", makeNullableEncoder Jenc.string x.optionalDate)
56+ , ("optional-time", makeNullableEncoder Jenc.string x.optionalTime)
57+ , ("optional-date-time", makeNullableEncoder Jenc.string x.optionalDateTime)
5858 ]
5959
6060 --- encoder helpers
Mschema-elm/test/inputs/schema/prefix-items.schema/default/QuickType.elm+5 −5
@@ -24,8 +24,8 @@ import Json.Encode as Jenc
2424 import Dict exposing (Dict)
2525
2626 type alias QuickType =
27- { open : List Open
28- , tuple : List Open
27+ { tuple : List Open
28+ , open : List Open
2929 }
3030
3131 type Open
@@ -40,14 +40,14 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
4040 quickType : Jdec.Decoder QuickType
4141 quickType =
4242 Jdec.succeed QuickType
43- |> Jpipe.required "open" (Jdec.list open)
4443 |> Jpipe.required "tuple" (Jdec.list open)
44+ |> Jpipe.required "open" (Jdec.list open)
4545
4646 encodeQuickType : QuickType -> Jenc.Value
4747 encodeQuickType x =
4848 Jenc.object
49- [ ("open", Jenc.list encodeOpen x.open)
50- , ("tuple", Jenc.list encodeOpen x.tuple)
49+ [ ("tuple", Jenc.list encodeOpen x.tuple)
50+ , ("open", Jenc.list encodeOpen x.open)
5151 ]
5252
5353 open : Jdec.Decoder Open
Aschema-elm/test/inputs/schema/property-order.schema/default/QuickType.elm+88 −0
@@ -0,0 +1,88 @@
1+-- To decode the JSON data, add this file to your project, run
2+--
3+-- elm install NoRedInk/elm-json-decode-pipeline
4+--
5+-- add these imports
6+--
7+-- import Json.Decode exposing (decodeString)
8+-- import QuickType exposing (quickType)
9+--
10+-- and you're off to the races with
11+--
12+-- decodeString quickType myJsonString
13+
14+module QuickType exposing
15+ ( QuickType
16+ , quickTypeToString
17+ , quickType
18+ , Ordered
19+ )
20+
21+import Json.Decode as Jdec
22+import Json.Decode.Pipeline as Jpipe
23+import Json.Encode as Jenc
24+import Dict exposing (Dict)
25+
26+type alias QuickType =
27+ { zebra : String
28+ , mango : Float
29+ , apple : Bool
30+ , delta : String
31+ , banana : Int
32+ , ordered : Ordered
33+ }
34+
35+type alias Ordered =
36+ { mango : Float
37+ , zebra : String
38+ , apple : Bool
39+ }
40+
41+-- decoders and encoders
42+
43+quickTypeToString : QuickType -> String
44+quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
45+
46+quickType : Jdec.Decoder QuickType
47+quickType =
48+ Jdec.succeed QuickType
49+ |> Jpipe.required "zebra" Jdec.string
50+ |> Jpipe.required "mango" Jdec.float
51+ |> Jpipe.required "apple" Jdec.bool
52+ |> Jpipe.required "delta" Jdec.string
53+ |> Jpipe.required "banana" Jdec.int
54+ |> Jpipe.required "ordered" ordered
55+
56+encodeQuickType : QuickType -> Jenc.Value
57+encodeQuickType x =
58+ Jenc.object
59+ [ ("zebra", Jenc.string x.zebra)
60+ , ("mango", Jenc.float x.mango)
61+ , ("apple", Jenc.bool x.apple)
62+ , ("delta", Jenc.string x.delta)
63+ , ("banana", Jenc.int x.banana)
64+ , ("ordered", encodeOrdered x.ordered)
65+ ]
66+
67+ordered : Jdec.Decoder Ordered
68+ordered =
69+ Jdec.succeed Ordered
70+ |> Jpipe.required "mango" Jdec.float
71+ |> Jpipe.required "zebra" Jdec.string
72+ |> Jpipe.required "apple" Jdec.bool
73+
74+encodeOrdered : Ordered -> Jenc.Value
75+encodeOrdered x =
76+ Jenc.object
77+ [ ("mango", Jenc.float x.mango)
78+ , ("zebra", Jenc.string x.zebra)
79+ , ("apple", Jenc.bool x.apple)
80+ ]
81+
82+--- encoder helpers
83+
84+makeNullableEncoder : (a -> Jenc.Value) -> Maybe a -> Jenc.Value
85+makeNullableEncoder f m =
86+ case m of
87+ Just x -> f x
88+ Nothing -> Jenc.null
Mschema-elm/test/inputs/schema/renaming-bug.schema/default/QuickType.elm+34 −34
@@ -45,13 +45,13 @@ type alias QuickType =
4545
4646 type alias Fruit =
4747 { apple : Maybe Bool
48- , berries : Maybe (List Berry)
4948 , orange : Maybe Bool
49+ , berries : Maybe (List Berry)
5050 }
5151
5252 type alias Berry =
53- { color : Maybe Color
54- , name : Maybe String
53+ { name : Maybe String
54+ , color : Maybe Color
5555 , shapes : Maybe (List Shape)
5656 }
5757
@@ -60,8 +60,8 @@ type alias Color =
6060 }
6161
6262 type alias Shape =
63- { geometry : Maybe Geometry
64- , history : Maybe History
63+ { history : Maybe History
64+ , geometry : Maybe Geometry
6565 }
6666
6767 type alias Geometry =
@@ -78,9 +78,9 @@ type alias RectShape =
7878 }
7979
8080 type alias Part =
81- { depth : Maybe String
82- , length : Maybe String
81+ { length : Maybe String
8382 , width : Maybe String
83+ , depth : Maybe String
8484 }
8585
8686 type alias History =
@@ -88,12 +88,12 @@ type alias History =
8888 }
8989
9090 type alias Vehicle =
91- { brand : Maybe String
92- , id : Maybe String
93- , speed : Maybe Speed
94- , subModule : Maybe Bool
91+ { id : Maybe String
9592 , vehicleType : Maybe VehicleType
93+ , speed : Maybe Speed
9694 , year : Maybe String
95+ , brand : Maybe String
96+ , subModule : Maybe Bool
9797 }
9898
9999 type alias Speed =
@@ -101,8 +101,8 @@ type alias Speed =
101101 }
102102
103103 type alias Limit =
104- { maximum : Maybe Float
105- , minimum : Maybe Float
104+ { minimum : Maybe Float
105+ , maximum : Maybe Float
106106 }
107107
108108 type alias VehicleType =
@@ -154,29 +154,29 @@ fruit : Jdec.Decoder Fruit
154154 fruit =
155155 Jdec.succeed Fruit
156156 |> Jpipe.optional "apple" (Jdec.nullable Jdec.bool) Nothing
157- |> Jpipe.optional "berries" (Jdec.nullable (Jdec.list berry)) Nothing
158157 |> Jpipe.optional "orange" (Jdec.nullable Jdec.bool) Nothing
158+ |> Jpipe.optional "berries" (Jdec.nullable (Jdec.list berry)) Nothing
159159
160160 encodeFruit : Fruit -> Jenc.Value
161161 encodeFruit x =
162162 Jenc.object
163163 [ ("apple", makeNullableEncoder Jenc.bool x.apple)
164- , ("berries", makeNullableEncoder (Jenc.list encodeBerry) x.berries)
165164 , ("orange", makeNullableEncoder Jenc.bool x.orange)
165+ , ("berries", makeNullableEncoder (Jenc.list encodeBerry) x.berries)
166166 ]
167167
168168 berry : Jdec.Decoder Berry
169169 berry =
170170 Jdec.succeed Berry
171- |> Jpipe.optional "color" (Jdec.nullable color) Nothing
172171 |> Jpipe.optional "name" (Jdec.nullable Jdec.string) Nothing
172+ |> Jpipe.optional "color" (Jdec.nullable color) Nothing
173173 |> Jpipe.optional "shapes" (Jdec.nullable (Jdec.list shape)) Nothing
174174
175175 encodeBerry : Berry -> Jenc.Value
176176 encodeBerry x =
177177 Jenc.object
178- [ ("color", makeNullableEncoder encodeColor x.color)
179- , ("name", makeNullableEncoder Jenc.string x.name)
178+ [ ("name", makeNullableEncoder Jenc.string x.name)
179+ , ("color", makeNullableEncoder encodeColor x.color)
180180 , ("shapes", makeNullableEncoder (Jenc.list encodeShape) x.shapes)
181181 ]
182182
@@ -194,14 +194,14 @@ encodeColor x =
194194 shape : Jdec.Decoder Shape
195195 shape =
196196 Jdec.succeed Shape
197- |> Jpipe.optional "geometry" (Jdec.nullable geometry) Nothing
198197 |> Jpipe.optional "history" (Jdec.nullable history) Nothing
198+ |> Jpipe.optional "geometry" (Jdec.nullable geometry) Nothing
199199
200200 encodeShape : Shape -> Jenc.Value
201201 encodeShape x =
202202 Jenc.object
203- [ ("geometry", makeNullableEncoder encodeGeometry x.geometry)
204- , ("history", makeNullableEncoder encodeHistory x.history)
203+ [ ("history", makeNullableEncoder encodeHistory x.history)
204+ , ("geometry", makeNullableEncoder encodeGeometry x.geometry)
205205 ]
206206
207207 geometry : Jdec.Decoder Geometry
@@ -242,16 +242,16 @@ encodeRectShape x =
242242 part : Jdec.Decoder Part
243243 part =
244244 Jdec.succeed Part
245- |> Jpipe.optional "depth" (Jdec.nullable Jdec.string) Nothing
246245 |> Jpipe.optional "length" (Jdec.nullable Jdec.string) Nothing
247246 |> Jpipe.optional "width" (Jdec.nullable Jdec.string) Nothing
247+ |> Jpipe.optional "depth" (Jdec.nullable Jdec.string) Nothing
248248
249249 encodePart : Part -> Jenc.Value
250250 encodePart x =
251251 Jenc.object
252- [ ("depth", makeNullableEncoder Jenc.string x.depth)
253- , ("length", makeNullableEncoder Jenc.string x.length)
252+ [ ("length", makeNullableEncoder Jenc.string x.length)
254253 , ("width", makeNullableEncoder Jenc.string x.width)
254+ , ("depth", makeNullableEncoder Jenc.string x.depth)
255255 ]
256256
257257 history : Jdec.Decoder History
@@ -268,22 +268,22 @@ encodeHistory x =
268268 vehicle : Jdec.Decoder Vehicle
269269 vehicle =
270270 Jdec.succeed Vehicle
271- |> Jpipe.optional "brand" (Jdec.nullable Jdec.string) Nothing
272271 |> Jpipe.optional "id" (Jdec.nullable Jdec.string) Nothing
273- |> Jpipe.optional "speed" (Jdec.nullable speed) Nothing
274- |> Jpipe.optional "subModule" (Jdec.nullable Jdec.bool) Nothing
275272 |> Jpipe.optional "type" (Jdec.nullable vehicleType) Nothing
273+ |> Jpipe.optional "speed" (Jdec.nullable speed) Nothing
276274 |> Jpipe.optional "year" (Jdec.nullable Jdec.string) Nothing
275+ |> Jpipe.optional "brand" (Jdec.nullable Jdec.string) Nothing
276+ |> Jpipe.optional "subModule" (Jdec.nullable Jdec.bool) Nothing
277277
278278 encodeVehicle : Vehicle -> Jenc.Value
279279 encodeVehicle x =
280280 Jenc.object
281- [ ("brand", makeNullableEncoder Jenc.string x.brand)
282- , ("id", makeNullableEncoder Jenc.string x.id)
283- , ("speed", makeNullableEncoder encodeSpeed x.speed)
284- , ("subModule", makeNullableEncoder Jenc.bool x.subModule)
281+ [ ("id", makeNullableEncoder Jenc.string x.id)
285282 , ("type", makeNullableEncoder encodeVehicleType x.vehicleType)
283+ , ("speed", makeNullableEncoder encodeSpeed x.speed)
286284 , ("year", makeNullableEncoder Jenc.string x.year)
285+ , ("brand", makeNullableEncoder Jenc.string x.brand)
286+ , ("subModule", makeNullableEncoder Jenc.bool x.subModule)
287287 ]
288288
289289 speed : Jdec.Decoder Speed
@@ -300,14 +300,14 @@ encodeSpeed x =
300300 limit : Jdec.Decoder Limit
301301 limit =
302302 Jdec.succeed Limit
303- |> Jpipe.optional "maximum" (Jdec.nullable Jdec.float) Nothing
304303 |> Jpipe.optional "minimum" (Jdec.nullable Jdec.float) Nothing
304+ |> Jpipe.optional "maximum" (Jdec.nullable Jdec.float) Nothing
305305
306306 encodeLimit : Limit -> Jenc.Value
307307 encodeLimit x =
308308 Jenc.object
309- [ ("maximum", makeNullableEncoder Jenc.float x.maximum)
310- , ("minimum", makeNullableEncoder Jenc.float x.minimum)
309+ [ ("minimum", makeNullableEncoder Jenc.float x.minimum)
310+ , ("maximum", makeNullableEncoder Jenc.float x.maximum)
311311 ]
312312
313313 vehicleType : Jdec.Decoder VehicleType
Mschema-elm/test/inputs/schema/uuid.schema/default/QuickType.elm+11 −11
@@ -23,11 +23,11 @@ import Json.Encode as Jenc
2323 import Dict exposing (Dict)
2424
2525 type alias QuickType =
26- { arrNullable : Maybe (List (Maybe String))
27- , arrOne : Maybe (List String)
28- , nullable : Maybe String
29- , one : String
26+ { one : String
3027 , optional : Maybe String
28+ , nullable : Maybe String
29+ , arrOne : Maybe (List String)
30+ , arrNullable : Maybe (List (Maybe String))
3131 , unionWithEnum : String
3232 }
3333
@@ -39,21 +39,21 @@ quickTypeToString r = Jenc.encode 0 (encodeQuickType r)
3939 quickType : Jdec.Decoder QuickType
4040 quickType =
4141 Jdec.succeed QuickType
42- |> Jpipe.optional "arrNullable" (Jdec.nullable (Jdec.list (Jdec.nullable Jdec.string))) Nothing
43- |> Jpipe.optional "arrOne" (Jdec.nullable (Jdec.list Jdec.string)) Nothing
44- |> Jpipe.optional "nullable" (Jdec.nullable Jdec.string) Nothing
4542 |> Jpipe.required "one" Jdec.string
4643 |> Jpipe.optional "optional" (Jdec.nullable Jdec.string) Nothing
44+ |> Jpipe.optional "nullable" (Jdec.nullable Jdec.string) Nothing
45+ |> Jpipe.optional "arrOne" (Jdec.nullable (Jdec.list Jdec.string)) Nothing
46+ |> Jpipe.optional "arrNullable" (Jdec.nullable (Jdec.list (Jdec.nullable Jdec.string))) Nothing
4747 |> Jpipe.required "unionWithEnum" Jdec.string
4848
4949 encodeQuickType : QuickType -> Jenc.Value
5050 encodeQuickType x =
5151 Jenc.object
52- [ ("arrNullable", makeNullableEncoder (Jenc.list (makeNullableEncoder Jenc.string)) x.arrNullable)
53- , ("arrOne", makeNullableEncoder (Jenc.list Jenc.string) x.arrOne)
54- , ("nullable", makeNullableEncoder Jenc.string x.nullable)
55- , ("one", Jenc.string x.one)
52+ [ ("one", Jenc.string x.one)
5653 , ("optional", makeNullableEncoder Jenc.string x.optional)
54+ , ("nullable", makeNullableEncoder Jenc.string x.nullable)
55+ , ("arrOne", makeNullableEncoder (Jenc.list Jenc.string) x.arrOne)
56+ , ("arrNullable", makeNullableEncoder (Jenc.list (makeNullableEncoder Jenc.string)) x.arrNullable)
5757 , ("unionWithEnum", Jenc.string x.unionWithEnum)
5858 ]
Mschema-flow/test/inputs/schema/accessors.schema/default/TopLevel.js+4 −4
@@ -10,10 +10,10 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- bar: string;
13+ union: Union;
1414 enum: Enum;
1515 foo: string;
16- union: Union;
16+ bar: string;
1717 };
1818
1919 export type Enum =
@@ -188,10 +188,10 @@ function r(name: string) {
188188
189189 const typeMap: any = {
190190 "TopLevel": o([
191- { json: "bar", js: "bar", typ: "" },
191+ { json: "union", js: "union", typ: u(true, 3.14) },
192192 { json: "enum", js: "enum", typ: r("Enum") },
193193 { json: "foo", js: "foo", typ: "" },
194- { json: "union", js: "union", typ: u(true, 3.14) },
194+ { json: "bar", js: "bar", typ: "" },
195195 ], false),
196196 "Enum": [
197197 "red",
Mschema-flow/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.js+2 −2
@@ -12,8 +12,8 @@
1212 export type TopLevel = {
1313 amount: number;
1414 frequency: Frequency;
15- description?: string;
1615 type: Type;
16+ description?: string;
1717 };
1818
1919 export type Frequency =
@@ -192,8 +192,8 @@ const typeMap: any = {
192192 "TopLevel": o([
193193 { json: "amount", js: "amount", typ: 3.14 },
194194 { json: "frequency", js: "frequency", typ: r("Frequency") },
195- { json: "description", js: "description", typ: u(undefined, "") },
196195 { json: "type", js: "type", typ: r("Type") },
196+ { json: "description", js: "description", typ: u(undefined, "") },
197197 ], false),
198198 "Frequency": [
199199 "Weekly",
Mschema-flow/test/inputs/schema/bool-string.schema/default/TopLevel.js+6 −6
@@ -10,11 +10,11 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- arrNullable?: (null | string)[];
14- arrOne?: string[];
15- nullable: null | string;
1613 one: string;
1714 optional?: string;
15+ nullable: null | string;
16+ arrOne?: string[];
17+ arrNullable?: (null | string)[];
1818 unionWithBool: UnionWithBool;
1919 unionWithBoolAndEnum: UnionWithBool;
2020 [property: string]: mixed;
@@ -187,11 +187,11 @@ function r(name: string) {
187187
188188 const typeMap: any = {
189189 "TopLevel": o([
190- { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
191- { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
192- { json: "nullable", js: "nullable", typ: u(null, "") },
193190 { json: "one", js: "one", typ: "" },
194191 { json: "optional", js: "optional", typ: u(undefined, "") },
192+ { json: "nullable", js: "nullable", typ: u(null, "") },
193+ { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
194+ { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
195195 { json: "unionWithBool", js: "unionWithBool", typ: u(true, "") },
196196 { json: "unionWithBoolAndEnum", js: "unionWithBoolAndEnum", typ: u(true, "") },
197197 ], "any"),
Mschema-flow/test/inputs/schema/boolean-subschema.schema/default/TopLevel.js+2 −2
@@ -10,9 +10,9 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13+ foo: string;
1314 disallowed?: mixed;
1415 empty: mixed[];
15- foo: string;
1616 impossible?: mixed;
1717 };
1818
@@ -181,9 +181,9 @@ function r(name: string) {
181181
182182 const typeMap: any = {
183183 "TopLevel": o([
184+ { json: "foo", js: "foo", typ: "" },
184185 { json: "disallowed", js: "disallowed", typ: u(undefined, "any") },
185186 { json: "empty", js: "empty", typ: a("any") },
186- { json: "foo", js: "foo", typ: "" },
187187 { json: "impossible", js: "impossible", typ: u(undefined, "any") },
188188 ], false),
189189 };
Mschema-flow/test/inputs/schema/comment-injection.schema/default/TopLevel.js+13 −13
@@ -24,18 +24,6 @@
2424 * }
2525 */
2626 export type TopLevel = {
27- /**
28- * Ends with a backslash \
29- */
30- trailingBackslash?: string;
31- /**
32- * Ends with a quote "
33- */
34- trailingQuote?: string;
35- /**
36- * Ends with a triple quote """
37- */
38- trailingTripleQuote?: string;
3927 /**
4028 * Property delimiters:
4129 * * /
@@ -51,6 +39,18 @@ export type TopLevel = {
5139 * }
5240 */
5341 value: string;
42+ /**
43+ * Ends with a backslash \
44+ */
45+ trailingBackslash?: string;
46+ /**
47+ * Ends with a quote "
48+ */
49+ trailingQuote?: string;
50+ /**
51+ * Ends with a triple quote """
52+ */
53+ trailingTripleQuote?: string;
5454 };
5555
5656 // Converts JSON strings to/from your types
@@ -218,10 +218,10 @@ function r(name: string) {
218218
219219 const typeMap: any = {
220220 "TopLevel": o([
221+ { json: "value", js: "value", typ: "" },
221222 { json: "trailingBackslash", js: "trailingBackslash", typ: u(undefined, "") },
222223 { json: "trailingQuote", js: "trailingQuote", typ: u(undefined, "") },
223224 { json: "trailingTripleQuote", js: "trailingTripleQuote", typ: u(undefined, "") },
224- { json: "value", js: "value", typ: "" },
225225 ], false),
226226 };
Mschema-flow/test/inputs/schema/const-non-string.schema/default/TopLevel.js+4 −4
@@ -10,11 +10,11 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13+ version: number;
1314 amount: number;
15+ ratio: number;
1416 enabled: boolean;
1517 kind: Kind;
16- ratio: number;
17- version: number;
1818 [property: string]: mixed;
1919 };
2020
@@ -186,11 +186,11 @@ function r(name: string) {
186186
187187 const typeMap: any = {
188188 "TopLevel": o([
189+ { json: "version", js: "version", typ: 3.14 },
189190 { json: "amount", js: "amount", typ: 0 },
191+ { json: "ratio", js: "ratio", typ: 3.14 },
190192 { json: "enabled", js: "enabled", typ: true },
191193 { json: "kind", js: "kind", typ: r("Kind") },
192- { json: "ratio", js: "ratio", typ: 3.14 },
193- { json: "version", js: "version", typ: 3.14 },
194194 ], "any"),
195195 "Kind": [
196196 "widget",
Mschema-flow/test/inputs/schema/date-time-or-string.schema/default/TopLevel.js+2 −2
@@ -10,8 +10,8 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- bar: BarUnion;
1413 foo: string;
14+ bar: BarUnion;
1515 [property: string]: mixed;
1616 };
1717
@@ -185,8 +185,8 @@ function r(name: string) {
185185
186186 const typeMap: any = {
187187 "TopLevel": o([
188- { json: "bar", js: "bar", typ: u(Date, r("BarEnum")) },
189188 { json: "foo", js: "foo", typ: "" },
189+ { json: "bar", js: "bar", typ: u(Date, r("BarEnum")) },
190190 ], "any"),
191191 "BarEnum": [
192192 "quux",
Mschema-flow/test/inputs/schema/date-time.schema/default/TopLevel.js+4 −4
@@ -10,11 +10,11 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- "complex-union-array": ComplexUnionArrayElement[];
1413 date: Date;
15- "date-time": Date;
1614 time: string;
15+ "date-time": Date;
1716 "union-array": string[];
17+ "complex-union-array": ComplexUnionArrayElement[];
1818 };
1919
2020 export type ComplexUnionArrayElement = Date | ComplexUnionArrayEnum | number;
@@ -188,11 +188,11 @@ function r(name: string) {
188188
189189 const typeMap: any = {
190190 "TopLevel": o([
191- { json: "complex-union-array", js: "complex-union-array", typ: a(u(Date, r("ComplexUnionArrayEnum"), 0)) },
192191 { json: "date", js: "date", typ: Date },
193- { json: "date-time", js: "date-time", typ: Date },
194192 { json: "time", js: "time", typ: "" },
193+ { json: "date-time", js: "date-time", typ: Date },
195194 { json: "union-array", js: "union-array", typ: a("") },
195+ { json: "complex-union-array", js: "complex-union-array", typ: a(u(Date, r("ComplexUnionArrayEnum"), 0)) },
196196 ], false),
197197 "ComplexUnionArrayEnum": [
198198 "foo",
Mschema-flow/test/inputs/schema/description.schema/default/TopLevel.js+9 −9
@@ -15,19 +15,19 @@
1515 */
1616 export type TopLevel = {
1717 /**
18- * A pretty boolean
18+ * Either a number or a string
1919 */
20- bar?: boolean;
20+ union: Union;
2121 /**
2222 * An enumeration
2323 */
24- enum: Enum;
25- foo?: number;
26- "object-or-string": ObjectOrStringUnion;
24+ enum: Enum;
25+ foo?: number;
2726 /**
28- * Either a number or a string
27+ * A pretty boolean
2928 */
30- union: Union;
29+ bar?: boolean;
30+ "object-or-string": ObjectOrStringUnion;
3131 };
3232
3333 /**
@@ -217,11 +217,11 @@ function r(name: string) {
217217
218218 const typeMap: any = {
219219 "TopLevel": o([
220- { json: "bar", js: "bar", typ: u(undefined, true) },
220+ { json: "union", js: "union", typ: u(3.14, "") },
221221 { json: "enum", js: "enum", typ: r("Enum") },
222222 { json: "foo", js: "foo", typ: u(undefined, 3.14) },
223+ { json: "bar", js: "bar", typ: u(undefined, true) },
223224 { json: "object-or-string", js: "object-or-string", typ: u(r("ObjectOrStringObject"), "") },
224- { json: "union", js: "union", typ: u(3.14, "") },
225225 ], false),
226226 "ObjectOrStringObject": o([
227227 { json: "prop", js: "prop", typ: 3.14 },
Mschema-flow/test/inputs/schema/direct-union.schema/default/TopLevel.js+2 −2
@@ -14,8 +14,8 @@ export type TopLevel = {
1414 };
1515
1616 export type Thing = {
17- optional?: Anything;
1817 required: Anything;
18+ optional?: Anything;
1919 };
2020
2121 export type Anything = mixed[] | boolean | number | number | { [key: string]: mixed } | null | string;
@@ -188,8 +188,8 @@ const typeMap: any = {
188188 { json: "stuff", js: "stuff", typ: m(r("Thing")) },
189189 ], false),
190190 "Thing": o([
191- { json: "optional", js: "optional", typ: u(undefined, u(a("any"), true, 3.14, 0, m("any"), null, "")) },
192191 { json: "required", js: "required", typ: u(a("any"), true, 3.14, 0, m("any"), null, "") },
192+ { json: "optional", js: "optional", typ: u(undefined, u(a("any"), true, 3.14, 0, m("any"), null, "")) },
193193 ], false),
194194 };
Mschema-flow/test/inputs/schema/enum.schema/default/TopLevel.js+6 −6
@@ -10,11 +10,11 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- arr?: Arr[];
14- for?: string;
15- gve: Gve;
1613 lvc?: Lvc;
14+ gve: Gve;
15+ arr?: Arr[];
1716 otherArr?: OtherArr[];
17+ for?: string;
1818 [property: string]: mixed;
1919 };
2020
@@ -200,11 +200,11 @@ function r(name: string) {
200200
201201 const typeMap: any = {
202202 "TopLevel": o([
203- { json: "arr", js: "arr", typ: u(undefined, a(u(r("OtherArr"), 0))) },
204- { json: "for", js: "for", typ: u(undefined, "") },
205- { json: "gve", js: "gve", typ: r("Gve") },
206203 { json: "lvc", js: "lvc", typ: u(undefined, r("Lvc")) },
204+ { json: "gve", js: "gve", typ: r("Gve") },
205+ { json: "arr", js: "arr", typ: u(undefined, a(u(r("OtherArr"), 0))) },
207206 { json: "otherArr", js: "otherArr", typ: u(undefined, a(r("OtherArr"))) },
207+ { json: "for", js: "for", typ: u(undefined, "") },
208208 ], "any"),
209209 "OtherArr": [
210210 "foo",
Mschema-flow/test/inputs/schema/integer-string.schema/default/TopLevel.js+6 −6
@@ -10,11 +10,11 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- arrNullable?: (null | string)[];
14- arrOne?: string[];
15- nullable: null | string;
1613 one: string;
1714 optional?: string;
15+ nullable: null | string;
16+ arrOne?: string[];
17+ arrNullable?: (null | string)[];
1818 unionWithInt: UnionWithInt;
1919 unionWithIntAndEnum: UnionWithInt;
2020 [property: string]: mixed;
@@ -187,11 +187,11 @@ function r(name: string) {
187187
188188 const typeMap: any = {
189189 "TopLevel": o([
190- { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
191- { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
192- { json: "nullable", js: "nullable", typ: u(null, "") },
193190 { json: "one", js: "one", typ: "" },
194191 { json: "optional", js: "optional", typ: u(undefined, "") },
192+ { json: "nullable", js: "nullable", typ: u(null, "") },
193+ { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
194+ { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
195195 { json: "unionWithInt", js: "unionWithInt", typ: u(0, "") },
196196 { json: "unionWithIntAndEnum", js: "unionWithIntAndEnum", typ: u(0, "") },
197197 ], "any"),
Mschema-flow/test/inputs/schema/integer-type.schema/default/TopLevel.js+10 −10
@@ -10,15 +10,15 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13+ small_positive: number;
14+ small_negative: number;
15+ i32_range: number;
1316 above_i32_max: number;
1417 below_i32_min: number;
15- i32_range: number;
16- large_bounds: number;
17- only_maximum: number;
1818 only_minimum: number;
19- small_negative: number;
20- small_positive: number;
19+ only_maximum: number;
2120 unbounded: number;
21+ large_bounds: number;
2222 [property: string]: mixed;
2323 };
2424
@@ -187,15 +187,15 @@ function r(name: string) {
187187
188188 const typeMap: any = {
189189 "TopLevel": o([
190+ { json: "small_positive", js: "small_positive", typ: 0 },
191+ { json: "small_negative", js: "small_negative", typ: 0 },
192+ { json: "i32_range", js: "i32_range", typ: 0 },
190193 { json: "above_i32_max", js: "above_i32_max", typ: 0 },
191194 { json: "below_i32_min", js: "below_i32_min", typ: 0 },
192- { json: "i32_range", js: "i32_range", typ: 0 },
193- { json: "large_bounds", js: "large_bounds", typ: 0 },
194- { json: "only_maximum", js: "only_maximum", typ: 0 },
195195 { json: "only_minimum", js: "only_minimum", typ: 0 },
196- { json: "small_negative", js: "small_negative", typ: 0 },
197- { json: "small_positive", js: "small_positive", typ: 0 },
196+ { json: "only_maximum", js: "only_maximum", typ: 0 },
198197 { json: "unbounded", js: "unbounded", typ: 0 },
198+ { json: "large_bounds", js: "large_bounds", typ: 0 },
199199 ], "any"),
200200 };
Mschema-flow/test/inputs/schema/light.schema/default/TopLevel.js+2 −2
@@ -14,8 +14,8 @@ export type TopLevel = {
1414 };
1515
1616 export type LightParams = {
17- app_id: string;
1817 outlet_id: string;
18+ app_id: string;
1919 rgba: string;
2020 };
2121
@@ -187,8 +187,8 @@ const typeMap: any = {
187187 { json: "LightParams", js: "LightParams", typ: r("LightParams") },
188188 ], false),
189189 "LightParams": o([
190- { json: "app_id", js: "app_id", typ: "" },
191190 { json: "outlet_id", js: "outlet_id", typ: "" },
191+ { json: "app_id", js: "app_id", typ: "" },
192192 { json: "rgba", js: "rgba", typ: "" },
193193 ], false),
194194 };
Mschema-flow/test/inputs/schema/min-max-items.schema/default/TopLevel.js+2 −2
@@ -10,9 +10,9 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13+ minOnly: string[];
1314 maxOnly: number[];
1415 minAndMax: number[];
15- minOnly: string[];
1616 plain: string[];
1717 unionItems: UnionItem[];
1818 [property: string]: mixed;
@@ -185,9 +185,9 @@ function r(name: string) {
185185
186186 const typeMap: any = {
187187 "TopLevel": o([
188+ { json: "minOnly", js: "minOnly", typ: a("") },
188189 { json: "maxOnly", js: "maxOnly", typ: a(0) },
189190 { json: "minAndMax", js: "minAndMax", typ: a(3.14) },
190- { json: "minOnly", js: "minOnly", typ: a("") },
191191 { json: "plain", js: "plain", typ: a("") },
192192 { json: "unionItems", js: "unionItems", typ: a(u(0, "")) },
193193 ], "any"),
Mschema-flow/test/inputs/schema/minmax-integer.schema/default/TopLevel.js+8 −8
@@ -11,13 +11,13 @@
1111
1212 export type TopLevel = {
1313 free: number;
14- intersection: number;
15- max: number;
1614 min: number;
15+ max: number;
1716 minmax: number;
18- minMaxIntersection: number;
19- minMaxUnion: number;
2017 union: number;
18+ minMaxUnion: number;
19+ intersection: number;
20+ minMaxIntersection: number;
2121 [property: string]: mixed;
2222 };
2323
@@ -187,13 +187,13 @@ function r(name: string) {
187187 const typeMap: any = {
188188 "TopLevel": o([
189189 { json: "free", js: "free", typ: 0 },
190- { json: "intersection", js: "intersection", typ: 0 },
191- { json: "max", js: "max", typ: 0 },
192190 { json: "min", js: "min", typ: 0 },
191+ { json: "max", js: "max", typ: 0 },
193192 { json: "minmax", js: "minmax", typ: 0 },
194- { json: "minMaxIntersection", js: "minMaxIntersection", typ: 0 },
195- { json: "minMaxUnion", js: "minMaxUnion", typ: 0 },
196193 { json: "union", js: "union", typ: 0 },
194+ { json: "minMaxUnion", js: "minMaxUnion", typ: 0 },
195+ { json: "intersection", js: "intersection", typ: 0 },
196+ { json: "minMaxIntersection", js: "minMaxIntersection", typ: 0 },
197197 ], "any"),
198198 };
Mschema-flow/test/inputs/schema/minmax.schema/default/TopLevel.js+8 −8
@@ -11,13 +11,13 @@
1111
1212 export type TopLevel = {
1313 free: number;
14- intersection: number;
15- max: number;
1614 min: number;
15+ max: number;
1716 minmax: number;
18- minMaxIntersection: number;
19- minMaxUnion: number;
2017 union: number;
18+ minMaxUnion: number;
19+ intersection: number;
20+ minMaxIntersection: number;
2121 [property: string]: mixed;
2222 };
2323
@@ -187,13 +187,13 @@ function r(name: string) {
187187 const typeMap: any = {
188188 "TopLevel": o([
189189 { json: "free", js: "free", typ: 3.14 },
190- { json: "intersection", js: "intersection", typ: 3.14 },
191- { json: "max", js: "max", typ: 3.14 },
192190 { json: "min", js: "min", typ: 3.14 },
191+ { json: "max", js: "max", typ: 3.14 },
193192 { json: "minmax", js: "minmax", typ: 3.14 },
194- { json: "minMaxIntersection", js: "minMaxIntersection", typ: 3.14 },
195- { json: "minMaxUnion", js: "minMaxUnion", typ: 3.14 },
196193 { json: "union", js: "union", typ: 3.14 },
194+ { json: "minMaxUnion", js: "minMaxUnion", typ: 3.14 },
195+ { json: "intersection", js: "intersection", typ: 3.14 },
196+ { json: "minMaxIntersection", js: "minMaxIntersection", typ: 3.14 },
197197 ], "any"),
198198 };
Mschema-flow/test/inputs/schema/minmaxlength.schema/default/TopLevel.js+10 −10
@@ -10,14 +10,14 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- intersection: string;
14- inUnion: InUnion;
15- maxlength: string;
1613 minlength: string;
17- minMaxIntersection: string;
14+ maxlength: string;
1815 minmaxlength: string;
19- minMaxUnion: string;
2016 union: string;
17+ inUnion: InUnion;
18+ minMaxUnion: string;
19+ intersection: string;
20+ minMaxIntersection: string;
2121 [property: string]: mixed;
2222 };
2323
@@ -188,14 +188,14 @@ function r(name: string) {
188188
189189 const typeMap: any = {
190190 "TopLevel": o([
191- { json: "intersection", js: "intersection", typ: "" },
192- { json: "inUnion", js: "inUnion", typ: u(3.14, "") },
193- { json: "maxlength", js: "maxlength", typ: "" },
194191 { json: "minlength", js: "minlength", typ: "" },
195- { json: "minMaxIntersection", js: "minMaxIntersection", typ: "" },
192+ { json: "maxlength", js: "maxlength", typ: "" },
196193 { json: "minmaxlength", js: "minmaxlength", typ: "" },
197- { json: "minMaxUnion", js: "minMaxUnion", typ: "" },
198194 { json: "union", js: "union", typ: "" },
195+ { json: "inUnion", js: "inUnion", typ: u(3.14, "") },
196+ { json: "minMaxUnion", js: "minMaxUnion", typ: "" },
197+ { json: "intersection", js: "intersection", typ: "" },
198+ { json: "minMaxIntersection", js: "minMaxIntersection", typ: "" },
199199 ], "any"),
200200 };
Mschema-flow/test/inputs/schema/non-standard-ref.schema/default/TopLevel.js+2 −2
@@ -10,8 +10,8 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- bar: number;
1413 foo: number;
14+ bar: number;
1515 quux: boolean;
1616 [property: string]: mixed;
1717 };
@@ -181,8 +181,8 @@ function r(name: string) {
181181
182182 const typeMap: any = {
183183 "TopLevel": o([
184- { json: "bar", js: "bar", typ: 0 },
185184 { json: "foo", js: "foo", typ: 0 },
185+ { json: "bar", js: "bar", typ: 0 },
186186 { json: "quux", js: "quux", typ: true },
187187 ], "any"),
188188 };
Mschema-flow/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.js+2 −2
@@ -10,8 +10,8 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- b?: null | string;
1413 kind: Kind;
14+ b?: null | string;
1515 [property: string]: mixed;
1616 };
1717
@@ -184,8 +184,8 @@ function r(name: string) {
184184
185185 const typeMap: any = {
186186 "TopLevel": o([
187- { json: "b", js: "b", typ: u(undefined, u(null, "")) },
188187 { json: "kind", js: "kind", typ: r("Kind") },
188+ { json: "b", js: "b", typ: u(undefined, u(null, "")) },
189189 ], "any"),
190190 "Kind": [
191191 "one",
Mschema-flow/test/inputs/schema/optional-any.schema/default/TopLevel.js+2 −2
@@ -10,8 +10,8 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- bar: boolean;
1413 foo?: mixed;
14+ bar: boolean;
1515 };
1616
1717 // Converts JSON strings to/from your types
@@ -179,8 +179,8 @@ function r(name: string) {
179179
180180 const typeMap: any = {
181181 "TopLevel": o([
182- { json: "bar", js: "bar", typ: true },
183182 { json: "foo", js: "foo", typ: u(undefined, "any") },
183+ { json: "bar", js: "bar", typ: true },
184184 ], false),
185185 };
Mschema-flow/test/inputs/schema/optional-const-ref.schema/default/TopLevel.js+6 −6
@@ -11,12 +11,12 @@
1111
1212 export type TopLevel = {
1313 coordinates?: Coordinate[];
14- count?: number;
15- label?: string;
1614 requiredCoordinates: Coordinate[];
15+ count?: number;
1716 requiredCount: number;
18- requiredLabel: string;
1917 weight?: number;
18+ label?: string;
19+ requiredLabel: string;
2020 };
2121
2222 export type Coordinate = {
@@ -190,12 +190,12 @@ function r(name: string) {
190190 const typeMap: any = {
191191 "TopLevel": o([
192192 { json: "coordinates", js: "coordinates", typ: u(undefined, a(r("Coordinate"))) },
193- { json: "count", js: "count", typ: u(undefined, 0) },
194- { json: "label", js: "label", typ: u(undefined, "") },
195193 { json: "requiredCoordinates", js: "requiredCoordinates", typ: a(r("Coordinate")) },
194+ { json: "count", js: "count", typ: u(undefined, 0) },
196195 { json: "requiredCount", js: "requiredCount", typ: 0 },
197- { json: "requiredLabel", js: "requiredLabel", typ: "" },
198196 { json: "weight", js: "weight", typ: u(undefined, 3.14) },
197+ { json: "label", js: "label", typ: u(undefined, "") },
198+ { json: "requiredLabel", js: "requiredLabel", typ: "" },
199199 ], false),
200200 "Coordinate": o([
201201 { json: "latitude", js: "latitude", typ: 3.14 },
Mschema-flow/test/inputs/schema/optional-constraints.schema/default/TopLevel.js+6 −6
@@ -10,11 +10,11 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- optDouble?: number;
13+ reqZeroMin: number;
1414 optInt?: number;
15- optPattern?: string;
15+ optDouble?: number;
1616 optString?: string;
17- reqZeroMin: number;
17+ optPattern?: string;
1818 [property: string]: mixed;
1919 };
2020
@@ -183,11 +183,11 @@ function r(name: string) {
183183
184184 const typeMap: any = {
185185 "TopLevel": o([
186- { json: "optDouble", js: "optDouble", typ: u(undefined, 3.14) },
186+ { json: "reqZeroMin", js: "reqZeroMin", typ: 0 },
187187 { json: "optInt", js: "optInt", typ: u(undefined, 0) },
188- { json: "optPattern", js: "optPattern", typ: u(undefined, "") },
188+ { json: "optDouble", js: "optDouble", typ: u(undefined, 3.14) },
189189 { json: "optString", js: "optString", typ: u(undefined, "") },
190- { json: "reqZeroMin", js: "reqZeroMin", typ: 0 },
190+ { json: "optPattern", js: "optPattern", typ: u(undefined, "") },
191191 ], "any"),
192192 };
Mschema-flow/test/inputs/schema/optional-date-time.schema/default/TopLevel.js+8 −8
@@ -10,12 +10,12 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- "optional-date"?: Date;
14- "optional-date-time"?: Date;
15- "optional-time"?: string;
1613 "required-date": Date;
17- "required-date-time": Date;
1814 "required-time": string;
15+ "required-date-time": Date;
16+ "optional-date"?: Date;
17+ "optional-time"?: string;
18+ "optional-date-time"?: Date;
1919 };
2020
2121 // Converts JSON strings to/from your types
@@ -183,12 +183,12 @@ function r(name: string) {
183183
184184 const typeMap: any = {
185185 "TopLevel": o([
186- { json: "optional-date", js: "optional-date", typ: u(undefined, Date) },
187- { json: "optional-date-time", js: "optional-date-time", typ: u(undefined, Date) },
188- { json: "optional-time", js: "optional-time", typ: u(undefined, "") },
189186 { json: "required-date", js: "required-date", typ: Date },
190- { json: "required-date-time", js: "required-date-time", typ: Date },
191187 { json: "required-time", js: "required-time", typ: "" },
188+ { json: "required-date-time", js: "required-date-time", typ: Date },
189+ { json: "optional-date", js: "optional-date", typ: u(undefined, Date) },
190+ { json: "optional-time", js: "optional-time", typ: u(undefined, "") },
191+ { json: "optional-date-time", js: "optional-date-time", typ: u(undefined, Date) },
192192 ], false),
193193 };
Mschema-flow/test/inputs/schema/prefix-items.schema/default/TopLevel.js+2 −2
@@ -10,8 +10,8 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- open: Open[];
1413 tuple: Open[];
14+ open: Open[];
1515 [property: string]: mixed;
1616 };
1717
@@ -182,8 +182,8 @@ function r(name: string) {
182182
183183 const typeMap: any = {
184184 "TopLevel": o([
185- { json: "open", js: "open", typ: a(u(true, 0)) },
186185 { json: "tuple", js: "tuple", typ: a(u(true, 0)) },
186+ { json: "open", js: "open", typ: a(u(true, 0)) },
187187 ], "any"),
188188 };
Aschema-flow/test/inputs/schema/property-order.schema/default/TopLevel.js+209 −0
@@ -0,0 +1,209 @@
1+// @flow
2+
3+// To parse this data:
4+//
5+// const Convert = require("./TopLevel");
6+//
7+// const topLevel = Convert.toTopLevel(json);
8+//
9+// These functions will throw an error if the JSON doesn't
10+// match the expected interface, even if the JSON is valid.
11+
12+export type TopLevel = {
13+ zebra: string;
14+ mango: number;
15+ apple: boolean;
16+ delta: string;
17+ banana: number;
18+ ordered: Ordered;
19+};
20+
21+export type Ordered = {
22+ mango: number;
23+ zebra: string;
24+ apple: boolean;
25+};
26+
27+// Converts JSON strings to/from your types
28+// and asserts the results of JSON.parse at runtime
29+function toTopLevel(json: string): TopLevel {
30+ return cast(JSON.parse(json), r("TopLevel"));
31+}
32+
33+function topLevelToJson(value: TopLevel): string {
34+ return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
35+}
36+
37+function invalidValue(typ: any, val: any, key: any, parent: any = '') {
38+ const prettyTyp = prettyTypeName(typ);
39+ const parentText = parent ? ` on ${parent}` : '';
40+ const keyText = key ? ` for key "${key}"` : '';
41+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
42+}
43+
44+function prettyTypeName(typ: any): string {
45+ if (Array.isArray(typ)) {
46+ if (typ.length === 2 && typ[0] === undefined) {
47+ return `an optional ${prettyTypeName(typ[1])}`;
48+ } else {
49+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
50+ }
51+ } else if (typeof typ === "object" && typ.literal !== undefined) {
52+ return typ.literal;
53+ } else {
54+ return typeof typ;
55+ }
56+}
57+
58+function jsonToJSProps(typ: any): any {
59+ if (typ.jsonToJS === undefined) {
60+ const map: any = {};
61+ typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
62+ typ.jsonToJS = map;
63+ }
64+ return typ.jsonToJS;
65+}
66+
67+function jsToJSONProps(typ: any): any {
68+ if (typ.jsToJSON === undefined) {
69+ const map: any = {};
70+ typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
71+ typ.jsToJSON = map;
72+ }
73+ return typ.jsToJSON;
74+}
75+
76+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
77+ function transformPrimitive(typ: string, val: any): any {
78+ if (typeof typ === typeof val) return val;
79+ return invalidValue(typ, val, key, parent);
80+ }
81+
82+ function transformUnion(typs: any[], val: any): any {
83+ // val must validate against one typ in typs
84+ const l = typs.length;
85+ for (let i = 0; i < l; i++) {
86+ const typ = typs[i];
87+ try {
88+ return transform(val, typ, getProps);
89+ } catch (_) {}
90+ }
91+ return invalidValue(typs, val, key, parent);
92+ }
93+
94+ function transformEnum(cases: string[], val: any): any {
95+ if (cases.indexOf(val) !== -1) return val;
96+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
97+ }
98+
99+ function transformArray(typ: any, val: any): any {
100+ // val must be an array with no invalid elements
101+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
102+ return val.map(el => transform(el, typ, getProps));
103+ }
104+
105+ function transformDate(val: any): any {
106+ if (val === null) {
107+ return null;
108+ }
109+ const d = new Date(val);
110+ if (isNaN(d.valueOf())) {
111+ return invalidValue(l("Date"), val, key, parent);
112+ }
113+ return d;
114+ }
115+
116+ function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
117+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
118+ return invalidValue(l(ref || "object"), val, key, parent);
119+ }
120+ const result: any = {};
121+ Object.getOwnPropertyNames(props).forEach(key => {
122+ const prop = props[key];
123+ const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
124+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
125+ });
126+ Object.getOwnPropertyNames(val).forEach(key => {
127+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
128+ result[key] = transform(val[key], additional, getProps, key, ref);
129+ }
130+ });
131+ return result;
132+ }
133+
134+ if (typ === "any") return val;
135+ if (typ === null) {
136+ if (val === null) return val;
137+ return invalidValue(typ, val, key, parent);
138+ }
139+ if (typ === false) return invalidValue(typ, val, key, parent);
140+ let ref: any = undefined;
141+ while (typeof typ === "object" && typ.ref !== undefined) {
142+ ref = typ.ref;
143+ typ = typeMap[typ.ref];
144+ }
145+ if (Array.isArray(typ)) return transformEnum(typ, val);
146+ if (typeof typ === "object") {
147+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
148+ : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
149+ : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
150+ : invalidValue(typ, val, key, parent);
151+ }
152+ // Numbers can be parsed by Date but shouldn't be.
153+ if (typ === Date && typeof val !== "number") return transformDate(val);
154+ return transformPrimitive(typ, val);
155+}
156+
157+function cast<T>(val: any, typ: any): T {
158+ return transform(val, typ, jsonToJSProps);
159+}
160+
161+function uncast<T>(val: T, typ: any): any {
162+ return transform(val, typ, jsToJSONProps);
163+}
164+
165+function l(typ: any) {
166+ return { literal: typ };
167+}
168+
169+function a(typ: any) {
170+ return { arrayItems: typ };
171+}
172+
173+function u(...typs: any[]) {
174+ return { unionMembers: typs };
175+}
176+
177+function o(props: any[], additional: any) {
178+ return { props, additional };
179+}
180+
181+function m(additional: any) {
182+ const props: any[] = [];
183+ return { props, additional };
184+}
185+
186+function r(name: string) {
187+ return { ref: name };
188+}
189+
190+const typeMap: any = {
191+ "TopLevel": o([
192+ { json: "zebra", js: "zebra", typ: "" },
193+ { json: "mango", js: "mango", typ: 3.14 },
194+ { json: "apple", js: "apple", typ: true },
195+ { json: "delta", js: "delta", typ: "" },
196+ { json: "banana", js: "banana", typ: 0 },
197+ { json: "ordered", js: "ordered", typ: r("Ordered") },
198+ ], false),
199+ "Ordered": o([
200+ { json: "mango", js: "mango", typ: 3.14 },
201+ { json: "zebra", js: "zebra", typ: "" },
202+ { json: "apple", js: "apple", typ: true },
203+ ], false),
204+};
205+
206+module.exports = {
207+ "topLevelToJson": topLevelToJson,
208+ "toTopLevel": toTopLevel,
209+};
Mschema-flow/test/inputs/schema/renaming-bug.schema/default/TopLevel.js+16 −16
@@ -18,14 +18,14 @@ export type TopLevel = {
1818
1919 export type Fruit = {
2020 apple?: boolean;
21- berries?: Berry[];
2221 orange?: boolean;
22+ berries?: Berry[];
2323 [property: string]: mixed;
2424 };
2525
2626 export type Berry = {
27- color?: Color;
2827 name?: string;
28+ color?: Color;
2929 shapes?: Shape[];
3030 [property: string]: mixed;
3131 };
@@ -36,8 +36,8 @@ export type Color = {
3636 };
3737
3838 export type Shape = {
39- geometry?: Geometry;
4039 history?: History;
40+ geometry?: Geometry;
4141 [property: string]: mixed;
4242 };
4343
@@ -58,9 +58,9 @@ export type RectShape = {
5858 };
5959
6060 export type Part = {
61- depth?: string;
6261 length?: string;
6362 width?: string;
63+ depth?: string;
6464 [property: string]: mixed;
6565 };
6666
@@ -70,12 +70,12 @@ export type History = {
7070 };
7171
7272 export type Vehicle = {
73- brand?: string;
7473 id?: string;
75- speed?: Speed;
76- subModule?: boolean;
7774 type?: VehicleType;
75+ speed?: Speed;
7876 year?: string;
77+ brand?: string;
78+ subModule?: boolean;
7979 [property: string]: mixed;
8080 };
8181
@@ -85,8 +85,8 @@ export type Speed = {
8585 };
8686
8787 export type Limit = {
88- maximum?: number;
8988 minimum?: number;
89+ maximum?: number;
9090 [property: string]: mixed;
9191 };
9292
@@ -287,20 +287,20 @@ const typeMap: any = {
287287 ], "any"),
288288 "Fruit": o([
289289 { json: "apple", js: "apple", typ: u(undefined, true) },
290- { json: "berries", js: "berries", typ: u(undefined, a(r("Berry"))) },
291290 { json: "orange", js: "orange", typ: u(undefined, true) },
291+ { json: "berries", js: "berries", typ: u(undefined, a(r("Berry"))) },
292292 ], "any"),
293293 "Berry": o([
294- { json: "color", js: "color", typ: u(undefined, r("Color")) },
295294 { json: "name", js: "name", typ: u(undefined, "") },
295+ { json: "color", js: "color", typ: u(undefined, r("Color")) },
296296 { json: "shapes", js: "shapes", typ: u(undefined, a(r("Shape"))) },
297297 ], "any"),
298298 "Color": o([
299299 { json: "rgb", js: "rgb", typ: u(undefined, 3.14) },
300300 ], "any"),
301301 "Shape": o([
302- { json: "geometry", js: "geometry", typ: u(undefined, r("Geometry")) },
303302 { json: "history", js: "history", typ: u(undefined, r("History")) },
303+ { json: "geometry", js: "geometry", typ: u(undefined, r("Geometry")) },
304304 ], "any"),
305305 "Geometry": o([
306306 { json: "rectShape", js: "rectShape", typ: u(undefined, r("RectShape")) },
@@ -313,27 +313,27 @@ const typeMap: any = {
313313 { json: "parts", js: "parts", typ: u(undefined, a(r("Part"))) },
314314 ], "any"),
315315 "Part": o([
316- { json: "depth", js: "depth", typ: u(undefined, "") },
317316 { json: "length", js: "length", typ: u(undefined, "") },
318317 { json: "width", js: "width", typ: u(undefined, "") },
318+ { json: "depth", js: "depth", typ: u(undefined, "") },
319319 ], "any"),
320320 "History": o([
321321 { json: "class", js: "class", typ: u(undefined, "") },
322322 ], "any"),
323323 "Vehicle": o([
324- { json: "brand", js: "brand", typ: u(undefined, "") },
325324 { json: "id", js: "id", typ: u(undefined, "") },
326- { json: "speed", js: "speed", typ: u(undefined, r("Speed")) },
327- { json: "subModule", js: "subModule", typ: u(undefined, true) },
328325 { json: "type", js: "type", typ: u(undefined, r("VehicleType")) },
326+ { json: "speed", js: "speed", typ: u(undefined, r("Speed")) },
329327 { json: "year", js: "year", typ: u(undefined, "") },
328+ { json: "brand", js: "brand", typ: u(undefined, "") },
329+ { json: "subModule", js: "subModule", typ: u(undefined, true) },
330330 ], "any"),
331331 "Speed": o([
332332 { json: "velocity", js: "velocity", typ: u(undefined, r("Limit")) },
333333 ], "any"),
334334 "Limit": o([
335- { json: "maximum", js: "maximum", typ: u(undefined, 3.14) },
336335 { json: "minimum", js: "minimum", typ: u(undefined, 3.14) },
336+ { json: "maximum", js: "maximum", typ: u(undefined, 3.14) },
337337 ], "any"),
338338 "VehicleType": o([
339339 { json: "name", js: "name", typ: u(undefined, r("Name")) },
Mschema-flow/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.js+4 −4
@@ -10,14 +10,14 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- next?: Next;
1413 value: string;
14+ next?: Next;
1515 [property: string]: mixed;
1616 };
1717
1818 export type Node = {
19- next?: Next;
2019 value: string;
20+ next?: Next;
2121 [property: string]: mixed;
2222 };
2323
@@ -188,12 +188,12 @@ function r(name: string) {
188188
189189 const typeMap: any = {
190190 "TopLevel": o([
191- { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
192191 { json: "value", js: "value", typ: "" },
192+ { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
193193 ], "any"),
194194 "Node": o([
195- { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
196195 { json: "value", js: "value", typ: "" },
196+ { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
197197 ], "any"),
198198 };
Mschema-flow/test/inputs/schema/uuid.schema/default/TopLevel.js+6 −6
@@ -10,11 +10,11 @@
1010 // match the expected interface, even if the JSON is valid.
1111
1212 export type TopLevel = {
13- arrNullable?: (null | string)[];
14- arrOne?: string[];
15- nullable: null | string;
1613 one: string;
1714 optional?: string;
15+ nullable: null | string;
16+ arrOne?: string[];
17+ arrNullable?: (null | string)[];
1818 unionWithEnum: string;
1919 [property: string]: mixed;
2020 };
@@ -184,11 +184,11 @@ function r(name: string) {
184184
185185 const typeMap: any = {
186186 "TopLevel": o([
187- { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
188- { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
189- { json: "nullable", js: "nullable", typ: u(null, "") },
190187 { json: "one", js: "one", typ: "" },
191188 { json: "optional", js: "optional", typ: u(undefined, "") },
189+ { json: "nullable", js: "nullable", typ: u(null, "") },
190+ { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
191+ { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
192192 { json: "unionWithEnum", js: "unionWithEnum", typ: "" },
193193 ], "any"),
194194 };
Mschema-flow/test/inputs/schema/vega-lite.schema/default/TopLevel.js+50 −50
@@ -503,6 +503,12 @@ export type MarkConfig = {
503503 * __Default value:__ (None)
504504 */
505505 fill?: string;
506+ /**
507+ * The fill opacity (value between [0,1]).
508+ *
509+ * __Default value:__ `1`
510+ */
511+ fillOpacity?: number;
506512 /**
507513 * Whether the mark's color should be used as fill color instead of stroke color.
508514 *
@@ -513,12 +519,6 @@ export type MarkConfig = {
513519 * __Note:__ This property cannot be used in a [style config](mark.html#style-config).
514520 */
515521 filled?: boolean;
516- /**
517- * The fill opacity (value between [0,1]).
518- *
519- * __Default value:__ `1`
520- */
521- fillOpacity?: number;
522522 /**
523523 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
524524 */
@@ -924,10 +924,6 @@ export type AxisConfig = {
924924 * Boolean flag indicating if pixel position values should be rounded to the nearest integer.
925925 */
926926 tickRound?: boolean;
927- /**
928- * Boolean value that determines whether the axis should include ticks.
929- */
930- ticks?: boolean;
931927 /**
932928 * The size in pixels of axis ticks.
933929 */
@@ -936,6 +932,10 @@ export type AxisConfig = {
936932 * The width, in pixels, of ticks.
937933 */
938934 tickWidth?: number;
935+ /**
936+ * Boolean value that determines whether the axis should include ticks.
937+ */
938+ ticks?: boolean;
939939 /**
940940 * Horizontal text alignment of axis titles.
941941 */
@@ -1174,10 +1174,6 @@ export type VGAxisConfig = {
11741174 * Boolean flag indicating if pixel position values should be rounded to the nearest integer.
11751175 */
11761176 tickRound?: boolean;
1177- /**
1178- * Boolean value that determines whether the axis should include ticks.
1179- */
1180- ticks?: boolean;
11811177 /**
11821178 * The size in pixels of axis ticks.
11831179 */
@@ -1186,6 +1182,10 @@ export type VGAxisConfig = {
11861182 * The width, in pixels, of ticks.
11871183 */
11881184 tickWidth?: number;
1185+ /**
1186+ * Boolean value that determines whether the axis should include ticks.
1187+ */
1188+ ticks?: boolean;
11891189 /**
11901190 * Horizontal text alignment of axis titles.
11911191 */
@@ -1303,6 +1303,12 @@ export type BarConfig = {
13031303 * __Default value:__ (None)
13041304 */
13051305 fill?: string;
1306+ /**
1307+ * The fill opacity (value between [0,1]).
1308+ *
1309+ * __Default value:__ `1`
1310+ */
1311+ fillOpacity?: number;
13061312 /**
13071313 * Whether the mark's color should be used as fill color instead of stroke color.
13081314 *
@@ -1313,12 +1319,6 @@ export type BarConfig = {
13131319 * __Note:__ This property cannot be used in a [style config](mark.html#style-config).
13141320 */
13151321 filled?: boolean;
1316- /**
1317- * The fill opacity (value between [0,1]).
1318- *
1319- * __Default value:__ `1`
1320- */
1321- fillOpacity?: number;
13221322 /**
13231323 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
13241324 */
@@ -2525,6 +2525,12 @@ export type TextConfig = {
25252525 * __Default value:__ (None)
25262526 */
25272527 fill?: string;
2528+ /**
2529+ * The fill opacity (value between [0,1]).
2530+ *
2531+ * __Default value:__ `1`
2532+ */
2533+ fillOpacity?: number;
25282534 /**
25292535 * Whether the mark's color should be used as fill color instead of stroke color.
25302536 *
@@ -2535,12 +2541,6 @@ export type TextConfig = {
25352541 * __Note:__ This property cannot be used in a [style config](mark.html#style-config).
25362542 */
25372543 filled?: boolean;
2538- /**
2539- * The fill opacity (value between [0,1]).
2540- *
2541- * __Default value:__ `1`
2542- */
2543- fillOpacity?: number;
25442544 /**
25452545 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
25462546 */
@@ -2725,6 +2725,12 @@ export type TickConfig = {
27252725 * __Default value:__ (None)
27262726 */
27272727 fill?: string;
2728+ /**
2729+ * The fill opacity (value between [0,1]).
2730+ *
2731+ * __Default value:__ `1`
2732+ */
2733+ fillOpacity?: number;
27282734 /**
27292735 * Whether the mark's color should be used as fill color instead of stroke color.
27302736 *
@@ -2735,12 +2741,6 @@ export type TickConfig = {
27352741 * __Note:__ This property cannot be used in a [style config](mark.html#style-config).
27362742 */
27372743 filled?: boolean;
2738- /**
2739- * The fill opacity (value between [0,1]).
2740- *
2741- * __Default value:__ `1`
2742- */
2743- fillOpacity?: number;
27442744 /**
27452745 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
27462746 */
@@ -5025,14 +5025,14 @@ export type Axis = {
50255025 * underlying scale's range.
50265026 */
50275027 tickCount?: number;
5028- /**
5029- * Boolean value that determines whether the axis should include ticks.
5030- */
5031- ticks?: boolean;
50325028 /**
50335029 * The size in pixels of axis ticks.
50345030 */
50355031 tickSize?: number;
5032+ /**
5033+ * Boolean value that determines whether the axis should include ticks.
5034+ */
5035+ ticks?: boolean;
50365036 /**
50375037 * A title for the field. If `null`, the title will be removed.
50385038 *
@@ -5523,6 +5523,12 @@ export type MarkDef = {
55235523 * __Default value:__ (None)
55245524 */
55255525 fill?: string;
5526+ /**
5527+ * The fill opacity (value between [0,1]).
5528+ *
5529+ * __Default value:__ `1`
5530+ */
5531+ fillOpacity?: number;
55265532 /**
55275533 * Whether the mark's color should be used as fill color instead of stroke color.
55285534 *
@@ -5533,12 +5539,6 @@ export type MarkDef = {
55335539 * __Note:__ This property cannot be used in a [style config](mark.html#style-config).
55345540 */
55355541 filled?: boolean;
5536- /**
5537- * The fill opacity (value between [0,1]).
5538- *
5539- * __Default value:__ `1`
5540- */
5541- fillOpacity?: number;
55425542 /**
55435543 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
55445544 */
@@ -6347,8 +6347,8 @@ const typeMap: any = {
63476347 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
63486348 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
63496349 { json: "fill", js: "fill", typ: u(undefined, "") },
6350- { json: "filled", js: "filled", typ: u(undefined, true) },
63516350 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
6351+ { json: "filled", js: "filled", typ: u(undefined, true) },
63526352 { json: "font", js: "font", typ: u(undefined, "") },
63536353 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
63546354 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
@@ -6395,9 +6395,9 @@ const typeMap: any = {
63956395 { json: "shortTimeLabels", js: "shortTimeLabels", typ: u(undefined, true) },
63966396 { json: "tickColor", js: "tickColor", typ: u(undefined, "") },
63976397 { json: "tickRound", js: "tickRound", typ: u(undefined, true) },
6398- { json: "ticks", js: "ticks", typ: u(undefined, true) },
63996398 { json: "tickSize", js: "tickSize", typ: u(undefined, 3.14) },
64006399 { json: "tickWidth", js: "tickWidth", typ: u(undefined, 3.14) },
6400+ { json: "ticks", js: "ticks", typ: u(undefined, true) },
64016401 { json: "titleAlign", js: "titleAlign", typ: u(undefined, "") },
64026402 { json: "titleAngle", js: "titleAngle", typ: u(undefined, 3.14) },
64036403 { json: "titleBaseline", js: "titleBaseline", typ: u(undefined, "") },
@@ -6435,9 +6435,9 @@ const typeMap: any = {
64356435 { json: "minExtent", js: "minExtent", typ: u(undefined, 3.14) },
64366436 { json: "tickColor", js: "tickColor", typ: u(undefined, "") },
64376437 { json: "tickRound", js: "tickRound", typ: u(undefined, true) },
6438- { json: "ticks", js: "ticks", typ: u(undefined, true) },
64396438 { json: "tickSize", js: "tickSize", typ: u(undefined, 3.14) },
64406439 { json: "tickWidth", js: "tickWidth", typ: u(undefined, 3.14) },
6440+ { json: "ticks", js: "ticks", typ: u(undefined, true) },
64416441 { json: "titleAlign", js: "titleAlign", typ: u(undefined, "") },
64426442 { json: "titleAngle", js: "titleAngle", typ: u(undefined, 3.14) },
64436443 { json: "titleBaseline", js: "titleBaseline", typ: u(undefined, "") },
@@ -6463,8 +6463,8 @@ const typeMap: any = {
64636463 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
64646464 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
64656465 { json: "fill", js: "fill", typ: u(undefined, "") },
6466- { json: "filled", js: "filled", typ: u(undefined, true) },
64676466 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
6467+ { json: "filled", js: "filled", typ: u(undefined, true) },
64686468 { json: "font", js: "font", typ: u(undefined, "") },
64696469 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
64706470 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
@@ -6680,8 +6680,8 @@ const typeMap: any = {
66806680 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
66816681 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
66826682 { json: "fill", js: "fill", typ: u(undefined, "") },
6683- { json: "filled", js: "filled", typ: u(undefined, true) },
66846683 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
6684+ { json: "filled", js: "filled", typ: u(undefined, true) },
66856685 { json: "font", js: "font", typ: u(undefined, "") },
66866686 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
66876687 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
@@ -6714,8 +6714,8 @@ const typeMap: any = {
67146714 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
67156715 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
67166716 { json: "fill", js: "fill", typ: u(undefined, "") },
6717- { json: "filled", js: "filled", typ: u(undefined, true) },
67186717 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
6718+ { json: "filled", js: "filled", typ: u(undefined, true) },
67196719 { json: "font", js: "font", typ: u(undefined, "") },
67206720 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
67216721 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
@@ -7011,8 +7011,8 @@ const typeMap: any = {
70117011 { json: "orient", js: "orient", typ: u(undefined, r("TitleOrient")) },
70127012 { json: "position", js: "position", typ: u(undefined, 3.14) },
70137013 { json: "tickCount", js: "tickCount", typ: u(undefined, 3.14) },
7014- { json: "ticks", js: "ticks", typ: u(undefined, true) },
70157014 { json: "tickSize", js: "tickSize", typ: u(undefined, 3.14) },
7015+ { json: "ticks", js: "ticks", typ: u(undefined, true) },
70167016 { json: "title", js: "title", typ: u(undefined, u(null, "")) },
70177017 { json: "titleMaxLength", js: "titleMaxLength", typ: u(undefined, 3.14) },
70187018 { json: "titlePadding", js: "titlePadding", typ: u(undefined, 3.14) },
@@ -7091,8 +7091,8 @@ const typeMap: any = {
70917091 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
70927092 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
70937093 { json: "fill", js: "fill", typ: u(undefined, "") },
7094- { json: "filled", js: "filled", typ: u(undefined, true) },
70957094 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
7095+ { json: "filled", js: "filled", typ: u(undefined, true) },
70967096 { json: "font", js: "font", typ: u(undefined, "") },
70977097 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
70987098 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
Mschema-golang-leading-comments/test/inputs/schema/date-time.schema/default/multi/TopLevel.go+2 −2
@@ -22,10 +22,10 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2222 }
2323
2424 type TopLevel struct {
25- Bah string `json:"bar"`
25+ Unionization *Union `json:"union"`
2626 Enumerification Enum `json:"enum"`
2727 Foo string `json:"foo"`
28- Unionization *Union `json:"union"`
28+ Bah string `json:"bar"`
2929 }
3030
3131 type Enum string
Mschema-golang-leading-comments/test/inputs/schema/date-time.schema/default/quicktype.go+1 −1
@@ -21,8 +21,8 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2121 type TopLevel struct {
2222 Amount float64 `json:"amount"`
2323 Frequency Frequency `json:"frequency"`
24- Description *string `json:"description,omitempty"`
2524 Type Type `json:"type"`
25+ Description *string `json:"description,omitempty"`
2626 }
2727
2828 type Frequency string
Mschema-golang/test/inputs/schema/accessors.schema/default/quicktype.go+3 −3
@@ -22,11 +22,11 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2222 }
2323
2424 type TopLevel struct {
25- ArrNullable []*string `json:"arrNullable,omitempty"`
26- ArrOne []string `json:"arrOne,omitempty"`
27- Nullable *string `json:"nullable"`
2825 One string `json:"one"`
2926 Optional *string `json:"optional,omitempty"`
27+ Nullable *string `json:"nullable"`
28+ ArrOne []string `json:"arrOne,omitempty"`
29+ ArrNullable []*string `json:"arrNullable,omitempty"`
3030 UnionWithBool *UnionWithBool `json:"unionWithBool"`
3131 UnionWithBoolAndEnum *UnionWithBool `json:"unionWithBoolAndEnum"`
3232 }
Mschema-golang/test/inputs/schema/all-of-additional-properties-false.schema/default/quicktype.go+1 −1
@@ -19,8 +19,8 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1919 }
2020
2121 type TopLevel struct {
22+ Foo string `json:"foo"`
2223 Disallowed interface{} `json:"disallowed"`
2324 Empty []interface{} `json:"empty"`
24- Foo string `json:"foo"`
2525 Impossible interface{} `json:"impossible"`
2626 }
Mschema-golang/test/inputs/schema/bool-string.schema/default/quicktype.go+6 −6
@@ -31,12 +31,6 @@ func (r *TopLevel) Marshal() ([]byte, error) {
3131 // }
3232 // }
3333 type TopLevel struct {
34- // Ends with a backslash \
35- TrailingBackslash *string `json:"trailingBackslash,omitempty"`
36- // Ends with a quote "
37- TrailingQuote *string `json:"trailingQuote,omitempty"`
38- // Ends with a triple quote """
39- TrailingTripleQuote *string `json:"trailingTripleQuote,omitempty"`
4034 // Property delimiters:
4135 // */
4236 // /*
@@ -50,4 +44,10 @@ type TopLevel struct {
5044 // }
5145 // }
5246 Value string `json:"value"`
47+ // Ends with a backslash \
48+ TrailingBackslash *string `json:"trailingBackslash,omitempty"`
49+ // Ends with a quote "
50+ TrailingQuote *string `json:"trailingQuote,omitempty"`
51+ // Ends with a triple quote """
52+ TrailingTripleQuote *string `json:"trailingTripleQuote,omitempty"`
5353 }
Mschema-golang/test/inputs/schema/boolean-subschema.schema/default/quicktype.go+2 −2
@@ -19,11 +19,11 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1919 }
2020
2121 type TopLevel struct {
22+ Version float64 `json:"version"`
2223 Amount int64 `json:"amount"`
24+ Ratio float64 `json:"ratio"`
2325 Enabled bool `json:"enabled"`
2426 Kind Kind `json:"kind"`
25- Ratio float64 `json:"ratio"`
26- Version float64 `json:"version"`
2727 }
2828
2929 type Kind string
Mschema-golang/test/inputs/schema/comment-injection.schema/default/quicktype.go+1 −1
@@ -23,8 +23,8 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2323 }
2424
2525 type TopLevel struct {
26- Bar *BarUnion `json:"bar"`
2726 Foo string `json:"foo"`
27+ Bar *BarUnion `json:"bar"`
2828 }
2929
3030 type BarEnum string
Mschema-golang/test/inputs/schema/const-non-string.schema/default/quicktype.go+2 −2
@@ -23,11 +23,11 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2323 }
2424
2525 type TopLevel struct {
26- ComplexUnionArray []ComplexUnionArrayElement `json:"complex-union-array"`
2726 Date string `json:"date"`
28- DateTime time.Time `json:"date-time"`
2927 Time string `json:"time"`
28+ DateTime time.Time `json:"date-time"`
3029 UnionArray []string `json:"union-array"`
30+ ComplexUnionArray []ComplexUnionArrayElement `json:"complex-union-array"`
3131 }
3232
3333 type ComplexUnionArrayEnum string
Mschema-golang/test/inputs/schema/date-time-or-string.schema/default/quicktype.go+4 −4
@@ -24,14 +24,14 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2424 // The top-level class.
2525 // Its description has two lines.
2626 type TopLevel struct {
27- // A pretty boolean
28- Bar *bool `json:"bar,omitempty"`
27+ // Either a number or a string
28+ Union *Union `json:"union"`
2929 // An enumeration
3030 Enum Enum `json:"enum"`
3131 Foo *float64 `json:"foo,omitempty"`
32+ // A pretty boolean
33+ Bar *bool `json:"bar,omitempty"`
3234 ObjectOrString *ObjectOrStringUnion `json:"object-or-string"`
33- // Either a number or a string
34- Union *Union `json:"union"`
3535 }
3636
3737 type ObjectOrStringClass struct {
Mschema-golang/test/inputs/schema/date-time.schema/default/quicktype.go+1 −1
@@ -26,8 +26,8 @@ type TopLevel struct {
2626 }
2727
2828 type Thing struct {
29- Optional *Anything `json:"optional"`
3029 Required *Anything `json:"required"`
30+ Optional *Anything `json:"optional"`
3131 }
3232
3333 type Anything struct {
Mschema-golang/test/inputs/schema/description.schema/default/quicktype.go+3 −3
@@ -22,11 +22,11 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2222 }
2323
2424 type TopLevel struct {
25- Arr []Arr `json:"arr,omitempty"`
26- For *string `json:"for,omitempty"`
27- Gve Gve `json:"gve"`
2825 Lvc *Lvc `json:"lvc,omitempty"`
26+ Gve Gve `json:"gve"`
27+ Arr []Arr `json:"arr,omitempty"`
2928 OtherArr []OtherArr `json:"otherArr,omitempty"`
29+ For *string `json:"for,omitempty"`
3030 }
3131
3232 type OtherArr string
Mschema-golang/test/inputs/schema/direct-union.schema/default/quicktype.go+3 −3
@@ -22,11 +22,11 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2222 }
2323
2424 type TopLevel struct {
25- ArrNullable []*string `json:"arrNullable,omitempty"`
26- ArrOne []string `json:"arrOne,omitempty"`
27- Nullable *string `json:"nullable"`
2825 One string `json:"one"`
2926 Optional *string `json:"optional,omitempty"`
27+ Nullable *string `json:"nullable"`
28+ ArrOne []string `json:"arrOne,omitempty"`
29+ ArrNullable []*string `json:"arrNullable,omitempty"`
3030 UnionWithInt *UnionWithInt `json:"unionWithInt"`
3131 UnionWithIntAndEnum *UnionWithInt `json:"unionWithIntAndEnum"`
3232 }
Mschema-golang/test/inputs/schema/enum.schema/default/quicktype.go+5 −5
@@ -19,13 +19,13 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1919 }
2020
2121 type TopLevel struct {
22+ SmallPositive int64 `json:"small_positive"`
23+ SmallNegative int64 `json:"small_negative"`
24+ I32Range int64 `json:"i32_range"`
2225 AboveI32Max int64 `json:"above_i32_max"`
2326 BelowI32Min int64 `json:"below_i32_min"`
24- I32Range int64 `json:"i32_range"`
25- LargeBounds int64 `json:"large_bounds"`
26- OnlyMaximum int64 `json:"only_maximum"`
2727 OnlyMinimum int64 `json:"only_minimum"`
28- SmallNegative int64 `json:"small_negative"`
29- SmallPositive int64 `json:"small_positive"`
28+ OnlyMaximum int64 `json:"only_maximum"`
3029 Unbounded int64 `json:"unbounded"`
30+ LargeBounds int64 `json:"large_bounds"`
3131 }
Mschema-golang/test/inputs/schema/integer-string.schema/default/quicktype.go+2 −2
@@ -98,7 +98,6 @@ type TopLevel struct {
9898 DidSet *UnionDidSet `json:"didSet"`
9999 Do *UnionDo `json:"do"`
100100 Double *UnionDouble `json:"double"`
101- Dummy *float64 `json:"dummy,omitempty"`
102101 Dynamic *UnionDynamic `json:"dynamic"`
103102 DynamicCast *UnionDynamicCast `json:"dynamic_cast"`
104103 Elif *UnionElif `json:"elif"`
@@ -151,8 +150,8 @@ type TopLevel struct {
151150 Int *UnionInt `json:"int"`
152151 Interface *UnionInterface `json:"interface"`
153152 Internal *UnionInternal `json:"internal"`
154- Is *UnionIs `json:"is"`
155153 Iterable *UnionIterable `json:"iterable"`
154+ Is *UnionIs `json:"is"`
156155 Jdec *UnionJdec `json:"jdec"`
157156 Jenc *UnionJenc `json:"jenc"`
158157 Jpipe *UnionJpipe `json:"jpipe"`
@@ -299,6 +298,7 @@ type TopLevel struct {
299298 XorEq *UnionXorEq `json:"xor_eq"`
300299 Yes *UnionYES `json:"YES"`
301300 Yield *UnionYield `json:"yield"`
301+ Dummy *float64 `json:"dummy,omitempty"`
302302 }
303303
304304 type ASM struct {
Mschema-golang/test/inputs/schema/integer-type.schema/default/quicktype.go+1 −1
@@ -23,7 +23,7 @@ type TopLevel struct {
2323 }
2424
2525 type LightParams struct {
26- AppID string `json:"app_id"`
2726 OutletID string `json:"outlet_id"`
27+ AppID string `json:"app_id"`
2828 RGBA string `json:"rgba"`
2929 }
Mschema-golang/test/inputs/schema/keyword-unions.schema/default/quicktype.go+1 −1
@@ -22,9 +22,9 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2222 }
2323
2424 type TopLevel struct {
25+ MinOnly []string `json:"minOnly"`
2526 MaxOnly []int64 `json:"maxOnly"`
2627 MinAndMax []float64 `json:"minAndMax"`
27- MinOnly []string `json:"minOnly"`
2828 Plain []string `json:"plain"`
2929 UnionItems []UnionItem `json:"unionItems"`
3030 }
Mschema-golang/test/inputs/schema/light.schema/default/quicktype.go+4 −4
@@ -20,11 +20,11 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2020
2121 type TopLevel struct {
2222 Free int64 `json:"free"`
23- Intersection int64 `json:"intersection"`
24- Max int64 `json:"max"`
2523 Min int64 `json:"min"`
24+ Max int64 `json:"max"`
2625 Minmax int64 `json:"minmax"`
27- MinMaxIntersection int64 `json:"minMaxIntersection"`
28- MinMaxUnion int64 `json:"minMaxUnion"`
2926 Union int64 `json:"union"`
27+ MinMaxUnion int64 `json:"minMaxUnion"`
28+ Intersection int64 `json:"intersection"`
29+ MinMaxIntersection int64 `json:"minMaxIntersection"`
3030 }
Mschema-golang/test/inputs/schema/min-max-items.schema/default/quicktype.go+4 −4
@@ -20,11 +20,11 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2020
2121 type TopLevel struct {
2222 Free float64 `json:"free"`
23- Intersection float64 `json:"intersection"`
24- Max float64 `json:"max"`
2523 Min float64 `json:"min"`
24+ Max float64 `json:"max"`
2625 Minmax float64 `json:"minmax"`
27- MinMaxIntersection float64 `json:"minMaxIntersection"`
28- MinMaxUnion float64 `json:"minMaxUnion"`
2926 Union float64 `json:"union"`
27+ MinMaxUnion float64 `json:"minMaxUnion"`
28+ Intersection float64 `json:"intersection"`
29+ MinMaxIntersection float64 `json:"minMaxIntersection"`
3030 }
Mschema-golang/test/inputs/schema/minmax-integer.schema/default/quicktype.go+5 −5
@@ -22,14 +22,14 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2222 }
2323
2424 type TopLevel struct {
25- Intersection string `json:"intersection"`
26- InUnion *InUnion `json:"inUnion"`
27- Maxlength string `json:"maxlength"`
2825 Minlength string `json:"minlength"`
29- MinMaxIntersection string `json:"minMaxIntersection"`
26+ Maxlength string `json:"maxlength"`
3027 Minmaxlength string `json:"minmaxlength"`
31- MinMaxUnion string `json:"minMaxUnion"`
3228 Union string `json:"union"`
29+ InUnion *InUnion `json:"inUnion"`
30+ MinMaxUnion string `json:"minMaxUnion"`
31+ Intersection string `json:"intersection"`
32+ MinMaxIntersection string `json:"minMaxIntersection"`
3333 }
3434
3535 type InUnion struct {
Mschema-golang/test/inputs/schema/minmax.schema/default/quicktype.go+1 −1
@@ -19,7 +19,7 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1919 }
2020
2121 type TopLevel struct {
22- Bar int64 `json:"bar"`
2322 Foo int64 `json:"foo"`
23+ Bar int64 `json:"bar"`
2424 Quux bool `json:"quux"`
2525 }
Mschema-golang/test/inputs/schema/minmaxlength.schema/default/quicktype.go+1 −1
@@ -19,8 +19,8 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1919 }
2020
2121 type TopLevel struct {
22- B *string `json:"b"`
2322 Kind Kind `json:"kind"`
23+ B *string `json:"b"`
2424 }
2525
2626 type Kind string
Mschema-golang/test/inputs/schema/non-standard-ref.schema/default/quicktype.go+1 −1
@@ -19,8 +19,8 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1919 }
2020
2121 type TopLevel struct {
22- B *string `json:"b"`
2322 Kind Kind `json:"kind"`
23+ B *string `json:"b"`
2424 }
2525
2626 type Kind string
Mschema-golang/test/inputs/schema/nullable-optional-one-of.schema/default/quicktype.go+1 −1
@@ -19,6 +19,6 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1919 }
2020
2121 type TopLevel struct {
22- Bar bool `json:"bar"`
2322 Foo interface{} `json:"foo"`
23+ Bar bool `json:"bar"`
2424 }
Mschema-golang/test/inputs/schema/nullable-optional-one-of.schema/omit-empty-true--1b4b28fcc762/quicktype.go+3 −3
@@ -20,12 +20,12 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2020
2121 type TopLevel struct {
2222 Coordinates []Coordinate `json:"coordinates,omitempty"`
23- Count *int64 `json:"count,omitempty"`
24- Label *string `json:"label,omitempty"`
2523 RequiredCoordinates []Coordinate `json:"requiredCoordinates"`
24+ Count *int64 `json:"count,omitempty"`
2625 RequiredCount int64 `json:"requiredCount"`
27- RequiredLabel string `json:"requiredLabel"`
2826 Weight *float64 `json:"weight,omitempty"`
27+ Label *string `json:"label,omitempty"`
28+ RequiredLabel string `json:"requiredLabel"`
2929 }
3030
3131 type Coordinate struct {
Mschema-golang/test/inputs/schema/optional-any.schema/default/quicktype.go+3 −3
@@ -19,9 +19,9 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1919 }
2020
2121 type TopLevel struct {
22- OptDouble *float64 `json:"optDouble,omitempty"`
22+ ReqZeroMin int64 `json:"reqZeroMin"`
2323 OptInt *int64 `json:"optInt,omitempty"`
24- OptPattern *string `json:"optPattern,omitempty"`
24+ OptDouble *float64 `json:"optDouble,omitempty"`
2525 OptString *string `json:"optString,omitempty"`
26- ReqZeroMin int64 `json:"reqZeroMin"`
26+ OptPattern *string `json:"optPattern,omitempty"`
2727 }
Mschema-golang/test/inputs/schema/optional-const-ref.schema/default/quicktype.go+4 −4
@@ -21,10 +21,10 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2121 }
2222
2323 type TopLevel struct {
24- OptionalDate *string `json:"optional-date,omitempty"`
25- OptionalDateTime *time.Time `json:"optional-date-time,omitempty"`
26- OptionalTime *string `json:"optional-time,omitempty"`
2724 RequiredDate string `json:"required-date"`
28- RequiredDateTime time.Time `json:"required-date-time"`
2925 RequiredTime string `json:"required-time"`
26+ RequiredDateTime time.Time `json:"required-date-time"`
27+ OptionalDate *string `json:"optional-date,omitempty"`
28+ OptionalTime *string `json:"optional-time,omitempty"`
29+ OptionalDateTime *time.Time `json:"optional-date-time,omitempty"`
3030 }
Mschema-golang/test/inputs/schema/optional-constraints.schema/default/quicktype.go+1 −1
@@ -22,8 +22,8 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2222 }
2323
2424 type TopLevel struct {
25- Open []Open `json:"open"`
2625 Tuple []Open `json:"tuple"`
26+ Open []Open `json:"open"`
2727 }
2828
2929 type Open struct {
Mschema-golang/test/inputs/schema/optional-date-time.schema/default/quicktype.go+34 −0
@@ -0,0 +1,34 @@
1+// Code generated from JSON Schema using quicktype. DO NOT EDIT.
2+// To parse and unparse this JSON data, add this code to your project and do:
3+//
4+// topLevel, err := UnmarshalTopLevel(bytes)
5+// bytes, err = topLevel.Marshal()
6+
7+package main
8+
9+import "encoding/json"
10+
11+func UnmarshalTopLevel(data []byte) (TopLevel, error) {
12+ var r TopLevel
13+ err := json.Unmarshal(data, &r)
14+ return r, err
15+}
16+
17+func (r *TopLevel) Marshal() ([]byte, error) {
18+ return json.Marshal(r)
19+}
20+
21+type TopLevel struct {
22+ Zebra string `json:"zebra"`
23+ Mango float64 `json:"mango"`
24+ Apple bool `json:"apple"`
25+ Delta string `json:"delta"`
26+ Banana int64 `json:"banana"`
27+ Ordered Ordered `json:"ordered"`
28+}
29+
30+type Ordered struct {
31+ Mango float64 `json:"mango"`
32+ Zebra string `json:"zebra"`
33+ Apple bool `json:"apple"`
34+}
Mschema-golang/test/inputs/schema/prefix-items.schema/default/quicktype.go+8 −8
@@ -26,13 +26,13 @@ type TopLevel struct {
2626
2727 type Fruit struct {
2828 Apple *bool `json:"apple,omitempty"`
29- Berries []Berry `json:"berries,omitempty"`
3029 Orange *bool `json:"orange,omitempty"`
30+ Berries []Berry `json:"berries,omitempty"`
3131 }
3232
3333 type Berry struct {
34- Color *Color `json:"color,omitempty"`
3534 Name *string `json:"name,omitempty"`
35+ Color *Color `json:"color,omitempty"`
3636 Shapes []Shape `json:"shapes,omitempty"`
3737 }
3838
@@ -41,8 +41,8 @@ type Color struct {
4141 }
4242
4343 type Shape struct {
44- Geometry *Geometry `json:"geometry,omitempty"`
4544 History *History `json:"history,omitempty"`
45+ Geometry *Geometry `json:"geometry,omitempty"`
4646 }
4747
4848 type Geometry struct {
@@ -59,9 +59,9 @@ type RectShape struct {
5959 }
6060
6161 type Part struct {
62- Depth *string `json:"depth,omitempty"`
6362 Length *string `json:"length,omitempty"`
6463 Width *string `json:"width,omitempty"`
64+ Depth *string `json:"depth,omitempty"`
6565 }
6666
6767 type History struct {
@@ -69,12 +69,12 @@ type History struct {
6969 }
7070
7171 type Vehicle struct {
72- Brand *string `json:"brand,omitempty"`
7372 ID *string `json:"id,omitempty"`
74- Speed *Speed `json:"speed,omitempty"`
75- SubModule *bool `json:"subModule,omitempty"`
7673 Type *VehicleType `json:"type,omitempty"`
74+ Speed *Speed `json:"speed,omitempty"`
7775 Year *string `json:"year,omitempty"`
76+ Brand *string `json:"brand,omitempty"`
77+ SubModule *bool `json:"subModule,omitempty"`
7878 }
7979
8080 type Speed struct {
@@ -82,8 +82,8 @@ type Speed struct {
8282 }
8383
8484 type Limit struct {
85- Maximum *float64 `json:"maximum,omitempty"`
8685 Minimum *float64 `json:"minimum,omitempty"`
86+ Maximum *float64 `json:"maximum,omitempty"`
8787 }
8888
8989 type VehicleType struct {
Aschema-golang/test/inputs/schema/property-order.schema/default/quicktype.go+2 −2
@@ -22,13 +22,13 @@ func (r *TopLevel) Marshal() ([]byte, error) {
2222 }
2323
2424 type TopLevel struct {
25- Next *Next `json:"next"`
2625 Value string `json:"value"`
26+ Next *Next `json:"next"`
2727 }
2828
2929 type Node struct {
30- Next *Next `json:"next"`
3130 Value string `json:"value"`
31+ Next *Next `json:"next"`
3232 }
3333
3434 type Next struct {
Mschema-golang/test/inputs/schema/renaming-bug.schema/default/quicktype.go+3 −3
@@ -19,10 +19,10 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1919 }
2020
2121 type TopLevel struct {
22- ArrNullable []*string `json:"arrNullable,omitempty"`
23- ArrOne []string `json:"arrOne,omitempty"`
24- Nullable *string `json:"nullable"`
2522 One string `json:"one"`
2623 Optional *string `json:"optional,omitempty"`
24+ Nullable *string `json:"nullable"`
25+ ArrOne []string `json:"arrOne,omitempty"`
26+ ArrNullable []*string `json:"arrNullable,omitempty"`
2727 UnionWithEnum string `json:"unionWithEnum"`
2828 }
Mschema-golang/test/inputs/schema/rust-cycle-breaker-union.schema/default/quicktype.go+26 −26
@@ -333,6 +333,10 @@ type MarkConfig struct {
333333 //
334334 // __Default value:__ (None)
335335 Fill *string `json:"fill,omitempty"`
336+ // The fill opacity (value between [0,1]).
337+ //
338+ // __Default value:__ `1`
339+ FillOpacity *float64 `json:"fillOpacity,omitempty"`
336340 // Whether the mark's color should be used as fill color instead of stroke color.
337341 //
338342 // __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -341,10 +345,6 @@ type MarkConfig struct {
341345 //
342346 // __Note:__ This property cannot be used in a [style config](mark.html#style-config).
343347 Filled *bool `json:"filled,omitempty"`
344- // The fill opacity (value between [0,1]).
345- //
346- // __Default value:__ `1`
347- FillOpacity *float64 `json:"fillOpacity,omitempty"`
348348 // The typeface to set the text in (e.g., `"Helvetica Neue"`).
349349 Font *string `json:"font,omitempty"`
350350 // The font size, in pixels.
@@ -530,12 +530,12 @@ type AxisConfig struct {
530530 TickColor *string `json:"tickColor,omitempty"`
531531 // Boolean flag indicating if pixel position values should be rounded to the nearest integer.
532532 TickRound *bool `json:"tickRound,omitempty"`
533- // Boolean value that determines whether the axis should include ticks.
534- Ticks *bool `json:"ticks,omitempty"`
535533 // The size in pixels of axis ticks.
536534 TickSize *float64 `json:"tickSize,omitempty"`
537535 // The width, in pixels, of ticks.
538536 TickWidth *float64 `json:"tickWidth,omitempty"`
537+ // Boolean value that determines whether the axis should include ticks.
538+ Ticks *bool `json:"ticks,omitempty"`
539539 // Horizontal text alignment of axis titles.
540540 TitleAlign *string `json:"titleAlign,omitempty"`
541541 // Angle in degrees of axis titles.
@@ -668,12 +668,12 @@ type VGAxisConfig struct {
668668 TickColor *string `json:"tickColor,omitempty"`
669669 // Boolean flag indicating if pixel position values should be rounded to the nearest integer.
670670 TickRound *bool `json:"tickRound,omitempty"`
671- // Boolean value that determines whether the axis should include ticks.
672- Ticks *bool `json:"ticks,omitempty"`
673671 // The size in pixels of axis ticks.
674672 TickSize *float64 `json:"tickSize,omitempty"`
675673 // The width, in pixels, of ticks.
676674 TickWidth *float64 `json:"tickWidth,omitempty"`
675+ // Boolean value that determines whether the axis should include ticks.
676+ Ticks *bool `json:"ticks,omitempty"`
677677 // Horizontal text alignment of axis titles.
678678 TitleAlign *string `json:"titleAlign,omitempty"`
679679 // Angle in degrees of axis titles.
@@ -743,6 +743,10 @@ type BarConfig struct {
743743 //
744744 // __Default value:__ (None)
745745 Fill *string `json:"fill,omitempty"`
746+ // The fill opacity (value between [0,1]).
747+ //
748+ // __Default value:__ `1`
749+ FillOpacity *float64 `json:"fillOpacity,omitempty"`
746750 // Whether the mark's color should be used as fill color instead of stroke color.
747751 //
748752 // __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -751,10 +755,6 @@ type BarConfig struct {
751755 //
752756 // __Note:__ This property cannot be used in a [style config](mark.html#style-config).
753757 Filled *bool `json:"filled,omitempty"`
754- // The fill opacity (value between [0,1]).
755- //
756- // __Default value:__ `1`
757- FillOpacity *float64 `json:"fillOpacity,omitempty"`
758758 // The typeface to set the text in (e.g., `"Helvetica Neue"`).
759759 Font *string `json:"font,omitempty"`
760760 // The font size, in pixels.
@@ -1422,6 +1422,10 @@ type TextConfig struct {
14221422 //
14231423 // __Default value:__ (None)
14241424 Fill *string `json:"fill,omitempty"`
1425+ // The fill opacity (value between [0,1]).
1426+ //
1427+ // __Default value:__ `1`
1428+ FillOpacity *float64 `json:"fillOpacity,omitempty"`
14251429 // Whether the mark's color should be used as fill color instead of stroke color.
14261430 //
14271431 // __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -1430,10 +1434,6 @@ type TextConfig struct {
14301434 //
14311435 // __Note:__ This property cannot be used in a [style config](mark.html#style-config).
14321436 Filled *bool `json:"filled,omitempty"`
1433- // The fill opacity (value between [0,1]).
1434- //
1435- // __Default value:__ `1`
1436- FillOpacity *float64 `json:"fillOpacity,omitempty"`
14371437 // The typeface to set the text in (e.g., `"Helvetica Neue"`).
14381438 Font *string `json:"font,omitempty"`
14391439 // The font size, in pixels.
@@ -1556,6 +1556,10 @@ type TickConfig struct {
15561556 //
15571557 // __Default value:__ (None)
15581558 Fill *string `json:"fill,omitempty"`
1559+ // The fill opacity (value between [0,1]).
1560+ //
1561+ // __Default value:__ `1`
1562+ FillOpacity *float64 `json:"fillOpacity,omitempty"`
15591563 // Whether the mark's color should be used as fill color instead of stroke color.
15601564 //
15611565 // __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -1564,10 +1568,6 @@ type TickConfig struct {
15641568 //
15651569 // __Note:__ This property cannot be used in a [style config](mark.html#style-config).
15661570 Filled *bool `json:"filled,omitempty"`
1567- // The fill opacity (value between [0,1]).
1568- //
1569- // __Default value:__ `1`
1570- FillOpacity *float64 `json:"fillOpacity,omitempty"`
15711571 // The typeface to set the text in (e.g., `"Helvetica Neue"`).
15721572 Font *string `json:"font,omitempty"`
15731573 // The font size, in pixels.
@@ -2962,10 +2962,10 @@ type Axis struct {
29622962 // may be different so that values are "nice" (multiples of 2, 5, 10) and lie within the
29632963 // underlying scale's range.
29642964 TickCount *float64 `json:"tickCount,omitempty"`
2965- // Boolean value that determines whether the axis should include ticks.
2966- Ticks *bool `json:"ticks,omitempty"`
29672965 // The size in pixels of axis ticks.
29682966 TickSize *float64 `json:"tickSize,omitempty"`
2967+ // Boolean value that determines whether the axis should include ticks.
2968+ Ticks *bool `json:"ticks,omitempty"`
29692969 // A title for the field. If `null`, the title will be removed.
29702970 //
29712971 // __Default value:__ derived from the field's name and transformation function
@@ -3304,6 +3304,10 @@ type MarkDef struct {
33043304 //
33053305 // __Default value:__ (None)
33063306 Fill *string `json:"fill,omitempty"`
3307+ // The fill opacity (value between [0,1]).
3308+ //
3309+ // __Default value:__ `1`
3310+ FillOpacity *float64 `json:"fillOpacity,omitempty"`
33073311 // Whether the mark's color should be used as fill color instead of stroke color.
33083312 //
33093313 // __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -3312,10 +3316,6 @@ type MarkDef struct {
33123316 //
33133317 // __Note:__ This property cannot be used in a [style config](mark.html#style-config).
33143318 Filled *bool `json:"filled,omitempty"`
3315- // The fill opacity (value between [0,1]).
3316- //
3317- // __Default value:__ `1`
3318- FillOpacity *float64 `json:"fillOpacity,omitempty"`
33193319 // The typeface to set the text in (e.g., `"Helvetica Neue"`).
33203320 Font *string `json:"font,omitempty"`
33213321 // The font size, in pixels.
Mschema-golang/test/inputs/schema/uuid.schema/default/quicktype.go+2 −2
@@ -14,9 +14,9 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1414 }
1515
1616 type TopLevel struct {
17- ComplexUnionArray []ComplexUnionArrayElement `json:"complex-union-array"`
1817 Date string `json:"date"`
19- DateTime time.Time `json:"date-time"`
2018 Time string `json:"time"`
19+ DateTime time.Time `json:"date-time"`
2120 UnionArray []string `json:"union-array"`
21+ ComplexUnionArray []ComplexUnionArrayElement `json:"complex-union-array"`
2222 }
Mschema-golang/test/inputs/schema/vega-lite.schema/default/quicktype.go+2 −2
@@ -17,11 +17,11 @@ func (r *TopLevel) Marshal() ([]byte, error) {
1717 }
1818
1919 type TopLevel struct {
20- ComplexUnionArray []ComplexUnionArrayElement `json:"complex-union-array"`
2120 Date string `json:"date"`
22- DateTime time.Time `json:"date-time"`
2321 Time string `json:"time"`
22+ DateTime time.Time `json:"date-time"`
2423 UnionArray []string `json:"union-array"`
24+ ComplexUnionArray []ComplexUnionArrayElement `json:"complex-union-array"`
2525 }
2626
2727 type ComplexUnionArrayEnum string
Mschema-haskell/test/inputs/schema/accessors.schema/default/QuickType.hs+7 −7
@@ -15,10 +15,10 @@ import Data.HashMap.Strict (HashMap)
1515 import Data.Text (Text)
1616
1717 data QuickType = QuickType
18- { barreQuickType :: Text
18+ { unionizationQuickType :: Union
1919 , enumerificationQuickType :: EnumEnum
2020 , fooQuickType :: Text
21- , unionizationQuickType :: Union
21+ , barreQuickType :: Text
2222 } deriving (Show)
2323
2424 data EnumEnum
@@ -36,20 +36,20 @@ decodeTopLevel :: ByteString -> Maybe QuickType
3636 decodeTopLevel = decode
3737
3838 instance ToJSON QuickType where
39- toJSON (QuickType barreQuickType enumerificationQuickType fooQuickType unionizationQuickType) =
39+ toJSON (QuickType unionizationQuickType enumerificationQuickType fooQuickType barreQuickType) =
4040 object
41- [ "bar" .= barreQuickType
41+ [ "union" .= unionizationQuickType
4242 , "enum" .= enumerificationQuickType
4343 , "foo" .= fooQuickType
44- , "union" .= unionizationQuickType
44+ , "bar" .= barreQuickType
4545 ]
4646
4747 instance FromJSON QuickType where
4848 parseJSON (Object v) = QuickType
49- <$> v .: "bar"
49+ <$> v .: "union"
5050 <*> v .: "enum"
5151 <*> v .: "foo"
52- <*> v .: "union"
52+ <*> v .: "bar"
5353
5454 instance ToJSON EnumEnum where
5555 toJSON FireEnumEnum = "red"
Mschema-haskell/test/inputs/schema/bool-string.schema/default/QuickType.hs+13 −13
@@ -14,11 +14,11 @@ import Data.HashMap.Strict (HashMap)
1414 import Data.Text (Text)
1515
1616 data QuickType = QuickType
17- { arrNullableQuickType :: Maybe ([(Maybe Text)])
18- , arrOneQuickType :: Maybe ([Text])
19- , nullableQuickType :: Maybe Text
20- , oneQuickType :: Text
17+ { oneQuickType :: Text
2118 , optionalQuickType :: Maybe Text
19+ , nullableQuickType :: Maybe Text
20+ , arrOneQuickType :: Maybe ([Text])
21+ , arrNullableQuickType :: Maybe ([(Maybe Text)])
2222 , unionWithBoolQuickType :: UnionWithBool
2323 , unionWithBoolAndEnumQuickType :: UnionWithBool
2424 } deriving (Show)
@@ -32,24 +32,24 @@ decodeTopLevel :: ByteString -> Maybe QuickType
3232 decodeTopLevel = decode
3333
3434 instance ToJSON QuickType where
35- toJSON (QuickType arrNullableQuickType arrOneQuickType nullableQuickType oneQuickType optionalQuickType unionWithBoolQuickType unionWithBoolAndEnumQuickType) =
35+ toJSON (QuickType oneQuickType optionalQuickType nullableQuickType arrOneQuickType arrNullableQuickType unionWithBoolQuickType unionWithBoolAndEnumQuickType) =
3636 object
37- [ "arrNullable" .= arrNullableQuickType
38- , "arrOne" .= arrOneQuickType
39- , "nullable" .= nullableQuickType
40- , "one" .= oneQuickType
37+ [ "one" .= oneQuickType
4138 , "optional" .= optionalQuickType
39+ , "nullable" .= nullableQuickType
40+ , "arrOne" .= arrOneQuickType
41+ , "arrNullable" .= arrNullableQuickType
4242 , "unionWithBool" .= unionWithBoolQuickType
4343 , "unionWithBoolAndEnum" .= unionWithBoolAndEnumQuickType
4444 ]
4545
4646 instance FromJSON QuickType where
4747 parseJSON (Object v) = QuickType
48- <$> v .:? "arrNullable"
49- <*> v .:? "arrOne"
50- <*> v .: "nullable"
51- <*> v .: "one"
48+ <$> v .: "one"
5249 <*> v .:? "optional"
50+ <*> v .: "nullable"
51+ <*> v .:? "arrOne"
52+ <*> v .:? "arrNullable"
5353 <*> v .: "unionWithBool"
5454 <*> v .: "unionWithBoolAndEnum"
Mschema-haskell/test/inputs/schema/comment-injection.schema/default/QuickType.hs+16 −16
@@ -25,15 +25,6 @@ import Data.Text (Text)
2525 }
2626 }
2727
28-trailingBackslash:
29-Ends with a backslash \
30-
31-trailingQuote:
32-Ends with a quote "
33-
34-trailingTripleQuote:
35-Ends with a triple quote """
36-
3728 value:
3829 Property delimiters:
3930 */
@@ -47,29 +38,38 @@ Property delimiters:
4738 }
4839 }
4940 }
41+
42+trailingBackslash:
43+Ends with a backslash \
44+
45+trailingQuote:
46+Ends with a quote "
47+
48+trailingTripleQuote:
49+Ends with a triple quote """
5050 -}
5151 data QuickType = QuickType
52- { trailingBackslashQuickType :: Maybe Text
52+ { valueQuickType :: Text
53+ , trailingBackslashQuickType :: Maybe Text
5354 , trailingQuoteQuickType :: Maybe Text
5455 , trailingTripleQuoteQuickType :: Maybe Text
55- , valueQuickType :: Text
5656 } deriving (Show)
5757
5858 decodeTopLevel :: ByteString -> Maybe QuickType
5959 decodeTopLevel = decode
6060
6161 instance ToJSON QuickType where
62- toJSON (QuickType trailingBackslashQuickType trailingQuoteQuickType trailingTripleQuoteQuickType valueQuickType) =
62+ toJSON (QuickType valueQuickType trailingBackslashQuickType trailingQuoteQuickType trailingTripleQuoteQuickType) =
6363 object
64- [ "trailingBackslash" .= trailingBackslashQuickType
64+ [ "value" .= valueQuickType
65+ , "trailingBackslash" .= trailingBackslashQuickType
6566 , "trailingQuote" .= trailingQuoteQuickType
6667 , "trailingTripleQuote" .= trailingTripleQuoteQuickType
67- , "value" .= valueQuickType
6868 ]
6969
7070 instance FromJSON QuickType where
7171 parseJSON (Object v) = QuickType
72- <$> v .:? "trailingBackslash"
72+ <$> v .: "value"
73+ <*> v .:? "trailingBackslash"
7374 <*> v .:? "trailingQuote"
7475 <*> v .:? "trailingTripleQuote"
75- <*> v .: "value"
Mschema-haskell/test/inputs/schema/date-time-or-string.schema/default/QuickType.hs+7 −7
@@ -13,21 +13,21 @@ import Data.HashMap.Strict (HashMap)
1313 import Data.Text (Text)
1414
1515 data QuickType = QuickType
16- { barQuickType :: Text
17- , fooQuickType :: Text
16+ { fooQuickType :: Text
17+ , barQuickType :: Text
1818 } deriving (Show)
1919
2020 decodeTopLevel :: ByteString -> Maybe QuickType
2121 decodeTopLevel = decode
2222
2323 instance ToJSON QuickType where
24- toJSON (QuickType barQuickType fooQuickType) =
24+ toJSON (QuickType fooQuickType barQuickType) =
2525 object
26- [ "bar" .= barQuickType
27- , "foo" .= fooQuickType
26+ [ "foo" .= fooQuickType
27+ , "bar" .= barQuickType
2828 ]
2929
3030 instance FromJSON QuickType where
3131 parseJSON (Object v) = QuickType
32- <$> v .: "bar"
33- <*> v .: "foo"
32+ <$> v .: "foo"
33+ <*> v .: "bar"
Mschema-haskell/test/inputs/schema/date-time.schema/default/QuickType.hs+10 −10
@@ -14,11 +14,11 @@ import Data.HashMap.Strict (HashMap)
1414 import Data.Text (Text)
1515
1616 data QuickType = QuickType
17- { complexUnionArrayQuickType :: [ComplexUnionArray]
18- , dateQuickType :: Text
19- , dateTimeQuickType :: Text
17+ { dateQuickType :: Text
2018 , timeQuickType :: Text
19+ , dateTimeQuickType :: Text
2120 , unionArrayQuickType :: [Text]
21+ , complexUnionArrayQuickType :: [ComplexUnionArray]
2222 } deriving (Show)
2323
2424 data ComplexUnionArray
@@ -30,22 +30,22 @@ decodeTopLevel :: ByteString -> Maybe QuickType
3030 decodeTopLevel = decode
3131
3232 instance ToJSON QuickType where
33- toJSON (QuickType complexUnionArrayQuickType dateQuickType dateTimeQuickType timeQuickType unionArrayQuickType) =
33+ toJSON (QuickType dateQuickType timeQuickType dateTimeQuickType unionArrayQuickType complexUnionArrayQuickType) =
3434 object
35- [ "complex-union-array" .= complexUnionArrayQuickType
36- , "date" .= dateQuickType
37- , "date-time" .= dateTimeQuickType
35+ [ "date" .= dateQuickType
3836 , "time" .= timeQuickType
37+ , "date-time" .= dateTimeQuickType
3938 , "union-array" .= unionArrayQuickType
39+ , "complex-union-array" .= complexUnionArrayQuickType
4040 ]
4141
4242 instance FromJSON QuickType where
4343 parseJSON (Object v) = QuickType
44- <$> v .: "complex-union-array"
45- <*> v .: "date"
46- <*> v .: "date-time"
44+ <$> v .: "date"
4745 <*> v .: "time"
46+ <*> v .: "date-time"
4847 <*> v .: "union-array"
48+ <*> v .: "complex-union-array"
4949
5050 instance ToJSON ComplexUnionArray where
5151 toJSON (IntegerInComplexUnionArray x) = toJSON x
Mschema-haskell/test/inputs/schema/description.schema/default/QuickType.hs+11 −11
@@ -19,21 +19,21 @@ import Data.Text (Text)
1919 {-| The top-level class.
2020 Its description has two lines.
2121
22-bar:
23-A pretty boolean
22+union:
23+Either a number or a string
2424
2525 enum:
2626 An enumeration
2727
28-union:
29-Either a number or a string
28+bar:
29+A pretty boolean
3030 -}
3131 data QuickType = QuickType
32- { barQuickType :: Maybe Bool
32+ { unionQuickType :: Union
3333 , enumQuickType :: EnumEnum
3434 , fooQuickType :: Maybe Float
35+ , barQuickType :: Maybe Bool
3536 , objectOrStringQuickType :: ObjectOrStringUnion
36- , unionQuickType :: Union
3737 } deriving (Show)
3838
3939 {-| An enumeration -}
@@ -66,22 +66,22 @@ decodeTopLevel :: ByteString -> Maybe QuickType
6666 decodeTopLevel = decode
6767
6868 instance ToJSON QuickType where
69- toJSON (QuickType barQuickType enumQuickType fooQuickType objectOrStringQuickType unionQuickType) =
69+ toJSON (QuickType unionQuickType enumQuickType fooQuickType barQuickType objectOrStringQuickType) =
7070 object
71- [ "bar" .= barQuickType
71+ [ "union" .= unionQuickType
7272 , "enum" .= enumQuickType
7373 , "foo" .= fooQuickType
74+ , "bar" .= barQuickType
7475 , "object-or-string" .= objectOrStringQuickType
75- , "union" .= unionQuickType
7676 ]
7777
7878 instance FromJSON QuickType where
7979 parseJSON (Object v) = QuickType
80- <$> v .:? "bar"
80+ <$> v .: "union"
8181 <*> v .: "enum"
8282 <*> v .:? "foo"
83+ <*> v .:? "bar"
8384 <*> v .: "object-or-string"
84- <*> v .: "union"
8585
8686 instance ToJSON EnumEnum where
8787 toJSON FooEnumEnum = "foo"
Mschema-haskell/test/inputs/schema/integer-string.schema/default/QuickType.hs+13 −13
@@ -14,11 +14,11 @@ import Data.HashMap.Strict (HashMap)
1414 import Data.Text (Text)
1515
1616 data QuickType = QuickType
17- { arrNullableQuickType :: Maybe ([(Maybe Text)])
18- , arrOneQuickType :: Maybe ([Text])
19- , nullableQuickType :: Maybe Text
20- , oneQuickType :: Text
17+ { oneQuickType :: Text
2118 , optionalQuickType :: Maybe Text
19+ , nullableQuickType :: Maybe Text
20+ , arrOneQuickType :: Maybe ([Text])
21+ , arrNullableQuickType :: Maybe ([(Maybe Text)])
2222 , unionWithIntQuickType :: UnionWithInt
2323 , unionWithIntAndEnumQuickType :: UnionWithInt
2424 } deriving (Show)
@@ -32,24 +32,24 @@ decodeTopLevel :: ByteString -> Maybe QuickType
3232 decodeTopLevel = decode
3333
3434 instance ToJSON QuickType where
35- toJSON (QuickType arrNullableQuickType arrOneQuickType nullableQuickType oneQuickType optionalQuickType unionWithIntQuickType unionWithIntAndEnumQuickType) =
35+ toJSON (QuickType oneQuickType optionalQuickType nullableQuickType arrOneQuickType arrNullableQuickType unionWithIntQuickType unionWithIntAndEnumQuickType) =
3636 object
37- [ "arrNullable" .= arrNullableQuickType
38- , "arrOne" .= arrOneQuickType
39- , "nullable" .= nullableQuickType
40- , "one" .= oneQuickType
37+ [ "one" .= oneQuickType
4138 , "optional" .= optionalQuickType
39+ , "nullable" .= nullableQuickType
40+ , "arrOne" .= arrOneQuickType
41+ , "arrNullable" .= arrNullableQuickType
4242 , "unionWithInt" .= unionWithIntQuickType
4343 , "unionWithIntAndEnum" .= unionWithIntAndEnumQuickType
4444 ]
4545
4646 instance FromJSON QuickType where
4747 parseJSON (Object v) = QuickType
48- <$> v .:? "arrNullable"
49- <*> v .:? "arrOne"
50- <*> v .: "nullable"
51- <*> v .: "one"
48+ <$> v .: "one"
5249 <*> v .:? "optional"
50+ <*> v .: "nullable"
51+ <*> v .:? "arrOne"
52+ <*> v .:? "arrNullable"
5353 <*> v .: "unionWithInt"
5454 <*> v .: "unionWithIntAndEnum"
Mschema-haskell/test/inputs/schema/integer-type.schema/default/QuickType.hs+19 −19
@@ -13,42 +13,42 @@ import Data.HashMap.Strict (HashMap)
1313 import Data.Text (Text)
1414
1515 data QuickType = QuickType
16- { aboveI32MaxQuickType :: Int
17- , belowI32MinQuickType :: Int
16+ { smallPositiveQuickType :: Int
17+ , smallNegativeQuickType :: Int
1818 , i32RangeQuickType :: Int
19- , largeBoundsQuickType :: Int
20- , onlyMaximumQuickType :: Int
19+ , aboveI32MaxQuickType :: Int
20+ , belowI32MinQuickType :: Int
2121 , onlyMinimumQuickType :: Int
22- , smallNegativeQuickType :: Int
23- , smallPositiveQuickType :: Int
22+ , onlyMaximumQuickType :: Int
2423 , unboundedQuickType :: Int
24+ , largeBoundsQuickType :: Int
2525 } deriving (Show)
2626
2727 decodeTopLevel :: ByteString -> Maybe QuickType
2828 decodeTopLevel = decode
2929
3030 instance ToJSON QuickType where
31- toJSON (QuickType aboveI32MaxQuickType belowI32MinQuickType i32RangeQuickType largeBoundsQuickType onlyMaximumQuickType onlyMinimumQuickType smallNegativeQuickType smallPositiveQuickType unboundedQuickType) =
31+ toJSON (QuickType smallPositiveQuickType smallNegativeQuickType i32RangeQuickType aboveI32MaxQuickType belowI32MinQuickType onlyMinimumQuickType onlyMaximumQuickType unboundedQuickType largeBoundsQuickType) =
3232 object
33- [ "above_i32_max" .= aboveI32MaxQuickType
34- , "below_i32_min" .= belowI32MinQuickType
33+ [ "small_positive" .= smallPositiveQuickType
34+ , "small_negative" .= smallNegativeQuickType
3535 , "i32_range" .= i32RangeQuickType
36- , "large_bounds" .= largeBoundsQuickType
37- , "only_maximum" .= onlyMaximumQuickType
36+ , "above_i32_max" .= aboveI32MaxQuickType
37+ , "below_i32_min" .= belowI32MinQuickType
3838 , "only_minimum" .= onlyMinimumQuickType
39- , "small_negative" .= smallNegativeQuickType
40- , "small_positive" .= smallPositiveQuickType
39+ , "only_maximum" .= onlyMaximumQuickType
4140 , "unbounded" .= unboundedQuickType
41+ , "large_bounds" .= largeBoundsQuickType
4242 ]
4343
4444 instance FromJSON QuickType where
4545 parseJSON (Object v) = QuickType
46- <$> v .: "above_i32_max"
47- <*> v .: "below_i32_min"
46+ <$> v .: "small_positive"
47+ <*> v .: "small_negative"
4848 <*> v .: "i32_range"
49- <*> v .: "large_bounds"
50- <*> v .: "only_maximum"
49+ <*> v .: "above_i32_max"
50+ <*> v .: "below_i32_min"
5151 <*> v .: "only_minimum"
52- <*> v .: "small_negative"
53- <*> v .: "small_positive"
52+ <*> v .: "only_maximum"
5453 <*> v .: "unbounded"
54+ <*> v .: "large_bounds"
Mschema-haskell/test/inputs/schema/light.schema/default/QuickType.hs+7 −7
@@ -18,8 +18,8 @@ data QuickType = QuickType
1818 } deriving (Show)
1919
2020 data LightParams = LightParams
21- { appIDLightParams :: Text
22- , outletIDLightParams :: Text
21+ { outletIDLightParams :: Text
22+ , appIDLightParams :: Text
2323 , rgbaLightParams :: Text
2424 } deriving (Show)
2525
@@ -37,15 +37,15 @@ instance FromJSON QuickType where
3737 <$> v .: "LightParams"
3838
3939 instance ToJSON LightParams where
40- toJSON (LightParams appIDLightParams outletIDLightParams rgbaLightParams) =
40+ toJSON (LightParams outletIDLightParams appIDLightParams rgbaLightParams) =
4141 object
42- [ "app_id" .= appIDLightParams
43- , "outlet_id" .= outletIDLightParams
42+ [ "outlet_id" .= outletIDLightParams
43+ , "app_id" .= appIDLightParams
4444 , "rgba" .= rgbaLightParams
4545 ]
4646
4747 instance FromJSON LightParams where
4848 parseJSON (Object v) = LightParams
49- <$> v .: "app_id"
50- <*> v .: "outlet_id"
49+ <$> v .: "outlet_id"
50+ <*> v .: "app_id"
5151 <*> v .: "rgba"
Mschema-haskell/test/inputs/schema/min-max-items.schema/default/QuickType.hs+7 −7
@@ -14,9 +14,9 @@ import Data.HashMap.Strict (HashMap)
1414 import Data.Text (Text)
1515
1616 data QuickType = QuickType
17- { maxOnlyQuickType :: [Int]
17+ { minOnlyQuickType :: [Text]
18+ , maxOnlyQuickType :: [Int]
1819 , minAndMaxQuickType :: [Float]
19- , minOnlyQuickType :: [Text]
2020 , plainQuickType :: [Text]
2121 , unionItemsQuickType :: [UnionItem]
2222 } deriving (Show)
@@ -30,20 +30,20 @@ decodeTopLevel :: ByteString -> Maybe QuickType
3030 decodeTopLevel = decode
3131
3232 instance ToJSON QuickType where
33- toJSON (QuickType maxOnlyQuickType minAndMaxQuickType minOnlyQuickType plainQuickType unionItemsQuickType) =
33+ toJSON (QuickType minOnlyQuickType maxOnlyQuickType minAndMaxQuickType plainQuickType unionItemsQuickType) =
3434 object
35- [ "maxOnly" .= maxOnlyQuickType
35+ [ "minOnly" .= minOnlyQuickType
36+ , "maxOnly" .= maxOnlyQuickType
3637 , "minAndMax" .= minAndMaxQuickType
37- , "minOnly" .= minOnlyQuickType
3838 , "plain" .= plainQuickType
3939 , "unionItems" .= unionItemsQuickType
4040 ]
4141
4242 instance FromJSON QuickType where
4343 parseJSON (Object v) = QuickType
44- <$> v .: "maxOnly"
44+ <$> v .: "minOnly"
45+ <*> v .: "maxOnly"
4546 <*> v .: "minAndMax"
46- <*> v .: "minOnly"
4747 <*> v .: "plain"
4848 <*> v .: "unionItems"
Mschema-haskell/test/inputs/schema/minmax-integer.schema/default/QuickType.hs+13 −13
@@ -14,38 +14,38 @@ import Data.Text (Text)
1414
1515 data QuickType = QuickType
1616 { freeQuickType :: Int
17- , intersectionQuickType :: Int
18- , maxQuickType :: Int
1917 , minQuickType :: Int
18+ , maxQuickType :: Int
2019 , minmaxQuickType :: Int
21- , minMaxIntersectionQuickType :: Int
22- , minMaxUnionQuickType :: Int
2320 , unionQuickType :: Int
21+ , minMaxUnionQuickType :: Int
22+ , intersectionQuickType :: Int
23+ , minMaxIntersectionQuickType :: Int
2424 } deriving (Show)
2525
2626 decodeTopLevel :: ByteString -> Maybe QuickType
2727 decodeTopLevel = decode
2828
2929 instance ToJSON QuickType where
30- toJSON (QuickType freeQuickType intersectionQuickType maxQuickType minQuickType minmaxQuickType minMaxIntersectionQuickType minMaxUnionQuickType unionQuickType) =
30+ toJSON (QuickType freeQuickType minQuickType maxQuickType minmaxQuickType unionQuickType minMaxUnionQuickType intersectionQuickType minMaxIntersectionQuickType) =
3131 object
3232 [ "free" .= freeQuickType
33- , "intersection" .= intersectionQuickType
34- , "max" .= maxQuickType
3533 , "min" .= minQuickType
34+ , "max" .= maxQuickType
3635 , "minmax" .= minmaxQuickType
37- , "minMaxIntersection" .= minMaxIntersectionQuickType
38- , "minMaxUnion" .= minMaxUnionQuickType
3936 , "union" .= unionQuickType
37+ , "minMaxUnion" .= minMaxUnionQuickType
38+ , "intersection" .= intersectionQuickType
39+ , "minMaxIntersection" .= minMaxIntersectionQuickType
4040 ]
4141
4242 instance FromJSON QuickType where
4343 parseJSON (Object v) = QuickType
4444 <$> v .: "free"
45- <*> v .: "intersection"
46- <*> v .: "max"
4745 <*> v .: "min"
46+ <*> v .: "max"
4847 <*> v .: "minmax"
49- <*> v .: "minMaxIntersection"
50- <*> v .: "minMaxUnion"
5148 <*> v .: "union"
49+ <*> v .: "minMaxUnion"
50+ <*> v .: "intersection"
51+ <*> v .: "minMaxIntersection"
Mschema-haskell/test/inputs/schema/minmax.schema/default/QuickType.hs+13 −13
@@ -14,38 +14,38 @@ import Data.Text (Text)
1414
1515 data QuickType = QuickType
1616 { freeQuickType :: Float
17- , intersectionQuickType :: Float
18- , maxQuickType :: Float
1917 , minQuickType :: Float
18+ , maxQuickType :: Float
2019 , minmaxQuickType :: Float
21- , minMaxIntersectionQuickType :: Float
22- , minMaxUnionQuickType :: Float
2320 , unionQuickType :: Float
21+ , minMaxUnionQuickType :: Float
22+ , intersectionQuickType :: Float
23+ , minMaxIntersectionQuickType :: Float
2424 } deriving (Show)
2525
2626 decodeTopLevel :: ByteString -> Maybe QuickType
2727 decodeTopLevel = decode
2828
2929 instance ToJSON QuickType where
30- toJSON (QuickType freeQuickType intersectionQuickType maxQuickType minQuickType minmaxQuickType minMaxIntersectionQuickType minMaxUnionQuickType unionQuickType) =
30+ toJSON (QuickType freeQuickType minQuickType maxQuickType minmaxQuickType unionQuickType minMaxUnionQuickType intersectionQuickType minMaxIntersectionQuickType) =
3131 object
3232 [ "free" .= freeQuickType
33- , "intersection" .= intersectionQuickType
34- , "max" .= maxQuickType
3533 , "min" .= minQuickType
34+ , "max" .= maxQuickType
3635 , "minmax" .= minmaxQuickType
37- , "minMaxIntersection" .= minMaxIntersectionQuickType
38- , "minMaxUnion" .= minMaxUnionQuickType
3936 , "union" .= unionQuickType
37+ , "minMaxUnion" .= minMaxUnionQuickType
38+ , "intersection" .= intersectionQuickType
39+ , "minMaxIntersection" .= minMaxIntersectionQuickType
4040 ]
4141
4242 instance FromJSON QuickType where
4343 parseJSON (Object v) = QuickType
4444 <$> v .: "free"
45- <*> v .: "intersection"
46- <*> v .: "max"
4745 <*> v .: "min"
46+ <*> v .: "max"
4847 <*> v .: "minmax"
49- <*> v .: "minMaxIntersection"
50- <*> v .: "minMaxUnion"
5148 <*> v .: "union"
49+ <*> v .: "minMaxUnion"
50+ <*> v .: "intersection"
51+ <*> v .: "minMaxIntersection"
Mschema-haskell/test/inputs/schema/minmaxlength.schema/default/QuickType.hs+16 −16
@@ -14,14 +14,14 @@ import Data.HashMap.Strict (HashMap)
1414 import Data.Text (Text)
1515
1616 data QuickType = QuickType
17- { intersectionQuickType :: Text
18- , inUnionQuickType :: InUnion
17+ { minlengthQuickType :: Text
1918 , maxlengthQuickType :: Text
20- , minlengthQuickType :: Text
21- , minMaxIntersectionQuickType :: Text
2219 , minmaxlengthQuickType :: Text
23- , minMaxUnionQuickType :: Text
2420 , unionQuickType :: Text
21+ , inUnionQuickType :: InUnion
22+ , minMaxUnionQuickType :: Text
23+ , intersectionQuickType :: Text
24+ , minMaxIntersectionQuickType :: Text
2525 } deriving (Show)
2626
2727 data InUnion
@@ -33,28 +33,28 @@ decodeTopLevel :: ByteString -> Maybe QuickType
3333 decodeTopLevel = decode
3434
3535 instance ToJSON QuickType where
36- toJSON (QuickType intersectionQuickType inUnionQuickType maxlengthQuickType minlengthQuickType minMaxIntersectionQuickType minmaxlengthQuickType minMaxUnionQuickType unionQuickType) =
36+ toJSON (QuickType minlengthQuickType maxlengthQuickType minmaxlengthQuickType unionQuickType inUnionQuickType minMaxUnionQuickType intersectionQuickType minMaxIntersectionQuickType) =
3737 object
38- [ "intersection" .= intersectionQuickType
39- , "inUnion" .= inUnionQuickType
38+ [ "minlength" .= minlengthQuickType
4039 , "maxlength" .= maxlengthQuickType
41- , "minlength" .= minlengthQuickType
42- , "minMaxIntersection" .= minMaxIntersectionQuickType
4340 , "minmaxlength" .= minmaxlengthQuickType
44- , "minMaxUnion" .= minMaxUnionQuickType
4541 , "union" .= unionQuickType
42+ , "inUnion" .= inUnionQuickType
43+ , "minMaxUnion" .= minMaxUnionQuickType
44+ , "intersection" .= intersectionQuickType
45+ , "minMaxIntersection" .= minMaxIntersectionQuickType
4646 ]
4747
4848 instance FromJSON QuickType where
4949 parseJSON (Object v) = QuickType
50- <$> v .: "intersection"
51- <*> v .: "inUnion"
50+ <$> v .: "minlength"
5251 <*> v .: "maxlength"
53- <*> v .: "minlength"
54- <*> v .: "minMaxIntersection"
5552 <*> v .: "minmaxlength"
56- <*> v .: "minMaxUnion"
5753 <*> v .: "union"
54+ <*> v .: "inUnion"
55+ <*> v .: "minMaxUnion"
56+ <*> v .: "intersection"
57+ <*> v .: "minMaxIntersection"
5858
5959 instance ToJSON InUnion where
6060 toJSON (DoubleInInUnion x) = toJSON x
Mschema-haskell/test/inputs/schema/non-standard-ref.schema/default/QuickType.hs+7 −7
@@ -13,8 +13,8 @@ import Data.HashMap.Strict (HashMap)
1313 import Data.Text (Text)
1414
1515 data QuickType = QuickType
16- { barQuickType :: Int
17- , fooQuickType :: Int
16+ { fooQuickType :: Int
17+ , barQuickType :: Int
1818 , quuxQuickType :: Bool
1919 } deriving (Show)
2020
@@ -22,15 +22,15 @@ decodeTopLevel :: ByteString -> Maybe QuickType
2222 decodeTopLevel = decode
2323
2424 instance ToJSON QuickType where
25- toJSON (QuickType barQuickType fooQuickType quuxQuickType) =
25+ toJSON (QuickType fooQuickType barQuickType quuxQuickType) =
2626 object
27- [ "bar" .= barQuickType
28- , "foo" .= fooQuickType
27+ [ "foo" .= fooQuickType
28+ , "bar" .= barQuickType
2929 , "quux" .= quuxQuickType
3030 ]
3131
3232 instance FromJSON QuickType where
3333 parseJSON (Object v) = QuickType
34- <$> v .: "bar"
35- <*> v .: "foo"
34+ <$> v .: "foo"
35+ <*> v .: "bar"
3636 <*> v .: "quux"
Mschema-haskell/test/inputs/schema/optional-const-ref.schema/default/QuickType.hs+10 −10
@@ -15,12 +15,12 @@ import Data.Text (Text)
1515
1616 data QuickType = QuickType
1717 { coordinatesQuickType :: Maybe ([Coordinate])
18- , countQuickType :: Maybe Int
19- , labelQuickType :: Maybe Text
2018 , requiredCoordinatesQuickType :: [Coordinate]
19+ , countQuickType :: Maybe Int
2120 , requiredCountQuickType :: Int
22- , requiredLabelQuickType :: Text
2321 , weightQuickType :: Maybe Float
22+ , labelQuickType :: Maybe Text
23+ , requiredLabelQuickType :: Text
2424 } deriving (Show)
2525
2626 data Coordinate = Coordinate
@@ -32,26 +32,26 @@ decodeTopLevel :: ByteString -> Maybe QuickType
3232 decodeTopLevel = decode
3333
3434 instance ToJSON QuickType where
35- toJSON (QuickType coordinatesQuickType countQuickType labelQuickType requiredCoordinatesQuickType requiredCountQuickType requiredLabelQuickType weightQuickType) =
35+ toJSON (QuickType coordinatesQuickType requiredCoordinatesQuickType countQuickType requiredCountQuickType weightQuickType labelQuickType requiredLabelQuickType) =
3636 object
3737 [ "coordinates" .= coordinatesQuickType
38- , "count" .= countQuickType
39- , "label" .= labelQuickType
4038 , "requiredCoordinates" .= requiredCoordinatesQuickType
39+ , "count" .= countQuickType
4140 , "requiredCount" .= requiredCountQuickType
42- , "requiredLabel" .= requiredLabelQuickType
4341 , "weight" .= weightQuickType
42+ , "label" .= labelQuickType
43+ , "requiredLabel" .= requiredLabelQuickType
4444 ]
4545
4646 instance FromJSON QuickType where
4747 parseJSON (Object v) = QuickType
4848 <$> v .:? "coordinates"
49- <*> v .:? "count"
50- <*> v .:? "label"
5149 <*> v .: "requiredCoordinates"
50+ <*> v .:? "count"
5251 <*> v .: "requiredCount"
53- <*> v .: "requiredLabel"
5452 <*> v .:? "weight"
53+ <*> v .:? "label"
54+ <*> v .: "requiredLabel"
5555
5656 instance ToJSON Coordinate where
5757 toJSON (Coordinate latitudeCoordinate longitudeCoordinate) =
Mschema-haskell/test/inputs/schema/optional-constraints.schema/default/QuickType.hs+10 −10
@@ -13,30 +13,30 @@ import Data.HashMap.Strict (HashMap)
1313 import Data.Text (Text)
1414
1515 data QuickType = QuickType
16- { optDoubleQuickType :: Maybe Float
16+ { reqZeroMinQuickType :: Int
1717 , optIntQuickType :: Maybe Int
18- , optPatternQuickType :: Maybe Text
18+ , optDoubleQuickType :: Maybe Float
1919 , optStringQuickType :: Maybe Text
20- , reqZeroMinQuickType :: Int
20+ , optPatternQuickType :: Maybe Text
2121 } deriving (Show)
2222
2323 decodeTopLevel :: ByteString -> Maybe QuickType
2424 decodeTopLevel = decode
2525
2626 instance ToJSON QuickType where
27- toJSON (QuickType optDoubleQuickType optIntQuickType optPatternQuickType optStringQuickType reqZeroMinQuickType) =
27+ toJSON (QuickType reqZeroMinQuickType optIntQuickType optDoubleQuickType optStringQuickType optPatternQuickType) =
2828 object
29- [ "optDouble" .= optDoubleQuickType
29+ [ "reqZeroMin" .= reqZeroMinQuickType
3030 , "optInt" .= optIntQuickType
31- , "optPattern" .= optPatternQuickType
31+ , "optDouble" .= optDoubleQuickType
3232 , "optString" .= optStringQuickType
33- , "reqZeroMin" .= reqZeroMinQuickType
33+ , "optPattern" .= optPatternQuickType
3434 ]
3535
3636 instance FromJSON QuickType where
3737 parseJSON (Object v) = QuickType
38- <$> v .:? "optDouble"
38+ <$> v .: "reqZeroMin"
3939 <*> v .:? "optInt"
40- <*> v .:? "optPattern"
40+ <*> v .:? "optDouble"
4141 <*> v .:? "optString"
42- <*> v .: "reqZeroMin"
42+ <*> v .:? "optPattern"
Mschema-haskell/test/inputs/schema/optional-date-time.schema/default/QuickType.hs+16 −16
@@ -13,33 +13,33 @@ import Data.HashMap.Strict (HashMap)
1313 import Data.Text (Text)
1414
1515 data QuickType = QuickType
16- { optionalDateQuickType :: Maybe Text
17- , optionalDateTimeQuickType :: Maybe Text
18- , optionalTimeQuickType :: Maybe Text
19- , requiredDateQuickType :: Text
20- , requiredDateTimeQuickType :: Text
16+ { requiredDateQuickType :: Text
2117 , requiredTimeQuickType :: Text
18+ , requiredDateTimeQuickType :: Text
19+ , optionalDateQuickType :: Maybe Text
20+ , optionalTimeQuickType :: Maybe Text
21+ , optionalDateTimeQuickType :: Maybe Text
2222 } deriving (Show)
2323
2424 decodeTopLevel :: ByteString -> Maybe QuickType
2525 decodeTopLevel = decode
2626
2727 instance ToJSON QuickType where
28- toJSON (QuickType optionalDateQuickType optionalDateTimeQuickType optionalTimeQuickType requiredDateQuickType requiredDateTimeQuickType requiredTimeQuickType) =
28+ toJSON (QuickType requiredDateQuickType requiredTimeQuickType requiredDateTimeQuickType optionalDateQuickType optionalTimeQuickType optionalDateTimeQuickType) =
2929 object
30- [ "optional-date" .= optionalDateQuickType
31- , "optional-date-time" .= optionalDateTimeQuickType
32- , "optional-time" .= optionalTimeQuickType
33- , "required-date" .= requiredDateQuickType
34- , "required-date-time" .= requiredDateTimeQuickType
30+ [ "required-date" .= requiredDateQuickType
3531 , "required-time" .= requiredTimeQuickType
32+ , "required-date-time" .= requiredDateTimeQuickType
33+ , "optional-date" .= optionalDateQuickType
34+ , "optional-time" .= optionalTimeQuickType
35+ , "optional-date-time" .= optionalDateTimeQuickType
3636 ]
3737
3838 instance FromJSON QuickType where
3939 parseJSON (Object v) = QuickType
40- <$> v .:? "optional-date"
41- <*> v .:? "optional-date-time"
42- <*> v .:? "optional-time"
43- <*> v .: "required-date"
44- <*> v .: "required-date-time"
40+ <$> v .: "required-date"
4541 <*> v .: "required-time"
42+ <*> v .: "required-date-time"
43+ <*> v .:? "optional-date"
44+ <*> v .:? "optional-time"
45+ <*> v .:? "optional-date-time"
Mschema-haskell/test/inputs/schema/renaming-bug.schema/default/QuickType.hs+45 −45
@@ -35,13 +35,13 @@ data QuickType = QuickType
3535
3636 data Fruit = Fruit
3737 { appleFruit :: Maybe Bool
38- , berriesFruit :: Maybe ([Berry])
3938 , orangeFruit :: Maybe Bool
39+ , berriesFruit :: Maybe ([Berry])
4040 } deriving (Show)
4141
4242 data Berry = Berry
43- { colorBerry :: Maybe Color
44- , nameBerry :: Maybe Text
43+ { nameBerry :: Maybe Text
44+ , colorBerry :: Maybe Color
4545 , shapesBerry :: Maybe ([Shape])
4646 } deriving (Show)
4747
@@ -50,8 +50,8 @@ data Color = Color
5050 } deriving (Show)
5151
5252 data Shape = Shape
53- { geometryShape :: Maybe Geometry
54- , historyShape :: Maybe History
53+ { historyShape :: Maybe History
54+ , geometryShape :: Maybe Geometry
5555 } deriving (Show)
5656
5757 data Geometry = Geometry
@@ -68,9 +68,9 @@ data RectShape = RectShape
6868 } deriving (Show)
6969
7070 data Part = Part
71- { depthPart :: Maybe Text
72- , lengthPart :: Maybe Text
71+ { lengthPart :: Maybe Text
7372 , widthPart :: Maybe Text
73+ , depthPart :: Maybe Text
7474 } deriving (Show)
7575
7676 data History = History
@@ -78,12 +78,12 @@ data History = History
7878 } deriving (Show)
7979
8080 data Vehicle = Vehicle
81- { brandVehicle :: Maybe Text
82- , vehicleIDVehicle :: Maybe Text
83- , speedVehicle :: Maybe Speed
84- , subModuleVehicle :: Maybe Bool
81+ { vehicleIDVehicle :: Maybe Text
8582 , vehicleTypeVehicle :: Maybe VehicleType
83+ , speedVehicle :: Maybe Speed
8684 , yearVehicle :: Maybe Text
85+ , brandVehicle :: Maybe Text
86+ , subModuleVehicle :: Maybe Bool
8787 } deriving (Show)
8888
8989 data Speed = Speed
@@ -91,8 +91,8 @@ data Speed = Speed
9191 } deriving (Show)
9292
9393 data Limit = Limit
94- { maximumLimit :: Maybe Float
95- , minimumLimit :: Maybe Float
94+ { minimumLimit :: Maybe Float
95+ , maximumLimit :: Maybe Float
9696 } deriving (Show)
9797
9898 data VehicleType = VehicleType
@@ -140,31 +140,31 @@ instance FromJSON QuickType where
140140 <*> v .:? "vehicles"
141141
142142 instance ToJSON Fruit where
143- toJSON (Fruit appleFruit berriesFruit orangeFruit) =
143+ toJSON (Fruit appleFruit orangeFruit berriesFruit) =
144144 object
145145 [ "apple" .= appleFruit
146- , "berries" .= berriesFruit
147146 , "orange" .= orangeFruit
147+ , "berries" .= berriesFruit
148148 ]
149149
150150 instance FromJSON Fruit where
151151 parseJSON (Object v) = Fruit
152152 <$> v .:? "apple"
153- <*> v .:? "berries"
154153 <*> v .:? "orange"
154+ <*> v .:? "berries"
155155
156156 instance ToJSON Berry where
157- toJSON (Berry colorBerry nameBerry shapesBerry) =
157+ toJSON (Berry nameBerry colorBerry shapesBerry) =
158158 object
159- [ "color" .= colorBerry
160- , "name" .= nameBerry
159+ [ "name" .= nameBerry
160+ , "color" .= colorBerry
161161 , "shapes" .= shapesBerry
162162 ]
163163
164164 instance FromJSON Berry where
165165 parseJSON (Object v) = Berry
166- <$> v .:? "color"
167- <*> v .:? "name"
166+ <$> v .:? "name"
167+ <*> v .:? "color"
168168 <*> v .:? "shapes"
169169
170170 instance ToJSON Color where
@@ -178,16 +178,16 @@ instance FromJSON Color where
178178 <$> v .:? "rgb"
179179
180180 instance ToJSON Shape where
181- toJSON (Shape geometryShape historyShape) =
181+ toJSON (Shape historyShape geometryShape) =
182182 object
183- [ "geometry" .= geometryShape
184- , "history" .= historyShape
183+ [ "history" .= historyShape
184+ , "geometry" .= geometryShape
185185 ]
186186
187187 instance FromJSON Shape where
188188 parseJSON (Object v) = Shape
189- <$> v .:? "geometry"
190- <*> v .:? "history"
189+ <$> v .:? "history"
190+ <*> v .:? "geometry"
191191
192192 instance ToJSON Geometry where
193193 toJSON (Geometry rectShapeGeometry circularShapeGeometry) =
@@ -222,18 +222,18 @@ instance FromJSON RectShape where
222222 <$> v .:? "parts"
223223
224224 instance ToJSON Part where
225- toJSON (Part depthPart lengthPart widthPart) =
225+ toJSON (Part lengthPart widthPart depthPart) =
226226 object
227- [ "depth" .= depthPart
228- , "length" .= lengthPart
227+ [ "length" .= lengthPart
229228 , "width" .= widthPart
229+ , "depth" .= depthPart
230230 ]
231231
232232 instance FromJSON Part where
233233 parseJSON (Object v) = Part
234- <$> v .:? "depth"
235- <*> v .:? "length"
234+ <$> v .:? "length"
236235 <*> v .:? "width"
236+ <*> v .:? "depth"
237237
238238 instance ToJSON History where
239239 toJSON (History historyClassHistory) =
@@ -246,24 +246,24 @@ instance FromJSON History where
246246 <$> v .:? "class"
247247
248248 instance ToJSON Vehicle where
249- toJSON (Vehicle brandVehicle vehicleIDVehicle speedVehicle subModuleVehicle vehicleTypeVehicle yearVehicle) =
249+ toJSON (Vehicle vehicleIDVehicle vehicleTypeVehicle speedVehicle yearVehicle brandVehicle subModuleVehicle) =
250250 object
251- [ "brand" .= brandVehicle
252- , "id" .= vehicleIDVehicle
253- , "speed" .= speedVehicle
254- , "subModule" .= subModuleVehicle
251+ [ "id" .= vehicleIDVehicle
255252 , "type" .= vehicleTypeVehicle
253+ , "speed" .= speedVehicle
256254 , "year" .= yearVehicle
255+ , "brand" .= brandVehicle
256+ , "subModule" .= subModuleVehicle
257257 ]
258258
259259 instance FromJSON Vehicle where
260260 parseJSON (Object v) = Vehicle
261- <$> v .:? "brand"
262- <*> v .:? "id"
263- <*> v .:? "speed"
264- <*> v .:? "subModule"
261+ <$> v .:? "id"
265262 <*> v .:? "type"
263+ <*> v .:? "speed"
266264 <*> v .:? "year"
265+ <*> v .:? "brand"
266+ <*> v .:? "subModule"
267267
268268 instance ToJSON Speed where
269269 toJSON (Speed velocitySpeed) =
@@ -276,16 +276,16 @@ instance FromJSON Speed where
276276 <$> v .:? "velocity"
277277
278278 instance ToJSON Limit where
279- toJSON (Limit maximumLimit minimumLimit) =
279+ toJSON (Limit minimumLimit maximumLimit) =
280280 object
281- [ "maximum" .= maximumLimit
282- , "minimum" .= minimumLimit
281+ [ "minimum" .= minimumLimit
282+ , "maximum" .= maximumLimit
283283 ]
284284
285285 instance FromJSON Limit where
286286 parseJSON (Object v) = Limit
287- <$> v .:? "maximum"
288- <*> v .:? "minimum"
287+ <$> v .:? "minimum"
288+ <*> v .:? "maximum"
289289
290290 instance ToJSON VehicleType where
291291 toJSON (VehicleType nameVehicleType widthVehicleType lengthVehicleType) =
Mschema-haskell/test/inputs/schema/rust-cycle-breaker-union.schema/default/QuickType.hs+14 −14
@@ -15,13 +15,13 @@ import Data.HashMap.Strict (HashMap)
1515 import Data.Text (Text)
1616
1717 data QuickType = QuickType
18- { nextQuickType :: Maybe Next
19- , valueQuickType :: Text
18+ { valueQuickType :: Text
19+ , nextQuickType :: Maybe Next
2020 } deriving (Show)
2121
2222 data Node = Node
23- { nextNode :: Maybe Next
24- , valueNode :: Text
23+ { valueNode :: Text
24+ , nextNode :: Maybe Next
2525 } deriving (Show)
2626
2727 data Next
@@ -34,28 +34,28 @@ decodeTopLevel :: ByteString -> Maybe QuickType
3434 decodeTopLevel = decode
3535
3636 instance ToJSON QuickType where
37- toJSON (QuickType nextQuickType valueQuickType) =
37+ toJSON (QuickType valueQuickType nextQuickType) =
3838 object
39- [ "next" .= nextQuickType
40- , "value" .= valueQuickType
39+ [ "value" .= valueQuickType
40+ , "next" .= nextQuickType
4141 ]
4242
4343 instance FromJSON QuickType where
4444 parseJSON (Object v) = QuickType
45- <$> v .:? "next"
46- <*> v .: "value"
45+ <$> v .: "value"
46+ <*> v .:? "next"
4747
4848 instance ToJSON Node where
49- toJSON (Node nextNode valueNode) =
49+ toJSON (Node valueNode nextNode) =
5050 object
51- [ "next" .= nextNode
52- , "value" .= valueNode
51+ [ "value" .= valueNode
52+ , "next" .= nextNode
5353 ]
5454
5555 instance FromJSON Node where
5656 parseJSON (Object v) = Node
57- <$> v .:? "next"
58- <*> v .: "value"
57+ <$> v .: "value"
58+ <*> v .:? "next"
5959
6060 instance ToJSON Next where
6161 toJSON (NodeInNext x) = toJSON x
Mschema-haskell/test/inputs/schema/uuid.schema/default/QuickType.hs+13 −13
@@ -13,11 +13,11 @@ import Data.HashMap.Strict (HashMap)
1313 import Data.Text (Text)
1414
1515 data QuickType = QuickType
16- { arrNullableQuickType :: Maybe ([(Maybe Text)])
17- , arrOneQuickType :: Maybe ([Text])
18- , nullableQuickType :: Maybe Text
19- , oneQuickType :: Text
16+ { oneQuickType :: Text
2017 , optionalQuickType :: Maybe Text
18+ , nullableQuickType :: Maybe Text
19+ , arrOneQuickType :: Maybe ([Text])
20+ , arrNullableQuickType :: Maybe ([(Maybe Text)])
2121 , unionWithEnumQuickType :: Text
2222 } deriving (Show)
2323
@@ -25,21 +25,21 @@ decodeTopLevel :: ByteString -> Maybe QuickType
2525 decodeTopLevel = decode
2626
2727 instance ToJSON QuickType where
28- toJSON (QuickType arrNullableQuickType arrOneQuickType nullableQuickType oneQuickType optionalQuickType unionWithEnumQuickType) =
28+ toJSON (QuickType oneQuickType optionalQuickType nullableQuickType arrOneQuickType arrNullableQuickType unionWithEnumQuickType) =
2929 object
30- [ "arrNullable" .= arrNullableQuickType
31- , "arrOne" .= arrOneQuickType
32- , "nullable" .= nullableQuickType
33- , "one" .= oneQuickType
30+ [ "one" .= oneQuickType
3431 , "optional" .= optionalQuickType
32+ , "nullable" .= nullableQuickType
33+ , "arrOne" .= arrOneQuickType
34+ , "arrNullable" .= arrNullableQuickType
3535 , "unionWithEnum" .= unionWithEnumQuickType
3636 ]
3737
3838 instance FromJSON QuickType where
3939 parseJSON (Object v) = QuickType
40- <$> v .:? "arrNullable"
41- <*> v .:? "arrOne"
42- <*> v .: "nullable"
43- <*> v .: "one"
40+ <$> v .: "one"
4441 <*> v .:? "optional"
42+ <*> v .: "nullable"
43+ <*> v .:? "arrOne"
44+ <*> v .:? "arrNullable"
4545 <*> v .: "unionWithEnum"
Mschema-haskell/test/inputs/schema/vega-lite.schema/default/QuickType.hs+66 −66
@@ -637,6 +637,11 @@ Default Fill Color. This has higher precedence than config.color
637637
638638 __Default value:__ (None)
639639
640+fillOpacity:
641+The fill opacity (value between [0,1]).
642+
643+__Default value:__ `1`
644+
640645 filled:
641646 Whether the mark's color should be used as fill color instead of stroke color.
642647
@@ -646,11 +651,6 @@ __Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.
646651
647652 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
648653
649-fillOpacity:
650-The fill opacity (value between [0,1]).
651-
652-__Default value:__ `1`
653-
654654 font:
655655 The typeface to set the text in (e.g., `"Helvetica Neue"`).
656656
@@ -764,8 +764,8 @@ data MarkConfig = MarkConfig
764764 , dxMarkConfig :: Maybe Float
765765 , dyMarkConfig :: Maybe Float
766766 , fillMarkConfig :: Maybe Text
767- , filledMarkConfig :: Maybe Bool
768767 , fillOpacityMarkConfig :: Maybe Float
768+ , filledMarkConfig :: Maybe Bool
769769 , fontMarkConfig :: Maybe Text
770770 , fontSizeMarkConfig :: Maybe Float
771771 , fontStyleMarkConfig :: Maybe FontStyle
@@ -1044,15 +1044,15 @@ The color of the axis's tick.
10441044 tickRound:
10451045 Boolean flag indicating if pixel position values should be rounded to the nearest integer.
10461046
1047-ticks:
1048-Boolean value that determines whether the axis should include ticks.
1049-
10501047 tickSize:
10511048 The size in pixels of axis ticks.
10521049
10531050 tickWidth:
10541051 The width, in pixels, of ticks.
10551052
1053+ticks:
1054+Boolean value that determines whether the axis should include ticks.
1055+
10561056 titleAlign:
10571057 Horizontal text alignment of axis titles.
10581058
@@ -1115,9 +1115,9 @@ data AxisConfig = AxisConfig
11151115 , shortTimeLabelsAxisConfig :: Maybe Bool
11161116 , tickColorAxisConfig :: Maybe Text
11171117 , tickRoundAxisConfig :: Maybe Bool
1118- , ticksAxisConfig :: Maybe Bool
11191118 , tickSizeAxisConfig :: Maybe Float
11201119 , tickWidthAxisConfig :: Maybe Float
1120+ , ticksAxisConfig :: Maybe Bool
11211121 , titleAlignAxisConfig :: Maybe Text
11221122 , titleAngleAxisConfig :: Maybe Float
11231123 , titleBaselineAxisConfig :: Maybe Text
@@ -1302,15 +1302,15 @@ The color of the axis's tick.
13021302 tickRound:
13031303 Boolean flag indicating if pixel position values should be rounded to the nearest integer.
13041304
1305-ticks:
1306-Boolean value that determines whether the axis should include ticks.
1307-
13081305 tickSize:
13091306 The size in pixels of axis ticks.
13101307
13111308 tickWidth:
13121309 The width, in pixels, of ticks.
13131310
1311+ticks:
1312+Boolean value that determines whether the axis should include ticks.
1313+
13141314 titleAlign:
13151315 Horizontal text alignment of axis titles.
13161316
@@ -1372,9 +1372,9 @@ data VGAxisConfig = VGAxisConfig
13721372 , minExtentVGAxisConfig :: Maybe Float
13731373 , tickColorVGAxisConfig :: Maybe Text
13741374 , tickRoundVGAxisConfig :: Maybe Bool
1375- , ticksVGAxisConfig :: Maybe Bool
13761375 , tickSizeVGAxisConfig :: Maybe Float
13771376 , tickWidthVGAxisConfig :: Maybe Float
1377+ , ticksVGAxisConfig :: Maybe Bool
13781378 , titleAlignVGAxisConfig :: Maybe Text
13791379 , titleAngleVGAxisConfig :: Maybe Float
13801380 , titleBaselineVGAxisConfig :: Maybe Text
@@ -1442,6 +1442,11 @@ Default Fill Color. This has higher precedence than config.color
14421442
14431443 __Default value:__ (None)
14441444
1445+fillOpacity:
1446+The fill opacity (value between [0,1]).
1447+
1448+__Default value:__ `1`
1449+
14451450 filled:
14461451 Whether the mark's color should be used as fill color instead of stroke color.
14471452
@@ -1451,11 +1456,6 @@ __Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.
14511456
14521457 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
14531458
1454-fillOpacity:
1455-The fill opacity (value between [0,1]).
1456-
1457-__Default value:__ `1`
1458-
14591459 font:
14601460 The typeface to set the text in (e.g., `"Helvetica Neue"`).
14611461
@@ -1572,8 +1572,8 @@ data BarConfig = BarConfig
15721572 , dxBarConfig :: Maybe Float
15731573 , dyBarConfig :: Maybe Float
15741574 , fillBarConfig :: Maybe Text
1575- , filledBarConfig :: Maybe Bool
15761575 , fillOpacityBarConfig :: Maybe Float
1576+ , filledBarConfig :: Maybe Bool
15771577 , fontBarConfig :: Maybe Text
15781578 , fontSizeBarConfig :: Maybe Float
15791579 , fontStyleBarConfig :: Maybe FontStyle
@@ -1634,6 +1634,11 @@ Default Fill Color. This has higher precedence than config.color
16341634
16351635 __Default value:__ (None)
16361636
1637+fillOpacity:
1638+The fill opacity (value between [0,1]).
1639+
1640+__Default value:__ `1`
1641+
16371642 filled:
16381643 Whether the mark's color should be used as fill color instead of stroke color.
16391644
@@ -1643,11 +1648,6 @@ __Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.
16431648
16441649 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
16451650
1646-fillOpacity:
1647-The fill opacity (value between [0,1]).
1648-
1649-__Default value:__ `1`
1650-
16511651 font:
16521652 The typeface to set the text in (e.g., `"Helvetica Neue"`).
16531653
@@ -1764,8 +1764,8 @@ data TextConfig = TextConfig
17641764 , dxTextConfig :: Maybe Float
17651765 , dyTextConfig :: Maybe Float
17661766 , fillTextConfig :: Maybe Text
1767- , filledTextConfig :: Maybe Bool
17681767 , fillOpacityTextConfig :: Maybe Float
1768+ , filledTextConfig :: Maybe Bool
17691769 , fontTextConfig :: Maybe Text
17701770 , fontSizeTextConfig :: Maybe Float
17711771 , fontStyleTextConfig :: Maybe FontStyle
@@ -2796,6 +2796,11 @@ Default Fill Color. This has higher precedence than config.color
27962796
27972797 __Default value:__ (None)
27982798
2799+fillOpacity:
2800+The fill opacity (value between [0,1]).
2801+
2802+__Default value:__ `1`
2803+
27992804 filled:
28002805 Whether the mark's color should be used as fill color instead of stroke color.
28012806
@@ -2805,11 +2810,6 @@ __Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.
28052810
28062811 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
28072812
2808-fillOpacity:
2809-The fill opacity (value between [0,1]).
2810-
2811-__Default value:__ `1`
2812-
28132813 font:
28142814 The typeface to set the text in (e.g., `"Helvetica Neue"`).
28152815
@@ -2929,8 +2929,8 @@ data TickConfig = TickConfig
29292929 , dxTickConfig :: Maybe Float
29302930 , dyTickConfig :: Maybe Float
29312931 , fillTickConfig :: Maybe Text
2932- , filledTickConfig :: Maybe Bool
29332932 , fillOpacityTickConfig :: Maybe Float
2933+ , filledTickConfig :: Maybe Bool
29342934 , fontTickConfig :: Maybe Text
29352935 , fontSizeTickConfig :: Maybe Float
29362936 , fontStyleTickConfig :: Maybe FontStyle
@@ -5024,12 +5024,12 @@ A desired number of ticks, for axes visualizing quantitative scales. The resulti
50245024 may be different so that values are "nice" (multiples of 2, 5, 10) and lie within the
50255025 underlying scale's range.
50265026
5027-ticks:
5028-Boolean value that determines whether the axis should include ticks.
5029-
50305027 tickSize:
50315028 The size in pixels of axis ticks.
50325029
5030+ticks:
5031+Boolean value that determines whether the axis should include ticks.
5032+
50335033 title:
50345034 A title for the field. If `null`, the title will be removed.
50355035
@@ -5078,8 +5078,8 @@ data Axis = Axis
50785078 , orientAxis :: Maybe TitleOrient
50795079 , positionAxis :: Maybe Float
50805080 , tickCountAxis :: Maybe Float
5081- , ticksAxis :: Maybe Bool
50825081 , tickSizeAxis :: Maybe Float
5082+ , ticksAxis :: Maybe Bool
50835083 , titleAxis :: Maybe Text
50845084 , titleMaxLengthAxis :: Maybe Float
50855085 , titlePaddingAxis :: Maybe Float
@@ -5655,6 +5655,11 @@ Default Fill Color. This has higher precedence than config.color
56555655
56565656 __Default value:__ (None)
56575657
5658+fillOpacity:
5659+The fill opacity (value between [0,1]).
5660+
5661+__Default value:__ `1`
5662+
56585663 filled:
56595664 Whether the mark's color should be used as fill color instead of stroke color.
56605665
@@ -5664,11 +5669,6 @@ __Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.
56645669
56655670 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
56665671
5667-fillOpacity:
5668-The fill opacity (value between [0,1]).
5669-
5670-__Default value:__ `1`
5671-
56725672 font:
56735673 The typeface to set the text in (e.g., `"Helvetica Neue"`).
56745674
@@ -5801,8 +5801,8 @@ data MarkDef = MarkDef
58015801 , dxMarkDef :: Maybe Float
58025802 , dyMarkDef :: Maybe Float
58035803 , fillMarkDef :: Maybe Text
5804- , filledMarkDef :: Maybe Bool
58055804 , fillOpacityMarkDef :: Maybe Float
5805+ , filledMarkDef :: Maybe Bool
58065806 , fontMarkDef :: Maybe Text
58075807 , fontSizeMarkDef :: Maybe Float
58085808 , fontStyleMarkDef :: Maybe FontStyle
@@ -6421,7 +6421,7 @@ instance FromJSON Config where
64216421 <*> v .:? "view"
64226422
64236423 instance ToJSON MarkConfig where
6424- toJSON (MarkConfig alignMarkConfig angleMarkConfig baselineMarkConfig colorMarkConfig cursorMarkConfig dxMarkConfig dyMarkConfig fillMarkConfig filledMarkConfig fillOpacityMarkConfig fontMarkConfig fontSizeMarkConfig fontStyleMarkConfig fontWeightMarkConfig hrefMarkConfig interpolateMarkConfig limitMarkConfig opacityMarkConfig orientMarkConfig radiusMarkConfig shapeMarkConfig sizeMarkConfig strokeMarkConfig strokeDashMarkConfig strokeDashOffsetMarkConfig strokeOpacityMarkConfig strokeWidthMarkConfig tensionMarkConfig markConfigTextMarkConfig thetaMarkConfig) =
6424+ toJSON (MarkConfig alignMarkConfig angleMarkConfig baselineMarkConfig colorMarkConfig cursorMarkConfig dxMarkConfig dyMarkConfig fillMarkConfig fillOpacityMarkConfig filledMarkConfig fontMarkConfig fontSizeMarkConfig fontStyleMarkConfig fontWeightMarkConfig hrefMarkConfig interpolateMarkConfig limitMarkConfig opacityMarkConfig orientMarkConfig radiusMarkConfig shapeMarkConfig sizeMarkConfig strokeMarkConfig strokeDashMarkConfig strokeDashOffsetMarkConfig strokeOpacityMarkConfig strokeWidthMarkConfig tensionMarkConfig markConfigTextMarkConfig thetaMarkConfig) =
64256425 object
64266426 [ "align" .= alignMarkConfig
64276427 , "angle" .= angleMarkConfig
@@ -6431,8 +6431,8 @@ instance ToJSON MarkConfig where
64316431 , "dx" .= dxMarkConfig
64326432 , "dy" .= dyMarkConfig
64336433 , "fill" .= fillMarkConfig
6434- , "filled" .= filledMarkConfig
64356434 , "fillOpacity" .= fillOpacityMarkConfig
6435+ , "filled" .= filledMarkConfig
64366436 , "font" .= fontMarkConfig
64376437 , "fontSize" .= fontSizeMarkConfig
64386438 , "fontStyle" .= fontStyleMarkConfig
@@ -6465,8 +6465,8 @@ instance FromJSON MarkConfig where
64656465 <*> v .:? "dx"
64666466 <*> v .:? "dy"
64676467 <*> v .:? "fill"
6468- <*> v .:? "filled"
64696468 <*> v .:? "fillOpacity"
6469+ <*> v .:? "filled"
64706470 <*> v .:? "font"
64716471 <*> v .:? "fontSize"
64726472 <*> v .:? "fontStyle"
@@ -6661,7 +6661,7 @@ instance FromJSON Orient where
66616661 parseText "vertical" = return VerticalOrient
66626662
66636663 instance ToJSON AxisConfig where
6664- toJSON (AxisConfig bandPositionAxisConfig domainAxisConfig domainColorAxisConfig domainWidthAxisConfig gridAxisConfig gridColorAxisConfig gridDashAxisConfig gridOpacityAxisConfig gridWidthAxisConfig labelAngleAxisConfig labelBoundAxisConfig labelColorAxisConfig labelFlushAxisConfig labelFontAxisConfig labelFontSizeAxisConfig labelLimitAxisConfig labelOverlapAxisConfig labelPaddingAxisConfig labelsAxisConfig maxExtentAxisConfig minExtentAxisConfig shortTimeLabelsAxisConfig tickColorAxisConfig tickRoundAxisConfig ticksAxisConfig tickSizeAxisConfig tickWidthAxisConfig titleAlignAxisConfig titleAngleAxisConfig titleBaselineAxisConfig titleColorAxisConfig titleFontAxisConfig titleFontSizeAxisConfig titleFontWeightAxisConfig titleLimitAxisConfig titleMaxLengthAxisConfig titlePaddingAxisConfig titleXAxisConfig titleYAxisConfig) =
6664+ toJSON (AxisConfig bandPositionAxisConfig domainAxisConfig domainColorAxisConfig domainWidthAxisConfig gridAxisConfig gridColorAxisConfig gridDashAxisConfig gridOpacityAxisConfig gridWidthAxisConfig labelAngleAxisConfig labelBoundAxisConfig labelColorAxisConfig labelFlushAxisConfig labelFontAxisConfig labelFontSizeAxisConfig labelLimitAxisConfig labelOverlapAxisConfig labelPaddingAxisConfig labelsAxisConfig maxExtentAxisConfig minExtentAxisConfig shortTimeLabelsAxisConfig tickColorAxisConfig tickRoundAxisConfig tickSizeAxisConfig tickWidthAxisConfig ticksAxisConfig titleAlignAxisConfig titleAngleAxisConfig titleBaselineAxisConfig titleColorAxisConfig titleFontAxisConfig titleFontSizeAxisConfig titleFontWeightAxisConfig titleLimitAxisConfig titleMaxLengthAxisConfig titlePaddingAxisConfig titleXAxisConfig titleYAxisConfig) =
66656665 object
66666666 [ "bandPosition" .= bandPositionAxisConfig
66676667 , "domain" .= domainAxisConfig
@@ -6687,9 +6687,9 @@ instance ToJSON AxisConfig where
66876687 , "shortTimeLabels" .= shortTimeLabelsAxisConfig
66886688 , "tickColor" .= tickColorAxisConfig
66896689 , "tickRound" .= tickRoundAxisConfig
6690- , "ticks" .= ticksAxisConfig
66916690 , "tickSize" .= tickSizeAxisConfig
66926691 , "tickWidth" .= tickWidthAxisConfig
6692+ , "ticks" .= ticksAxisConfig
66936693 , "titleAlign" .= titleAlignAxisConfig
66946694 , "titleAngle" .= titleAngleAxisConfig
66956695 , "titleBaseline" .= titleBaselineAxisConfig
@@ -6730,9 +6730,9 @@ instance FromJSON AxisConfig where
67306730 <*> v .:? "shortTimeLabels"
67316731 <*> v .:? "tickColor"
67326732 <*> v .:? "tickRound"
6733- <*> v .:? "ticks"
67346733 <*> v .:? "tickSize"
67356734 <*> v .:? "tickWidth"
6735+ <*> v .:? "ticks"
67366736 <*> v .:? "titleAlign"
67376737 <*> v .:? "titleAngle"
67386738 <*> v .:? "titleBaseline"
@@ -6781,7 +6781,7 @@ instance FromJSON TitleFontWeight where
67816781 parseJSON xs@(String _) = (fmap StringInTitleFontWeight . parseJSON) xs
67826782
67836783 instance ToJSON VGAxisConfig where
6784- toJSON (VGAxisConfig bandPositionVGAxisConfig domainVGAxisConfig domainColorVGAxisConfig domainWidthVGAxisConfig gridVGAxisConfig gridColorVGAxisConfig gridDashVGAxisConfig gridOpacityVGAxisConfig gridWidthVGAxisConfig labelAngleVGAxisConfig labelBoundVGAxisConfig labelColorVGAxisConfig labelFlushVGAxisConfig labelFontVGAxisConfig labelFontSizeVGAxisConfig labelLimitVGAxisConfig labelOverlapVGAxisConfig labelPaddingVGAxisConfig labelsVGAxisConfig maxExtentVGAxisConfig minExtentVGAxisConfig tickColorVGAxisConfig tickRoundVGAxisConfig ticksVGAxisConfig tickSizeVGAxisConfig tickWidthVGAxisConfig titleAlignVGAxisConfig titleAngleVGAxisConfig titleBaselineVGAxisConfig titleColorVGAxisConfig titleFontVGAxisConfig titleFontSizeVGAxisConfig titleFontWeightVGAxisConfig titleLimitVGAxisConfig titleMaxLengthVGAxisConfig titlePaddingVGAxisConfig titleXVGAxisConfig titleYVGAxisConfig) =
6784+ toJSON (VGAxisConfig bandPositionVGAxisConfig domainVGAxisConfig domainColorVGAxisConfig domainWidthVGAxisConfig gridVGAxisConfig gridColorVGAxisConfig gridDashVGAxisConfig gridOpacityVGAxisConfig gridWidthVGAxisConfig labelAngleVGAxisConfig labelBoundVGAxisConfig labelColorVGAxisConfig labelFlushVGAxisConfig labelFontVGAxisConfig labelFontSizeVGAxisConfig labelLimitVGAxisConfig labelOverlapVGAxisConfig labelPaddingVGAxisConfig labelsVGAxisConfig maxExtentVGAxisConfig minExtentVGAxisConfig tickColorVGAxisConfig tickRoundVGAxisConfig tickSizeVGAxisConfig tickWidthVGAxisConfig ticksVGAxisConfig titleAlignVGAxisConfig titleAngleVGAxisConfig titleBaselineVGAxisConfig titleColorVGAxisConfig titleFontVGAxisConfig titleFontSizeVGAxisConfig titleFontWeightVGAxisConfig titleLimitVGAxisConfig titleMaxLengthVGAxisConfig titlePaddingVGAxisConfig titleXVGAxisConfig titleYVGAxisConfig) =
67856785 object
67866786 [ "bandPosition" .= bandPositionVGAxisConfig
67876787 , "domain" .= domainVGAxisConfig
@@ -6806,9 +6806,9 @@ instance ToJSON VGAxisConfig where
68066806 , "minExtent" .= minExtentVGAxisConfig
68076807 , "tickColor" .= tickColorVGAxisConfig
68086808 , "tickRound" .= tickRoundVGAxisConfig
6809- , "ticks" .= ticksVGAxisConfig
68106809 , "tickSize" .= tickSizeVGAxisConfig
68116810 , "tickWidth" .= tickWidthVGAxisConfig
6811+ , "ticks" .= ticksVGAxisConfig
68126812 , "titleAlign" .= titleAlignVGAxisConfig
68136813 , "titleAngle" .= titleAngleVGAxisConfig
68146814 , "titleBaseline" .= titleBaselineVGAxisConfig
@@ -6848,9 +6848,9 @@ instance FromJSON VGAxisConfig where
68486848 <*> v .:? "minExtent"
68496849 <*> v .:? "tickColor"
68506850 <*> v .:? "tickRound"
6851- <*> v .:? "ticks"
68526851 <*> v .:? "tickSize"
68536852 <*> v .:? "tickWidth"
6853+ <*> v .:? "ticks"
68546854 <*> v .:? "titleAlign"
68556855 <*> v .:? "titleAngle"
68566856 <*> v .:? "titleBaseline"
@@ -6865,7 +6865,7 @@ instance FromJSON VGAxisConfig where
68656865 <*> v .:? "titleY"
68666866
68676867 instance ToJSON BarConfig where
6868- toJSON (BarConfig alignBarConfig angleBarConfig baselineBarConfig binSpacingBarConfig colorBarConfig continuousBandSizeBarConfig cursorBarConfig discreteBandSizeBarConfig dxBarConfig dyBarConfig fillBarConfig filledBarConfig fillOpacityBarConfig fontBarConfig fontSizeBarConfig fontStyleBarConfig fontWeightBarConfig hrefBarConfig interpolateBarConfig limitBarConfig opacityBarConfig orientBarConfig radiusBarConfig shapeBarConfig sizeBarConfig strokeBarConfig strokeDashBarConfig strokeDashOffsetBarConfig strokeOpacityBarConfig strokeWidthBarConfig tensionBarConfig barConfigTextBarConfig thetaBarConfig) =
6868+ toJSON (BarConfig alignBarConfig angleBarConfig baselineBarConfig binSpacingBarConfig colorBarConfig continuousBandSizeBarConfig cursorBarConfig discreteBandSizeBarConfig dxBarConfig dyBarConfig fillBarConfig fillOpacityBarConfig filledBarConfig fontBarConfig fontSizeBarConfig fontStyleBarConfig fontWeightBarConfig hrefBarConfig interpolateBarConfig limitBarConfig opacityBarConfig orientBarConfig radiusBarConfig shapeBarConfig sizeBarConfig strokeBarConfig strokeDashBarConfig strokeDashOffsetBarConfig strokeOpacityBarConfig strokeWidthBarConfig tensionBarConfig barConfigTextBarConfig thetaBarConfig) =
68696869 object
68706870 [ "align" .= alignBarConfig
68716871 , "angle" .= angleBarConfig
@@ -6878,8 +6878,8 @@ instance ToJSON BarConfig where
68786878 , "dx" .= dxBarConfig
68796879 , "dy" .= dyBarConfig
68806880 , "fill" .= fillBarConfig
6881- , "filled" .= filledBarConfig
68826881 , "fillOpacity" .= fillOpacityBarConfig
6882+ , "filled" .= filledBarConfig
68836883 , "font" .= fontBarConfig
68846884 , "fontSize" .= fontSizeBarConfig
68856885 , "fontStyle" .= fontStyleBarConfig
@@ -6915,8 +6915,8 @@ instance FromJSON BarConfig where
69156915 <*> v .:? "dx"
69166916 <*> v .:? "dy"
69176917 <*> v .:? "fill"
6918- <*> v .:? "filled"
69196918 <*> v .:? "fillOpacity"
6919+ <*> v .:? "filled"
69206920 <*> v .:? "font"
69216921 <*> v .:? "fontSize"
69226922 <*> v .:? "fontStyle"
@@ -6939,7 +6939,7 @@ instance FromJSON BarConfig where
69396939 <*> v .:? "theta"
69406940
69416941 instance ToJSON TextConfig where
6942- toJSON (TextConfig alignTextConfig angleTextConfig baselineTextConfig colorTextConfig cursorTextConfig dxTextConfig dyTextConfig fillTextConfig filledTextConfig fillOpacityTextConfig fontTextConfig fontSizeTextConfig fontStyleTextConfig fontWeightTextConfig hrefTextConfig interpolateTextConfig limitTextConfig opacityTextConfig orientTextConfig radiusTextConfig shapeTextConfig shortTimeLabelsTextConfig sizeTextConfig strokeTextConfig strokeDashTextConfig strokeDashOffsetTextConfig strokeOpacityTextConfig strokeWidthTextConfig tensionTextConfig textConfigTextTextConfig thetaTextConfig) =
6942+ toJSON (TextConfig alignTextConfig angleTextConfig baselineTextConfig colorTextConfig cursorTextConfig dxTextConfig dyTextConfig fillTextConfig fillOpacityTextConfig filledTextConfig fontTextConfig fontSizeTextConfig fontStyleTextConfig fontWeightTextConfig hrefTextConfig interpolateTextConfig limitTextConfig opacityTextConfig orientTextConfig radiusTextConfig shapeTextConfig shortTimeLabelsTextConfig sizeTextConfig strokeTextConfig strokeDashTextConfig strokeDashOffsetTextConfig strokeOpacityTextConfig strokeWidthTextConfig tensionTextConfig textConfigTextTextConfig thetaTextConfig) =
69436943 object
69446944 [ "align" .= alignTextConfig
69456945 , "angle" .= angleTextConfig
@@ -6949,8 +6949,8 @@ instance ToJSON TextConfig where
69496949 , "dx" .= dxTextConfig
69506950 , "dy" .= dyTextConfig
69516951 , "fill" .= fillTextConfig
6952- , "filled" .= filledTextConfig
69536952 , "fillOpacity" .= fillOpacityTextConfig
6953+ , "filled" .= filledTextConfig
69546954 , "font" .= fontTextConfig
69556955 , "fontSize" .= fontSizeTextConfig
69566956 , "fontStyle" .= fontStyleTextConfig
@@ -6984,8 +6984,8 @@ instance FromJSON TextConfig where
69846984 <*> v .:? "dx"
69856985 <*> v .:? "dy"
69866986 <*> v .:? "fill"
6987- <*> v .:? "filled"
69886987 <*> v .:? "fillOpacity"
6988+ <*> v .:? "filled"
69896989 <*> v .:? "font"
69906990 <*> v .:? "fontSize"
69916991 <*> v .:? "fontStyle"
@@ -7565,7 +7565,7 @@ instance FromJSON VGMarkConfig where
75657565 <*> v .:? "theta"
75667566
75677567 instance ToJSON TickConfig where
7568- toJSON (TickConfig alignTickConfig angleTickConfig bandSizeTickConfig baselineTickConfig colorTickConfig cursorTickConfig dxTickConfig dyTickConfig fillTickConfig filledTickConfig fillOpacityTickConfig fontTickConfig fontSizeTickConfig fontStyleTickConfig fontWeightTickConfig hrefTickConfig interpolateTickConfig limitTickConfig opacityTickConfig orientTickConfig radiusTickConfig shapeTickConfig sizeTickConfig strokeTickConfig strokeDashTickConfig strokeDashOffsetTickConfig strokeOpacityTickConfig strokeWidthTickConfig tensionTickConfig tickConfigTextTickConfig thetaTickConfig thicknessTickConfig) =
7568+ toJSON (TickConfig alignTickConfig angleTickConfig bandSizeTickConfig baselineTickConfig colorTickConfig cursorTickConfig dxTickConfig dyTickConfig fillTickConfig fillOpacityTickConfig filledTickConfig fontTickConfig fontSizeTickConfig fontStyleTickConfig fontWeightTickConfig hrefTickConfig interpolateTickConfig limitTickConfig opacityTickConfig orientTickConfig radiusTickConfig shapeTickConfig sizeTickConfig strokeTickConfig strokeDashTickConfig strokeDashOffsetTickConfig strokeOpacityTickConfig strokeWidthTickConfig tensionTickConfig tickConfigTextTickConfig thetaTickConfig thicknessTickConfig) =
75697569 object
75707570 [ "align" .= alignTickConfig
75717571 , "angle" .= angleTickConfig
@@ -7576,8 +7576,8 @@ instance ToJSON TickConfig where
75767576 , "dx" .= dxTickConfig
75777577 , "dy" .= dyTickConfig
75787578 , "fill" .= fillTickConfig
7579- , "filled" .= filledTickConfig
75807579 , "fillOpacity" .= fillOpacityTickConfig
7580+ , "filled" .= filledTickConfig
75817581 , "font" .= fontTickConfig
75827582 , "fontSize" .= fontSizeTickConfig
75837583 , "fontStyle" .= fontStyleTickConfig
@@ -7612,8 +7612,8 @@ instance FromJSON TickConfig where
76127612 <*> v .:? "dx"
76137613 <*> v .:? "dy"
76147614 <*> v .:? "fill"
7615- <*> v .:? "filled"
76167615 <*> v .:? "fillOpacity"
7616+ <*> v .:? "filled"
76177617 <*> v .:? "font"
76187618 <*> v .:? "fontSize"
76197619 <*> v .:? "fontStyle"
@@ -8707,7 +8707,7 @@ instance FromJSON XClass where
87078707 <*> v .:? "value"
87088708
87098709 instance ToJSON Axis where
8710- toJSON (Axis domainAxis formatAxis gridAxis labelAngleAxis labelBoundAxis labelFlushAxis labelOverlapAxis labelPaddingAxis labelsAxis maxExtentAxis minExtentAxis offsetAxis orientAxis positionAxis tickCountAxis ticksAxis tickSizeAxis titleAxis titleMaxLengthAxis titlePaddingAxis valuesAxis zindexAxis) =
8710+ toJSON (Axis domainAxis formatAxis gridAxis labelAngleAxis labelBoundAxis labelFlushAxis labelOverlapAxis labelPaddingAxis labelsAxis maxExtentAxis minExtentAxis offsetAxis orientAxis positionAxis tickCountAxis tickSizeAxis ticksAxis titleAxis titleMaxLengthAxis titlePaddingAxis valuesAxis zindexAxis) =
87118711 object
87128712 [ "domain" .= domainAxis
87138713 , "format" .= formatAxis
@@ -8724,8 +8724,8 @@ instance ToJSON Axis where
87248724 , "orient" .= orientAxis
87258725 , "position" .= positionAxis
87268726 , "tickCount" .= tickCountAxis
8727- , "ticks" .= ticksAxis
87288727 , "tickSize" .= tickSizeAxis
8728+ , "ticks" .= ticksAxis
87298729 , "title" .= titleAxis
87308730 , "titleMaxLength" .= titleMaxLengthAxis
87318731 , "titlePadding" .= titlePaddingAxis
@@ -8750,8 +8750,8 @@ instance FromJSON Axis where
87508750 <*> v .:? "orient"
87518751 <*> v .:? "position"
87528752 <*> v .:? "tickCount"
8753- <*> v .:? "ticks"
87548753 <*> v .:? "tickSize"
8754+ <*> v .:? "ticks"
87558755 <*> v .:? "title"
87568756 <*> v .:? "titleMaxLength"
87578757 <*> v .:? "titlePadding"
@@ -9005,7 +9005,7 @@ instance FromJSON AnyMark where
90059005 parseJSON xs@(Object _) = (fmap MarkDefInAnyMark . parseJSON) xs
90069006
90079007 instance ToJSON MarkDef where
9008- toJSON (MarkDef alignMarkDef angleMarkDef baselineMarkDef clipMarkDef colorMarkDef cursorMarkDef dxMarkDef dyMarkDef fillMarkDef filledMarkDef fillOpacityMarkDef fontMarkDef fontSizeMarkDef fontStyleMarkDef fontWeightMarkDef hrefMarkDef interpolateMarkDef limitMarkDef opacityMarkDef orientMarkDef radiusMarkDef shapeMarkDef sizeMarkDef strokeMarkDef strokeDashMarkDef strokeDashOffsetMarkDef strokeOpacityMarkDef strokeWidthMarkDef styleMarkDef tensionMarkDef markDefTextMarkDef thetaMarkDef markDefTypeMarkDef) =
9008+ toJSON (MarkDef alignMarkDef angleMarkDef baselineMarkDef clipMarkDef colorMarkDef cursorMarkDef dxMarkDef dyMarkDef fillMarkDef fillOpacityMarkDef filledMarkDef fontMarkDef fontSizeMarkDef fontStyleMarkDef fontWeightMarkDef hrefMarkDef interpolateMarkDef limitMarkDef opacityMarkDef orientMarkDef radiusMarkDef shapeMarkDef sizeMarkDef strokeMarkDef strokeDashMarkDef strokeDashOffsetMarkDef strokeOpacityMarkDef strokeWidthMarkDef styleMarkDef tensionMarkDef markDefTextMarkDef thetaMarkDef markDefTypeMarkDef) =
90099009 object
90109010 [ "align" .= alignMarkDef
90119011 , "angle" .= angleMarkDef
@@ -9016,8 +9016,8 @@ instance ToJSON MarkDef where
90169016 , "dx" .= dxMarkDef
90179017 , "dy" .= dyMarkDef
90189018 , "fill" .= fillMarkDef
9019- , "filled" .= filledMarkDef
90209019 , "fillOpacity" .= fillOpacityMarkDef
9020+ , "filled" .= filledMarkDef
90219021 , "font" .= fontMarkDef
90229022 , "fontSize" .= fontSizeMarkDef
90239023 , "fontStyle" .= fontStyleMarkDef
@@ -9053,8 +9053,8 @@ instance FromJSON MarkDef where
90539053 <*> v .:? "dx"
90549054 <*> v .:? "dy"
90559055 <*> v .:? "fill"
9056- <*> v .:? "filled"
90579056 <*> v .:? "fillOpacity"
9057+ <*> v .:? "filled"
90589058 <*> v .:? "font"
90599059 <*> v .:? "fontSize"
90609060 <*> v .:? "fontStyle"
Mschema-java-datetime-legacy/test/inputs/schema/accessors.schema/default/src/main/java/io/quicktype/TopLevel.java+10 −10
@@ -3,15 +3,15 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private String barre;
6+ private Union unionization;
77 private Enum enumerification;
88 private String Goo;
9- private Union unionization;
9+ private String barre;
1010
11- @JsonProperty("bar")
12- public String getBarre() { return barre; }
13- @JsonProperty("bar")
14- public void setBarre(String value) { this.barre = value; }
11+ @JsonProperty("union")
12+ public Union getUnionization() { return unionization; }
13+ @JsonProperty("union")
14+ public void setUnionization(Union value) { this.unionization = value; }
1515
1616 @JsonProperty("enum")
1717 public Enum getEnumerification() { return enumerification; }
@@ -23,8 +23,8 @@ public class TopLevel {
2323 @JsonProperty("foo")
2424 public void setGoo(String value) { this.Goo = value; }
2525
26- @JsonProperty("union")
27- public Union getUnionization() { return unionization; }
28- @JsonProperty("union")
29- public void setUnionization(Union value) { this.unionization = value; }
26+ @JsonProperty("bar")
27+ public String getBarre() { return barre; }
28+ @JsonProperty("bar")
29+ public void setBarre(String value) { this.barre = value; }
3030 }
Mschema-java-datetime-legacy/test/inputs/schema/all-of-additional-properties-false.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -5,8 +5,8 @@ import com.fasterxml.jackson.annotation.*;
55 public class TopLevel {
66 private double amount;
77 private Frequency frequency;
8- private String description;
98 private Type type;
9+ private String description;
1010
1111 @JsonProperty("amount")
1212 public double getAmount() { return amount; }
@@ -18,13 +18,13 @@ public class TopLevel {
1818 @JsonProperty("frequency")
1919 public void setFrequency(Frequency value) { this.frequency = value; }
2020
21- @JsonProperty("description")
22- public String getDescription() { return description; }
23- @JsonProperty("description")
24- public void setDescription(String value) { this.description = value; }
25-
2621 @JsonProperty("type")
2722 public Type getType() { return type; }
2823 @JsonProperty("type")
2924 public void setType(Type value) { this.type = value; }
25+
26+ @JsonProperty("description")
27+ public String getDescription() { return description; }
28+ @JsonProperty("description")
29+ public void setDescription(String value) { this.description = value; }
3030 }
Mschema-java-datetime-legacy/test/inputs/schema/bool-string.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -4,29 +4,14 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<String> arrNullable;
8- private List<String> arrOne;
9- private String nullable;
107 private String one;
118 private String optional;
9+ private String nullable;
10+ private List<String> arrOne;
11+ private List<String> arrNullable;
1212 private UnionWithBool unionWithBool;
1313 private UnionWithBool unionWithBoolAndEnum;
1414
15- @JsonProperty("arrNullable")
16- public List<String> getArrNullable() { return arrNullable; }
17- @JsonProperty("arrNullable")
18- public void setArrNullable(List<String> value) { this.arrNullable = value; }
19-
20- @JsonProperty("arrOne")
21- public List<String> getArrOne() { return arrOne; }
22- @JsonProperty("arrOne")
23- public void setArrOne(List<String> value) { this.arrOne = value; }
24-
25- @JsonProperty("nullable")
26- public String getNullable() { return nullable; }
27- @JsonProperty("nullable")
28- public void setNullable(String value) { this.nullable = value; }
29-
3015 @JsonProperty("one")
3116 public String getOne() { return one; }
3217 @JsonProperty("one")
@@ -37,6 +22,21 @@ public class TopLevel {
3722 @JsonProperty("optional")
3823 public void setOptional(String value) { this.optional = value; }
3924
25+ @JsonProperty("nullable")
26+ public String getNullable() { return nullable; }
27+ @JsonProperty("nullable")
28+ public void setNullable(String value) { this.nullable = value; }
29+
30+ @JsonProperty("arrOne")
31+ public List<String> getArrOne() { return arrOne; }
32+ @JsonProperty("arrOne")
33+ public void setArrOne(List<String> value) { this.arrOne = value; }
34+
35+ @JsonProperty("arrNullable")
36+ public List<String> getArrNullable() { return arrNullable; }
37+ @JsonProperty("arrNullable")
38+ public void setArrNullable(List<String> value) { this.arrNullable = value; }
39+
4040 @JsonProperty("unionWithBool")
4141 public UnionWithBool getUnionWithBool() { return unionWithBool; }
4242 @JsonProperty("unionWithBool")
Mschema-java-datetime-legacy/test/inputs/schema/boolean-subschema.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,11 +4,16 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7+ private String foo;
78 private Object disallowed;
89 private List<Object> empty;
9- private String foo;
1010 private Object impossible;
1111
12+ @JsonProperty("foo")
13+ public String getFoo() { return foo; }
14+ @JsonProperty("foo")
15+ public void setFoo(String value) { this.foo = value; }
16+
1217 @JsonProperty("disallowed")
1318 public Object getDisallowed() { return disallowed; }
1419 @JsonProperty("disallowed")
@@ -19,11 +24,6 @@ public class TopLevel {
1924 @JsonProperty("empty")
2025 public void setEmpty(List<Object> value) { this.empty = value; }
2126
22- @JsonProperty("foo")
23- public String getFoo() { return foo; }
24- @JsonProperty("foo")
25- public void setFoo(String value) { this.foo = value; }
26-
2727 @JsonProperty("impossible")
2828 public Object getImpossible() { return impossible; }
2929 @JsonProperty("impossible")
Mschema-java-datetime-legacy/test/inputs/schema/comment-injection.schema/default/src/main/java/io/quicktype/TopLevel.java+20 −20
@@ -17,10 +17,29 @@ import com.fasterxml.jackson.annotation.*;
1717 * }
1818 */
1919 public class TopLevel {
20+ private String value;
2021 private String trailingBackslash;
2122 private String trailingQuote;
2223 private String trailingTripleQuote;
23- private String value;
24+
25+ /**
26+ * Property delimiters:
27+ * * /
28+ * / *
29+ * {-
30+ * -}
31+ * """
32+ * </summary> & <br>
33+ * }
34+ * }
35+ * }
36+ * }
37+ * }
38+ */
39+ @JsonProperty("value")
40+ public String getValue() { return value; }
41+ @JsonProperty("value")
42+ public void setValue(String value) { this.value = value; }
2443
2544 /**
2645 * Ends with a backslash \
@@ -45,23 +64,4 @@ public class TopLevel {
4564 public String getTrailingTripleQuote() { return trailingTripleQuote; }
4665 @JsonProperty("trailingTripleQuote")
4766 public void setTrailingTripleQuote(String value) { this.trailingTripleQuote = value; }
48-
49- /**
50- * Property delimiters:
51- * * /
52- * / *
53- * {-
54- * -}
55- * """
56- * </summary> & <br>
57- * }
58- * }
59- * }
60- * }
61- * }
62- */
63- @JsonProperty("value")
64- public String getValue() { return value; }
65- @JsonProperty("value")
66- public void setValue(String value) { this.value = value; }
6767 }
Mschema-java-datetime-legacy/test/inputs/schema/const-non-string.schema/default/src/main/java/io/quicktype/TopLevel.java+12 −12
@@ -3,17 +3,27 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6+ private double version;
67 private long amount;
8+ private double ratio;
79 private boolean enabled;
810 private Kind kind;
9- private double ratio;
10- private double version;
11+
12+ @JsonProperty("version")
13+ public double getVersion() { return version; }
14+ @JsonProperty("version")
15+ public void setVersion(double value) { this.version = value; }
1116
1217 @JsonProperty("amount")
1318 public long getAmount() { return amount; }
1419 @JsonProperty("amount")
1520 public void setAmount(long value) { this.amount = value; }
1621
22+ @JsonProperty("ratio")
23+ public double getRatio() { return ratio; }
24+ @JsonProperty("ratio")
25+ public void setRatio(double value) { this.ratio = value; }
26+
1727 @JsonProperty("enabled")
1828 public boolean getEnabled() { return enabled; }
1929 @JsonProperty("enabled")
@@ -23,14 +33,4 @@ public class TopLevel {
2333 public Kind getKind() { return kind; }
2434 @JsonProperty("kind")
2535 public void setKind(Kind value) { this.kind = value; }
26-
27- @JsonProperty("ratio")
28- public double getRatio() { return ratio; }
29- @JsonProperty("ratio")
30- public void setRatio(double value) { this.ratio = value; }
31-
32- @JsonProperty("version")
33- public double getVersion() { return version; }
34- @JsonProperty("version")
35- public void setVersion(double value) { this.version = value; }
3636 }
Mschema-java-datetime-legacy/test/inputs/schema/date-time-or-string.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,16 +4,16 @@ import com.fasterxml.jackson.annotation.*;
44 import java.time.OffsetDateTime;
55
66 public class TopLevel {
7- private BarUnion bar;
87 private String foo;
9-
10- @JsonProperty("bar")
11- public BarUnion getBar() { return bar; }
12- @JsonProperty("bar")
13- public void setBar(BarUnion value) { this.bar = value; }
8+ private BarUnion bar;
149
1510 @JsonProperty("foo")
1611 public String getFoo() { return foo; }
1712 @JsonProperty("foo")
1813 public void setFoo(String value) { this.foo = value; }
14+
15+ @JsonProperty("bar")
16+ public BarUnion getBar() { return bar; }
17+ @JsonProperty("bar")
18+ public void setBar(BarUnion value) { this.bar = value; }
1919 }
Mschema-java-datetime-legacy/test/inputs/schema/description.schema/default/src/main/java/io/quicktype/TopLevel.java+12 −12
@@ -7,34 +7,34 @@ import java.time.OffsetTime;
77 import java.util.List;
88
99 public class TopLevel {
10- private List<ComplexUnionArrayElement> complexUnionArray;
1110 private LocalDate date;
12- private OffsetDateTime dateTime;
1311 private OffsetTime time;
12+ private OffsetDateTime dateTime;
1413 private List<UnionArray> unionArray;
15-
16- @JsonProperty("complex-union-array")
17- public List<ComplexUnionArrayElement> getComplexUnionArray() { return complexUnionArray; }
18- @JsonProperty("complex-union-array")
19- public void setComplexUnionArray(List<ComplexUnionArrayElement> value) { this.complexUnionArray = value; }
14+ private List<ComplexUnionArrayElement> complexUnionArray;
2015
2116 @JsonProperty("date")
2217 public LocalDate getDate() { return date; }
2318 @JsonProperty("date")
2419 public void setDate(LocalDate value) { this.date = value; }
2520
26- @JsonProperty("date-time")
27- public OffsetDateTime getDateTime() { return dateTime; }
28- @JsonProperty("date-time")
29- public void setDateTime(OffsetDateTime value) { this.dateTime = value; }
30-
3121 @JsonProperty("time")
3222 public OffsetTime getTime() { return time; }
3323 @JsonProperty("time")
3424 public void setTime(OffsetTime value) { this.time = value; }
3525
26+ @JsonProperty("date-time")
27+ public OffsetDateTime getDateTime() { return dateTime; }
28+ @JsonProperty("date-time")
29+ public void setDateTime(OffsetDateTime value) { this.dateTime = value; }
30+
3631 @JsonProperty("union-array")
3732 public List<UnionArray> getUnionArray() { return unionArray; }
3833 @JsonProperty("union-array")
3934 public void setUnionArray(List<UnionArray> value) { this.unionArray = value; }
35+
36+ @JsonProperty("complex-union-array")
37+ public List<ComplexUnionArrayElement> getComplexUnionArray() { return complexUnionArray; }
38+ @JsonProperty("complex-union-array")
39+ public void setComplexUnionArray(List<ComplexUnionArrayElement> value) { this.complexUnionArray = value; }
4040 }
Mschema-java-datetime-legacy/test/inputs/schema/direct-union.schema/default/src/main/java/io/quicktype/Thing.java+15 −15
@@ -7,19 +7,19 @@ import com.fasterxml.jackson.annotation.*;
77 * Its description has two lines.
88 */
99 public class TopLevel {
10- private Boolean bar;
10+ private Union union;
1111 private Enum topLevelEnum;
1212 private Double foo;
13+ private Boolean bar;
1314 private ObjectOrStringUnion objectOrString;
14- private Union union;
1515
1616 /**
17- * A pretty boolean
17+ * Either a number or a string
1818 */
19- @JsonProperty("bar")
20- public Boolean getBar() { return bar; }
21- @JsonProperty("bar")
22- public void setBar(Boolean value) { this.bar = value; }
19+ @JsonProperty("union")
20+ public Union getUnion() { return union; }
21+ @JsonProperty("union")
22+ public void setUnion(Union value) { this.union = value; }
2323
2424 /**
2525 * An enumeration
@@ -34,16 +34,16 @@ public class TopLevel {
3434 @JsonProperty("foo")
3535 public void setFoo(Double value) { this.foo = value; }
3636
37+ /**
38+ * A pretty boolean
39+ */
40+ @JsonProperty("bar")
41+ public Boolean getBar() { return bar; }
42+ @JsonProperty("bar")
43+ public void setBar(Boolean value) { this.bar = value; }
44+
3745 @JsonProperty("object-or-string")
3846 public ObjectOrStringUnion getObjectOrString() { return objectOrString; }
3947 @JsonProperty("object-or-string")
4048 public void setObjectOrString(ObjectOrStringUnion value) { this.objectOrString = value; }
41-
42- /**
43- * Either a number or a string
44- */
45- @JsonProperty("union")
46- public Union getUnion() { return union; }
47- @JsonProperty("union")
48- public void setUnion(Union value) { this.union = value; }
4949 }
Mschema-java-datetime-legacy/test/inputs/schema/enum.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -5,16 +5,16 @@ import java.util.List;
55 import java.util.Map;
66
77 public class Thing {
8- private Anything optional;
98 private Anything required;
10-
11- @JsonProperty("optional")
12- public Anything getOptional() { return optional; }
13- @JsonProperty("optional")
14- public void setOptional(Anything value) { this.optional = value; }
9+ private Anything optional;
1510
1611 @JsonProperty("required")
1712 public Anything getRequired() { return required; }
1813 @JsonProperty("required")
1914 public void setRequired(Anything value) { this.required = value; }
15+
16+ @JsonProperty("optional")
17+ public Anything getOptional() { return optional; }
18+ @JsonProperty("optional")
19+ public void setOptional(Anything value) { this.optional = value; }
2020 }
Mschema-java-datetime-legacy/test/inputs/schema/integer-string.schema/default/src/main/java/io/quicktype/TopLevel.java+16 −16
@@ -4,34 +4,34 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<Arr> arr;
8- private String topLevelFor;
9- private Gve gve;
107 private Lvc lvc;
8+ private Gve gve;
9+ private List<Arr> arr;
1110 private List<OtherArr> otherArr;
11+ private String topLevelFor;
1212
13- @JsonProperty("arr")
14- public List<Arr> getArr() { return arr; }
15- @JsonProperty("arr")
16- public void setArr(List<Arr> value) { this.arr = value; }
17-
18- @JsonProperty("for")
19- public String getTopLevelFor() { return topLevelFor; }
20- @JsonProperty("for")
21- public void setTopLevelFor(String value) { this.topLevelFor = value; }
13+ @JsonProperty("lvc")
14+ public Lvc getLvc() { return lvc; }
15+ @JsonProperty("lvc")
16+ public void setLvc(Lvc value) { this.lvc = value; }
2217
2318 @JsonProperty("gve")
2419 public Gve getGve() { return gve; }
2520 @JsonProperty("gve")
2621 public void setGve(Gve value) { this.gve = value; }
2722
28- @JsonProperty("lvc")
29- public Lvc getLvc() { return lvc; }
30- @JsonProperty("lvc")
31- public void setLvc(Lvc value) { this.lvc = value; }
23+ @JsonProperty("arr")
24+ public List<Arr> getArr() { return arr; }
25+ @JsonProperty("arr")
26+ public void setArr(List<Arr> value) { this.arr = value; }
3227
3328 @JsonProperty("otherArr")
3429 public List<OtherArr> getOtherArr() { return otherArr; }
3530 @JsonProperty("otherArr")
3631 public void setOtherArr(List<OtherArr> value) { this.otherArr = value; }
32+
33+ @JsonProperty("for")
34+ public String getTopLevelFor() { return topLevelFor; }
35+ @JsonProperty("for")
36+ public void setTopLevelFor(String value) { this.topLevelFor = value; }
3737 }
Mschema-java-datetime-legacy/test/inputs/schema/integer-type.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -4,29 +4,14 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<String> arrNullable;
8- private List<String> arrOne;
9- private String nullable;
107 private String one;
118 private String optional;
9+ private String nullable;
10+ private List<String> arrOne;
11+ private List<String> arrNullable;
1212 private UnionWithInt unionWithInt;
1313 private UnionWithInt unionWithIntAndEnum;
1414
15- @JsonProperty("arrNullable")
16- public List<String> getArrNullable() { return arrNullable; }
17- @JsonProperty("arrNullable")
18- public void setArrNullable(List<String> value) { this.arrNullable = value; }
19-
20- @JsonProperty("arrOne")
21- public List<String> getArrOne() { return arrOne; }
22- @JsonProperty("arrOne")
23- public void setArrOne(List<String> value) { this.arrOne = value; }
24-
25- @JsonProperty("nullable")
26- public String getNullable() { return nullable; }
27- @JsonProperty("nullable")
28- public void setNullable(String value) { this.nullable = value; }
29-
3015 @JsonProperty("one")
3116 public String getOne() { return one; }
3217 @JsonProperty("one")
@@ -37,6 +22,21 @@ public class TopLevel {
3722 @JsonProperty("optional")
3823 public void setOptional(String value) { this.optional = value; }
3924
25+ @JsonProperty("nullable")
26+ public String getNullable() { return nullable; }
27+ @JsonProperty("nullable")
28+ public void setNullable(String value) { this.nullable = value; }
29+
30+ @JsonProperty("arrOne")
31+ public List<String> getArrOne() { return arrOne; }
32+ @JsonProperty("arrOne")
33+ public void setArrOne(List<String> value) { this.arrOne = value; }
34+
35+ @JsonProperty("arrNullable")
36+ public List<String> getArrNullable() { return arrNullable; }
37+ @JsonProperty("arrNullable")
38+ public void setArrNullable(List<String> value) { this.arrNullable = value; }
39+
4040 @JsonProperty("unionWithInt")
4141 public UnionWithInt getUnionWithInt() { return unionWithInt; }
4242 @JsonProperty("unionWithInt")
Mschema-java-datetime-legacy/test/inputs/schema/light.schema/default/src/main/java/io/quicktype/LightParams.java+29 −29
@@ -3,15 +3,30 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6+ private long smallPositive;
7+ private long smallNegative;
8+ private long i32Range;
69 private long aboveI32Max;
710 private long belowI32Min;
8- private long i32Range;
9- private long largeBounds;
10- private long onlyMaximum;
1111 private long onlyMinimum;
12- private long smallNegative;
13- private long smallPositive;
12+ private long onlyMaximum;
1413 private long unbounded;
14+ private long largeBounds;
15+
16+ @JsonProperty("small_positive")
17+ public long getSmallPositive() { return smallPositive; }
18+ @JsonProperty("small_positive")
19+ public void setSmallPositive(long value) { this.smallPositive = value; }
20+
21+ @JsonProperty("small_negative")
22+ public long getSmallNegative() { return smallNegative; }
23+ @JsonProperty("small_negative")
24+ public void setSmallNegative(long value) { this.smallNegative = value; }
25+
26+ @JsonProperty("i32_range")
27+ public long getI32Range() { return i32Range; }
28+ @JsonProperty("i32_range")
29+ public void setI32Range(long value) { this.i32Range = value; }
1530
1631 @JsonProperty("above_i32_max")
1732 public long getAboveI32Max() { return aboveI32Max; }
@@ -23,38 +38,23 @@ public class TopLevel {
2338 @JsonProperty("below_i32_min")
2439 public void setBelowI32Min(long value) { this.belowI32Min = value; }
2540
26- @JsonProperty("i32_range")
27- public long getI32Range() { return i32Range; }
28- @JsonProperty("i32_range")
29- public void setI32Range(long value) { this.i32Range = value; }
30-
31- @JsonProperty("large_bounds")
32- public long getLargeBounds() { return largeBounds; }
33- @JsonProperty("large_bounds")
34- public void setLargeBounds(long value) { this.largeBounds = value; }
35-
36- @JsonProperty("only_maximum")
37- public long getOnlyMaximum() { return onlyMaximum; }
38- @JsonProperty("only_maximum")
39- public void setOnlyMaximum(long value) { this.onlyMaximum = value; }
40-
4141 @JsonProperty("only_minimum")
4242 public long getOnlyMinimum() { return onlyMinimum; }
4343 @JsonProperty("only_minimum")
4444 public void setOnlyMinimum(long value) { this.onlyMinimum = value; }
4545
46- @JsonProperty("small_negative")
47- public long getSmallNegative() { return smallNegative; }
48- @JsonProperty("small_negative")
49- public void setSmallNegative(long value) { this.smallNegative = value; }
50-
51- @JsonProperty("small_positive")
52- public long getSmallPositive() { return smallPositive; }
53- @JsonProperty("small_positive")
54- public void setSmallPositive(long value) { this.smallPositive = value; }
46+ @JsonProperty("only_maximum")
47+ public long getOnlyMaximum() { return onlyMaximum; }
48+ @JsonProperty("only_maximum")
49+ public void setOnlyMaximum(long value) { this.onlyMaximum = value; }
5550
5651 @JsonProperty("unbounded")
5752 public long getUnbounded() { return unbounded; }
5853 @JsonProperty("unbounded")
5954 public void setUnbounded(long value) { this.unbounded = value; }
55+
56+ @JsonProperty("large_bounds")
57+ public long getLargeBounds() { return largeBounds; }
58+ @JsonProperty("large_bounds")
59+ public void setLargeBounds(long value) { this.largeBounds = value; }
6060 }
Mschema-java-datetime-legacy/test/inputs/schema/min-max-items.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,20 +3,20 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class LightParams {
6- private String appID;
76 private String outletID;
7+ private String appID;
88 private String rgba;
99
10- @JsonProperty("app_id")
11- public String getAppID() { return appID; }
12- @JsonProperty("app_id")
13- public void setAppID(String value) { this.appID = value; }
14-
1510 @JsonProperty("outlet_id")
1611 public String getOutletID() { return outletID; }
1712 @JsonProperty("outlet_id")
1813 public void setOutletID(String value) { this.outletID = value; }
1914
15+ @JsonProperty("app_id")
16+ public String getAppID() { return appID; }
17+ @JsonProperty("app_id")
18+ public void setAppID(String value) { this.appID = value; }
19+
2020 @JsonProperty("rgba")
2121 public String getRGBA() { return rgba; }
2222 @JsonProperty("rgba")
Mschema-java-datetime-legacy/test/inputs/schema/minmax-integer.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,12 +4,17 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7+ private List<String> minOnly;
78 private List<Long> maxOnly;
89 private List<Double> minAndMax;
9- private List<String> minOnly;
1010 private List<String> plain;
1111 private List<UnionItem> unionItems;
1212
13+ @JsonProperty("minOnly")
14+ public List<String> getMinOnly() { return minOnly; }
15+ @JsonProperty("minOnly")
16+ public void setMinOnly(List<String> value) { this.minOnly = value; }
17+
1318 @JsonProperty("maxOnly")
1419 public List<Long> getMaxOnly() { return maxOnly; }
1520 @JsonProperty("maxOnly")
@@ -20,11 +25,6 @@ public class TopLevel {
2025 @JsonProperty("minAndMax")
2126 public void setMinAndMax(List<Double> value) { this.minAndMax = value; }
2227
23- @JsonProperty("minOnly")
24- public List<String> getMinOnly() { return minOnly; }
25- @JsonProperty("minOnly")
26- public void setMinOnly(List<String> value) { this.minOnly = value; }
27-
2828 @JsonProperty("plain")
2929 public List<String> getPlain() { return plain; }
3030 @JsonProperty("plain")
Mschema-java-datetime-legacy/test/inputs/schema/minmax.schema/default/src/main/java/io/quicktype/TopLevel.java+21 −21
@@ -4,51 +4,51 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
66 private long free;
7- private long intersection;
8- private long max;
97 private long min;
8+ private long max;
109 private long minmax;
11- private long minMaxIntersection;
12- private long minMaxUnion;
1310 private long union;
11+ private long minMaxUnion;
12+ private long intersection;
13+ private long minMaxIntersection;
1414
1515 @JsonProperty("free")
1616 public long getFree() { return free; }
1717 @JsonProperty("free")
1818 public void setFree(long value) { this.free = value; }
1919
20- @JsonProperty("intersection")
21- public long getIntersection() { return intersection; }
22- @JsonProperty("intersection")
23- public void setIntersection(long value) { this.intersection = value; }
20+ @JsonProperty("min")
21+ public long getMin() { return min; }
22+ @JsonProperty("min")
23+ public void setMin(long value) { this.min = value; }
2424
2525 @JsonProperty("max")
2626 public long getMax() { return max; }
2727 @JsonProperty("max")
2828 public void setMax(long value) { this.max = value; }
2929
30- @JsonProperty("min")
31- public long getMin() { return min; }
32- @JsonProperty("min")
33- public void setMin(long value) { this.min = value; }
34-
3530 @JsonProperty("minmax")
3631 public long getMinmax() { return minmax; }
3732 @JsonProperty("minmax")
3833 public void setMinmax(long value) { this.minmax = value; }
3934
40- @JsonProperty("minMaxIntersection")
41- public long getMinMaxIntersection() { return minMaxIntersection; }
42- @JsonProperty("minMaxIntersection")
43- public void setMinMaxIntersection(long value) { this.minMaxIntersection = value; }
35+ @JsonProperty("union")
36+ public long getUnion() { return union; }
37+ @JsonProperty("union")
38+ public void setUnion(long value) { this.union = value; }
4439
4540 @JsonProperty("minMaxUnion")
4641 public long getMinMaxUnion() { return minMaxUnion; }
4742 @JsonProperty("minMaxUnion")
4843 public void setMinMaxUnion(long value) { this.minMaxUnion = value; }
4944
50- @JsonProperty("union")
51- public long getUnion() { return union; }
52- @JsonProperty("union")
53- public void setUnion(long value) { this.union = value; }
45+ @JsonProperty("intersection")
46+ public long getIntersection() { return intersection; }
47+ @JsonProperty("intersection")
48+ public void setIntersection(long value) { this.intersection = value; }
49+
50+ @JsonProperty("minMaxIntersection")
51+ public long getMinMaxIntersection() { return minMaxIntersection; }
52+ @JsonProperty("minMaxIntersection")
53+ public void setMinMaxIntersection(long value) { this.minMaxIntersection = value; }
5454 }
Mschema-java-datetime-legacy/test/inputs/schema/minmaxlength.schema/default/src/main/java/io/quicktype/TopLevel.java+21 −21
@@ -4,51 +4,51 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
66 private double free;
7- private double intersection;
8- private double max;
97 private double min;
8+ private double max;
109 private double minmax;
11- private double minMaxIntersection;
12- private double minMaxUnion;
1310 private double union;
11+ private double minMaxUnion;
12+ private double intersection;
13+ private double minMaxIntersection;
1414
1515 @JsonProperty("free")
1616 public double getFree() { return free; }
1717 @JsonProperty("free")
1818 public void setFree(double value) { this.free = value; }
1919
20- @JsonProperty("intersection")
21- public double getIntersection() { return intersection; }
22- @JsonProperty("intersection")
23- public void setIntersection(double value) { this.intersection = value; }
20+ @JsonProperty("min")
21+ public double getMin() { return min; }
22+ @JsonProperty("min")
23+ public void setMin(double value) { this.min = value; }
2424
2525 @JsonProperty("max")
2626 public double getMax() { return max; }
2727 @JsonProperty("max")
2828 public void setMax(double value) { this.max = value; }
2929
30- @JsonProperty("min")
31- public double getMin() { return min; }
32- @JsonProperty("min")
33- public void setMin(double value) { this.min = value; }
34-
3530 @JsonProperty("minmax")
3631 public double getMinmax() { return minmax; }
3732 @JsonProperty("minmax")
3833 public void setMinmax(double value) { this.minmax = value; }
3934
40- @JsonProperty("minMaxIntersection")
41- public double getMinMaxIntersection() { return minMaxIntersection; }
42- @JsonProperty("minMaxIntersection")
43- public void setMinMaxIntersection(double value) { this.minMaxIntersection = value; }
35+ @JsonProperty("union")
36+ public double getUnion() { return union; }
37+ @JsonProperty("union")
38+ public void setUnion(double value) { this.union = value; }
4439
4540 @JsonProperty("minMaxUnion")
4641 public double getMinMaxUnion() { return minMaxUnion; }
4742 @JsonProperty("minMaxUnion")
4843 public void setMinMaxUnion(double value) { this.minMaxUnion = value; }
4944
50- @JsonProperty("union")
51- public double getUnion() { return union; }
52- @JsonProperty("union")
53- public void setUnion(double value) { this.union = value; }
45+ @JsonProperty("intersection")
46+ public double getIntersection() { return intersection; }
47+ @JsonProperty("intersection")
48+ public void setIntersection(double value) { this.intersection = value; }
49+
50+ @JsonProperty("minMaxIntersection")
51+ public double getMinMaxIntersection() { return minMaxIntersection; }
52+ @JsonProperty("minMaxIntersection")
53+ public void setMinMaxIntersection(double value) { this.minMaxIntersection = value; }
5454 }
Mschema-java-datetime-legacy/test/inputs/schema/non-standard-ref.schema/default/src/main/java/io/quicktype/TopLevel.java+28 −28
@@ -3,52 +3,52 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private String intersection;
7- private InUnion inUnion;
8- private String maxlength;
96 private String minlength;
10- private String minMaxIntersection;
7+ private String maxlength;
118 private String minmaxlength;
12- private String minMaxUnion;
139 private String union;
14-
15- @JsonProperty("intersection")
16- public String getIntersection() { return intersection; }
17- @JsonProperty("intersection")
18- public void setIntersection(String value) { this.intersection = value; }
19-
20- @JsonProperty("inUnion")
21- public InUnion getInUnion() { return inUnion; }
22- @JsonProperty("inUnion")
23- public void setInUnion(InUnion value) { this.inUnion = value; }
24-
25- @JsonProperty("maxlength")
26- public String getMaxlength() { return maxlength; }
27- @JsonProperty("maxlength")
28- public void setMaxlength(String value) { this.maxlength = value; }
10+ private InUnion inUnion;
11+ private String minMaxUnion;
12+ private String intersection;
13+ private String minMaxIntersection;
2914
3015 @JsonProperty("minlength")
3116 public String getMinlength() { return minlength; }
3217 @JsonProperty("minlength")
3318 public void setMinlength(String value) { this.minlength = value; }
3419
35- @JsonProperty("minMaxIntersection")
36- public String getMinMaxIntersection() { return minMaxIntersection; }
37- @JsonProperty("minMaxIntersection")
38- public void setMinMaxIntersection(String value) { this.minMaxIntersection = value; }
20+ @JsonProperty("maxlength")
21+ public String getMaxlength() { return maxlength; }
22+ @JsonProperty("maxlength")
23+ public void setMaxlength(String value) { this.maxlength = value; }
3924
4025 @JsonProperty("minmaxlength")
4126 public String getMinmaxlength() { return minmaxlength; }
4227 @JsonProperty("minmaxlength")
4328 public void setMinmaxlength(String value) { this.minmaxlength = value; }
4429
30+ @JsonProperty("union")
31+ public String getUnion() { return union; }
32+ @JsonProperty("union")
33+ public void setUnion(String value) { this.union = value; }
34+
35+ @JsonProperty("inUnion")
36+ public InUnion getInUnion() { return inUnion; }
37+ @JsonProperty("inUnion")
38+ public void setInUnion(InUnion value) { this.inUnion = value; }
39+
4540 @JsonProperty("minMaxUnion")
4641 public String getMinMaxUnion() { return minMaxUnion; }
4742 @JsonProperty("minMaxUnion")
4843 public void setMinMaxUnion(String value) { this.minMaxUnion = value; }
4944
50- @JsonProperty("union")
51- public String getUnion() { return union; }
52- @JsonProperty("union")
53- public void setUnion(String value) { this.union = value; }
45+ @JsonProperty("intersection")
46+ public String getIntersection() { return intersection; }
47+ @JsonProperty("intersection")
48+ public void setIntersection(String value) { this.intersection = value; }
49+
50+ @JsonProperty("minMaxIntersection")
51+ public String getMinMaxIntersection() { return minMaxIntersection; }
52+ @JsonProperty("minMaxIntersection")
53+ public void setMinMaxIntersection(String value) { this.minMaxIntersection = value; }
5454 }
Mschema-java-datetime-legacy/test/inputs/schema/nullable-optional-one-of.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,20 +3,20 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private long bar;
76 private long foo;
7+ private long bar;
88 private boolean quux;
99
10- @JsonProperty("bar")
11- public long getBar() { return bar; }
12- @JsonProperty("bar")
13- public void setBar(long value) { this.bar = value; }
14-
1510 @JsonProperty("foo")
1611 public long getFoo() { return foo; }
1712 @JsonProperty("foo")
1813 public void setFoo(long value) { this.foo = value; }
1914
15+ @JsonProperty("bar")
16+ public long getBar() { return bar; }
17+ @JsonProperty("bar")
18+ public void setBar(long value) { this.bar = value; }
19+
2020 @JsonProperty("quux")
2121 public boolean getQuux() { return quux; }
2222 @JsonProperty("quux")
Mschema-java-datetime-legacy/test/inputs/schema/optional-any.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private String b;
76 private Kind kind;
8-
9- @JsonProperty("b")
10- public String getB() { return b; }
11- @JsonProperty("b")
12- public void setB(String value) { this.b = value; }
7+ private String b;
138
149 @JsonProperty("kind")
1510 public Kind getKind() { return kind; }
1611 @JsonProperty("kind")
1712 public void setKind(Kind value) { this.kind = value; }
13+
14+ @JsonProperty("b")
15+ public String getB() { return b; }
16+ @JsonProperty("b")
17+ public void setB(String value) { this.b = value; }
1818 }
Mschema-java-datetime-legacy/test/inputs/schema/optional-const-ref.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private boolean bar;
76 private Object foo;
8-
9- @JsonProperty("bar")
10- public boolean getBar() { return bar; }
11- @JsonProperty("bar")
12- public void setBar(boolean value) { this.bar = value; }
7+ private boolean bar;
138
149 @JsonProperty("foo")
1510 public Object getFoo() { return foo; }
1611 @JsonProperty("foo")
1712 public void setFoo(Object value) { this.foo = value; }
13+
14+ @JsonProperty("bar")
15+ public boolean getBar() { return bar; }
16+ @JsonProperty("bar")
17+ public void setBar(boolean value) { this.bar = value; }
1818 }
Mschema-java-datetime-legacy/test/inputs/schema/optional-constraints.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -5,45 +5,45 @@ import java.util.List;
55
66 public class TopLevel {
77 private List<Coordinate> coordinates;
8- private Long count;
9- private String label;
108 private List<Coordinate> requiredCoordinates;
9+ private Long count;
1110 private long requiredCount;
12- private String requiredLabel;
1311 private Double weight;
12+ private String label;
13+ private String requiredLabel;
1414
1515 @JsonProperty("coordinates")
1616 public List<Coordinate> getCoordinates() { return coordinates; }
1717 @JsonProperty("coordinates")
1818 public void setCoordinates(List<Coordinate> value) { this.coordinates = value; }
1919
20- @JsonProperty("count")
21- public Long getCount() { return count; }
22- @JsonProperty("count")
23- public void setCount(Long value) { this.count = value; }
24-
25- @JsonProperty("label")
26- public String getLabel() { return label; }
27- @JsonProperty("label")
28- public void setLabel(String value) { this.label = value; }
29-
3020 @JsonProperty("requiredCoordinates")
3121 public List<Coordinate> getRequiredCoordinates() { return requiredCoordinates; }
3222 @JsonProperty("requiredCoordinates")
3323 public void setRequiredCoordinates(List<Coordinate> value) { this.requiredCoordinates = value; }
3424
25+ @JsonProperty("count")
26+ public Long getCount() { return count; }
27+ @JsonProperty("count")
28+ public void setCount(Long value) { this.count = value; }
29+
3530 @JsonProperty("requiredCount")
3631 public long getRequiredCount() { return requiredCount; }
3732 @JsonProperty("requiredCount")
3833 public void setRequiredCount(long value) { this.requiredCount = value; }
3934
40- @JsonProperty("requiredLabel")
41- public String getRequiredLabel() { return requiredLabel; }
42- @JsonProperty("requiredLabel")
43- public void setRequiredLabel(String value) { this.requiredLabel = value; }
44-
4535 @JsonProperty("weight")
4636 public Double getWeight() { return weight; }
4737 @JsonProperty("weight")
4838 public void setWeight(Double value) { this.weight = value; }
39+
40+ @JsonProperty("label")
41+ public String getLabel() { return label; }
42+ @JsonProperty("label")
43+ public void setLabel(String value) { this.label = value; }
44+
45+ @JsonProperty("requiredLabel")
46+ public String getRequiredLabel() { return requiredLabel; }
47+ @JsonProperty("requiredLabel")
48+ public void setRequiredLabel(String value) { this.requiredLabel = value; }
4949 }
Mschema-java-datetime-legacy/test/inputs/schema/optional-date-time.schema/default/src/main/java/io/quicktype/TopLevel.java+15 −15
@@ -3,34 +3,34 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private Double optDouble;
6+ private long reqZeroMin;
77 private Long optInt;
8- private String optPattern;
8+ private Double optDouble;
99 private String optString;
10- private long reqZeroMin;
10+ private String optPattern;
1111
12- @JsonProperty("optDouble")
13- public Double getOptDouble() { return optDouble; }
14- @JsonProperty("optDouble")
15- public void setOptDouble(Double value) { this.optDouble = value; }
12+ @JsonProperty("reqZeroMin")
13+ public long getReqZeroMin() { return reqZeroMin; }
14+ @JsonProperty("reqZeroMin")
15+ public void setReqZeroMin(long value) { this.reqZeroMin = value; }
1616
1717 @JsonProperty("optInt")
1818 public Long getOptInt() { return optInt; }
1919 @JsonProperty("optInt")
2020 public void setOptInt(Long value) { this.optInt = value; }
2121
22- @JsonProperty("optPattern")
23- public String getOptPattern() { return optPattern; }
24- @JsonProperty("optPattern")
25- public void setOptPattern(String value) { this.optPattern = value; }
22+ @JsonProperty("optDouble")
23+ public Double getOptDouble() { return optDouble; }
24+ @JsonProperty("optDouble")
25+ public void setOptDouble(Double value) { this.optDouble = value; }
2626
2727 @JsonProperty("optString")
2828 public String getOptString() { return optString; }
2929 @JsonProperty("optString")
3030 public void setOptString(String value) { this.optString = value; }
3131
32- @JsonProperty("reqZeroMin")
33- public long getReqZeroMin() { return reqZeroMin; }
34- @JsonProperty("reqZeroMin")
35- public void setReqZeroMin(long value) { this.reqZeroMin = value; }
32+ @JsonProperty("optPattern")
33+ public String getOptPattern() { return optPattern; }
34+ @JsonProperty("optPattern")
35+ public void setOptPattern(String value) { this.optPattern = value; }
3636 }
Mschema-java-datetime-legacy/test/inputs/schema/prefix-items.schema/default/src/main/java/io/quicktype/TopLevel.java+23 −23
@@ -6,40 +6,40 @@ import java.time.OffsetDateTime;
66 import java.time.OffsetTime;
77
88 public class TopLevel {
9- private LocalDate optionalDate;
10- private OffsetDateTime optionalDateTime;
11- private OffsetTime optionalTime;
129 private LocalDate requiredDate;
13- private OffsetDateTime requiredDateTime;
1410 private OffsetTime requiredTime;
15-
16- @JsonProperty("optional-date")
17- public LocalDate getOptionalDate() { return optionalDate; }
18- @JsonProperty("optional-date")
19- public void setOptionalDate(LocalDate value) { this.optionalDate = value; }
20-
21- @JsonProperty("optional-date-time")
22- public OffsetDateTime getOptionalDateTime() { return optionalDateTime; }
23- @JsonProperty("optional-date-time")
24- public void setOptionalDateTime(OffsetDateTime value) { this.optionalDateTime = value; }
25-
26- @JsonProperty("optional-time")
27- public OffsetTime getOptionalTime() { return optionalTime; }
28- @JsonProperty("optional-time")
29- public void setOptionalTime(OffsetTime value) { this.optionalTime = value; }
11+ private OffsetDateTime requiredDateTime;
12+ private LocalDate optionalDate;
13+ private OffsetTime optionalTime;
14+ private OffsetDateTime optionalDateTime;
3015
3116 @JsonProperty("required-date")
3217 public LocalDate getRequiredDate() { return requiredDate; }
3318 @JsonProperty("required-date")
3419 public void setRequiredDate(LocalDate value) { this.requiredDate = value; }
3520
21+ @JsonProperty("required-time")
22+ public OffsetTime getRequiredTime() { return requiredTime; }
23+ @JsonProperty("required-time")
24+ public void setRequiredTime(OffsetTime value) { this.requiredTime = value; }
25+
3626 @JsonProperty("required-date-time")
3727 public OffsetDateTime getRequiredDateTime() { return requiredDateTime; }
3828 @JsonProperty("required-date-time")
3929 public void setRequiredDateTime(OffsetDateTime value) { this.requiredDateTime = value; }
4030
41- @JsonProperty("required-time")
42- public OffsetTime getRequiredTime() { return requiredTime; }
43- @JsonProperty("required-time")
44- public void setRequiredTime(OffsetTime value) { this.requiredTime = value; }
31+ @JsonProperty("optional-date")
32+ public LocalDate getOptionalDate() { return optionalDate; }
33+ @JsonProperty("optional-date")
34+ public void setOptionalDate(LocalDate value) { this.optionalDate = value; }
35+
36+ @JsonProperty("optional-time")
37+ public OffsetTime getOptionalTime() { return optionalTime; }
38+ @JsonProperty("optional-time")
39+ public void setOptionalTime(OffsetTime value) { this.optionalTime = value; }
40+
41+ @JsonProperty("optional-date-time")
42+ public OffsetDateTime getOptionalDateTime() { return optionalDateTime; }
43+ @JsonProperty("optional-date-time")
44+ public void setOptionalDateTime(OffsetDateTime value) { this.optionalDateTime = value; }
4545 }
Aschema-java-datetime-legacy/test/inputs/schema/property-order.schema/default/src/main/java/io/quicktype/Converter.java+6 −6
@@ -4,16 +4,16 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<Open> open;
87 private List<Open> tuple;
9-
10- @JsonProperty("open")
11- public List<Open> getOpen() { return open; }
12- @JsonProperty("open")
13- public void setOpen(List<Open> value) { this.open = value; }
8+ private List<Open> open;
149
1510 @JsonProperty("tuple")
1611 public List<Open> getTuple() { return tuple; }
1712 @JsonProperty("tuple")
1813 public void setTuple(List<Open> value) { this.tuple = value; }
14+
15+ @JsonProperty("open")
16+ public List<Open> getOpen() { return open; }
17+ @JsonProperty("open")
18+ public void setOpen(List<Open> value) { this.open = value; }
1919 }
Aschema-java-datetime-legacy/test/inputs/schema/property-order.schema/default/src/main/java/io/quicktype/Ordered.java+101 −0
@@ -0,0 +1,101 @@
1+// To use this code, add the following Maven dependency to your project:
2+//
3+//
4+// com.fasterxml.jackson.core : jackson-databind : 2.9.0
5+// com.fasterxml.jackson.datatype : jackson-datatype-jsr310 : 2.9.0
6+//
7+// Import this package:
8+//
9+// import io.quicktype.Converter;
10+//
11+// Then you can deserialize a JSON string with
12+//
13+// TopLevel data = Converter.fromJsonString(jsonString);
14+
15+package io.quicktype;
16+
17+import java.io.IOException;
18+import com.fasterxml.jackson.databind.*;
19+import com.fasterxml.jackson.databind.module.SimpleModule;
20+import com.fasterxml.jackson.core.JsonParser;
21+import com.fasterxml.jackson.core.JsonProcessingException;
22+import java.util.*;
23+import java.time.LocalDate;
24+import java.time.OffsetDateTime;
25+import java.time.OffsetTime;
26+import java.time.ZoneOffset;
27+import java.time.ZonedDateTime;
28+import java.time.format.DateTimeFormatter;
29+import java.time.format.DateTimeFormatterBuilder;
30+import java.time.temporal.ChronoField;
31+
32+public class Converter {
33+ // Date-time helpers
34+
35+ private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
36+ .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
37+ .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
38+ .appendOptional(DateTimeFormatter.ISO_INSTANT)
39+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
40+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
41+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
42+ .toFormatter()
43+ .withZone(ZoneOffset.UTC);
44+
45+ public static OffsetDateTime parseDateTimeString(String str) {
46+ return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
47+ }
48+
49+ private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
50+ .appendOptional(DateTimeFormatter.ISO_TIME)
51+ .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
52+ .parseDefaulting(ChronoField.YEAR, 2020)
53+ .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
54+ .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
55+ .toFormatter()
56+ .withZone(ZoneOffset.UTC);
57+
58+ public static OffsetTime parseTimeString(String str) {
59+ return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
60+ }
61+ // Serialize/deserialize helpers
62+
63+ public static TopLevel fromJsonString(String json) throws IOException {
64+ return getObjectReader().readValue(json);
65+ }
66+
67+ public static String toJsonString(TopLevel obj) throws JsonProcessingException {
68+ return getObjectWriter().writeValueAsString(obj);
69+ }
70+
71+ private static ObjectReader reader;
72+ private static ObjectWriter writer;
73+
74+ private static void instantiateMapper() {
75+ ObjectMapper mapper = new ObjectMapper();
76+ mapper.findAndRegisterModules();
77+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
78+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
79+ SimpleModule module = new SimpleModule();
80+ module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
81+ @Override
82+ public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
83+ String value = jsonParser.getText();
84+ return Converter.parseDateTimeString(value);
85+ }
86+ });
87+ mapper.registerModule(module);
88+ reader = mapper.readerFor(TopLevel.class);
89+ writer = mapper.writerFor(TopLevel.class);
90+ }
91+
92+ private static ObjectReader getObjectReader() {
93+ if (reader == null) instantiateMapper();
94+ return reader;
95+ }
96+
97+ private static ObjectWriter getObjectWriter() {
98+ if (writer == null) instantiateMapper();
99+ return writer;
100+ }
101+}
Aschema-java-datetime-legacy/test/inputs/schema/property-order.schema/default/src/main/java/io/quicktype/TopLevel.java+24 −0
@@ -0,0 +1,24 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Ordered {
6+ private double mango;
7+ private String zebra;
8+ private boolean apple;
9+
10+ @JsonProperty("mango")
11+ public double getMango() { return mango; }
12+ @JsonProperty("mango")
13+ public void setMango(double value) { this.mango = value; }
14+
15+ @JsonProperty("zebra")
16+ public String getZebra() { return zebra; }
17+ @JsonProperty("zebra")
18+ public void setZebra(String value) { this.zebra = value; }
19+
20+ @JsonProperty("apple")
21+ public boolean getApple() { return apple; }
22+ @JsonProperty("apple")
23+ public void setApple(boolean value) { this.apple = value; }
24+}
Mschema-java-datetime-legacy/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Berry.java+42 −0
@@ -0,0 +1,42 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class TopLevel {
6+ private String zebra;
7+ private double mango;
8+ private boolean apple;
9+ private String delta;
10+ private long banana;
11+ private Ordered ordered;
12+
13+ @JsonProperty("zebra")
14+ public String getZebra() { return zebra; }
15+ @JsonProperty("zebra")
16+ public void setZebra(String value) { this.zebra = value; }
17+
18+ @JsonProperty("mango")
19+ public double getMango() { return mango; }
20+ @JsonProperty("mango")
21+ public void setMango(double value) { this.mango = value; }
22+
23+ @JsonProperty("apple")
24+ public boolean getApple() { return apple; }
25+ @JsonProperty("apple")
26+ public void setApple(boolean value) { this.apple = value; }
27+
28+ @JsonProperty("delta")
29+ public String getDelta() { return delta; }
30+ @JsonProperty("delta")
31+ public void setDelta(String value) { this.delta = value; }
32+
33+ @JsonProperty("banana")
34+ public long getBanana() { return banana; }
35+ @JsonProperty("banana")
36+ public void setBanana(long value) { this.banana = value; }
37+
38+ @JsonProperty("ordered")
39+ public Ordered getOrdered() { return ordered; }
40+ @JsonProperty("ordered")
41+ public void setOrdered(Ordered value) { this.ordered = value; }
42+}
Mschema-java-datetime-legacy/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Fruit.java+6 −6
@@ -4,20 +4,20 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class Berry {
7- private Color color;
87 private String name;
8+ private Color color;
99 private List<Shape> shapes;
1010
11- @JsonProperty("color")
12- public Color getColor() { return color; }
13- @JsonProperty("color")
14- public void setColor(Color value) { this.color = value; }
15-
1611 @JsonProperty("name")
1712 public String getName() { return name; }
1813 @JsonProperty("name")
1914 public void setName(String value) { this.name = value; }
2015
16+ @JsonProperty("color")
17+ public Color getColor() { return color; }
18+ @JsonProperty("color")
19+ public void setColor(Color value) { this.color = value; }
20+
2121 @JsonProperty("shapes")
2222 public List<Shape> getShapes() { return shapes; }
2323 @JsonProperty("shapes")
Mschema-java-datetime-legacy/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Limit.java+6 −6
@@ -5,21 +5,21 @@ import java.util.List;
55
66 public class Fruit {
77 private Boolean apple;
8- private List<Berry> berries;
98 private Boolean orange;
9+ private List<Berry> berries;
1010
1111 @JsonProperty("apple")
1212 public Boolean getApple() { return apple; }
1313 @JsonProperty("apple")
1414 public void setApple(Boolean value) { this.apple = value; }
1515
16- @JsonProperty("berries")
17- public List<Berry> getBerries() { return berries; }
18- @JsonProperty("berries")
19- public void setBerries(List<Berry> value) { this.berries = value; }
20-
2116 @JsonProperty("orange")
2217 public Boolean getOrange() { return orange; }
2318 @JsonProperty("orange")
2419 public void setOrange(Boolean value) { this.orange = value; }
20+
21+ @JsonProperty("berries")
22+ public List<Berry> getBerries() { return berries; }
23+ @JsonProperty("berries")
24+ public void setBerries(List<Berry> value) { this.berries = value; }
2525 }
Mschema-java-datetime-legacy/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Part.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Limit {
6- private Double maximum;
76 private Double minimum;
8-
9- @JsonProperty("maximum")
10- public Double getMaximum() { return maximum; }
11- @JsonProperty("maximum")
12- public void setMaximum(Double value) { this.maximum = value; }
7+ private Double maximum;
138
149 @JsonProperty("minimum")
1510 public Double getMinimum() { return minimum; }
1611 @JsonProperty("minimum")
1712 public void setMinimum(Double value) { this.minimum = value; }
13+
14+ @JsonProperty("maximum")
15+ public Double getMaximum() { return maximum; }
16+ @JsonProperty("maximum")
17+ public void setMaximum(Double value) { this.maximum = value; }
1818 }
Mschema-java-datetime-legacy/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Shape.java+6 −6
@@ -3,14 +3,9 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Part {
6- private String depth;
76 private String length;
87 private String width;
9-
10- @JsonProperty("depth")
11- public String getDepth() { return depth; }
12- @JsonProperty("depth")
13- public void setDepth(String value) { this.depth = value; }
8+ private String depth;
149
1510 @JsonProperty("length")
1611 public String getLength() { return length; }
@@ -21,4 +16,9 @@ public class Part {
2116 public String getWidth() { return width; }
2217 @JsonProperty("width")
2318 public void setWidth(String value) { this.width = value; }
19+
20+ @JsonProperty("depth")
21+ public String getDepth() { return depth; }
22+ @JsonProperty("depth")
23+ public void setDepth(String value) { this.depth = value; }
2424 }
Mschema-java-datetime-legacy/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Vehicle.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Shape {
6- private Geometry geometry;
76 private History history;
8-
9- @JsonProperty("geometry")
10- public Geometry getGeometry() { return geometry; }
11- @JsonProperty("geometry")
12- public void setGeometry(Geometry value) { this.geometry = value; }
7+ private Geometry geometry;
138
149 @JsonProperty("history")
1510 public History getHistory() { return history; }
1611 @JsonProperty("history")
1712 public void setHistory(History value) { this.history = value; }
13+
14+ @JsonProperty("geometry")
15+ public Geometry getGeometry() { return geometry; }
16+ @JsonProperty("geometry")
17+ public void setGeometry(Geometry value) { this.geometry = value; }
1818 }
Mschema-java-datetime-legacy/test/inputs/schema/rust-cycle-breaker-union.schema/default/src/main/java/io/quicktype/Node.java+18 −18
@@ -3,40 +3,40 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Vehicle {
6- private String brand;
76 private String id;
8- private Speed speed;
9- private Boolean subModule;
107 private VehicleType type;
8+ private Speed speed;
119 private String year;
12-
13- @JsonProperty("brand")
14- public String getBrand() { return brand; }
15- @JsonProperty("brand")
16- public void setBrand(String value) { this.brand = value; }
10+ private String brand;
11+ private Boolean subModule;
1712
1813 @JsonProperty("id")
1914 public String getID() { return id; }
2015 @JsonProperty("id")
2116 public void setID(String value) { this.id = value; }
2217
23- @JsonProperty("speed")
24- public Speed getSpeed() { return speed; }
25- @JsonProperty("speed")
26- public void setSpeed(Speed value) { this.speed = value; }
27-
28- @JsonProperty("subModule")
29- public Boolean getSubModule() { return subModule; }
30- @JsonProperty("subModule")
31- public void setSubModule(Boolean value) { this.subModule = value; }
32-
3318 @JsonProperty("type")
3419 public VehicleType getType() { return type; }
3520 @JsonProperty("type")
3621 public void setType(VehicleType value) { this.type = value; }
3722
23+ @JsonProperty("speed")
24+ public Speed getSpeed() { return speed; }
25+ @JsonProperty("speed")
26+ public void setSpeed(Speed value) { this.speed = value; }
27+
3828 @JsonProperty("year")
3929 public String getYear() { return year; }
4030 @JsonProperty("year")
4131 public void setYear(String value) { this.year = value; }
32+
33+ @JsonProperty("brand")
34+ public String getBrand() { return brand; }
35+ @JsonProperty("brand")
36+ public void setBrand(String value) { this.brand = value; }
37+
38+ @JsonProperty("subModule")
39+ public Boolean getSubModule() { return subModule; }
40+ @JsonProperty("subModule")
41+ public void setSubModule(Boolean value) { this.subModule = value; }
4242 }
Mschema-java-datetime-legacy/test/inputs/schema/rust-cycle-breaker-union.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Node {
6- private Next next;
76 private String value;
8-
9- @JsonProperty("next")
10- public Next getNext() { return next; }
11- @JsonProperty("next")
12- public void setNext(Next value) { this.next = value; }
7+ private Next next;
138
149 @JsonProperty("value")
1510 public String getValue() { return value; }
1611 @JsonProperty("value")
1712 public void setValue(String value) { this.value = value; }
13+
14+ @JsonProperty("next")
15+ public Next getNext() { return next; }
16+ @JsonProperty("next")
17+ public void setNext(Next value) { this.next = value; }
1818 }
Mschema-java-datetime-legacy/test/inputs/schema/uuid.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private Next next;
76 private String value;
8-
9- @JsonProperty("next")
10- public Next getNext() { return next; }
11- @JsonProperty("next")
12- public void setNext(Next value) { this.next = value; }
7+ private Next next;
138
149 @JsonProperty("value")
1510 public String getValue() { return value; }
1611 @JsonProperty("value")
1712 public void setValue(String value) { this.value = value; }
13+
14+ @JsonProperty("next")
15+ public Next getNext() { return next; }
16+ @JsonProperty("next")
17+ public void setNext(Next value) { this.next = value; }
1818 }
Mschema-java-datetime-legacy/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/Axis.java+18 −18
@@ -5,28 +5,13 @@ import java.util.List;
55 import java.util.UUID;
66
77 public class TopLevel {
8- private List<UUID> arrNullable;
9- private List<UUID> arrOne;
10- private UUID nullable;
118 private UUID one;
129 private UUID optional;
10+ private UUID nullable;
11+ private List<UUID> arrOne;
12+ private List<UUID> arrNullable;
1313 private UnionWithEnumUnion unionWithEnum;
1414
15- @JsonProperty("arrNullable")
16- public List<UUID> getArrNullable() { return arrNullable; }
17- @JsonProperty("arrNullable")
18- public void setArrNullable(List<UUID> value) { this.arrNullable = value; }
19-
20- @JsonProperty("arrOne")
21- public List<UUID> getArrOne() { return arrOne; }
22- @JsonProperty("arrOne")
23- public void setArrOne(List<UUID> value) { this.arrOne = value; }
24-
25- @JsonProperty("nullable")
26- public UUID getNullable() { return nullable; }
27- @JsonProperty("nullable")
28- public void setNullable(UUID value) { this.nullable = value; }
29-
3015 @JsonProperty("one")
3116 public UUID getOne() { return one; }
3217 @JsonProperty("one")
@@ -37,6 +22,21 @@ public class TopLevel {
3722 @JsonProperty("optional")
3823 public void setOptional(UUID value) { this.optional = value; }
3924
25+ @JsonProperty("nullable")
26+ public UUID getNullable() { return nullable; }
27+ @JsonProperty("nullable")
28+ public void setNullable(UUID value) { this.nullable = value; }
29+
30+ @JsonProperty("arrOne")
31+ public List<UUID> getArrOne() { return arrOne; }
32+ @JsonProperty("arrOne")
33+ public void setArrOne(List<UUID> value) { this.arrOne = value; }
34+
35+ @JsonProperty("arrNullable")
36+ public List<UUID> getArrNullable() { return arrNullable; }
37+ @JsonProperty("arrNullable")
38+ public void setArrNullable(List<UUID> value) { this.arrNullable = value; }
39+
4040 @JsonProperty("unionWithEnum")
4141 public UnionWithEnumUnion getUnionWithEnum() { return unionWithEnum; }
4242 @JsonProperty("unionWithEnum")
Mschema-java-datetime-legacy/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/AxisConfig.java+9 −9
@@ -19,8 +19,8 @@ public class Axis {
1919 private TitleOrient orient;
2020 private Double position;
2121 private Double tickCount;
22- private Boolean ticks;
2322 private Double tickSize;
23+ private Boolean ticks;
2424 private String title;
2525 private Double titleMaxLength;
2626 private Double titlePadding;
@@ -206,14 +206,6 @@ public class Axis {
206206 @JsonProperty("tickCount")
207207 public void setTickCount(Double value) { this.tickCount = value; }
208208
209- /**
210- * Boolean value that determines whether the axis should include ticks.
211- */
212- @JsonProperty("ticks")
213- public Boolean getTicks() { return ticks; }
214- @JsonProperty("ticks")
215- public void setTicks(Boolean value) { this.ticks = value; }
216-
217209 /**
218210 * The size in pixels of axis ticks.
219211 */
@@ -222,6 +214,14 @@ public class Axis {
222214 @JsonProperty("tickSize")
223215 public void setTickSize(Double value) { this.tickSize = value; }
224216
217+ /**
218+ * Boolean value that determines whether the axis should include ticks.
219+ */
220+ @JsonProperty("ticks")
221+ public Boolean getTicks() { return ticks; }
222+ @JsonProperty("ticks")
223+ public void setTicks(Boolean value) { this.ticks = value; }
224+
225225 /**
226226 * A title for the field. If `null`, the title will be removed.
227227 *
Mschema-java-datetime-legacy/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/BarConfig.java+9 −9
@@ -33,9 +33,9 @@ public class AxisConfig {
3333 private Boolean shortTimeLabels;
3434 private String tickColor;
3535 private Boolean tickRound;
36- private Boolean ticks;
3736 private Double tickSize;
3837 private Double tickWidth;
38+ private Boolean ticks;
3939 private String titleAlign;
4040 private Double titleAngle;
4141 private String titleBaseline;
@@ -288,14 +288,6 @@ public class AxisConfig {
288288 @JsonProperty("tickRound")
289289 public void setTickRound(Boolean value) { this.tickRound = value; }
290290
291- /**
292- * Boolean value that determines whether the axis should include ticks.
293- */
294- @JsonProperty("ticks")
295- public Boolean getTicks() { return ticks; }
296- @JsonProperty("ticks")
297- public void setTicks(Boolean value) { this.ticks = value; }
298-
299291 /**
300292 * The size in pixels of axis ticks.
301293 */
@@ -312,6 +304,14 @@ public class AxisConfig {
312304 @JsonProperty("tickWidth")
313305 public void setTickWidth(Double value) { this.tickWidth = value; }
314306
307+ /**
308+ * Boolean value that determines whether the axis should include ticks.
309+ */
310+ @JsonProperty("ticks")
311+ public Boolean getTicks() { return ticks; }
312+ @JsonProperty("ticks")
313+ public void setTicks(Boolean value) { this.ticks = value; }
314+
315315 /**
316316 * Horizontal text alignment of axis titles.
317317 */
Mschema-java-datetime-legacy/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/MarkConfig.java+11 −11
@@ -18,8 +18,8 @@ public class BarConfig {
1818 private Double dx;
1919 private Double dy;
2020 private String fill;
21- private Boolean filled;
2221 private Double fillOpacity;
22+ private Boolean filled;
2323 private String font;
2424 private Double fontSize;
2525 private FontStyle fontStyle;
@@ -147,6 +147,16 @@ public class BarConfig {
147147 @JsonProperty("fill")
148148 public void setFill(String value) { this.fill = value; }
149149
150+ /**
151+ * The fill opacity (value between [0,1]).
152+ *
153+ * __Default value:__ `1`
154+ */
155+ @JsonProperty("fillOpacity")
156+ public Double getFillOpacity() { return fillOpacity; }
157+ @JsonProperty("fillOpacity")
158+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
159+
150160 /**
151161 * Whether the mark's color should be used as fill color instead of stroke color.
152162 *
@@ -161,16 +171,6 @@ public class BarConfig {
161171 @JsonProperty("filled")
162172 public void setFilled(Boolean value) { this.filled = value; }
163173
164- /**
165- * The fill opacity (value between [0,1]).
166- *
167- * __Default value:__ `1`
168- */
169- @JsonProperty("fillOpacity")
170- public Double getFillOpacity() { return fillOpacity; }
171- @JsonProperty("fillOpacity")
172- public void setFillOpacity(Double value) { this.fillOpacity = value; }
173-
174174 /**
175175 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
176176 */
Mschema-java-datetime-legacy/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/MarkDef.java+11 −11
@@ -31,8 +31,8 @@ public class MarkConfig {
3131 private Double dx;
3232 private Double dy;
3333 private String fill;
34- private Boolean filled;
3534 private Double fillOpacity;
35+ private Boolean filled;
3636 private String font;
3737 private Double fontSize;
3838 private FontStyle fontStyle;
@@ -130,6 +130,16 @@ public class MarkConfig {
130130 @JsonProperty("fill")
131131 public void setFill(String value) { this.fill = value; }
132132
133+ /**
134+ * The fill opacity (value between [0,1]).
135+ *
136+ * __Default value:__ `1`
137+ */
138+ @JsonProperty("fillOpacity")
139+ public Double getFillOpacity() { return fillOpacity; }
140+ @JsonProperty("fillOpacity")
141+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
142+
133143 /**
134144 * Whether the mark's color should be used as fill color instead of stroke color.
135145 *
@@ -144,16 +154,6 @@ public class MarkConfig {
144154 @JsonProperty("filled")
145155 public void setFilled(Boolean value) { this.filled = value; }
146156
147- /**
148- * The fill opacity (value between [0,1]).
149- *
150- * __Default value:__ `1`
151- */
152- @JsonProperty("fillOpacity")
153- public Double getFillOpacity() { return fillOpacity; }
154- @JsonProperty("fillOpacity")
155- public void setFillOpacity(Double value) { this.fillOpacity = value; }
156-
157157 /**
158158 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
159159 */
Mschema-java-datetime-legacy/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/TextConfig.java+11 −11
@@ -13,8 +13,8 @@ public class MarkDef {
1313 private Double dx;
1414 private Double dy;
1515 private String fill;
16- private Boolean filled;
1716 private Double fillOpacity;
17+ private Boolean filled;
1818 private String font;
1919 private Double fontSize;
2020 private FontStyle fontStyle;
@@ -122,6 +122,16 @@ public class MarkDef {
122122 @JsonProperty("fill")
123123 public void setFill(String value) { this.fill = value; }
124124
125+ /**
126+ * The fill opacity (value between [0,1]).
127+ *
128+ * __Default value:__ `1`
129+ */
130+ @JsonProperty("fillOpacity")
131+ public Double getFillOpacity() { return fillOpacity; }
132+ @JsonProperty("fillOpacity")
133+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
134+
125135 /**
126136 * Whether the mark's color should be used as fill color instead of stroke color.
127137 *
@@ -136,16 +146,6 @@ public class MarkDef {
136146 @JsonProperty("filled")
137147 public void setFilled(Boolean value) { this.filled = value; }
138148
139- /**
140- * The fill opacity (value between [0,1]).
141- *
142- * __Default value:__ `1`
143- */
144- @JsonProperty("fillOpacity")
145- public Double getFillOpacity() { return fillOpacity; }
146- @JsonProperty("fillOpacity")
147- public void setFillOpacity(Double value) { this.fillOpacity = value; }
148-
149149 /**
150150 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
151151 */
Mschema-java-datetime-legacy/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/TickConfig.java+11 −11
@@ -15,8 +15,8 @@ public class TextConfig {
1515 private Double dx;
1616 private Double dy;
1717 private String fill;
18- private Boolean filled;
1918 private Double fillOpacity;
19+ private Boolean filled;
2020 private String font;
2121 private Double fontSize;
2222 private FontStyle fontStyle;
@@ -115,6 +115,16 @@ public class TextConfig {
115115 @JsonProperty("fill")
116116 public void setFill(String value) { this.fill = value; }
117117
118+ /**
119+ * The fill opacity (value between [0,1]).
120+ *
121+ * __Default value:__ `1`
122+ */
123+ @JsonProperty("fillOpacity")
124+ public Double getFillOpacity() { return fillOpacity; }
125+ @JsonProperty("fillOpacity")
126+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
127+
118128 /**
119129 * Whether the mark's color should be used as fill color instead of stroke color.
120130 *
@@ -129,16 +139,6 @@ public class TextConfig {
129139 @JsonProperty("filled")
130140 public void setFilled(Boolean value) { this.filled = value; }
131141
132- /**
133- * The fill opacity (value between [0,1]).
134- *
135- * __Default value:__ `1`
136- */
137- @JsonProperty("fillOpacity")
138- public Double getFillOpacity() { return fillOpacity; }
139- @JsonProperty("fillOpacity")
140- public void setFillOpacity(Double value) { this.fillOpacity = value; }
141-
142142 /**
143143 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
144144 */
Mschema-java-datetime-legacy/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/VGAxisConfig.java+11 −11
@@ -16,8 +16,8 @@ public class TickConfig {
1616 private Double dx;
1717 private Double dy;
1818 private String fill;
19- private Boolean filled;
2019 private Double fillOpacity;
20+ private Boolean filled;
2121 private String font;
2222 private Double fontSize;
2323 private FontStyle fontStyle;
@@ -126,6 +126,16 @@ public class TickConfig {
126126 @JsonProperty("fill")
127127 public void setFill(String value) { this.fill = value; }
128128
129+ /**
130+ * The fill opacity (value between [0,1]).
131+ *
132+ * __Default value:__ `1`
133+ */
134+ @JsonProperty("fillOpacity")
135+ public Double getFillOpacity() { return fillOpacity; }
136+ @JsonProperty("fillOpacity")
137+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
138+
129139 /**
130140 * Whether the mark's color should be used as fill color instead of stroke color.
131141 *
@@ -140,16 +150,6 @@ public class TickConfig {
140150 @JsonProperty("filled")
141151 public void setFilled(Boolean value) { this.filled = value; }
142152
143- /**
144- * The fill opacity (value between [0,1]).
145- *
146- * __Default value:__ `1`
147- */
148- @JsonProperty("fillOpacity")
149- public Double getFillOpacity() { return fillOpacity; }
150- @JsonProperty("fillOpacity")
151- public void setFillOpacity(Double value) { this.fillOpacity = value; }
152-
153153 /**
154154 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
155155 */
Mschema-java-lombok/test/inputs/schema/accessors.schema/default/src/main/java/io/quicktype/TopLevel.java+9 −9
@@ -42,9 +42,9 @@ public class VGAxisConfig {
4242 private Double minExtent;
4343 private String tickColor;
4444 private Boolean tickRound;
45- private Boolean ticks;
4645 private Double tickSize;
4746 private Double tickWidth;
47+ private Boolean ticks;
4848 private String titleAlign;
4949 private Double titleAngle;
5050 private String titleBaseline;
@@ -287,14 +287,6 @@ public class VGAxisConfig {
287287 @JsonProperty("tickRound")
288288 public void setTickRound(Boolean value) { this.tickRound = value; }
289289
290- /**
291- * Boolean value that determines whether the axis should include ticks.
292- */
293- @JsonProperty("ticks")
294- public Boolean getTicks() { return ticks; }
295- @JsonProperty("ticks")
296- public void setTicks(Boolean value) { this.ticks = value; }
297-
298290 /**
299291 * The size in pixels of axis ticks.
300292 */
@@ -311,6 +303,14 @@ public class VGAxisConfig {
311303 @JsonProperty("tickWidth")
312304 public void setTickWidth(Double value) { this.tickWidth = value; }
313305
306+ /**
307+ * Boolean value that determines whether the axis should include ticks.
308+ */
309+ @JsonProperty("ticks")
310+ public Boolean getTicks() { return ticks; }
311+ @JsonProperty("ticks")
312+ public void setTicks(Boolean value) { this.ticks = value; }
313+
314314 /**
315315 * Horizontal text alignment of axis titles.
316316 */
Mschema-java-lombok/test/inputs/schema/all-of-additional-properties-false.schema/default/src/main/java/io/quicktype/TopLevel.java+10 −10
@@ -3,15 +3,15 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private String barre;
6+ private Union unionization;
77 private Enum enumerification;
88 private String Goo;
9- private Union unionization;
9+ private String barre;
1010
11- @JsonProperty("bar")
12- public String getBarre() { return barre; }
13- @JsonProperty("bar")
14- public void setBarre(String value) { this.barre = value; }
11+ @JsonProperty("union")
12+ public Union getUnionization() { return unionization; }
13+ @JsonProperty("union")
14+ public void setUnionization(Union value) { this.unionization = value; }
1515
1616 @JsonProperty("enum")
1717 public Enum getEnumerification() { return enumerification; }
@@ -23,8 +23,8 @@ public class TopLevel {
2323 @JsonProperty("foo")
2424 public void setGoo(String value) { this.Goo = value; }
2525
26- @JsonProperty("union")
27- public Union getUnionization() { return unionization; }
28- @JsonProperty("union")
29- public void setUnionization(Union value) { this.unionization = value; }
26+ @JsonProperty("bar")
27+ public String getBarre() { return barre; }
28+ @JsonProperty("bar")
29+ public void setBarre(String value) { this.barre = value; }
3030 }
Mschema-java-lombok/test/inputs/schema/bool-string.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -5,8 +5,8 @@ import com.fasterxml.jackson.annotation.*;
55 public class TopLevel {
66 private double amount;
77 private Frequency frequency;
8- private String description;
98 private Type type;
9+ private String description;
1010
1111 @JsonProperty("amount")
1212 public double getAmount() { return amount; }
@@ -18,13 +18,13 @@ public class TopLevel {
1818 @JsonProperty("frequency")
1919 public void setFrequency(Frequency value) { this.frequency = value; }
2020
21- @JsonProperty("description")
22- public String getDescription() { return description; }
23- @JsonProperty("description")
24- public void setDescription(String value) { this.description = value; }
25-
2621 @JsonProperty("type")
2722 public Type getType() { return type; }
2823 @JsonProperty("type")
2924 public void setType(Type value) { this.type = value; }
25+
26+ @JsonProperty("description")
27+ public String getDescription() { return description; }
28+ @JsonProperty("description")
29+ public void setDescription(String value) { this.description = value; }
3030 }
Mschema-java-lombok/test/inputs/schema/boolean-subschema.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -4,29 +4,14 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<String> arrNullable;
8- private List<String> arrOne;
9- private String nullable;
107 private String one;
118 private String optional;
9+ private String nullable;
10+ private List<String> arrOne;
11+ private List<String> arrNullable;
1212 private UnionWithBool unionWithBool;
1313 private UnionWithBool unionWithBoolAndEnum;
1414
15- @JsonProperty("arrNullable")
16- public List<String> getArrNullable() { return arrNullable; }
17- @JsonProperty("arrNullable")
18- public void setArrNullable(List<String> value) { this.arrNullable = value; }
19-
20- @JsonProperty("arrOne")
21- public List<String> getArrOne() { return arrOne; }
22- @JsonProperty("arrOne")
23- public void setArrOne(List<String> value) { this.arrOne = value; }
24-
25- @JsonProperty("nullable")
26- public String getNullable() { return nullable; }
27- @JsonProperty("nullable")
28- public void setNullable(String value) { this.nullable = value; }
29-
3015 @JsonProperty("one")
3116 public String getOne() { return one; }
3217 @JsonProperty("one")
@@ -37,6 +22,21 @@ public class TopLevel {
3722 @JsonProperty("optional")
3823 public void setOptional(String value) { this.optional = value; }
3924
25+ @JsonProperty("nullable")
26+ public String getNullable() { return nullable; }
27+ @JsonProperty("nullable")
28+ public void setNullable(String value) { this.nullable = value; }
29+
30+ @JsonProperty("arrOne")
31+ public List<String> getArrOne() { return arrOne; }
32+ @JsonProperty("arrOne")
33+ public void setArrOne(List<String> value) { this.arrOne = value; }
34+
35+ @JsonProperty("arrNullable")
36+ public List<String> getArrNullable() { return arrNullable; }
37+ @JsonProperty("arrNullable")
38+ public void setArrNullable(List<String> value) { this.arrNullable = value; }
39+
4040 @JsonProperty("unionWithBool")
4141 public UnionWithBool getUnionWithBool() { return unionWithBool; }
4242 @JsonProperty("unionWithBool")
Mschema-java-lombok/test/inputs/schema/comment-injection.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,11 +4,16 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7+ private String foo;
78 private Object disallowed;
89 private List<Object> empty;
9- private String foo;
1010 private Object impossible;
1111
12+ @JsonProperty("foo")
13+ public String getFoo() { return foo; }
14+ @JsonProperty("foo")
15+ public void setFoo(String value) { this.foo = value; }
16+
1217 @JsonProperty("disallowed")
1318 public Object getDisallowed() { return disallowed; }
1419 @JsonProperty("disallowed")
@@ -19,11 +24,6 @@ public class TopLevel {
1924 @JsonProperty("empty")
2025 public void setEmpty(List<Object> value) { this.empty = value; }
2126
22- @JsonProperty("foo")
23- public String getFoo() { return foo; }
24- @JsonProperty("foo")
25- public void setFoo(String value) { this.foo = value; }
26-
2727 @JsonProperty("impossible")
2828 public Object getImpossible() { return impossible; }
2929 @JsonProperty("impossible")
Mschema-java-lombok/test/inputs/schema/const-non-string.schema/default/src/main/java/io/quicktype/TopLevel.java+20 −20
@@ -17,10 +17,29 @@ import com.fasterxml.jackson.annotation.*;
1717 * }
1818 */
1919 public class TopLevel {
20+ private String value;
2021 private String trailingBackslash;
2122 private String trailingQuote;
2223 private String trailingTripleQuote;
23- private String value;
24+
25+ /**
26+ * Property delimiters:
27+ * * /
28+ * / *
29+ * {-
30+ * -}
31+ * """
32+ * </summary> & <br>
33+ * }
34+ * }
35+ * }
36+ * }
37+ * }
38+ */
39+ @JsonProperty("value")
40+ public String getValue() { return value; }
41+ @JsonProperty("value")
42+ public void setValue(String value) { this.value = value; }
2443
2544 /**
2645 * Ends with a backslash \
@@ -45,23 +64,4 @@ public class TopLevel {
4564 public String getTrailingTripleQuote() { return trailingTripleQuote; }
4665 @JsonProperty("trailingTripleQuote")
4766 public void setTrailingTripleQuote(String value) { this.trailingTripleQuote = value; }
48-
49- /**
50- * Property delimiters:
51- * * /
52- * / *
53- * {-
54- * -}
55- * """
56- * </summary> & <br>
57- * }
58- * }
59- * }
60- * }
61- * }
62- */
63- @JsonProperty("value")
64- public String getValue() { return value; }
65- @JsonProperty("value")
66- public void setValue(String value) { this.value = value; }
6767 }
Mschema-java-lombok/test/inputs/schema/date-time-or-string.schema/default/src/main/java/io/quicktype/TopLevel.java+12 −12
@@ -3,17 +3,27 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6+ private double version;
67 private long amount;
8+ private double ratio;
79 private boolean enabled;
810 private Kind kind;
9- private double ratio;
10- private double version;
11+
12+ @JsonProperty("version")
13+ public double getVersion() { return version; }
14+ @JsonProperty("version")
15+ public void setVersion(double value) { this.version = value; }
1116
1217 @JsonProperty("amount")
1318 public long getAmount() { return amount; }
1419 @JsonProperty("amount")
1520 public void setAmount(long value) { this.amount = value; }
1621
22+ @JsonProperty("ratio")
23+ public double getRatio() { return ratio; }
24+ @JsonProperty("ratio")
25+ public void setRatio(double value) { this.ratio = value; }
26+
1727 @JsonProperty("enabled")
1828 public boolean getEnabled() { return enabled; }
1929 @JsonProperty("enabled")
@@ -23,14 +33,4 @@ public class TopLevel {
2333 public Kind getKind() { return kind; }
2434 @JsonProperty("kind")
2535 public void setKind(Kind value) { this.kind = value; }
26-
27- @JsonProperty("ratio")
28- public double getRatio() { return ratio; }
29- @JsonProperty("ratio")
30- public void setRatio(double value) { this.ratio = value; }
31-
32- @JsonProperty("version")
33- public double getVersion() { return version; }
34- @JsonProperty("version")
35- public void setVersion(double value) { this.version = value; }
3636 }
Mschema-java-lombok/test/inputs/schema/date-time.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,16 +4,16 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.Date;
55
66 public class TopLevel {
7- private BarUnion bar;
87 private String foo;
9-
10- @JsonProperty("bar")
11- public BarUnion getBar() { return bar; }
12- @JsonProperty("bar")
13- public void setBar(BarUnion value) { this.bar = value; }
8+ private BarUnion bar;
149
1510 @JsonProperty("foo")
1611 public String getFoo() { return foo; }
1712 @JsonProperty("foo")
1813 public void setFoo(String value) { this.foo = value; }
14+
15+ @JsonProperty("bar")
16+ public BarUnion getBar() { return bar; }
17+ @JsonProperty("bar")
18+ public void setBar(BarUnion value) { this.bar = value; }
1919 }
Mschema-java-lombok/test/inputs/schema/description.schema/default/src/main/java/io/quicktype/TopLevel.java+15 −15
@@ -7,19 +7,19 @@ import com.fasterxml.jackson.annotation.*;
77 * Its description has two lines.
88 */
99 public class TopLevel {
10- private Boolean bar;
10+ private Union union;
1111 private Enum topLevelEnum;
1212 private Double foo;
13+ private Boolean bar;
1314 private ObjectOrStringUnion objectOrString;
14- private Union union;
1515
1616 /**
17- * A pretty boolean
17+ * Either a number or a string
1818 */
19- @JsonProperty("bar")
20- public Boolean getBar() { return bar; }
21- @JsonProperty("bar")
22- public void setBar(Boolean value) { this.bar = value; }
19+ @JsonProperty("union")
20+ public Union getUnion() { return union; }
21+ @JsonProperty("union")
22+ public void setUnion(Union value) { this.union = value; }
2323
2424 /**
2525 * An enumeration
@@ -34,16 +34,16 @@ public class TopLevel {
3434 @JsonProperty("foo")
3535 public void setFoo(Double value) { this.foo = value; }
3636
37+ /**
38+ * A pretty boolean
39+ */
40+ @JsonProperty("bar")
41+ public Boolean getBar() { return bar; }
42+ @JsonProperty("bar")
43+ public void setBar(Boolean value) { this.bar = value; }
44+
3745 @JsonProperty("object-or-string")
3846 public ObjectOrStringUnion getObjectOrString() { return objectOrString; }
3947 @JsonProperty("object-or-string")
4048 public void setObjectOrString(ObjectOrStringUnion value) { this.objectOrString = value; }
41-
42- /**
43- * Either a number or a string
44- */
45- @JsonProperty("union")
46- public Union getUnion() { return union; }
47- @JsonProperty("union")
48- public void setUnion(Union value) { this.union = value; }
4949 }
Mschema-java-lombok/test/inputs/schema/direct-union.schema/default/src/main/java/io/quicktype/Thing.java+6 −6
@@ -5,16 +5,16 @@ import java.util.List;
55 import java.util.Map;
66
77 public class Thing {
8- private Anything optional;
98 private Anything required;
10-
11- @JsonProperty("optional")
12- public Anything getOptional() { return optional; }
13- @JsonProperty("optional")
14- public void setOptional(Anything value) { this.optional = value; }
9+ private Anything optional;
1510
1611 @JsonProperty("required")
1712 public Anything getRequired() { return required; }
1813 @JsonProperty("required")
1914 public void setRequired(Anything value) { this.required = value; }
15+
16+ @JsonProperty("optional")
17+ public Anything getOptional() { return optional; }
18+ @JsonProperty("optional")
19+ public void setOptional(Anything value) { this.optional = value; }
2020 }
Mschema-java-lombok/test/inputs/schema/enum.schema/default/src/main/java/io/quicktype/TopLevel.java+16 −16
@@ -4,34 +4,34 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<Arr> arr;
8- private String topLevelFor;
9- private Gve gve;
107 private Lvc lvc;
8+ private Gve gve;
9+ private List<Arr> arr;
1110 private List<OtherArr> otherArr;
11+ private String topLevelFor;
1212
13- @JsonProperty("arr")
14- public List<Arr> getArr() { return arr; }
15- @JsonProperty("arr")
16- public void setArr(List<Arr> value) { this.arr = value; }
17-
18- @JsonProperty("for")
19- public String getTopLevelFor() { return topLevelFor; }
20- @JsonProperty("for")
21- public void setTopLevelFor(String value) { this.topLevelFor = value; }
13+ @JsonProperty("lvc")
14+ public Lvc getLvc() { return lvc; }
15+ @JsonProperty("lvc")
16+ public void setLvc(Lvc value) { this.lvc = value; }
2217
2318 @JsonProperty("gve")
2419 public Gve getGve() { return gve; }
2520 @JsonProperty("gve")
2621 public void setGve(Gve value) { this.gve = value; }
2722
28- @JsonProperty("lvc")
29- public Lvc getLvc() { return lvc; }
30- @JsonProperty("lvc")
31- public void setLvc(Lvc value) { this.lvc = value; }
23+ @JsonProperty("arr")
24+ public List<Arr> getArr() { return arr; }
25+ @JsonProperty("arr")
26+ public void setArr(List<Arr> value) { this.arr = value; }
3227
3328 @JsonProperty("otherArr")
3429 public List<OtherArr> getOtherArr() { return otherArr; }
3530 @JsonProperty("otherArr")
3631 public void setOtherArr(List<OtherArr> value) { this.otherArr = value; }
32+
33+ @JsonProperty("for")
34+ public String getTopLevelFor() { return topLevelFor; }
35+ @JsonProperty("for")
36+ public void setTopLevelFor(String value) { this.topLevelFor = value; }
3737 }
Mschema-java-lombok/test/inputs/schema/integer-string.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -4,29 +4,14 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<String> arrNullable;
8- private List<String> arrOne;
9- private String nullable;
107 private String one;
118 private String optional;
9+ private String nullable;
10+ private List<String> arrOne;
11+ private List<String> arrNullable;
1212 private UnionWithInt unionWithInt;
1313 private UnionWithInt unionWithIntAndEnum;
1414
15- @JsonProperty("arrNullable")
16- public List<String> getArrNullable() { return arrNullable; }
17- @JsonProperty("arrNullable")
18- public void setArrNullable(List<String> value) { this.arrNullable = value; }
19-
20- @JsonProperty("arrOne")
21- public List<String> getArrOne() { return arrOne; }
22- @JsonProperty("arrOne")
23- public void setArrOne(List<String> value) { this.arrOne = value; }
24-
25- @JsonProperty("nullable")
26- public String getNullable() { return nullable; }
27- @JsonProperty("nullable")
28- public void setNullable(String value) { this.nullable = value; }
29-
3015 @JsonProperty("one")
3116 public String getOne() { return one; }
3217 @JsonProperty("one")
@@ -37,6 +22,21 @@ public class TopLevel {
3722 @JsonProperty("optional")
3823 public void setOptional(String value) { this.optional = value; }
3924
25+ @JsonProperty("nullable")
26+ public String getNullable() { return nullable; }
27+ @JsonProperty("nullable")
28+ public void setNullable(String value) { this.nullable = value; }
29+
30+ @JsonProperty("arrOne")
31+ public List<String> getArrOne() { return arrOne; }
32+ @JsonProperty("arrOne")
33+ public void setArrOne(List<String> value) { this.arrOne = value; }
34+
35+ @JsonProperty("arrNullable")
36+ public List<String> getArrNullable() { return arrNullable; }
37+ @JsonProperty("arrNullable")
38+ public void setArrNullable(List<String> value) { this.arrNullable = value; }
39+
4040 @JsonProperty("unionWithInt")
4141 public UnionWithInt getUnionWithInt() { return unionWithInt; }
4242 @JsonProperty("unionWithInt")
Mschema-java-lombok/test/inputs/schema/integer-type.schema/default/src/main/java/io/quicktype/TopLevel.java+29 −29
@@ -3,15 +3,30 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6+ private long smallPositive;
7+ private long smallNegative;
8+ private long i32Range;
69 private long aboveI32Max;
710 private long belowI32Min;
8- private long i32Range;
9- private long largeBounds;
10- private long onlyMaximum;
1111 private long onlyMinimum;
12- private long smallNegative;
13- private long smallPositive;
12+ private long onlyMaximum;
1413 private long unbounded;
14+ private long largeBounds;
15+
16+ @JsonProperty("small_positive")
17+ public long getSmallPositive() { return smallPositive; }
18+ @JsonProperty("small_positive")
19+ public void setSmallPositive(long value) { this.smallPositive = value; }
20+
21+ @JsonProperty("small_negative")
22+ public long getSmallNegative() { return smallNegative; }
23+ @JsonProperty("small_negative")
24+ public void setSmallNegative(long value) { this.smallNegative = value; }
25+
26+ @JsonProperty("i32_range")
27+ public long getI32Range() { return i32Range; }
28+ @JsonProperty("i32_range")
29+ public void setI32Range(long value) { this.i32Range = value; }
1530
1631 @JsonProperty("above_i32_max")
1732 public long getAboveI32Max() { return aboveI32Max; }
@@ -23,38 +38,23 @@ public class TopLevel {
2338 @JsonProperty("below_i32_min")
2439 public void setBelowI32Min(long value) { this.belowI32Min = value; }
2540
26- @JsonProperty("i32_range")
27- public long getI32Range() { return i32Range; }
28- @JsonProperty("i32_range")
29- public void setI32Range(long value) { this.i32Range = value; }
30-
31- @JsonProperty("large_bounds")
32- public long getLargeBounds() { return largeBounds; }
33- @JsonProperty("large_bounds")
34- public void setLargeBounds(long value) { this.largeBounds = value; }
35-
36- @JsonProperty("only_maximum")
37- public long getOnlyMaximum() { return onlyMaximum; }
38- @JsonProperty("only_maximum")
39- public void setOnlyMaximum(long value) { this.onlyMaximum = value; }
40-
4141 @JsonProperty("only_minimum")
4242 public long getOnlyMinimum() { return onlyMinimum; }
4343 @JsonProperty("only_minimum")
4444 public void setOnlyMinimum(long value) { this.onlyMinimum = value; }
4545
46- @JsonProperty("small_negative")
47- public long getSmallNegative() { return smallNegative; }
48- @JsonProperty("small_negative")
49- public void setSmallNegative(long value) { this.smallNegative = value; }
50-
51- @JsonProperty("small_positive")
52- public long getSmallPositive() { return smallPositive; }
53- @JsonProperty("small_positive")
54- public void setSmallPositive(long value) { this.smallPositive = value; }
46+ @JsonProperty("only_maximum")
47+ public long getOnlyMaximum() { return onlyMaximum; }
48+ @JsonProperty("only_maximum")
49+ public void setOnlyMaximum(long value) { this.onlyMaximum = value; }
5550
5651 @JsonProperty("unbounded")
5752 public long getUnbounded() { return unbounded; }
5853 @JsonProperty("unbounded")
5954 public void setUnbounded(long value) { this.unbounded = value; }
55+
56+ @JsonProperty("large_bounds")
57+ public long getLargeBounds() { return largeBounds; }
58+ @JsonProperty("large_bounds")
59+ public void setLargeBounds(long value) { this.largeBounds = value; }
6060 }
Mschema-java-lombok/test/inputs/schema/light.schema/default/src/main/java/io/quicktype/LightParams.java+6 −6
@@ -3,20 +3,20 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class LightParams {
6- private String appID;
76 private String outletID;
7+ private String appID;
88 private String rgba;
99
10- @JsonProperty("app_id")
11- public String getAppID() { return appID; }
12- @JsonProperty("app_id")
13- public void setAppID(String value) { this.appID = value; }
14-
1510 @JsonProperty("outlet_id")
1611 public String getOutletID() { return outletID; }
1712 @JsonProperty("outlet_id")
1813 public void setOutletID(String value) { this.outletID = value; }
1914
15+ @JsonProperty("app_id")
16+ public String getAppID() { return appID; }
17+ @JsonProperty("app_id")
18+ public void setAppID(String value) { this.appID = value; }
19+
2020 @JsonProperty("rgba")
2121 public String getRGBA() { return rgba; }
2222 @JsonProperty("rgba")
Mschema-java-lombok/test/inputs/schema/min-max-items.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,12 +4,17 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7+ private List<String> minOnly;
78 private List<Long> maxOnly;
89 private List<Double> minAndMax;
9- private List<String> minOnly;
1010 private List<String> plain;
1111 private List<UnionItem> unionItems;
1212
13+ @JsonProperty("minOnly")
14+ public List<String> getMinOnly() { return minOnly; }
15+ @JsonProperty("minOnly")
16+ public void setMinOnly(List<String> value) { this.minOnly = value; }
17+
1318 @JsonProperty("maxOnly")
1419 public List<Long> getMaxOnly() { return maxOnly; }
1520 @JsonProperty("maxOnly")
@@ -20,11 +25,6 @@ public class TopLevel {
2025 @JsonProperty("minAndMax")
2126 public void setMinAndMax(List<Double> value) { this.minAndMax = value; }
2227
23- @JsonProperty("minOnly")
24- public List<String> getMinOnly() { return minOnly; }
25- @JsonProperty("minOnly")
26- public void setMinOnly(List<String> value) { this.minOnly = value; }
27-
2828 @JsonProperty("plain")
2929 public List<String> getPlain() { return plain; }
3030 @JsonProperty("plain")
Mschema-java-lombok/test/inputs/schema/minmax-integer.schema/default/src/main/java/io/quicktype/TopLevel.java+21 −21
@@ -4,51 +4,51 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
66 private long free;
7- private long intersection;
8- private long max;
97 private long min;
8+ private long max;
109 private long minmax;
11- private long minMaxIntersection;
12- private long minMaxUnion;
1310 private long union;
11+ private long minMaxUnion;
12+ private long intersection;
13+ private long minMaxIntersection;
1414
1515 @JsonProperty("free")
1616 public long getFree() { return free; }
1717 @JsonProperty("free")
1818 public void setFree(long value) { this.free = value; }
1919
20- @JsonProperty("intersection")
21- public long getIntersection() { return intersection; }
22- @JsonProperty("intersection")
23- public void setIntersection(long value) { this.intersection = value; }
20+ @JsonProperty("min")
21+ public long getMin() { return min; }
22+ @JsonProperty("min")
23+ public void setMin(long value) { this.min = value; }
2424
2525 @JsonProperty("max")
2626 public long getMax() { return max; }
2727 @JsonProperty("max")
2828 public void setMax(long value) { this.max = value; }
2929
30- @JsonProperty("min")
31- public long getMin() { return min; }
32- @JsonProperty("min")
33- public void setMin(long value) { this.min = value; }
34-
3530 @JsonProperty("minmax")
3631 public long getMinmax() { return minmax; }
3732 @JsonProperty("minmax")
3833 public void setMinmax(long value) { this.minmax = value; }
3934
40- @JsonProperty("minMaxIntersection")
41- public long getMinMaxIntersection() { return minMaxIntersection; }
42- @JsonProperty("minMaxIntersection")
43- public void setMinMaxIntersection(long value) { this.minMaxIntersection = value; }
35+ @JsonProperty("union")
36+ public long getUnion() { return union; }
37+ @JsonProperty("union")
38+ public void setUnion(long value) { this.union = value; }
4439
4540 @JsonProperty("minMaxUnion")
4641 public long getMinMaxUnion() { return minMaxUnion; }
4742 @JsonProperty("minMaxUnion")
4843 public void setMinMaxUnion(long value) { this.minMaxUnion = value; }
4944
50- @JsonProperty("union")
51- public long getUnion() { return union; }
52- @JsonProperty("union")
53- public void setUnion(long value) { this.union = value; }
45+ @JsonProperty("intersection")
46+ public long getIntersection() { return intersection; }
47+ @JsonProperty("intersection")
48+ public void setIntersection(long value) { this.intersection = value; }
49+
50+ @JsonProperty("minMaxIntersection")
51+ public long getMinMaxIntersection() { return minMaxIntersection; }
52+ @JsonProperty("minMaxIntersection")
53+ public void setMinMaxIntersection(long value) { this.minMaxIntersection = value; }
5454 }
Mschema-java-lombok/test/inputs/schema/minmax.schema/default/src/main/java/io/quicktype/TopLevel.java+21 −21
@@ -4,51 +4,51 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
66 private double free;
7- private double intersection;
8- private double max;
97 private double min;
8+ private double max;
109 private double minmax;
11- private double minMaxIntersection;
12- private double minMaxUnion;
1310 private double union;
11+ private double minMaxUnion;
12+ private double intersection;
13+ private double minMaxIntersection;
1414
1515 @JsonProperty("free")
1616 public double getFree() { return free; }
1717 @JsonProperty("free")
1818 public void setFree(double value) { this.free = value; }
1919
20- @JsonProperty("intersection")
21- public double getIntersection() { return intersection; }
22- @JsonProperty("intersection")
23- public void setIntersection(double value) { this.intersection = value; }
20+ @JsonProperty("min")
21+ public double getMin() { return min; }
22+ @JsonProperty("min")
23+ public void setMin(double value) { this.min = value; }
2424
2525 @JsonProperty("max")
2626 public double getMax() { return max; }
2727 @JsonProperty("max")
2828 public void setMax(double value) { this.max = value; }
2929
30- @JsonProperty("min")
31- public double getMin() { return min; }
32- @JsonProperty("min")
33- public void setMin(double value) { this.min = value; }
34-
3530 @JsonProperty("minmax")
3631 public double getMinmax() { return minmax; }
3732 @JsonProperty("minmax")
3833 public void setMinmax(double value) { this.minmax = value; }
3934
40- @JsonProperty("minMaxIntersection")
41- public double getMinMaxIntersection() { return minMaxIntersection; }
42- @JsonProperty("minMaxIntersection")
43- public void setMinMaxIntersection(double value) { this.minMaxIntersection = value; }
35+ @JsonProperty("union")
36+ public double getUnion() { return union; }
37+ @JsonProperty("union")
38+ public void setUnion(double value) { this.union = value; }
4439
4540 @JsonProperty("minMaxUnion")
4641 public double getMinMaxUnion() { return minMaxUnion; }
4742 @JsonProperty("minMaxUnion")
4843 public void setMinMaxUnion(double value) { this.minMaxUnion = value; }
4944
50- @JsonProperty("union")
51- public double getUnion() { return union; }
52- @JsonProperty("union")
53- public void setUnion(double value) { this.union = value; }
45+ @JsonProperty("intersection")
46+ public double getIntersection() { return intersection; }
47+ @JsonProperty("intersection")
48+ public void setIntersection(double value) { this.intersection = value; }
49+
50+ @JsonProperty("minMaxIntersection")
51+ public double getMinMaxIntersection() { return minMaxIntersection; }
52+ @JsonProperty("minMaxIntersection")
53+ public void setMinMaxIntersection(double value) { this.minMaxIntersection = value; }
5454 }
Mschema-java-lombok/test/inputs/schema/minmaxlength.schema/default/src/main/java/io/quicktype/TopLevel.java+28 −28
@@ -3,52 +3,52 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private String intersection;
7- private InUnion inUnion;
8- private String maxlength;
96 private String minlength;
10- private String minMaxIntersection;
7+ private String maxlength;
118 private String minmaxlength;
12- private String minMaxUnion;
139 private String union;
14-
15- @JsonProperty("intersection")
16- public String getIntersection() { return intersection; }
17- @JsonProperty("intersection")
18- public void setIntersection(String value) { this.intersection = value; }
19-
20- @JsonProperty("inUnion")
21- public InUnion getInUnion() { return inUnion; }
22- @JsonProperty("inUnion")
23- public void setInUnion(InUnion value) { this.inUnion = value; }
24-
25- @JsonProperty("maxlength")
26- public String getMaxlength() { return maxlength; }
27- @JsonProperty("maxlength")
28- public void setMaxlength(String value) { this.maxlength = value; }
10+ private InUnion inUnion;
11+ private String minMaxUnion;
12+ private String intersection;
13+ private String minMaxIntersection;
2914
3015 @JsonProperty("minlength")
3116 public String getMinlength() { return minlength; }
3217 @JsonProperty("minlength")
3318 public void setMinlength(String value) { this.minlength = value; }
3419
35- @JsonProperty("minMaxIntersection")
36- public String getMinMaxIntersection() { return minMaxIntersection; }
37- @JsonProperty("minMaxIntersection")
38- public void setMinMaxIntersection(String value) { this.minMaxIntersection = value; }
20+ @JsonProperty("maxlength")
21+ public String getMaxlength() { return maxlength; }
22+ @JsonProperty("maxlength")
23+ public void setMaxlength(String value) { this.maxlength = value; }
3924
4025 @JsonProperty("minmaxlength")
4126 public String getMinmaxlength() { return minmaxlength; }
4227 @JsonProperty("minmaxlength")
4328 public void setMinmaxlength(String value) { this.minmaxlength = value; }
4429
30+ @JsonProperty("union")
31+ public String getUnion() { return union; }
32+ @JsonProperty("union")
33+ public void setUnion(String value) { this.union = value; }
34+
35+ @JsonProperty("inUnion")
36+ public InUnion getInUnion() { return inUnion; }
37+ @JsonProperty("inUnion")
38+ public void setInUnion(InUnion value) { this.inUnion = value; }
39+
4540 @JsonProperty("minMaxUnion")
4641 public String getMinMaxUnion() { return minMaxUnion; }
4742 @JsonProperty("minMaxUnion")
4843 public void setMinMaxUnion(String value) { this.minMaxUnion = value; }
4944
50- @JsonProperty("union")
51- public String getUnion() { return union; }
52- @JsonProperty("union")
53- public void setUnion(String value) { this.union = value; }
45+ @JsonProperty("intersection")
46+ public String getIntersection() { return intersection; }
47+ @JsonProperty("intersection")
48+ public void setIntersection(String value) { this.intersection = value; }
49+
50+ @JsonProperty("minMaxIntersection")
51+ public String getMinMaxIntersection() { return minMaxIntersection; }
52+ @JsonProperty("minMaxIntersection")
53+ public void setMinMaxIntersection(String value) { this.minMaxIntersection = value; }
5454 }
Mschema-java-lombok/test/inputs/schema/non-standard-ref.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,20 +3,20 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private long bar;
76 private long foo;
7+ private long bar;
88 private boolean quux;
99
10- @JsonProperty("bar")
11- public long getBar() { return bar; }
12- @JsonProperty("bar")
13- public void setBar(long value) { this.bar = value; }
14-
1510 @JsonProperty("foo")
1611 public long getFoo() { return foo; }
1712 @JsonProperty("foo")
1813 public void setFoo(long value) { this.foo = value; }
1914
15+ @JsonProperty("bar")
16+ public long getBar() { return bar; }
17+ @JsonProperty("bar")
18+ public void setBar(long value) { this.bar = value; }
19+
2020 @JsonProperty("quux")
2121 public boolean getQuux() { return quux; }
2222 @JsonProperty("quux")
Mschema-java-lombok/test/inputs/schema/nullable-optional-one-of.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private String b;
76 private Kind kind;
8-
9- @JsonProperty("b")
10- public String getB() { return b; }
11- @JsonProperty("b")
12- public void setB(String value) { this.b = value; }
7+ private String b;
138
149 @JsonProperty("kind")
1510 public Kind getKind() { return kind; }
1611 @JsonProperty("kind")
1712 public void setKind(Kind value) { this.kind = value; }
13+
14+ @JsonProperty("b")
15+ public String getB() { return b; }
16+ @JsonProperty("b")
17+ public void setB(String value) { this.b = value; }
1818 }
Mschema-java-lombok/test/inputs/schema/optional-any.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private boolean bar;
76 private Object foo;
8-
9- @JsonProperty("bar")
10- public boolean getBar() { return bar; }
11- @JsonProperty("bar")
12- public void setBar(boolean value) { this.bar = value; }
7+ private boolean bar;
138
149 @JsonProperty("foo")
1510 public Object getFoo() { return foo; }
1611 @JsonProperty("foo")
1712 public void setFoo(Object value) { this.foo = value; }
13+
14+ @JsonProperty("bar")
15+ public boolean getBar() { return bar; }
16+ @JsonProperty("bar")
17+ public void setBar(boolean value) { this.bar = value; }
1818 }
Mschema-java-lombok/test/inputs/schema/optional-const-ref.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -5,45 +5,45 @@ import java.util.List;
55
66 public class TopLevel {
77 private List<Coordinate> coordinates;
8- private Long count;
9- private String label;
108 private List<Coordinate> requiredCoordinates;
9+ private Long count;
1110 private long requiredCount;
12- private String requiredLabel;
1311 private Double weight;
12+ private String label;
13+ private String requiredLabel;
1414
1515 @JsonProperty("coordinates")
1616 public List<Coordinate> getCoordinates() { return coordinates; }
1717 @JsonProperty("coordinates")
1818 public void setCoordinates(List<Coordinate> value) { this.coordinates = value; }
1919
20- @JsonProperty("count")
21- public Long getCount() { return count; }
22- @JsonProperty("count")
23- public void setCount(Long value) { this.count = value; }
24-
25- @JsonProperty("label")
26- public String getLabel() { return label; }
27- @JsonProperty("label")
28- public void setLabel(String value) { this.label = value; }
29-
3020 @JsonProperty("requiredCoordinates")
3121 public List<Coordinate> getRequiredCoordinates() { return requiredCoordinates; }
3222 @JsonProperty("requiredCoordinates")
3323 public void setRequiredCoordinates(List<Coordinate> value) { this.requiredCoordinates = value; }
3424
25+ @JsonProperty("count")
26+ public Long getCount() { return count; }
27+ @JsonProperty("count")
28+ public void setCount(Long value) { this.count = value; }
29+
3530 @JsonProperty("requiredCount")
3631 public long getRequiredCount() { return requiredCount; }
3732 @JsonProperty("requiredCount")
3833 public void setRequiredCount(long value) { this.requiredCount = value; }
3934
40- @JsonProperty("requiredLabel")
41- public String getRequiredLabel() { return requiredLabel; }
42- @JsonProperty("requiredLabel")
43- public void setRequiredLabel(String value) { this.requiredLabel = value; }
44-
4535 @JsonProperty("weight")
4636 public Double getWeight() { return weight; }
4737 @JsonProperty("weight")
4838 public void setWeight(Double value) { this.weight = value; }
39+
40+ @JsonProperty("label")
41+ public String getLabel() { return label; }
42+ @JsonProperty("label")
43+ public void setLabel(String value) { this.label = value; }
44+
45+ @JsonProperty("requiredLabel")
46+ public String getRequiredLabel() { return requiredLabel; }
47+ @JsonProperty("requiredLabel")
48+ public void setRequiredLabel(String value) { this.requiredLabel = value; }
4949 }
Mschema-java-lombok/test/inputs/schema/optional-constraints.schema/default/src/main/java/io/quicktype/TopLevel.java+15 −15
@@ -3,34 +3,34 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private Double optDouble;
6+ private long reqZeroMin;
77 private Long optInt;
8- private String optPattern;
8+ private Double optDouble;
99 private String optString;
10- private long reqZeroMin;
10+ private String optPattern;
1111
12- @JsonProperty("optDouble")
13- public Double getOptDouble() { return optDouble; }
14- @JsonProperty("optDouble")
15- public void setOptDouble(Double value) { this.optDouble = value; }
12+ @JsonProperty("reqZeroMin")
13+ public long getReqZeroMin() { return reqZeroMin; }
14+ @JsonProperty("reqZeroMin")
15+ public void setReqZeroMin(long value) { this.reqZeroMin = value; }
1616
1717 @JsonProperty("optInt")
1818 public Long getOptInt() { return optInt; }
1919 @JsonProperty("optInt")
2020 public void setOptInt(Long value) { this.optInt = value; }
2121
22- @JsonProperty("optPattern")
23- public String getOptPattern() { return optPattern; }
24- @JsonProperty("optPattern")
25- public void setOptPattern(String value) { this.optPattern = value; }
22+ @JsonProperty("optDouble")
23+ public Double getOptDouble() { return optDouble; }
24+ @JsonProperty("optDouble")
25+ public void setOptDouble(Double value) { this.optDouble = value; }
2626
2727 @JsonProperty("optString")
2828 public String getOptString() { return optString; }
2929 @JsonProperty("optString")
3030 public void setOptString(String value) { this.optString = value; }
3131
32- @JsonProperty("reqZeroMin")
33- public long getReqZeroMin() { return reqZeroMin; }
34- @JsonProperty("reqZeroMin")
35- public void setReqZeroMin(long value) { this.reqZeroMin = value; }
32+ @JsonProperty("optPattern")
33+ public String getOptPattern() { return optPattern; }
34+ @JsonProperty("optPattern")
35+ public void setOptPattern(String value) { this.optPattern = value; }
3636 }
Mschema-java-lombok/test/inputs/schema/optional-date-time.schema/default/src/main/java/io/quicktype/TopLevel.java+29 −29
@@ -4,33 +4,12 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.Date;
55
66 public class TopLevel {
7- private Date optionalDate;
8- private Date optionalDateTime;
9- private Date optionalTime;
107 private Date requiredDate;
11- private Date requiredDateTime;
128 private Date requiredTime;
13-
14- @JsonProperty("optional-date")
15- @JsonFormat(pattern = "yyyy-MM-dd")
16- public Date getOptionalDate() { return optionalDate; }
17- @JsonProperty("optional-date")
18- @JsonFormat(pattern = "yyyy-MM-dd")
19- public void setOptionalDate(Date value) { this.optionalDate = value; }
20-
21- @JsonProperty("optional-date-time")
22- @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssX", timezone = "UTC")
23- public Date getOptionalDateTime() { return optionalDateTime; }
24- @JsonProperty("optional-date-time")
25- @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssX", timezone = "UTC")
26- public void setOptionalDateTime(Date value) { this.optionalDateTime = value; }
27-
28- @JsonProperty("optional-time")
29- @JsonFormat(pattern = "HH:mm:ssX", timezone = "UTC")
30- public Date getOptionalTime() { return optionalTime; }
31- @JsonProperty("optional-time")
32- @JsonFormat(pattern = "HH:mm:ssX", timezone = "UTC")
33- public void setOptionalTime(Date value) { this.optionalTime = value; }
9+ private Date requiredDateTime;
10+ private Date optionalDate;
11+ private Date optionalTime;
12+ private Date optionalDateTime;
3413
3514 @JsonProperty("required-date")
3615 @JsonFormat(pattern = "yyyy-MM-dd")
@@ -39,6 +18,13 @@ public class TopLevel {
3918 @JsonFormat(pattern = "yyyy-MM-dd")
4019 public void setRequiredDate(Date value) { this.requiredDate = value; }
4120
21+ @JsonProperty("required-time")
22+ @JsonFormat(pattern = "HH:mm:ssX", timezone = "UTC")
23+ public Date getRequiredTime() { return requiredTime; }
24+ @JsonProperty("required-time")
25+ @JsonFormat(pattern = "HH:mm:ssX", timezone = "UTC")
26+ public void setRequiredTime(Date value) { this.requiredTime = value; }
27+
4228 @JsonProperty("required-date-time")
4329 @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssX", timezone = "UTC")
4430 public Date getRequiredDateTime() { return requiredDateTime; }
@@ -46,10 +32,24 @@ public class TopLevel {
4632 @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssX", timezone = "UTC")
4733 public void setRequiredDateTime(Date value) { this.requiredDateTime = value; }
4834
49- @JsonProperty("required-time")
35+ @JsonProperty("optional-date")
36+ @JsonFormat(pattern = "yyyy-MM-dd")
37+ public Date getOptionalDate() { return optionalDate; }
38+ @JsonProperty("optional-date")
39+ @JsonFormat(pattern = "yyyy-MM-dd")
40+ public void setOptionalDate(Date value) { this.optionalDate = value; }
41+
42+ @JsonProperty("optional-time")
5043 @JsonFormat(pattern = "HH:mm:ssX", timezone = "UTC")
51- public Date getRequiredTime() { return requiredTime; }
52- @JsonProperty("required-time")
44+ public Date getOptionalTime() { return optionalTime; }
45+ @JsonProperty("optional-time")
5346 @JsonFormat(pattern = "HH:mm:ssX", timezone = "UTC")
54- public void setRequiredTime(Date value) { this.requiredTime = value; }
47+ public void setOptionalTime(Date value) { this.optionalTime = value; }
48+
49+ @JsonProperty("optional-date-time")
50+ @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssX", timezone = "UTC")
51+ public Date getOptionalDateTime() { return optionalDateTime; }
52+ @JsonProperty("optional-date-time")
53+ @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssX", timezone = "UTC")
54+ public void setOptionalDateTime(Date value) { this.optionalDateTime = value; }
5555 }
Mschema-java-lombok/test/inputs/schema/prefix-items.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,16 +4,16 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<Open> open;
87 private List<Open> tuple;
9-
10- @JsonProperty("open")
11- public List<Open> getOpen() { return open; }
12- @JsonProperty("open")
13- public void setOpen(List<Open> value) { this.open = value; }
8+ private List<Open> open;
149
1510 @JsonProperty("tuple")
1611 public List<Open> getTuple() { return tuple; }
1712 @JsonProperty("tuple")
1813 public void setTuple(List<Open> value) { this.tuple = value; }
14+
15+ @JsonProperty("open")
16+ public List<Open> getOpen() { return open; }
17+ @JsonProperty("open")
18+ public void setOpen(List<Open> value) { this.open = value; }
1919 }
Aschema-java-lombok/test/inputs/schema/property-order.schema/default/src/main/java/io/quicktype/Converter.java+121 −0
@@ -0,0 +1,121 @@
1+// To use this code, add the following Maven dependency to your project:
2+//
3+//
4+// com.fasterxml.jackson.core : jackson-databind : 2.9.0
5+//
6+//
7+// Import this package:
8+//
9+// import io.quicktype.Converter;
10+//
11+// Then you can deserialize a JSON string with
12+//
13+// TopLevel data = Converter.fromJsonString(jsonString);
14+
15+package io.quicktype;
16+
17+import java.io.IOException;
18+import com.fasterxml.jackson.databind.*;
19+import com.fasterxml.jackson.databind.module.SimpleModule;
20+import com.fasterxml.jackson.core.JsonParser;
21+import com.fasterxml.jackson.core.JsonProcessingException;
22+import java.util.*;
23+import java.util.Date;
24+import java.text.SimpleDateFormat;
25+
26+public class Converter {
27+ // Date-time helpers
28+
29+ private static final String[] DATE_TIME_FORMATS = {
30+ "yyyy-MM-dd'T'HH:mm:ss.SX",
31+ "yyyy-MM-dd'T'HH:mm:ss.S",
32+ "yyyy-MM-dd'T'HH:mm:ssX",
33+ "yyyy-MM-dd'T'HH:mm:ss",
34+ "yyyy-MM-dd HH:mm:ss.SX",
35+ "yyyy-MM-dd HH:mm:ss.S",
36+ "yyyy-MM-dd HH:mm:ssX",
37+ "yyyy-MM-dd HH:mm:ss",
38+ "HH:mm:ss.SZ",
39+ "HH:mm:ss.S",
40+ "HH:mm:ssZ",
41+ "HH:mm:ss",
42+ "yyyy-MM-dd",
43+ };
44+
45+ public static Date parseAllDateTimeString(String str) {
46+ for (String format : DATE_TIME_FORMATS) {
47+ try {
48+ return new SimpleDateFormat(format).parse(str);
49+ } catch (Exception ex) {
50+ // Ignored
51+ }
52+ }
53+ return null;
54+ }
55+
56+ public static String serializeDateTime(Date datetime) {
57+ return new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ").format(datetime);
58+ }
59+
60+ public static String serializeDate(Date datetime) {
61+ return new SimpleDateFormat("yyyy-MM-dd").format(datetime);
62+ }
63+
64+ public static String serializeTime(Date datetime) {
65+ return new SimpleDateFormat("hh:mm:ssZ").format(datetime);
66+ }
67+ // Serialize/deserialize helpers
68+
69+ public static TopLevel fromJsonString(String json) throws IOException {
70+ return getObjectReader().readValue(json);
71+ }
72+
73+ public static String toJsonString(TopLevel obj) throws JsonProcessingException {
74+ return getObjectWriter().writeValueAsString(obj);
75+ }
76+
77+ private static ObjectReader reader;
78+ private static ObjectWriter writer;
79+
80+ private static void instantiateMapper() {
81+ ObjectMapper mapper = new ObjectMapper();
82+ mapper.findAndRegisterModules();
83+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
84+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
85+ SimpleModule module = new SimpleModule();
86+ module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
87+ @Override
88+ public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
89+ String value = jsonParser.getText();
90+ return Converter.parseAllDateTimeString(value);
91+ }
92+ });
93+ module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
94+ @Override
95+ public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
96+ String value = jsonParser.getText();
97+ return Converter.parseAllDateTimeString(value);
98+ }
99+ });
100+ module.addDeserializer(Date.class, new JsonDeserializer<Date>() {
101+ @Override
102+ public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
103+ String value = jsonParser.getText();
104+ return Converter.parseAllDateTimeString(value);
105+ }
106+ });
107+ mapper.registerModule(module);
108+ reader = mapper.readerFor(TopLevel.class);
109+ writer = mapper.writerFor(TopLevel.class);
110+ }
111+
112+ private static ObjectReader getObjectReader() {
113+ if (reader == null) instantiateMapper();
114+ return reader;
115+ }
116+
117+ private static ObjectWriter getObjectWriter() {
118+ if (writer == null) instantiateMapper();
119+ return writer;
120+ }
121+}
Aschema-java-lombok/test/inputs/schema/property-order.schema/default/src/main/java/io/quicktype/Ordered.java+24 −0
@@ -0,0 +1,24 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Ordered {
6+ private double mango;
7+ private String zebra;
8+ private boolean apple;
9+
10+ @JsonProperty("mango")
11+ public double getMango() { return mango; }
12+ @JsonProperty("mango")
13+ public void setMango(double value) { this.mango = value; }
14+
15+ @JsonProperty("zebra")
16+ public String getZebra() { return zebra; }
17+ @JsonProperty("zebra")
18+ public void setZebra(String value) { this.zebra = value; }
19+
20+ @JsonProperty("apple")
21+ public boolean getApple() { return apple; }
22+ @JsonProperty("apple")
23+ public void setApple(boolean value) { this.apple = value; }
24+}
Aschema-java-lombok/test/inputs/schema/property-order.schema/default/src/main/java/io/quicktype/TopLevel.java+42 −0
@@ -0,0 +1,42 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class TopLevel {
6+ private String zebra;
7+ private double mango;
8+ private boolean apple;
9+ private String delta;
10+ private long banana;
11+ private Ordered ordered;
12+
13+ @JsonProperty("zebra")
14+ public String getZebra() { return zebra; }
15+ @JsonProperty("zebra")
16+ public void setZebra(String value) { this.zebra = value; }
17+
18+ @JsonProperty("mango")
19+ public double getMango() { return mango; }
20+ @JsonProperty("mango")
21+ public void setMango(double value) { this.mango = value; }
22+
23+ @JsonProperty("apple")
24+ public boolean getApple() { return apple; }
25+ @JsonProperty("apple")
26+ public void setApple(boolean value) { this.apple = value; }
27+
28+ @JsonProperty("delta")
29+ public String getDelta() { return delta; }
30+ @JsonProperty("delta")
31+ public void setDelta(String value) { this.delta = value; }
32+
33+ @JsonProperty("banana")
34+ public long getBanana() { return banana; }
35+ @JsonProperty("banana")
36+ public void setBanana(long value) { this.banana = value; }
37+
38+ @JsonProperty("ordered")
39+ public Ordered getOrdered() { return ordered; }
40+ @JsonProperty("ordered")
41+ public void setOrdered(Ordered value) { this.ordered = value; }
42+}
Mschema-java-lombok/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Berry.java+6 −6
@@ -4,20 +4,20 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class Berry {
7- private Color color;
87 private String name;
8+ private Color color;
99 private List<Shape> shapes;
1010
11- @JsonProperty("color")
12- public Color getColor() { return color; }
13- @JsonProperty("color")
14- public void setColor(Color value) { this.color = value; }
15-
1611 @JsonProperty("name")
1712 public String getName() { return name; }
1813 @JsonProperty("name")
1914 public void setName(String value) { this.name = value; }
2015
16+ @JsonProperty("color")
17+ public Color getColor() { return color; }
18+ @JsonProperty("color")
19+ public void setColor(Color value) { this.color = value; }
20+
2121 @JsonProperty("shapes")
2222 public List<Shape> getShapes() { return shapes; }
2323 @JsonProperty("shapes")
Mschema-java-lombok/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Fruit.java+6 −6
@@ -5,21 +5,21 @@ import java.util.List;
55
66 public class Fruit {
77 private Boolean apple;
8- private List<Berry> berries;
98 private Boolean orange;
9+ private List<Berry> berries;
1010
1111 @JsonProperty("apple")
1212 public Boolean getApple() { return apple; }
1313 @JsonProperty("apple")
1414 public void setApple(Boolean value) { this.apple = value; }
1515
16- @JsonProperty("berries")
17- public List<Berry> getBerries() { return berries; }
18- @JsonProperty("berries")
19- public void setBerries(List<Berry> value) { this.berries = value; }
20-
2116 @JsonProperty("orange")
2217 public Boolean getOrange() { return orange; }
2318 @JsonProperty("orange")
2419 public void setOrange(Boolean value) { this.orange = value; }
20+
21+ @JsonProperty("berries")
22+ public List<Berry> getBerries() { return berries; }
23+ @JsonProperty("berries")
24+ public void setBerries(List<Berry> value) { this.berries = value; }
2525 }
Mschema-java-lombok/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Limit.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Limit {
6- private Double maximum;
76 private Double minimum;
8-
9- @JsonProperty("maximum")
10- public Double getMaximum() { return maximum; }
11- @JsonProperty("maximum")
12- public void setMaximum(Double value) { this.maximum = value; }
7+ private Double maximum;
138
149 @JsonProperty("minimum")
1510 public Double getMinimum() { return minimum; }
1611 @JsonProperty("minimum")
1712 public void setMinimum(Double value) { this.minimum = value; }
13+
14+ @JsonProperty("maximum")
15+ public Double getMaximum() { return maximum; }
16+ @JsonProperty("maximum")
17+ public void setMaximum(Double value) { this.maximum = value; }
1818 }
Mschema-java-lombok/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Part.java+6 −6
@@ -3,14 +3,9 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Part {
6- private String depth;
76 private String length;
87 private String width;
9-
10- @JsonProperty("depth")
11- public String getDepth() { return depth; }
12- @JsonProperty("depth")
13- public void setDepth(String value) { this.depth = value; }
8+ private String depth;
149
1510 @JsonProperty("length")
1611 public String getLength() { return length; }
@@ -21,4 +16,9 @@ public class Part {
2116 public String getWidth() { return width; }
2217 @JsonProperty("width")
2318 public void setWidth(String value) { this.width = value; }
19+
20+ @JsonProperty("depth")
21+ public String getDepth() { return depth; }
22+ @JsonProperty("depth")
23+ public void setDepth(String value) { this.depth = value; }
2424 }
Mschema-java-lombok/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Shape.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Shape {
6- private Geometry geometry;
76 private History history;
8-
9- @JsonProperty("geometry")
10- public Geometry getGeometry() { return geometry; }
11- @JsonProperty("geometry")
12- public void setGeometry(Geometry value) { this.geometry = value; }
7+ private Geometry geometry;
138
149 @JsonProperty("history")
1510 public History getHistory() { return history; }
1611 @JsonProperty("history")
1712 public void setHistory(History value) { this.history = value; }
13+
14+ @JsonProperty("geometry")
15+ public Geometry getGeometry() { return geometry; }
16+ @JsonProperty("geometry")
17+ public void setGeometry(Geometry value) { this.geometry = value; }
1818 }
Mschema-java-lombok/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Vehicle.java+18 −18
@@ -3,40 +3,40 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Vehicle {
6- private String brand;
76 private String id;
8- private Speed speed;
9- private Boolean subModule;
107 private VehicleType type;
8+ private Speed speed;
119 private String year;
12-
13- @JsonProperty("brand")
14- public String getBrand() { return brand; }
15- @JsonProperty("brand")
16- public void setBrand(String value) { this.brand = value; }
10+ private String brand;
11+ private Boolean subModule;
1712
1813 @JsonProperty("id")
1914 public String getID() { return id; }
2015 @JsonProperty("id")
2116 public void setID(String value) { this.id = value; }
2217
23- @JsonProperty("speed")
24- public Speed getSpeed() { return speed; }
25- @JsonProperty("speed")
26- public void setSpeed(Speed value) { this.speed = value; }
27-
28- @JsonProperty("subModule")
29- public Boolean getSubModule() { return subModule; }
30- @JsonProperty("subModule")
31- public void setSubModule(Boolean value) { this.subModule = value; }
32-
3318 @JsonProperty("type")
3419 public VehicleType getType() { return type; }
3520 @JsonProperty("type")
3621 public void setType(VehicleType value) { this.type = value; }
3722
23+ @JsonProperty("speed")
24+ public Speed getSpeed() { return speed; }
25+ @JsonProperty("speed")
26+ public void setSpeed(Speed value) { this.speed = value; }
27+
3828 @JsonProperty("year")
3929 public String getYear() { return year; }
4030 @JsonProperty("year")
4131 public void setYear(String value) { this.year = value; }
32+
33+ @JsonProperty("brand")
34+ public String getBrand() { return brand; }
35+ @JsonProperty("brand")
36+ public void setBrand(String value) { this.brand = value; }
37+
38+ @JsonProperty("subModule")
39+ public Boolean getSubModule() { return subModule; }
40+ @JsonProperty("subModule")
41+ public void setSubModule(Boolean value) { this.subModule = value; }
4242 }
Mschema-java-lombok/test/inputs/schema/rust-cycle-breaker-union.schema/default/src/main/java/io/quicktype/Node.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Node {
6- private Next next;
76 private String value;
8-
9- @JsonProperty("next")
10- public Next getNext() { return next; }
11- @JsonProperty("next")
12- public void setNext(Next value) { this.next = value; }
7+ private Next next;
138
149 @JsonProperty("value")
1510 public String getValue() { return value; }
1611 @JsonProperty("value")
1712 public void setValue(String value) { this.value = value; }
13+
14+ @JsonProperty("next")
15+ public Next getNext() { return next; }
16+ @JsonProperty("next")
17+ public void setNext(Next value) { this.next = value; }
1818 }
Mschema-java-lombok/test/inputs/schema/rust-cycle-breaker-union.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private Next next;
76 private String value;
8-
9- @JsonProperty("next")
10- public Next getNext() { return next; }
11- @JsonProperty("next")
12- public void setNext(Next value) { this.next = value; }
7+ private Next next;
138
149 @JsonProperty("value")
1510 public String getValue() { return value; }
1611 @JsonProperty("value")
1712 public void setValue(String value) { this.value = value; }
13+
14+ @JsonProperty("next")
15+ public Next getNext() { return next; }
16+ @JsonProperty("next")
17+ public void setNext(Next value) { this.next = value; }
1818 }
Mschema-java-lombok/test/inputs/schema/uuid.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -5,28 +5,13 @@ import java.util.List;
55 import java.util.UUID;
66
77 public class TopLevel {
8- private List<UUID> arrNullable;
9- private List<UUID> arrOne;
10- private UUID nullable;
118 private UUID one;
129 private UUID optional;
10+ private UUID nullable;
11+ private List<UUID> arrOne;
12+ private List<UUID> arrNullable;
1313 private UnionWithEnumUnion unionWithEnum;
1414
15- @JsonProperty("arrNullable")
16- public List<UUID> getArrNullable() { return arrNullable; }
17- @JsonProperty("arrNullable")
18- public void setArrNullable(List<UUID> value) { this.arrNullable = value; }
19-
20- @JsonProperty("arrOne")
21- public List<UUID> getArrOne() { return arrOne; }
22- @JsonProperty("arrOne")
23- public void setArrOne(List<UUID> value) { this.arrOne = value; }
24-
25- @JsonProperty("nullable")
26- public UUID getNullable() { return nullable; }
27- @JsonProperty("nullable")
28- public void setNullable(UUID value) { this.nullable = value; }
29-
3015 @JsonProperty("one")
3116 public UUID getOne() { return one; }
3217 @JsonProperty("one")
@@ -37,6 +22,21 @@ public class TopLevel {
3722 @JsonProperty("optional")
3823 public void setOptional(UUID value) { this.optional = value; }
3924
25+ @JsonProperty("nullable")
26+ public UUID getNullable() { return nullable; }
27+ @JsonProperty("nullable")
28+ public void setNullable(UUID value) { this.nullable = value; }
29+
30+ @JsonProperty("arrOne")
31+ public List<UUID> getArrOne() { return arrOne; }
32+ @JsonProperty("arrOne")
33+ public void setArrOne(List<UUID> value) { this.arrOne = value; }
34+
35+ @JsonProperty("arrNullable")
36+ public List<UUID> getArrNullable() { return arrNullable; }
37+ @JsonProperty("arrNullable")
38+ public void setArrNullable(List<UUID> value) { this.arrNullable = value; }
39+
4040 @JsonProperty("unionWithEnum")
4141 public UnionWithEnumUnion getUnionWithEnum() { return unionWithEnum; }
4242 @JsonProperty("unionWithEnum")
Mschema-java-lombok/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/Axis.java+9 −9
@@ -19,8 +19,8 @@ public class Axis {
1919 private TitleOrient orient;
2020 private Double position;
2121 private Double tickCount;
22- private Boolean ticks;
2322 private Double tickSize;
23+ private Boolean ticks;
2424 private String title;
2525 private Double titleMaxLength;
2626 private Double titlePadding;
@@ -206,14 +206,6 @@ public class Axis {
206206 @JsonProperty("tickCount")
207207 public void setTickCount(Double value) { this.tickCount = value; }
208208
209- /**
210- * Boolean value that determines whether the axis should include ticks.
211- */
212- @JsonProperty("ticks")
213- public Boolean getTicks() { return ticks; }
214- @JsonProperty("ticks")
215- public void setTicks(Boolean value) { this.ticks = value; }
216-
217209 /**
218210 * The size in pixels of axis ticks.
219211 */
@@ -222,6 +214,14 @@ public class Axis {
222214 @JsonProperty("tickSize")
223215 public void setTickSize(Double value) { this.tickSize = value; }
224216
217+ /**
218+ * Boolean value that determines whether the axis should include ticks.
219+ */
220+ @JsonProperty("ticks")
221+ public Boolean getTicks() { return ticks; }
222+ @JsonProperty("ticks")
223+ public void setTicks(Boolean value) { this.ticks = value; }
224+
225225 /**
226226 * A title for the field. If `null`, the title will be removed.
227227 *
Mschema-java-lombok/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/AxisConfig.java+9 −9
@@ -33,9 +33,9 @@ public class AxisConfig {
3333 private Boolean shortTimeLabels;
3434 private String tickColor;
3535 private Boolean tickRound;
36- private Boolean ticks;
3736 private Double tickSize;
3837 private Double tickWidth;
38+ private Boolean ticks;
3939 private String titleAlign;
4040 private Double titleAngle;
4141 private String titleBaseline;
@@ -288,14 +288,6 @@ public class AxisConfig {
288288 @JsonProperty("tickRound")
289289 public void setTickRound(Boolean value) { this.tickRound = value; }
290290
291- /**
292- * Boolean value that determines whether the axis should include ticks.
293- */
294- @JsonProperty("ticks")
295- public Boolean getTicks() { return ticks; }
296- @JsonProperty("ticks")
297- public void setTicks(Boolean value) { this.ticks = value; }
298-
299291 /**
300292 * The size in pixels of axis ticks.
301293 */
@@ -312,6 +304,14 @@ public class AxisConfig {
312304 @JsonProperty("tickWidth")
313305 public void setTickWidth(Double value) { this.tickWidth = value; }
314306
307+ /**
308+ * Boolean value that determines whether the axis should include ticks.
309+ */
310+ @JsonProperty("ticks")
311+ public Boolean getTicks() { return ticks; }
312+ @JsonProperty("ticks")
313+ public void setTicks(Boolean value) { this.ticks = value; }
314+
315315 /**
316316 * Horizontal text alignment of axis titles.
317317 */
Mschema-java-lombok/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/BarConfig.java+11 −11
@@ -18,8 +18,8 @@ public class BarConfig {
1818 private Double dx;
1919 private Double dy;
2020 private String fill;
21- private Boolean filled;
2221 private Double fillOpacity;
22+ private Boolean filled;
2323 private String font;
2424 private Double fontSize;
2525 private FontStyle fontStyle;
@@ -147,6 +147,16 @@ public class BarConfig {
147147 @JsonProperty("fill")
148148 public void setFill(String value) { this.fill = value; }
149149
150+ /**
151+ * The fill opacity (value between [0,1]).
152+ *
153+ * __Default value:__ `1`
154+ */
155+ @JsonProperty("fillOpacity")
156+ public Double getFillOpacity() { return fillOpacity; }
157+ @JsonProperty("fillOpacity")
158+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
159+
150160 /**
151161 * Whether the mark's color should be used as fill color instead of stroke color.
152162 *
@@ -161,16 +171,6 @@ public class BarConfig {
161171 @JsonProperty("filled")
162172 public void setFilled(Boolean value) { this.filled = value; }
163173
164- /**
165- * The fill opacity (value between [0,1]).
166- *
167- * __Default value:__ `1`
168- */
169- @JsonProperty("fillOpacity")
170- public Double getFillOpacity() { return fillOpacity; }
171- @JsonProperty("fillOpacity")
172- public void setFillOpacity(Double value) { this.fillOpacity = value; }
173-
174174 /**
175175 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
176176 */
Mschema-java-lombok/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/MarkConfig.java+11 −11
@@ -31,8 +31,8 @@ public class MarkConfig {
3131 private Double dx;
3232 private Double dy;
3333 private String fill;
34- private Boolean filled;
3534 private Double fillOpacity;
35+ private Boolean filled;
3636 private String font;
3737 private Double fontSize;
3838 private FontStyle fontStyle;
@@ -130,6 +130,16 @@ public class MarkConfig {
130130 @JsonProperty("fill")
131131 public void setFill(String value) { this.fill = value; }
132132
133+ /**
134+ * The fill opacity (value between [0,1]).
135+ *
136+ * __Default value:__ `1`
137+ */
138+ @JsonProperty("fillOpacity")
139+ public Double getFillOpacity() { return fillOpacity; }
140+ @JsonProperty("fillOpacity")
141+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
142+
133143 /**
134144 * Whether the mark's color should be used as fill color instead of stroke color.
135145 *
@@ -144,16 +154,6 @@ public class MarkConfig {
144154 @JsonProperty("filled")
145155 public void setFilled(Boolean value) { this.filled = value; }
146156
147- /**
148- * The fill opacity (value between [0,1]).
149- *
150- * __Default value:__ `1`
151- */
152- @JsonProperty("fillOpacity")
153- public Double getFillOpacity() { return fillOpacity; }
154- @JsonProperty("fillOpacity")
155- public void setFillOpacity(Double value) { this.fillOpacity = value; }
156-
157157 /**
158158 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
159159 */
Mschema-java-lombok/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/MarkDef.java+11 −11
@@ -13,8 +13,8 @@ public class MarkDef {
1313 private Double dx;
1414 private Double dy;
1515 private String fill;
16- private Boolean filled;
1716 private Double fillOpacity;
17+ private Boolean filled;
1818 private String font;
1919 private Double fontSize;
2020 private FontStyle fontStyle;
@@ -122,6 +122,16 @@ public class MarkDef {
122122 @JsonProperty("fill")
123123 public void setFill(String value) { this.fill = value; }
124124
125+ /**
126+ * The fill opacity (value between [0,1]).
127+ *
128+ * __Default value:__ `1`
129+ */
130+ @JsonProperty("fillOpacity")
131+ public Double getFillOpacity() { return fillOpacity; }
132+ @JsonProperty("fillOpacity")
133+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
134+
125135 /**
126136 * Whether the mark's color should be used as fill color instead of stroke color.
127137 *
@@ -136,16 +146,6 @@ public class MarkDef {
136146 @JsonProperty("filled")
137147 public void setFilled(Boolean value) { this.filled = value; }
138148
139- /**
140- * The fill opacity (value between [0,1]).
141- *
142- * __Default value:__ `1`
143- */
144- @JsonProperty("fillOpacity")
145- public Double getFillOpacity() { return fillOpacity; }
146- @JsonProperty("fillOpacity")
147- public void setFillOpacity(Double value) { this.fillOpacity = value; }
148-
149149 /**
150150 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
151151 */
Mschema-java-lombok/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/TextConfig.java+11 −11
@@ -15,8 +15,8 @@ public class TextConfig {
1515 private Double dx;
1616 private Double dy;
1717 private String fill;
18- private Boolean filled;
1918 private Double fillOpacity;
19+ private Boolean filled;
2020 private String font;
2121 private Double fontSize;
2222 private FontStyle fontStyle;
@@ -115,6 +115,16 @@ public class TextConfig {
115115 @JsonProperty("fill")
116116 public void setFill(String value) { this.fill = value; }
117117
118+ /**
119+ * The fill opacity (value between [0,1]).
120+ *
121+ * __Default value:__ `1`
122+ */
123+ @JsonProperty("fillOpacity")
124+ public Double getFillOpacity() { return fillOpacity; }
125+ @JsonProperty("fillOpacity")
126+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
127+
118128 /**
119129 * Whether the mark's color should be used as fill color instead of stroke color.
120130 *
@@ -129,16 +139,6 @@ public class TextConfig {
129139 @JsonProperty("filled")
130140 public void setFilled(Boolean value) { this.filled = value; }
131141
132- /**
133- * The fill opacity (value between [0,1]).
134- *
135- * __Default value:__ `1`
136- */
137- @JsonProperty("fillOpacity")
138- public Double getFillOpacity() { return fillOpacity; }
139- @JsonProperty("fillOpacity")
140- public void setFillOpacity(Double value) { this.fillOpacity = value; }
141-
142142 /**
143143 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
144144 */
Mschema-java-lombok/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/TickConfig.java+11 −11
@@ -16,8 +16,8 @@ public class TickConfig {
1616 private Double dx;
1717 private Double dy;
1818 private String fill;
19- private Boolean filled;
2019 private Double fillOpacity;
20+ private Boolean filled;
2121 private String font;
2222 private Double fontSize;
2323 private FontStyle fontStyle;
@@ -126,6 +126,16 @@ public class TickConfig {
126126 @JsonProperty("fill")
127127 public void setFill(String value) { this.fill = value; }
128128
129+ /**
130+ * The fill opacity (value between [0,1]).
131+ *
132+ * __Default value:__ `1`
133+ */
134+ @JsonProperty("fillOpacity")
135+ public Double getFillOpacity() { return fillOpacity; }
136+ @JsonProperty("fillOpacity")
137+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
138+
129139 /**
130140 * Whether the mark's color should be used as fill color instead of stroke color.
131141 *
@@ -140,16 +150,6 @@ public class TickConfig {
140150 @JsonProperty("filled")
141151 public void setFilled(Boolean value) { this.filled = value; }
142152
143- /**
144- * The fill opacity (value between [0,1]).
145- *
146- * __Default value:__ `1`
147- */
148- @JsonProperty("fillOpacity")
149- public Double getFillOpacity() { return fillOpacity; }
150- @JsonProperty("fillOpacity")
151- public void setFillOpacity(Double value) { this.fillOpacity = value; }
152-
153153 /**
154154 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
155155 */
Mschema-java-lombok/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/VGAxisConfig.java+9 −9
@@ -42,9 +42,9 @@ public class VGAxisConfig {
4242 private Double minExtent;
4343 private String tickColor;
4444 private Boolean tickRound;
45- private Boolean ticks;
4645 private Double tickSize;
4746 private Double tickWidth;
47+ private Boolean ticks;
4848 private String titleAlign;
4949 private Double titleAngle;
5050 private String titleBaseline;
@@ -287,14 +287,6 @@ public class VGAxisConfig {
287287 @JsonProperty("tickRound")
288288 public void setTickRound(Boolean value) { this.tickRound = value; }
289289
290- /**
291- * Boolean value that determines whether the axis should include ticks.
292- */
293- @JsonProperty("ticks")
294- public Boolean getTicks() { return ticks; }
295- @JsonProperty("ticks")
296- public void setTicks(Boolean value) { this.ticks = value; }
297-
298290 /**
299291 * The size in pixels of axis ticks.
300292 */
@@ -311,6 +303,14 @@ public class VGAxisConfig {
311303 @JsonProperty("tickWidth")
312304 public void setTickWidth(Double value) { this.tickWidth = value; }
313305
306+ /**
307+ * Boolean value that determines whether the axis should include ticks.
308+ */
309+ @JsonProperty("ticks")
310+ public Boolean getTicks() { return ticks; }
311+ @JsonProperty("ticks")
312+ public void setTicks(Boolean value) { this.ticks = value; }
313+
314314 /**
315315 * Horizontal text alignment of axis titles.
316316 */
Mschema-java/test/inputs/schema/accessors.schema/default/src/main/java/io/quicktype/TopLevel.java+10 −10
@@ -3,15 +3,15 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private String barre;
6+ private Union unionization;
77 private Enum enumerification;
88 private String Goo;
9- private Union unionization;
9+ private String barre;
1010
11- @JsonProperty("bar")
12- public String getBarre() { return barre; }
13- @JsonProperty("bar")
14- public void setBarre(String value) { this.barre = value; }
11+ @JsonProperty("union")
12+ public Union getUnionization() { return unionization; }
13+ @JsonProperty("union")
14+ public void setUnionization(Union value) { this.unionization = value; }
1515
1616 @JsonProperty("enum")
1717 public Enum getEnumerification() { return enumerification; }
@@ -23,8 +23,8 @@ public class TopLevel {
2323 @JsonProperty("foo")
2424 public void setGoo(String value) { this.Goo = value; }
2525
26- @JsonProperty("union")
27- public Union getUnionization() { return unionization; }
28- @JsonProperty("union")
29- public void setUnionization(Union value) { this.unionization = value; }
26+ @JsonProperty("bar")
27+ public String getBarre() { return barre; }
28+ @JsonProperty("bar")
29+ public void setBarre(String value) { this.barre = value; }
3030 }
Mschema-java/test/inputs/schema/all-of-additional-properties-false.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -5,8 +5,8 @@ import com.fasterxml.jackson.annotation.*;
55 public class TopLevel {
66 private double amount;
77 private Frequency frequency;
8- private String description;
98 private Type type;
9+ private String description;
1010
1111 @JsonProperty("amount")
1212 public double getAmount() { return amount; }
@@ -18,13 +18,13 @@ public class TopLevel {
1818 @JsonProperty("frequency")
1919 public void setFrequency(Frequency value) { this.frequency = value; }
2020
21- @JsonProperty("description")
22- public String getDescription() { return description; }
23- @JsonProperty("description")
24- public void setDescription(String value) { this.description = value; }
25-
2621 @JsonProperty("type")
2722 public Type getType() { return type; }
2823 @JsonProperty("type")
2924 public void setType(Type value) { this.type = value; }
25+
26+ @JsonProperty("description")
27+ public String getDescription() { return description; }
28+ @JsonProperty("description")
29+ public void setDescription(String value) { this.description = value; }
3030 }
Mschema-java/test/inputs/schema/bool-string.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -4,29 +4,14 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<String> arrNullable;
8- private List<String> arrOne;
9- private String nullable;
107 private String one;
118 private String optional;
9+ private String nullable;
10+ private List<String> arrOne;
11+ private List<String> arrNullable;
1212 private UnionWithBool unionWithBool;
1313 private UnionWithBool unionWithBoolAndEnum;
1414
15- @JsonProperty("arrNullable")
16- public List<String> getArrNullable() { return arrNullable; }
17- @JsonProperty("arrNullable")
18- public void setArrNullable(List<String> value) { this.arrNullable = value; }
19-
20- @JsonProperty("arrOne")
21- public List<String> getArrOne() { return arrOne; }
22- @JsonProperty("arrOne")
23- public void setArrOne(List<String> value) { this.arrOne = value; }
24-
25- @JsonProperty("nullable")
26- public String getNullable() { return nullable; }
27- @JsonProperty("nullable")
28- public void setNullable(String value) { this.nullable = value; }
29-
3015 @JsonProperty("one")
3116 public String getOne() { return one; }
3217 @JsonProperty("one")
@@ -37,6 +22,21 @@ public class TopLevel {
3722 @JsonProperty("optional")
3823 public void setOptional(String value) { this.optional = value; }
3924
25+ @JsonProperty("nullable")
26+ public String getNullable() { return nullable; }
27+ @JsonProperty("nullable")
28+ public void setNullable(String value) { this.nullable = value; }
29+
30+ @JsonProperty("arrOne")
31+ public List<String> getArrOne() { return arrOne; }
32+ @JsonProperty("arrOne")
33+ public void setArrOne(List<String> value) { this.arrOne = value; }
34+
35+ @JsonProperty("arrNullable")
36+ public List<String> getArrNullable() { return arrNullable; }
37+ @JsonProperty("arrNullable")
38+ public void setArrNullable(List<String> value) { this.arrNullable = value; }
39+
4040 @JsonProperty("unionWithBool")
4141 public UnionWithBool getUnionWithBool() { return unionWithBool; }
4242 @JsonProperty("unionWithBool")
Mschema-java/test/inputs/schema/boolean-subschema.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,11 +4,16 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7+ private String foo;
78 private Object disallowed;
89 private List<Object> empty;
9- private String foo;
1010 private Object impossible;
1111
12+ @JsonProperty("foo")
13+ public String getFoo() { return foo; }
14+ @JsonProperty("foo")
15+ public void setFoo(String value) { this.foo = value; }
16+
1217 @JsonProperty("disallowed")
1318 public Object getDisallowed() { return disallowed; }
1419 @JsonProperty("disallowed")
@@ -19,11 +24,6 @@ public class TopLevel {
1924 @JsonProperty("empty")
2025 public void setEmpty(List<Object> value) { this.empty = value; }
2126
22- @JsonProperty("foo")
23- public String getFoo() { return foo; }
24- @JsonProperty("foo")
25- public void setFoo(String value) { this.foo = value; }
26-
2727 @JsonProperty("impossible")
2828 public Object getImpossible() { return impossible; }
2929 @JsonProperty("impossible")
Mschema-java/test/inputs/schema/comment-injection.schema/default/src/main/java/io/quicktype/TopLevel.java+20 −20
@@ -17,10 +17,29 @@ import com.fasterxml.jackson.annotation.*;
1717 * }
1818 */
1919 public class TopLevel {
20+ private String value;
2021 private String trailingBackslash;
2122 private String trailingQuote;
2223 private String trailingTripleQuote;
23- private String value;
24+
25+ /**
26+ * Property delimiters:
27+ * * /
28+ * / *
29+ * {-
30+ * -}
31+ * """
32+ * </summary> & <br>
33+ * }
34+ * }
35+ * }
36+ * }
37+ * }
38+ */
39+ @JsonProperty("value")
40+ public String getValue() { return value; }
41+ @JsonProperty("value")
42+ public void setValue(String value) { this.value = value; }
2443
2544 /**
2645 * Ends with a backslash \
@@ -45,23 +64,4 @@ public class TopLevel {
4564 public String getTrailingTripleQuote() { return trailingTripleQuote; }
4665 @JsonProperty("trailingTripleQuote")
4766 public void setTrailingTripleQuote(String value) { this.trailingTripleQuote = value; }
48-
49- /**
50- * Property delimiters:
51- * * /
52- * / *
53- * {-
54- * -}
55- * """
56- * </summary> & <br>
57- * }
58- * }
59- * }
60- * }
61- * }
62- */
63- @JsonProperty("value")
64- public String getValue() { return value; }
65- @JsonProperty("value")
66- public void setValue(String value) { this.value = value; }
6767 }
Mschema-java/test/inputs/schema/const-non-string.schema/default/src/main/java/io/quicktype/TopLevel.java+12 −12
@@ -3,17 +3,27 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6+ private double version;
67 private long amount;
8+ private double ratio;
79 private boolean enabled;
810 private Kind kind;
9- private double ratio;
10- private double version;
11+
12+ @JsonProperty("version")
13+ public double getVersion() { return version; }
14+ @JsonProperty("version")
15+ public void setVersion(double value) { this.version = value; }
1116
1217 @JsonProperty("amount")
1318 public long getAmount() { return amount; }
1419 @JsonProperty("amount")
1520 public void setAmount(long value) { this.amount = value; }
1621
22+ @JsonProperty("ratio")
23+ public double getRatio() { return ratio; }
24+ @JsonProperty("ratio")
25+ public void setRatio(double value) { this.ratio = value; }
26+
1727 @JsonProperty("enabled")
1828 public boolean getEnabled() { return enabled; }
1929 @JsonProperty("enabled")
@@ -23,14 +33,4 @@ public class TopLevel {
2333 public Kind getKind() { return kind; }
2434 @JsonProperty("kind")
2535 public void setKind(Kind value) { this.kind = value; }
26-
27- @JsonProperty("ratio")
28- public double getRatio() { return ratio; }
29- @JsonProperty("ratio")
30- public void setRatio(double value) { this.ratio = value; }
31-
32- @JsonProperty("version")
33- public double getVersion() { return version; }
34- @JsonProperty("version")
35- public void setVersion(double value) { this.version = value; }
3636 }
Mschema-java/test/inputs/schema/date-time-or-string.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,16 +4,16 @@ import com.fasterxml.jackson.annotation.*;
44 import java.time.OffsetDateTime;
55
66 public class TopLevel {
7- private BarUnion bar;
87 private String foo;
9-
10- @JsonProperty("bar")
11- public BarUnion getBar() { return bar; }
12- @JsonProperty("bar")
13- public void setBar(BarUnion value) { this.bar = value; }
8+ private BarUnion bar;
149
1510 @JsonProperty("foo")
1611 public String getFoo() { return foo; }
1712 @JsonProperty("foo")
1813 public void setFoo(String value) { this.foo = value; }
14+
15+ @JsonProperty("bar")
16+ public BarUnion getBar() { return bar; }
17+ @JsonProperty("bar")
18+ public void setBar(BarUnion value) { this.bar = value; }
1919 }
Mschema-java/test/inputs/schema/date-time.schema/default/src/main/java/io/quicktype/TopLevel.java+12 −12
@@ -7,34 +7,34 @@ import java.time.OffsetTime;
77 import java.util.List;
88
99 public class TopLevel {
10- private List<ComplexUnionArrayElement> complexUnionArray;
1110 private LocalDate date;
12- private OffsetDateTime dateTime;
1311 private OffsetTime time;
12+ private OffsetDateTime dateTime;
1413 private List<UnionArray> unionArray;
15-
16- @JsonProperty("complex-union-array")
17- public List<ComplexUnionArrayElement> getComplexUnionArray() { return complexUnionArray; }
18- @JsonProperty("complex-union-array")
19- public void setComplexUnionArray(List<ComplexUnionArrayElement> value) { this.complexUnionArray = value; }
14+ private List<ComplexUnionArrayElement> complexUnionArray;
2015
2116 @JsonProperty("date")
2217 public LocalDate getDate() { return date; }
2318 @JsonProperty("date")
2419 public void setDate(LocalDate value) { this.date = value; }
2520
26- @JsonProperty("date-time")
27- public OffsetDateTime getDateTime() { return dateTime; }
28- @JsonProperty("date-time")
29- public void setDateTime(OffsetDateTime value) { this.dateTime = value; }
30-
3121 @JsonProperty("time")
3222 public OffsetTime getTime() { return time; }
3323 @JsonProperty("time")
3424 public void setTime(OffsetTime value) { this.time = value; }
3525
26+ @JsonProperty("date-time")
27+ public OffsetDateTime getDateTime() { return dateTime; }
28+ @JsonProperty("date-time")
29+ public void setDateTime(OffsetDateTime value) { this.dateTime = value; }
30+
3631 @JsonProperty("union-array")
3732 public List<UnionArray> getUnionArray() { return unionArray; }
3833 @JsonProperty("union-array")
3934 public void setUnionArray(List<UnionArray> value) { this.unionArray = value; }
35+
36+ @JsonProperty("complex-union-array")
37+ public List<ComplexUnionArrayElement> getComplexUnionArray() { return complexUnionArray; }
38+ @JsonProperty("complex-union-array")
39+ public void setComplexUnionArray(List<ComplexUnionArrayElement> value) { this.complexUnionArray = value; }
4040 }
Mschema-java/test/inputs/schema/description.schema/default/src/main/java/io/quicktype/TopLevel.java+15 −15
@@ -7,19 +7,19 @@ import com.fasterxml.jackson.annotation.*;
77 * Its description has two lines.
88 */
99 public class TopLevel {
10- private Boolean bar;
10+ private Union union;
1111 private Enum topLevelEnum;
1212 private Double foo;
13+ private Boolean bar;
1314 private ObjectOrStringUnion objectOrString;
14- private Union union;
1515
1616 /**
17- * A pretty boolean
17+ * Either a number or a string
1818 */
19- @JsonProperty("bar")
20- public Boolean getBar() { return bar; }
21- @JsonProperty("bar")
22- public void setBar(Boolean value) { this.bar = value; }
19+ @JsonProperty("union")
20+ public Union getUnion() { return union; }
21+ @JsonProperty("union")
22+ public void setUnion(Union value) { this.union = value; }
2323
2424 /**
2525 * An enumeration
@@ -34,16 +34,16 @@ public class TopLevel {
3434 @JsonProperty("foo")
3535 public void setFoo(Double value) { this.foo = value; }
3636
37+ /**
38+ * A pretty boolean
39+ */
40+ @JsonProperty("bar")
41+ public Boolean getBar() { return bar; }
42+ @JsonProperty("bar")
43+ public void setBar(Boolean value) { this.bar = value; }
44+
3745 @JsonProperty("object-or-string")
3846 public ObjectOrStringUnion getObjectOrString() { return objectOrString; }
3947 @JsonProperty("object-or-string")
4048 public void setObjectOrString(ObjectOrStringUnion value) { this.objectOrString = value; }
41-
42- /**
43- * Either a number or a string
44- */
45- @JsonProperty("union")
46- public Union getUnion() { return union; }
47- @JsonProperty("union")
48- public void setUnion(Union value) { this.union = value; }
4949 }
Mschema-java/test/inputs/schema/direct-union.schema/default/src/main/java/io/quicktype/Thing.java+6 −6
@@ -5,16 +5,16 @@ import java.util.List;
55 import java.util.Map;
66
77 public class Thing {
8- private Anything optional;
98 private Anything required;
10-
11- @JsonProperty("optional")
12- public Anything getOptional() { return optional; }
13- @JsonProperty("optional")
14- public void setOptional(Anything value) { this.optional = value; }
9+ private Anything optional;
1510
1611 @JsonProperty("required")
1712 public Anything getRequired() { return required; }
1813 @JsonProperty("required")
1914 public void setRequired(Anything value) { this.required = value; }
15+
16+ @JsonProperty("optional")
17+ public Anything getOptional() { return optional; }
18+ @JsonProperty("optional")
19+ public void setOptional(Anything value) { this.optional = value; }
2020 }
Mschema-java/test/inputs/schema/enum.schema/default/src/main/java/io/quicktype/TopLevel.java+16 −16
@@ -4,34 +4,34 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<Arr> arr;
8- private String topLevelFor;
9- private Gve gve;
107 private Lvc lvc;
8+ private Gve gve;
9+ private List<Arr> arr;
1110 private List<OtherArr> otherArr;
11+ private String topLevelFor;
1212
13- @JsonProperty("arr")
14- public List<Arr> getArr() { return arr; }
15- @JsonProperty("arr")
16- public void setArr(List<Arr> value) { this.arr = value; }
17-
18- @JsonProperty("for")
19- public String getTopLevelFor() { return topLevelFor; }
20- @JsonProperty("for")
21- public void setTopLevelFor(String value) { this.topLevelFor = value; }
13+ @JsonProperty("lvc")
14+ public Lvc getLvc() { return lvc; }
15+ @JsonProperty("lvc")
16+ public void setLvc(Lvc value) { this.lvc = value; }
2217
2318 @JsonProperty("gve")
2419 public Gve getGve() { return gve; }
2520 @JsonProperty("gve")
2621 public void setGve(Gve value) { this.gve = value; }
2722
28- @JsonProperty("lvc")
29- public Lvc getLvc() { return lvc; }
30- @JsonProperty("lvc")
31- public void setLvc(Lvc value) { this.lvc = value; }
23+ @JsonProperty("arr")
24+ public List<Arr> getArr() { return arr; }
25+ @JsonProperty("arr")
26+ public void setArr(List<Arr> value) { this.arr = value; }
3227
3328 @JsonProperty("otherArr")
3429 public List<OtherArr> getOtherArr() { return otherArr; }
3530 @JsonProperty("otherArr")
3631 public void setOtherArr(List<OtherArr> value) { this.otherArr = value; }
32+
33+ @JsonProperty("for")
34+ public String getTopLevelFor() { return topLevelFor; }
35+ @JsonProperty("for")
36+ public void setTopLevelFor(String value) { this.topLevelFor = value; }
3737 }
Mschema-java/test/inputs/schema/integer-string.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -4,29 +4,14 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<String> arrNullable;
8- private List<String> arrOne;
9- private String nullable;
107 private String one;
118 private String optional;
9+ private String nullable;
10+ private List<String> arrOne;
11+ private List<String> arrNullable;
1212 private UnionWithInt unionWithInt;
1313 private UnionWithInt unionWithIntAndEnum;
1414
15- @JsonProperty("arrNullable")
16- public List<String> getArrNullable() { return arrNullable; }
17- @JsonProperty("arrNullable")
18- public void setArrNullable(List<String> value) { this.arrNullable = value; }
19-
20- @JsonProperty("arrOne")
21- public List<String> getArrOne() { return arrOne; }
22- @JsonProperty("arrOne")
23- public void setArrOne(List<String> value) { this.arrOne = value; }
24-
25- @JsonProperty("nullable")
26- public String getNullable() { return nullable; }
27- @JsonProperty("nullable")
28- public void setNullable(String value) { this.nullable = value; }
29-
3015 @JsonProperty("one")
3116 public String getOne() { return one; }
3217 @JsonProperty("one")
@@ -37,6 +22,21 @@ public class TopLevel {
3722 @JsonProperty("optional")
3823 public void setOptional(String value) { this.optional = value; }
3924
25+ @JsonProperty("nullable")
26+ public String getNullable() { return nullable; }
27+ @JsonProperty("nullable")
28+ public void setNullable(String value) { this.nullable = value; }
29+
30+ @JsonProperty("arrOne")
31+ public List<String> getArrOne() { return arrOne; }
32+ @JsonProperty("arrOne")
33+ public void setArrOne(List<String> value) { this.arrOne = value; }
34+
35+ @JsonProperty("arrNullable")
36+ public List<String> getArrNullable() { return arrNullable; }
37+ @JsonProperty("arrNullable")
38+ public void setArrNullable(List<String> value) { this.arrNullable = value; }
39+
4040 @JsonProperty("unionWithInt")
4141 public UnionWithInt getUnionWithInt() { return unionWithInt; }
4242 @JsonProperty("unionWithInt")
Mschema-java/test/inputs/schema/integer-type.schema/default/src/main/java/io/quicktype/TopLevel.java+29 −29
@@ -3,15 +3,30 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6+ private long smallPositive;
7+ private long smallNegative;
8+ private long i32Range;
69 private long aboveI32Max;
710 private long belowI32Min;
8- private long i32Range;
9- private long largeBounds;
10- private long onlyMaximum;
1111 private long onlyMinimum;
12- private long smallNegative;
13- private long smallPositive;
12+ private long onlyMaximum;
1413 private long unbounded;
14+ private long largeBounds;
15+
16+ @JsonProperty("small_positive")
17+ public long getSmallPositive() { return smallPositive; }
18+ @JsonProperty("small_positive")
19+ public void setSmallPositive(long value) { this.smallPositive = value; }
20+
21+ @JsonProperty("small_negative")
22+ public long getSmallNegative() { return smallNegative; }
23+ @JsonProperty("small_negative")
24+ public void setSmallNegative(long value) { this.smallNegative = value; }
25+
26+ @JsonProperty("i32_range")
27+ public long getI32Range() { return i32Range; }
28+ @JsonProperty("i32_range")
29+ public void setI32Range(long value) { this.i32Range = value; }
1530
1631 @JsonProperty("above_i32_max")
1732 public long getAboveI32Max() { return aboveI32Max; }
@@ -23,38 +38,23 @@ public class TopLevel {
2338 @JsonProperty("below_i32_min")
2439 public void setBelowI32Min(long value) { this.belowI32Min = value; }
2540
26- @JsonProperty("i32_range")
27- public long getI32Range() { return i32Range; }
28- @JsonProperty("i32_range")
29- public void setI32Range(long value) { this.i32Range = value; }
30-
31- @JsonProperty("large_bounds")
32- public long getLargeBounds() { return largeBounds; }
33- @JsonProperty("large_bounds")
34- public void setLargeBounds(long value) { this.largeBounds = value; }
35-
36- @JsonProperty("only_maximum")
37- public long getOnlyMaximum() { return onlyMaximum; }
38- @JsonProperty("only_maximum")
39- public void setOnlyMaximum(long value) { this.onlyMaximum = value; }
40-
4141 @JsonProperty("only_minimum")
4242 public long getOnlyMinimum() { return onlyMinimum; }
4343 @JsonProperty("only_minimum")
4444 public void setOnlyMinimum(long value) { this.onlyMinimum = value; }
4545
46- @JsonProperty("small_negative")
47- public long getSmallNegative() { return smallNegative; }
48- @JsonProperty("small_negative")
49- public void setSmallNegative(long value) { this.smallNegative = value; }
50-
51- @JsonProperty("small_positive")
52- public long getSmallPositive() { return smallPositive; }
53- @JsonProperty("small_positive")
54- public void setSmallPositive(long value) { this.smallPositive = value; }
46+ @JsonProperty("only_maximum")
47+ public long getOnlyMaximum() { return onlyMaximum; }
48+ @JsonProperty("only_maximum")
49+ public void setOnlyMaximum(long value) { this.onlyMaximum = value; }
5550
5651 @JsonProperty("unbounded")
5752 public long getUnbounded() { return unbounded; }
5853 @JsonProperty("unbounded")
5954 public void setUnbounded(long value) { this.unbounded = value; }
55+
56+ @JsonProperty("large_bounds")
57+ public long getLargeBounds() { return largeBounds; }
58+ @JsonProperty("large_bounds")
59+ public void setLargeBounds(long value) { this.largeBounds = value; }
6060 }
Mschema-java/test/inputs/schema/light.schema/default/src/main/java/io/quicktype/LightParams.java+6 −6
@@ -3,20 +3,20 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class LightParams {
6- private String appID;
76 private String outletID;
7+ private String appID;
88 private String rgba;
99
10- @JsonProperty("app_id")
11- public String getAppID() { return appID; }
12- @JsonProperty("app_id")
13- public void setAppID(String value) { this.appID = value; }
14-
1510 @JsonProperty("outlet_id")
1611 public String getOutletID() { return outletID; }
1712 @JsonProperty("outlet_id")
1813 public void setOutletID(String value) { this.outletID = value; }
1914
15+ @JsonProperty("app_id")
16+ public String getAppID() { return appID; }
17+ @JsonProperty("app_id")
18+ public void setAppID(String value) { this.appID = value; }
19+
2020 @JsonProperty("rgba")
2121 public String getRGBA() { return rgba; }
2222 @JsonProperty("rgba")
Mschema-java/test/inputs/schema/min-max-items.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,12 +4,17 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7+ private List<String> minOnly;
78 private List<Long> maxOnly;
89 private List<Double> minAndMax;
9- private List<String> minOnly;
1010 private List<String> plain;
1111 private List<UnionItem> unionItems;
1212
13+ @JsonProperty("minOnly")
14+ public List<String> getMinOnly() { return minOnly; }
15+ @JsonProperty("minOnly")
16+ public void setMinOnly(List<String> value) { this.minOnly = value; }
17+
1318 @JsonProperty("maxOnly")
1419 public List<Long> getMaxOnly() { return maxOnly; }
1520 @JsonProperty("maxOnly")
@@ -20,11 +25,6 @@ public class TopLevel {
2025 @JsonProperty("minAndMax")
2126 public void setMinAndMax(List<Double> value) { this.minAndMax = value; }
2227
23- @JsonProperty("minOnly")
24- public List<String> getMinOnly() { return minOnly; }
25- @JsonProperty("minOnly")
26- public void setMinOnly(List<String> value) { this.minOnly = value; }
27-
2828 @JsonProperty("plain")
2929 public List<String> getPlain() { return plain; }
3030 @JsonProperty("plain")
Mschema-java/test/inputs/schema/minmax-integer.schema/default/src/main/java/io/quicktype/TopLevel.java+21 −21
@@ -4,51 +4,51 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
66 private long free;
7- private long intersection;
8- private long max;
97 private long min;
8+ private long max;
109 private long minmax;
11- private long minMaxIntersection;
12- private long minMaxUnion;
1310 private long union;
11+ private long minMaxUnion;
12+ private long intersection;
13+ private long minMaxIntersection;
1414
1515 @JsonProperty("free")
1616 public long getFree() { return free; }
1717 @JsonProperty("free")
1818 public void setFree(long value) { this.free = value; }
1919
20- @JsonProperty("intersection")
21- public long getIntersection() { return intersection; }
22- @JsonProperty("intersection")
23- public void setIntersection(long value) { this.intersection = value; }
20+ @JsonProperty("min")
21+ public long getMin() { return min; }
22+ @JsonProperty("min")
23+ public void setMin(long value) { this.min = value; }
2424
2525 @JsonProperty("max")
2626 public long getMax() { return max; }
2727 @JsonProperty("max")
2828 public void setMax(long value) { this.max = value; }
2929
30- @JsonProperty("min")
31- public long getMin() { return min; }
32- @JsonProperty("min")
33- public void setMin(long value) { this.min = value; }
34-
3530 @JsonProperty("minmax")
3631 public long getMinmax() { return minmax; }
3732 @JsonProperty("minmax")
3833 public void setMinmax(long value) { this.minmax = value; }
3934
40- @JsonProperty("minMaxIntersection")
41- public long getMinMaxIntersection() { return minMaxIntersection; }
42- @JsonProperty("minMaxIntersection")
43- public void setMinMaxIntersection(long value) { this.minMaxIntersection = value; }
35+ @JsonProperty("union")
36+ public long getUnion() { return union; }
37+ @JsonProperty("union")
38+ public void setUnion(long value) { this.union = value; }
4439
4540 @JsonProperty("minMaxUnion")
4641 public long getMinMaxUnion() { return minMaxUnion; }
4742 @JsonProperty("minMaxUnion")
4843 public void setMinMaxUnion(long value) { this.minMaxUnion = value; }
4944
50- @JsonProperty("union")
51- public long getUnion() { return union; }
52- @JsonProperty("union")
53- public void setUnion(long value) { this.union = value; }
45+ @JsonProperty("intersection")
46+ public long getIntersection() { return intersection; }
47+ @JsonProperty("intersection")
48+ public void setIntersection(long value) { this.intersection = value; }
49+
50+ @JsonProperty("minMaxIntersection")
51+ public long getMinMaxIntersection() { return minMaxIntersection; }
52+ @JsonProperty("minMaxIntersection")
53+ public void setMinMaxIntersection(long value) { this.minMaxIntersection = value; }
5454 }
Mschema-java/test/inputs/schema/minmax.schema/default/src/main/java/io/quicktype/TopLevel.java+21 −21
@@ -4,51 +4,51 @@ import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
66 private double free;
7- private double intersection;
8- private double max;
97 private double min;
8+ private double max;
109 private double minmax;
11- private double minMaxIntersection;
12- private double minMaxUnion;
1310 private double union;
11+ private double minMaxUnion;
12+ private double intersection;
13+ private double minMaxIntersection;
1414
1515 @JsonProperty("free")
1616 public double getFree() { return free; }
1717 @JsonProperty("free")
1818 public void setFree(double value) { this.free = value; }
1919
20- @JsonProperty("intersection")
21- public double getIntersection() { return intersection; }
22- @JsonProperty("intersection")
23- public void setIntersection(double value) { this.intersection = value; }
20+ @JsonProperty("min")
21+ public double getMin() { return min; }
22+ @JsonProperty("min")
23+ public void setMin(double value) { this.min = value; }
2424
2525 @JsonProperty("max")
2626 public double getMax() { return max; }
2727 @JsonProperty("max")
2828 public void setMax(double value) { this.max = value; }
2929
30- @JsonProperty("min")
31- public double getMin() { return min; }
32- @JsonProperty("min")
33- public void setMin(double value) { this.min = value; }
34-
3530 @JsonProperty("minmax")
3631 public double getMinmax() { return minmax; }
3732 @JsonProperty("minmax")
3833 public void setMinmax(double value) { this.minmax = value; }
3934
40- @JsonProperty("minMaxIntersection")
41- public double getMinMaxIntersection() { return minMaxIntersection; }
42- @JsonProperty("minMaxIntersection")
43- public void setMinMaxIntersection(double value) { this.minMaxIntersection = value; }
35+ @JsonProperty("union")
36+ public double getUnion() { return union; }
37+ @JsonProperty("union")
38+ public void setUnion(double value) { this.union = value; }
4439
4540 @JsonProperty("minMaxUnion")
4641 public double getMinMaxUnion() { return minMaxUnion; }
4742 @JsonProperty("minMaxUnion")
4843 public void setMinMaxUnion(double value) { this.minMaxUnion = value; }
4944
50- @JsonProperty("union")
51- public double getUnion() { return union; }
52- @JsonProperty("union")
53- public void setUnion(double value) { this.union = value; }
45+ @JsonProperty("intersection")
46+ public double getIntersection() { return intersection; }
47+ @JsonProperty("intersection")
48+ public void setIntersection(double value) { this.intersection = value; }
49+
50+ @JsonProperty("minMaxIntersection")
51+ public double getMinMaxIntersection() { return minMaxIntersection; }
52+ @JsonProperty("minMaxIntersection")
53+ public void setMinMaxIntersection(double value) { this.minMaxIntersection = value; }
5454 }
Mschema-java/test/inputs/schema/minmaxlength.schema/default/src/main/java/io/quicktype/TopLevel.java+28 −28
@@ -3,52 +3,52 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private String intersection;
7- private InUnion inUnion;
8- private String maxlength;
96 private String minlength;
10- private String minMaxIntersection;
7+ private String maxlength;
118 private String minmaxlength;
12- private String minMaxUnion;
139 private String union;
14-
15- @JsonProperty("intersection")
16- public String getIntersection() { return intersection; }
17- @JsonProperty("intersection")
18- public void setIntersection(String value) { this.intersection = value; }
19-
20- @JsonProperty("inUnion")
21- public InUnion getInUnion() { return inUnion; }
22- @JsonProperty("inUnion")
23- public void setInUnion(InUnion value) { this.inUnion = value; }
24-
25- @JsonProperty("maxlength")
26- public String getMaxlength() { return maxlength; }
27- @JsonProperty("maxlength")
28- public void setMaxlength(String value) { this.maxlength = value; }
10+ private InUnion inUnion;
11+ private String minMaxUnion;
12+ private String intersection;
13+ private String minMaxIntersection;
2914
3015 @JsonProperty("minlength")
3116 public String getMinlength() { return minlength; }
3217 @JsonProperty("minlength")
3318 public void setMinlength(String value) { this.minlength = value; }
3419
35- @JsonProperty("minMaxIntersection")
36- public String getMinMaxIntersection() { return minMaxIntersection; }
37- @JsonProperty("minMaxIntersection")
38- public void setMinMaxIntersection(String value) { this.minMaxIntersection = value; }
20+ @JsonProperty("maxlength")
21+ public String getMaxlength() { return maxlength; }
22+ @JsonProperty("maxlength")
23+ public void setMaxlength(String value) { this.maxlength = value; }
3924
4025 @JsonProperty("minmaxlength")
4126 public String getMinmaxlength() { return minmaxlength; }
4227 @JsonProperty("minmaxlength")
4328 public void setMinmaxlength(String value) { this.minmaxlength = value; }
4429
30+ @JsonProperty("union")
31+ public String getUnion() { return union; }
32+ @JsonProperty("union")
33+ public void setUnion(String value) { this.union = value; }
34+
35+ @JsonProperty("inUnion")
36+ public InUnion getInUnion() { return inUnion; }
37+ @JsonProperty("inUnion")
38+ public void setInUnion(InUnion value) { this.inUnion = value; }
39+
4540 @JsonProperty("minMaxUnion")
4641 public String getMinMaxUnion() { return minMaxUnion; }
4742 @JsonProperty("minMaxUnion")
4843 public void setMinMaxUnion(String value) { this.minMaxUnion = value; }
4944
50- @JsonProperty("union")
51- public String getUnion() { return union; }
52- @JsonProperty("union")
53- public void setUnion(String value) { this.union = value; }
45+ @JsonProperty("intersection")
46+ public String getIntersection() { return intersection; }
47+ @JsonProperty("intersection")
48+ public void setIntersection(String value) { this.intersection = value; }
49+
50+ @JsonProperty("minMaxIntersection")
51+ public String getMinMaxIntersection() { return minMaxIntersection; }
52+ @JsonProperty("minMaxIntersection")
53+ public void setMinMaxIntersection(String value) { this.minMaxIntersection = value; }
5454 }
Mschema-java/test/inputs/schema/non-standard-ref.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,20 +3,20 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private long bar;
76 private long foo;
7+ private long bar;
88 private boolean quux;
99
10- @JsonProperty("bar")
11- public long getBar() { return bar; }
12- @JsonProperty("bar")
13- public void setBar(long value) { this.bar = value; }
14-
1510 @JsonProperty("foo")
1611 public long getFoo() { return foo; }
1712 @JsonProperty("foo")
1813 public void setFoo(long value) { this.foo = value; }
1914
15+ @JsonProperty("bar")
16+ public long getBar() { return bar; }
17+ @JsonProperty("bar")
18+ public void setBar(long value) { this.bar = value; }
19+
2020 @JsonProperty("quux")
2121 public boolean getQuux() { return quux; }
2222 @JsonProperty("quux")
Mschema-java/test/inputs/schema/nullable-optional-one-of.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private String b;
76 private Kind kind;
8-
9- @JsonProperty("b")
10- public String getB() { return b; }
11- @JsonProperty("b")
12- public void setB(String value) { this.b = value; }
7+ private String b;
138
149 @JsonProperty("kind")
1510 public Kind getKind() { return kind; }
1611 @JsonProperty("kind")
1712 public void setKind(Kind value) { this.kind = value; }
13+
14+ @JsonProperty("b")
15+ public String getB() { return b; }
16+ @JsonProperty("b")
17+ public void setB(String value) { this.b = value; }
1818 }
Mschema-java/test/inputs/schema/optional-any.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private boolean bar;
76 private Object foo;
8-
9- @JsonProperty("bar")
10- public boolean getBar() { return bar; }
11- @JsonProperty("bar")
12- public void setBar(boolean value) { this.bar = value; }
7+ private boolean bar;
138
149 @JsonProperty("foo")
1510 public Object getFoo() { return foo; }
1611 @JsonProperty("foo")
1712 public void setFoo(Object value) { this.foo = value; }
13+
14+ @JsonProperty("bar")
15+ public boolean getBar() { return bar; }
16+ @JsonProperty("bar")
17+ public void setBar(boolean value) { this.bar = value; }
1818 }
Mschema-java/test/inputs/schema/optional-const-ref.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -5,45 +5,45 @@ import java.util.List;
55
66 public class TopLevel {
77 private List<Coordinate> coordinates;
8- private Long count;
9- private String label;
108 private List<Coordinate> requiredCoordinates;
9+ private Long count;
1110 private long requiredCount;
12- private String requiredLabel;
1311 private Double weight;
12+ private String label;
13+ private String requiredLabel;
1414
1515 @JsonProperty("coordinates")
1616 public List<Coordinate> getCoordinates() { return coordinates; }
1717 @JsonProperty("coordinates")
1818 public void setCoordinates(List<Coordinate> value) { this.coordinates = value; }
1919
20- @JsonProperty("count")
21- public Long getCount() { return count; }
22- @JsonProperty("count")
23- public void setCount(Long value) { this.count = value; }
24-
25- @JsonProperty("label")
26- public String getLabel() { return label; }
27- @JsonProperty("label")
28- public void setLabel(String value) { this.label = value; }
29-
3020 @JsonProperty("requiredCoordinates")
3121 public List<Coordinate> getRequiredCoordinates() { return requiredCoordinates; }
3222 @JsonProperty("requiredCoordinates")
3323 public void setRequiredCoordinates(List<Coordinate> value) { this.requiredCoordinates = value; }
3424
25+ @JsonProperty("count")
26+ public Long getCount() { return count; }
27+ @JsonProperty("count")
28+ public void setCount(Long value) { this.count = value; }
29+
3530 @JsonProperty("requiredCount")
3631 public long getRequiredCount() { return requiredCount; }
3732 @JsonProperty("requiredCount")
3833 public void setRequiredCount(long value) { this.requiredCount = value; }
3934
40- @JsonProperty("requiredLabel")
41- public String getRequiredLabel() { return requiredLabel; }
42- @JsonProperty("requiredLabel")
43- public void setRequiredLabel(String value) { this.requiredLabel = value; }
44-
4535 @JsonProperty("weight")
4636 public Double getWeight() { return weight; }
4737 @JsonProperty("weight")
4838 public void setWeight(Double value) { this.weight = value; }
39+
40+ @JsonProperty("label")
41+ public String getLabel() { return label; }
42+ @JsonProperty("label")
43+ public void setLabel(String value) { this.label = value; }
44+
45+ @JsonProperty("requiredLabel")
46+ public String getRequiredLabel() { return requiredLabel; }
47+ @JsonProperty("requiredLabel")
48+ public void setRequiredLabel(String value) { this.requiredLabel = value; }
4949 }
Mschema-java/test/inputs/schema/optional-constraints.schema/default/src/main/java/io/quicktype/TopLevel.java+15 −15
@@ -3,34 +3,34 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private Double optDouble;
6+ private long reqZeroMin;
77 private Long optInt;
8- private String optPattern;
8+ private Double optDouble;
99 private String optString;
10- private long reqZeroMin;
10+ private String optPattern;
1111
12- @JsonProperty("optDouble")
13- public Double getOptDouble() { return optDouble; }
14- @JsonProperty("optDouble")
15- public void setOptDouble(Double value) { this.optDouble = value; }
12+ @JsonProperty("reqZeroMin")
13+ public long getReqZeroMin() { return reqZeroMin; }
14+ @JsonProperty("reqZeroMin")
15+ public void setReqZeroMin(long value) { this.reqZeroMin = value; }
1616
1717 @JsonProperty("optInt")
1818 public Long getOptInt() { return optInt; }
1919 @JsonProperty("optInt")
2020 public void setOptInt(Long value) { this.optInt = value; }
2121
22- @JsonProperty("optPattern")
23- public String getOptPattern() { return optPattern; }
24- @JsonProperty("optPattern")
25- public void setOptPattern(String value) { this.optPattern = value; }
22+ @JsonProperty("optDouble")
23+ public Double getOptDouble() { return optDouble; }
24+ @JsonProperty("optDouble")
25+ public void setOptDouble(Double value) { this.optDouble = value; }
2626
2727 @JsonProperty("optString")
2828 public String getOptString() { return optString; }
2929 @JsonProperty("optString")
3030 public void setOptString(String value) { this.optString = value; }
3131
32- @JsonProperty("reqZeroMin")
33- public long getReqZeroMin() { return reqZeroMin; }
34- @JsonProperty("reqZeroMin")
35- public void setReqZeroMin(long value) { this.reqZeroMin = value; }
32+ @JsonProperty("optPattern")
33+ public String getOptPattern() { return optPattern; }
34+ @JsonProperty("optPattern")
35+ public void setOptPattern(String value) { this.optPattern = value; }
3636 }
Mschema-java/test/inputs/schema/optional-date-time.schema/default/src/main/java/io/quicktype/TopLevel.java+23 −23
@@ -6,40 +6,40 @@ import java.time.OffsetDateTime;
66 import java.time.OffsetTime;
77
88 public class TopLevel {
9- private LocalDate optionalDate;
10- private OffsetDateTime optionalDateTime;
11- private OffsetTime optionalTime;
129 private LocalDate requiredDate;
13- private OffsetDateTime requiredDateTime;
1410 private OffsetTime requiredTime;
15-
16- @JsonProperty("optional-date")
17- public LocalDate getOptionalDate() { return optionalDate; }
18- @JsonProperty("optional-date")
19- public void setOptionalDate(LocalDate value) { this.optionalDate = value; }
20-
21- @JsonProperty("optional-date-time")
22- public OffsetDateTime getOptionalDateTime() { return optionalDateTime; }
23- @JsonProperty("optional-date-time")
24- public void setOptionalDateTime(OffsetDateTime value) { this.optionalDateTime = value; }
25-
26- @JsonProperty("optional-time")
27- public OffsetTime getOptionalTime() { return optionalTime; }
28- @JsonProperty("optional-time")
29- public void setOptionalTime(OffsetTime value) { this.optionalTime = value; }
11+ private OffsetDateTime requiredDateTime;
12+ private LocalDate optionalDate;
13+ private OffsetTime optionalTime;
14+ private OffsetDateTime optionalDateTime;
3015
3116 @JsonProperty("required-date")
3217 public LocalDate getRequiredDate() { return requiredDate; }
3318 @JsonProperty("required-date")
3419 public void setRequiredDate(LocalDate value) { this.requiredDate = value; }
3520
21+ @JsonProperty("required-time")
22+ public OffsetTime getRequiredTime() { return requiredTime; }
23+ @JsonProperty("required-time")
24+ public void setRequiredTime(OffsetTime value) { this.requiredTime = value; }
25+
3626 @JsonProperty("required-date-time")
3727 public OffsetDateTime getRequiredDateTime() { return requiredDateTime; }
3828 @JsonProperty("required-date-time")
3929 public void setRequiredDateTime(OffsetDateTime value) { this.requiredDateTime = value; }
4030
41- @JsonProperty("required-time")
42- public OffsetTime getRequiredTime() { return requiredTime; }
43- @JsonProperty("required-time")
44- public void setRequiredTime(OffsetTime value) { this.requiredTime = value; }
31+ @JsonProperty("optional-date")
32+ public LocalDate getOptionalDate() { return optionalDate; }
33+ @JsonProperty("optional-date")
34+ public void setOptionalDate(LocalDate value) { this.optionalDate = value; }
35+
36+ @JsonProperty("optional-time")
37+ public OffsetTime getOptionalTime() { return optionalTime; }
38+ @JsonProperty("optional-time")
39+ public void setOptionalTime(OffsetTime value) { this.optionalTime = value; }
40+
41+ @JsonProperty("optional-date-time")
42+ public OffsetDateTime getOptionalDateTime() { return optionalDateTime; }
43+ @JsonProperty("optional-date-time")
44+ public void setOptionalDateTime(OffsetDateTime value) { this.optionalDateTime = value; }
4545 }
Mschema-java/test/inputs/schema/prefix-items.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -4,16 +4,16 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class TopLevel {
7- private List<Open> open;
87 private List<Open> tuple;
9-
10- @JsonProperty("open")
11- public List<Open> getOpen() { return open; }
12- @JsonProperty("open")
13- public void setOpen(List<Open> value) { this.open = value; }
8+ private List<Open> open;
149
1510 @JsonProperty("tuple")
1611 public List<Open> getTuple() { return tuple; }
1712 @JsonProperty("tuple")
1813 public void setTuple(List<Open> value) { this.tuple = value; }
14+
15+ @JsonProperty("open")
16+ public List<Open> getOpen() { return open; }
17+ @JsonProperty("open")
18+ public void setOpen(List<Open> value) { this.open = value; }
1919 }
Aschema-java/test/inputs/schema/property-order.schema/default/src/main/java/io/quicktype/Converter.java+101 −0
@@ -0,0 +1,101 @@
1+// To use this code, add the following Maven dependency to your project:
2+//
3+//
4+// com.fasterxml.jackson.core : jackson-databind : 2.9.0
5+// com.fasterxml.jackson.datatype : jackson-datatype-jsr310 : 2.9.0
6+//
7+// Import this package:
8+//
9+// import io.quicktype.Converter;
10+//
11+// Then you can deserialize a JSON string with
12+//
13+// TopLevel data = Converter.fromJsonString(jsonString);
14+
15+package io.quicktype;
16+
17+import java.io.IOException;
18+import com.fasterxml.jackson.databind.*;
19+import com.fasterxml.jackson.databind.module.SimpleModule;
20+import com.fasterxml.jackson.core.JsonParser;
21+import com.fasterxml.jackson.core.JsonProcessingException;
22+import java.util.*;
23+import java.time.LocalDate;
24+import java.time.OffsetDateTime;
25+import java.time.OffsetTime;
26+import java.time.ZoneOffset;
27+import java.time.ZonedDateTime;
28+import java.time.format.DateTimeFormatter;
29+import java.time.format.DateTimeFormatterBuilder;
30+import java.time.temporal.ChronoField;
31+
32+public class Converter {
33+ // Date-time helpers
34+
35+ private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()
36+ .appendOptional(DateTimeFormatter.ISO_DATE_TIME)
37+ .appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
38+ .appendOptional(DateTimeFormatter.ISO_INSTANT)
39+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SX"))
40+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"))
41+ .appendOptional(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
42+ .toFormatter()
43+ .withZone(ZoneOffset.UTC);
44+
45+ public static OffsetDateTime parseDateTimeString(String str) {
46+ return ZonedDateTime.from(Converter.DATE_TIME_FORMATTER.parse(str)).toOffsetDateTime();
47+ }
48+
49+ private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
50+ .appendOptional(DateTimeFormatter.ISO_TIME)
51+ .appendOptional(DateTimeFormatter.ISO_OFFSET_TIME)
52+ .parseDefaulting(ChronoField.YEAR, 2020)
53+ .parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
54+ .parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
55+ .toFormatter()
56+ .withZone(ZoneOffset.UTC);
57+
58+ public static OffsetTime parseTimeString(String str) {
59+ return ZonedDateTime.from(Converter.TIME_FORMATTER.parse(str)).toOffsetDateTime().toOffsetTime();
60+ }
61+ // Serialize/deserialize helpers
62+
63+ public static TopLevel fromJsonString(String json) throws IOException {
64+ return getObjectReader().readValue(json);
65+ }
66+
67+ public static String toJsonString(TopLevel obj) throws JsonProcessingException {
68+ return getObjectWriter().writeValueAsString(obj);
69+ }
70+
71+ private static ObjectReader reader;
72+ private static ObjectWriter writer;
73+
74+ private static void instantiateMapper() {
75+ ObjectMapper mapper = new ObjectMapper();
76+ mapper.findAndRegisterModules();
77+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
78+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
79+ SimpleModule module = new SimpleModule();
80+ module.addDeserializer(OffsetDateTime.class, new JsonDeserializer<OffsetDateTime>() {
81+ @Override
82+ public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
83+ String value = jsonParser.getText();
84+ return Converter.parseDateTimeString(value);
85+ }
86+ });
87+ mapper.registerModule(module);
88+ reader = mapper.readerFor(TopLevel.class);
89+ writer = mapper.writerFor(TopLevel.class);
90+ }
91+
92+ private static ObjectReader getObjectReader() {
93+ if (reader == null) instantiateMapper();
94+ return reader;
95+ }
96+
97+ private static ObjectWriter getObjectWriter() {
98+ if (writer == null) instantiateMapper();
99+ return writer;
100+ }
101+}
Aschema-java/test/inputs/schema/property-order.schema/default/src/main/java/io/quicktype/Ordered.java+24 −0
@@ -0,0 +1,24 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class Ordered {
6+ private double mango;
7+ private String zebra;
8+ private boolean apple;
9+
10+ @JsonProperty("mango")
11+ public double getMango() { return mango; }
12+ @JsonProperty("mango")
13+ public void setMango(double value) { this.mango = value; }
14+
15+ @JsonProperty("zebra")
16+ public String getZebra() { return zebra; }
17+ @JsonProperty("zebra")
18+ public void setZebra(String value) { this.zebra = value; }
19+
20+ @JsonProperty("apple")
21+ public boolean getApple() { return apple; }
22+ @JsonProperty("apple")
23+ public void setApple(boolean value) { this.apple = value; }
24+}
Aschema-java/test/inputs/schema/property-order.schema/default/src/main/java/io/quicktype/TopLevel.java+42 −0
@@ -0,0 +1,42 @@
1+package io.quicktype;
2+
3+import com.fasterxml.jackson.annotation.*;
4+
5+public class TopLevel {
6+ private String zebra;
7+ private double mango;
8+ private boolean apple;
9+ private String delta;
10+ private long banana;
11+ private Ordered ordered;
12+
13+ @JsonProperty("zebra")
14+ public String getZebra() { return zebra; }
15+ @JsonProperty("zebra")
16+ public void setZebra(String value) { this.zebra = value; }
17+
18+ @JsonProperty("mango")
19+ public double getMango() { return mango; }
20+ @JsonProperty("mango")
21+ public void setMango(double value) { this.mango = value; }
22+
23+ @JsonProperty("apple")
24+ public boolean getApple() { return apple; }
25+ @JsonProperty("apple")
26+ public void setApple(boolean value) { this.apple = value; }
27+
28+ @JsonProperty("delta")
29+ public String getDelta() { return delta; }
30+ @JsonProperty("delta")
31+ public void setDelta(String value) { this.delta = value; }
32+
33+ @JsonProperty("banana")
34+ public long getBanana() { return banana; }
35+ @JsonProperty("banana")
36+ public void setBanana(long value) { this.banana = value; }
37+
38+ @JsonProperty("ordered")
39+ public Ordered getOrdered() { return ordered; }
40+ @JsonProperty("ordered")
41+ public void setOrdered(Ordered value) { this.ordered = value; }
42+}
Mschema-java/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Berry.java+6 −6
@@ -4,20 +4,20 @@ import com.fasterxml.jackson.annotation.*;
44 import java.util.List;
55
66 public class Berry {
7- private Color color;
87 private String name;
8+ private Color color;
99 private List<Shape> shapes;
1010
11- @JsonProperty("color")
12- public Color getColor() { return color; }
13- @JsonProperty("color")
14- public void setColor(Color value) { this.color = value; }
15-
1611 @JsonProperty("name")
1712 public String getName() { return name; }
1813 @JsonProperty("name")
1914 public void setName(String value) { this.name = value; }
2015
16+ @JsonProperty("color")
17+ public Color getColor() { return color; }
18+ @JsonProperty("color")
19+ public void setColor(Color value) { this.color = value; }
20+
2121 @JsonProperty("shapes")
2222 public List<Shape> getShapes() { return shapes; }
2323 @JsonProperty("shapes")
Mschema-java/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Fruit.java+6 −6
@@ -5,21 +5,21 @@ import java.util.List;
55
66 public class Fruit {
77 private Boolean apple;
8- private List<Berry> berries;
98 private Boolean orange;
9+ private List<Berry> berries;
1010
1111 @JsonProperty("apple")
1212 public Boolean getApple() { return apple; }
1313 @JsonProperty("apple")
1414 public void setApple(Boolean value) { this.apple = value; }
1515
16- @JsonProperty("berries")
17- public List<Berry> getBerries() { return berries; }
18- @JsonProperty("berries")
19- public void setBerries(List<Berry> value) { this.berries = value; }
20-
2116 @JsonProperty("orange")
2217 public Boolean getOrange() { return orange; }
2318 @JsonProperty("orange")
2419 public void setOrange(Boolean value) { this.orange = value; }
20+
21+ @JsonProperty("berries")
22+ public List<Berry> getBerries() { return berries; }
23+ @JsonProperty("berries")
24+ public void setBerries(List<Berry> value) { this.berries = value; }
2525 }
Mschema-java/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Limit.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Limit {
6- private Double maximum;
76 private Double minimum;
8-
9- @JsonProperty("maximum")
10- public Double getMaximum() { return maximum; }
11- @JsonProperty("maximum")
12- public void setMaximum(Double value) { this.maximum = value; }
7+ private Double maximum;
138
149 @JsonProperty("minimum")
1510 public Double getMinimum() { return minimum; }
1611 @JsonProperty("minimum")
1712 public void setMinimum(Double value) { this.minimum = value; }
13+
14+ @JsonProperty("maximum")
15+ public Double getMaximum() { return maximum; }
16+ @JsonProperty("maximum")
17+ public void setMaximum(Double value) { this.maximum = value; }
1818 }
Mschema-java/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Part.java+6 −6
@@ -3,14 +3,9 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Part {
6- private String depth;
76 private String length;
87 private String width;
9-
10- @JsonProperty("depth")
11- public String getDepth() { return depth; }
12- @JsonProperty("depth")
13- public void setDepth(String value) { this.depth = value; }
8+ private String depth;
149
1510 @JsonProperty("length")
1611 public String getLength() { return length; }
@@ -21,4 +16,9 @@ public class Part {
2116 public String getWidth() { return width; }
2217 @JsonProperty("width")
2318 public void setWidth(String value) { this.width = value; }
19+
20+ @JsonProperty("depth")
21+ public String getDepth() { return depth; }
22+ @JsonProperty("depth")
23+ public void setDepth(String value) { this.depth = value; }
2424 }
Mschema-java/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Shape.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Shape {
6- private Geometry geometry;
76 private History history;
8-
9- @JsonProperty("geometry")
10- public Geometry getGeometry() { return geometry; }
11- @JsonProperty("geometry")
12- public void setGeometry(Geometry value) { this.geometry = value; }
7+ private Geometry geometry;
138
149 @JsonProperty("history")
1510 public History getHistory() { return history; }
1611 @JsonProperty("history")
1712 public void setHistory(History value) { this.history = value; }
13+
14+ @JsonProperty("geometry")
15+ public Geometry getGeometry() { return geometry; }
16+ @JsonProperty("geometry")
17+ public void setGeometry(Geometry value) { this.geometry = value; }
1818 }
Mschema-java/test/inputs/schema/renaming-bug.schema/default/src/main/java/io/quicktype/Vehicle.java+18 −18
@@ -3,40 +3,40 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Vehicle {
6- private String brand;
76 private String id;
8- private Speed speed;
9- private Boolean subModule;
107 private VehicleType type;
8+ private Speed speed;
119 private String year;
12-
13- @JsonProperty("brand")
14- public String getBrand() { return brand; }
15- @JsonProperty("brand")
16- public void setBrand(String value) { this.brand = value; }
10+ private String brand;
11+ private Boolean subModule;
1712
1813 @JsonProperty("id")
1914 public String getID() { return id; }
2015 @JsonProperty("id")
2116 public void setID(String value) { this.id = value; }
2217
23- @JsonProperty("speed")
24- public Speed getSpeed() { return speed; }
25- @JsonProperty("speed")
26- public void setSpeed(Speed value) { this.speed = value; }
27-
28- @JsonProperty("subModule")
29- public Boolean getSubModule() { return subModule; }
30- @JsonProperty("subModule")
31- public void setSubModule(Boolean value) { this.subModule = value; }
32-
3318 @JsonProperty("type")
3419 public VehicleType getType() { return type; }
3520 @JsonProperty("type")
3621 public void setType(VehicleType value) { this.type = value; }
3722
23+ @JsonProperty("speed")
24+ public Speed getSpeed() { return speed; }
25+ @JsonProperty("speed")
26+ public void setSpeed(Speed value) { this.speed = value; }
27+
3828 @JsonProperty("year")
3929 public String getYear() { return year; }
4030 @JsonProperty("year")
4131 public void setYear(String value) { this.year = value; }
32+
33+ @JsonProperty("brand")
34+ public String getBrand() { return brand; }
35+ @JsonProperty("brand")
36+ public void setBrand(String value) { this.brand = value; }
37+
38+ @JsonProperty("subModule")
39+ public Boolean getSubModule() { return subModule; }
40+ @JsonProperty("subModule")
41+ public void setSubModule(Boolean value) { this.subModule = value; }
4242 }
Mschema-java/test/inputs/schema/rust-cycle-breaker-union.schema/default/src/main/java/io/quicktype/Node.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class Node {
6- private Next next;
76 private String value;
8-
9- @JsonProperty("next")
10- public Next getNext() { return next; }
11- @JsonProperty("next")
12- public void setNext(Next value) { this.next = value; }
7+ private Next next;
138
149 @JsonProperty("value")
1510 public String getValue() { return value; }
1611 @JsonProperty("value")
1712 public void setValue(String value) { this.value = value; }
13+
14+ @JsonProperty("next")
15+ public Next getNext() { return next; }
16+ @JsonProperty("next")
17+ public void setNext(Next value) { this.next = value; }
1818 }
Mschema-java/test/inputs/schema/rust-cycle-breaker-union.schema/default/src/main/java/io/quicktype/TopLevel.java+6 −6
@@ -3,16 +3,16 @@ package io.quicktype;
33 import com.fasterxml.jackson.annotation.*;
44
55 public class TopLevel {
6- private Next next;
76 private String value;
8-
9- @JsonProperty("next")
10- public Next getNext() { return next; }
11- @JsonProperty("next")
12- public void setNext(Next value) { this.next = value; }
7+ private Next next;
138
149 @JsonProperty("value")
1510 public String getValue() { return value; }
1611 @JsonProperty("value")
1712 public void setValue(String value) { this.value = value; }
13+
14+ @JsonProperty("next")
15+ public Next getNext() { return next; }
16+ @JsonProperty("next")
17+ public void setNext(Next value) { this.next = value; }
1818 }
Mschema-java/test/inputs/schema/uuid.schema/default/src/main/java/io/quicktype/TopLevel.java+18 −18
@@ -5,28 +5,13 @@ import java.util.List;
55 import java.util.UUID;
66
77 public class TopLevel {
8- private List<UUID> arrNullable;
9- private List<UUID> arrOne;
10- private UUID nullable;
118 private UUID one;
129 private UUID optional;
10+ private UUID nullable;
11+ private List<UUID> arrOne;
12+ private List<UUID> arrNullable;
1313 private UnionWithEnumUnion unionWithEnum;
1414
15- @JsonProperty("arrNullable")
16- public List<UUID> getArrNullable() { return arrNullable; }
17- @JsonProperty("arrNullable")
18- public void setArrNullable(List<UUID> value) { this.arrNullable = value; }
19-
20- @JsonProperty("arrOne")
21- public List<UUID> getArrOne() { return arrOne; }
22- @JsonProperty("arrOne")
23- public void setArrOne(List<UUID> value) { this.arrOne = value; }
24-
25- @JsonProperty("nullable")
26- public UUID getNullable() { return nullable; }
27- @JsonProperty("nullable")
28- public void setNullable(UUID value) { this.nullable = value; }
29-
3015 @JsonProperty("one")
3116 public UUID getOne() { return one; }
3217 @JsonProperty("one")
@@ -37,6 +22,21 @@ public class TopLevel {
3722 @JsonProperty("optional")
3823 public void setOptional(UUID value) { this.optional = value; }
3924
25+ @JsonProperty("nullable")
26+ public UUID getNullable() { return nullable; }
27+ @JsonProperty("nullable")
28+ public void setNullable(UUID value) { this.nullable = value; }
29+
30+ @JsonProperty("arrOne")
31+ public List<UUID> getArrOne() { return arrOne; }
32+ @JsonProperty("arrOne")
33+ public void setArrOne(List<UUID> value) { this.arrOne = value; }
34+
35+ @JsonProperty("arrNullable")
36+ public List<UUID> getArrNullable() { return arrNullable; }
37+ @JsonProperty("arrNullable")
38+ public void setArrNullable(List<UUID> value) { this.arrNullable = value; }
39+
4040 @JsonProperty("unionWithEnum")
4141 public UnionWithEnumUnion getUnionWithEnum() { return unionWithEnum; }
4242 @JsonProperty("unionWithEnum")
Mschema-java/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/Axis.java+9 −9
@@ -19,8 +19,8 @@ public class Axis {
1919 private TitleOrient orient;
2020 private Double position;
2121 private Double tickCount;
22- private Boolean ticks;
2322 private Double tickSize;
23+ private Boolean ticks;
2424 private String title;
2525 private Double titleMaxLength;
2626 private Double titlePadding;
@@ -206,14 +206,6 @@ public class Axis {
206206 @JsonProperty("tickCount")
207207 public void setTickCount(Double value) { this.tickCount = value; }
208208
209- /**
210- * Boolean value that determines whether the axis should include ticks.
211- */
212- @JsonProperty("ticks")
213- public Boolean getTicks() { return ticks; }
214- @JsonProperty("ticks")
215- public void setTicks(Boolean value) { this.ticks = value; }
216-
217209 /**
218210 * The size in pixels of axis ticks.
219211 */
@@ -222,6 +214,14 @@ public class Axis {
222214 @JsonProperty("tickSize")
223215 public void setTickSize(Double value) { this.tickSize = value; }
224216
217+ /**
218+ * Boolean value that determines whether the axis should include ticks.
219+ */
220+ @JsonProperty("ticks")
221+ public Boolean getTicks() { return ticks; }
222+ @JsonProperty("ticks")
223+ public void setTicks(Boolean value) { this.ticks = value; }
224+
225225 /**
226226 * A title for the field. If `null`, the title will be removed.
227227 *
Mschema-java/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/AxisConfig.java+9 −9
@@ -33,9 +33,9 @@ public class AxisConfig {
3333 private Boolean shortTimeLabels;
3434 private String tickColor;
3535 private Boolean tickRound;
36- private Boolean ticks;
3736 private Double tickSize;
3837 private Double tickWidth;
38+ private Boolean ticks;
3939 private String titleAlign;
4040 private Double titleAngle;
4141 private String titleBaseline;
@@ -288,14 +288,6 @@ public class AxisConfig {
288288 @JsonProperty("tickRound")
289289 public void setTickRound(Boolean value) { this.tickRound = value; }
290290
291- /**
292- * Boolean value that determines whether the axis should include ticks.
293- */
294- @JsonProperty("ticks")
295- public Boolean getTicks() { return ticks; }
296- @JsonProperty("ticks")
297- public void setTicks(Boolean value) { this.ticks = value; }
298-
299291 /**
300292 * The size in pixels of axis ticks.
301293 */
@@ -312,6 +304,14 @@ public class AxisConfig {
312304 @JsonProperty("tickWidth")
313305 public void setTickWidth(Double value) { this.tickWidth = value; }
314306
307+ /**
308+ * Boolean value that determines whether the axis should include ticks.
309+ */
310+ @JsonProperty("ticks")
311+ public Boolean getTicks() { return ticks; }
312+ @JsonProperty("ticks")
313+ public void setTicks(Boolean value) { this.ticks = value; }
314+
315315 /**
316316 * Horizontal text alignment of axis titles.
317317 */
Mschema-java/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/BarConfig.java+11 −11
@@ -18,8 +18,8 @@ public class BarConfig {
1818 private Double dx;
1919 private Double dy;
2020 private String fill;
21- private Boolean filled;
2221 private Double fillOpacity;
22+ private Boolean filled;
2323 private String font;
2424 private Double fontSize;
2525 private FontStyle fontStyle;
@@ -147,6 +147,16 @@ public class BarConfig {
147147 @JsonProperty("fill")
148148 public void setFill(String value) { this.fill = value; }
149149
150+ /**
151+ * The fill opacity (value between [0,1]).
152+ *
153+ * __Default value:__ `1`
154+ */
155+ @JsonProperty("fillOpacity")
156+ public Double getFillOpacity() { return fillOpacity; }
157+ @JsonProperty("fillOpacity")
158+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
159+
150160 /**
151161 * Whether the mark's color should be used as fill color instead of stroke color.
152162 *
@@ -161,16 +171,6 @@ public class BarConfig {
161171 @JsonProperty("filled")
162172 public void setFilled(Boolean value) { this.filled = value; }
163173
164- /**
165- * The fill opacity (value between [0,1]).
166- *
167- * __Default value:__ `1`
168- */
169- @JsonProperty("fillOpacity")
170- public Double getFillOpacity() { return fillOpacity; }
171- @JsonProperty("fillOpacity")
172- public void setFillOpacity(Double value) { this.fillOpacity = value; }
173-
174174 /**
175175 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
176176 */
Mschema-java/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/MarkConfig.java+11 −11
@@ -31,8 +31,8 @@ public class MarkConfig {
3131 private Double dx;
3232 private Double dy;
3333 private String fill;
34- private Boolean filled;
3534 private Double fillOpacity;
35+ private Boolean filled;
3636 private String font;
3737 private Double fontSize;
3838 private FontStyle fontStyle;
@@ -130,6 +130,16 @@ public class MarkConfig {
130130 @JsonProperty("fill")
131131 public void setFill(String value) { this.fill = value; }
132132
133+ /**
134+ * The fill opacity (value between [0,1]).
135+ *
136+ * __Default value:__ `1`
137+ */
138+ @JsonProperty("fillOpacity")
139+ public Double getFillOpacity() { return fillOpacity; }
140+ @JsonProperty("fillOpacity")
141+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
142+
133143 /**
134144 * Whether the mark's color should be used as fill color instead of stroke color.
135145 *
@@ -144,16 +154,6 @@ public class MarkConfig {
144154 @JsonProperty("filled")
145155 public void setFilled(Boolean value) { this.filled = value; }
146156
147- /**
148- * The fill opacity (value between [0,1]).
149- *
150- * __Default value:__ `1`
151- */
152- @JsonProperty("fillOpacity")
153- public Double getFillOpacity() { return fillOpacity; }
154- @JsonProperty("fillOpacity")
155- public void setFillOpacity(Double value) { this.fillOpacity = value; }
156-
157157 /**
158158 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
159159 */
Mschema-java/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/MarkDef.java+11 −11
@@ -13,8 +13,8 @@ public class MarkDef {
1313 private Double dx;
1414 private Double dy;
1515 private String fill;
16- private Boolean filled;
1716 private Double fillOpacity;
17+ private Boolean filled;
1818 private String font;
1919 private Double fontSize;
2020 private FontStyle fontStyle;
@@ -122,6 +122,16 @@ public class MarkDef {
122122 @JsonProperty("fill")
123123 public void setFill(String value) { this.fill = value; }
124124
125+ /**
126+ * The fill opacity (value between [0,1]).
127+ *
128+ * __Default value:__ `1`
129+ */
130+ @JsonProperty("fillOpacity")
131+ public Double getFillOpacity() { return fillOpacity; }
132+ @JsonProperty("fillOpacity")
133+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
134+
125135 /**
126136 * Whether the mark's color should be used as fill color instead of stroke color.
127137 *
@@ -136,16 +146,6 @@ public class MarkDef {
136146 @JsonProperty("filled")
137147 public void setFilled(Boolean value) { this.filled = value; }
138148
139- /**
140- * The fill opacity (value between [0,1]).
141- *
142- * __Default value:__ `1`
143- */
144- @JsonProperty("fillOpacity")
145- public Double getFillOpacity() { return fillOpacity; }
146- @JsonProperty("fillOpacity")
147- public void setFillOpacity(Double value) { this.fillOpacity = value; }
148-
149149 /**
150150 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
151151 */
Mschema-java/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/TextConfig.java+11 −11
@@ -15,8 +15,8 @@ public class TextConfig {
1515 private Double dx;
1616 private Double dy;
1717 private String fill;
18- private Boolean filled;
1918 private Double fillOpacity;
19+ private Boolean filled;
2020 private String font;
2121 private Double fontSize;
2222 private FontStyle fontStyle;
@@ -115,6 +115,16 @@ public class TextConfig {
115115 @JsonProperty("fill")
116116 public void setFill(String value) { this.fill = value; }
117117
118+ /**
119+ * The fill opacity (value between [0,1]).
120+ *
121+ * __Default value:__ `1`
122+ */
123+ @JsonProperty("fillOpacity")
124+ public Double getFillOpacity() { return fillOpacity; }
125+ @JsonProperty("fillOpacity")
126+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
127+
118128 /**
119129 * Whether the mark's color should be used as fill color instead of stroke color.
120130 *
@@ -129,16 +139,6 @@ public class TextConfig {
129139 @JsonProperty("filled")
130140 public void setFilled(Boolean value) { this.filled = value; }
131141
132- /**
133- * The fill opacity (value between [0,1]).
134- *
135- * __Default value:__ `1`
136- */
137- @JsonProperty("fillOpacity")
138- public Double getFillOpacity() { return fillOpacity; }
139- @JsonProperty("fillOpacity")
140- public void setFillOpacity(Double value) { this.fillOpacity = value; }
141-
142142 /**
143143 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
144144 */
Mschema-java/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/TickConfig.java+11 −11
@@ -16,8 +16,8 @@ public class TickConfig {
1616 private Double dx;
1717 private Double dy;
1818 private String fill;
19- private Boolean filled;
2019 private Double fillOpacity;
20+ private Boolean filled;
2121 private String font;
2222 private Double fontSize;
2323 private FontStyle fontStyle;
@@ -126,6 +126,16 @@ public class TickConfig {
126126 @JsonProperty("fill")
127127 public void setFill(String value) { this.fill = value; }
128128
129+ /**
130+ * The fill opacity (value between [0,1]).
131+ *
132+ * __Default value:__ `1`
133+ */
134+ @JsonProperty("fillOpacity")
135+ public Double getFillOpacity() { return fillOpacity; }
136+ @JsonProperty("fillOpacity")
137+ public void setFillOpacity(Double value) { this.fillOpacity = value; }
138+
129139 /**
130140 * Whether the mark's color should be used as fill color instead of stroke color.
131141 *
@@ -140,16 +150,6 @@ public class TickConfig {
140150 @JsonProperty("filled")
141151 public void setFilled(Boolean value) { this.filled = value; }
142152
143- /**
144- * The fill opacity (value between [0,1]).
145- *
146- * __Default value:__ `1`
147- */
148- @JsonProperty("fillOpacity")
149- public Double getFillOpacity() { return fillOpacity; }
150- @JsonProperty("fillOpacity")
151- public void setFillOpacity(Double value) { this.fillOpacity = value; }
152-
153153 /**
154154 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
155155 */
Mschema-java/test/inputs/schema/vega-lite.schema/default/src/main/java/io/quicktype/VGAxisConfig.java+9 −9
@@ -42,9 +42,9 @@ public class VGAxisConfig {
4242 private Double minExtent;
4343 private String tickColor;
4444 private Boolean tickRound;
45- private Boolean ticks;
4645 private Double tickSize;
4746 private Double tickWidth;
47+ private Boolean ticks;
4848 private String titleAlign;
4949 private Double titleAngle;
5050 private String titleBaseline;
@@ -287,14 +287,6 @@ public class VGAxisConfig {
287287 @JsonProperty("tickRound")
288288 public void setTickRound(Boolean value) { this.tickRound = value; }
289289
290- /**
291- * Boolean value that determines whether the axis should include ticks.
292- */
293- @JsonProperty("ticks")
294- public Boolean getTicks() { return ticks; }
295- @JsonProperty("ticks")
296- public void setTicks(Boolean value) { this.ticks = value; }
297-
298290 /**
299291 * The size in pixels of axis ticks.
300292 */
@@ -311,6 +303,14 @@ public class VGAxisConfig {
311303 @JsonProperty("tickWidth")
312304 public void setTickWidth(Double value) { this.tickWidth = value; }
313305
306+ /**
307+ * Boolean value that determines whether the axis should include ticks.
308+ */
309+ @JsonProperty("ticks")
310+ public Boolean getTicks() { return ticks; }
311+ @JsonProperty("ticks")
312+ public void setTicks(Boolean value) { this.ticks = value; }
313+
314314 /**
315315 * Horizontal text alignment of axis titles.
316316 */
Mschema-javascript/test/inputs/schema/accessors.schema/default/TopLevel.js+2 −2
@@ -172,10 +172,10 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "bar", js: "bar", typ: "" },
175+ { json: "union", js: "union", typ: u(true, 3.14) },
176176 { json: "enum", js: "enum", typ: r("Enum") },
177177 { json: "foo", js: "foo", typ: "" },
178- { json: "union", js: "union", typ: u(true, 3.14) },
178+ { json: "bar", js: "bar", typ: "" },
179179 ], false),
180180 "Enum": [
181181 "red",
Mschema-javascript/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.js+1 −1
@@ -174,8 +174,8 @@ const typeMap = {
174174 "TopLevel": o([
175175 { json: "amount", js: "amount", typ: 3.14 },
176176 { json: "frequency", js: "frequency", typ: r("Frequency") },
177- { json: "description", js: "description", typ: u(undefined, "") },
178177 { json: "type", js: "type", typ: r("Type") },
178+ { json: "description", js: "description", typ: u(undefined, "") },
179179 ], false),
180180 "Frequency": [
181181 "Weekly",
Mschema-javascript/test/inputs/schema/bool-string.schema/default/TopLevel.js+3 −3
@@ -172,11 +172,11 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
176- { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
177- { json: "nullable", js: "nullable", typ: u(null, "") },
178175 { json: "one", js: "one", typ: "" },
179176 { json: "optional", js: "optional", typ: u(undefined, "") },
177+ { json: "nullable", js: "nullable", typ: u(null, "") },
178+ { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
179+ { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
180180 { json: "unionWithBool", js: "unionWithBool", typ: u(true, "") },
181181 { json: "unionWithBoolAndEnum", js: "unionWithBoolAndEnum", typ: u(true, "") },
182182 ], "any"),
Mschema-javascript/test/inputs/schema/boolean-subschema.schema/default/TopLevel.js+1 −1
@@ -172,9 +172,9 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175+ { json: "foo", js: "foo", typ: "" },
175176 { json: "disallowed", js: "disallowed", typ: u(undefined, "any") },
176177 { json: "empty", js: "empty", typ: a("any") },
177- { json: "foo", js: "foo", typ: "" },
178178 { json: "impossible", js: "impossible", typ: u(undefined, "any") },
179179 ], false),
180180 };
Mschema-javascript/test/inputs/schema/comment-injection.schema/default/TopLevel.js+1 −1
@@ -172,10 +172,10 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175+ { json: "value", js: "value", typ: "" },
175176 { json: "trailingBackslash", js: "trailingBackslash", typ: u(undefined, "") },
176177 { json: "trailingQuote", js: "trailingQuote", typ: u(undefined, "") },
177178 { json: "trailingTripleQuote", js: "trailingTripleQuote", typ: u(undefined, "") },
178- { json: "value", js: "value", typ: "" },
179179 ], false),
180180 };
Mschema-javascript/test/inputs/schema/const-non-string.schema/default/TopLevel.js+2 −2
@@ -172,11 +172,11 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175+ { json: "version", js: "version", typ: 3.14 },
175176 { json: "amount", js: "amount", typ: 0 },
177+ { json: "ratio", js: "ratio", typ: 3.14 },
176178 { json: "enabled", js: "enabled", typ: true },
177179 { json: "kind", js: "kind", typ: r("Kind") },
178- { json: "ratio", js: "ratio", typ: 3.14 },
179- { json: "version", js: "version", typ: 3.14 },
180180 ], "any"),
181181 "Kind": [
182182 "widget",
Mschema-javascript/test/inputs/schema/date-time-or-string.schema/default/TopLevel.js+1 −1
@@ -172,8 +172,8 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "bar", js: "bar", typ: u(Date, r("BarEnum")) },
176175 { json: "foo", js: "foo", typ: "" },
176+ { json: "bar", js: "bar", typ: u(Date, r("BarEnum")) },
177177 ], "any"),
178178 "BarEnum": [
179179 "quux",
Mschema-javascript/test/inputs/schema/date-time.schema/default/TopLevel.js+2 −2
@@ -172,11 +172,11 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "complex-union-array", js: "complex-union-array", typ: a(u(Date, r("ComplexUnionArrayEnum"), 0)) },
176175 { json: "date", js: "date", typ: Date },
177- { json: "date-time", js: "date-time", typ: Date },
178176 { json: "time", js: "time", typ: "" },
177+ { json: "date-time", js: "date-time", typ: Date },
179178 { json: "union-array", js: "union-array", typ: a("") },
179+ { json: "complex-union-array", js: "complex-union-array", typ: a(u(Date, r("ComplexUnionArrayEnum"), 0)) },
180180 ], false),
181181 "ComplexUnionArrayEnum": [
182182 "foo",
Mschema-javascript/test/inputs/schema/description.schema/default/TopLevel.js+2 −2
@@ -172,11 +172,11 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "bar", js: "bar", typ: u(undefined, true) },
175+ { json: "union", js: "union", typ: u(3.14, "") },
176176 { json: "enum", js: "enum", typ: r("Enum") },
177177 { json: "foo", js: "foo", typ: u(undefined, 3.14) },
178+ { json: "bar", js: "bar", typ: u(undefined, true) },
178179 { json: "object-or-string", js: "object-or-string", typ: u(r("ObjectOrStringObject"), "") },
179- { json: "union", js: "union", typ: u(3.14, "") },
180180 ], false),
181181 "ObjectOrStringObject": o([
182182 { json: "prop", js: "prop", typ: 3.14 },
Mschema-javascript/test/inputs/schema/direct-union.schema/default/TopLevel.js+1 −1
@@ -175,8 +175,8 @@ const typeMap = {
175175 { json: "stuff", js: "stuff", typ: m(r("Thing")) },
176176 ], false),
177177 "Thing": o([
178- { json: "optional", js: "optional", typ: u(undefined, u(a("any"), true, 3.14, 0, m("any"), null, "")) },
179178 { json: "required", js: "required", typ: u(a("any"), true, 3.14, 0, m("any"), null, "") },
179+ { json: "optional", js: "optional", typ: u(undefined, u(a("any"), true, 3.14, 0, m("any"), null, "")) },
180180 ], false),
181181 };
Mschema-javascript/test/inputs/schema/enum.schema/default/TopLevel.js+3 −3
@@ -172,11 +172,11 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "arr", js: "arr", typ: u(undefined, a(u(r("OtherArr"), 0))) },
176- { json: "for", js: "for", typ: u(undefined, "") },
177- { json: "gve", js: "gve", typ: r("Gve") },
178175 { json: "lvc", js: "lvc", typ: u(undefined, r("Lvc")) },
176+ { json: "gve", js: "gve", typ: r("Gve") },
177+ { json: "arr", js: "arr", typ: u(undefined, a(u(r("OtherArr"), 0))) },
179178 { json: "otherArr", js: "otherArr", typ: u(undefined, a(r("OtherArr"))) },
179+ { json: "for", js: "for", typ: u(undefined, "") },
180180 ], "any"),
181181 "OtherArr": [
182182 "foo",
Mschema-javascript/test/inputs/schema/integer-string.schema/default/TopLevel.js+3 −3
@@ -172,11 +172,11 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
176- { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
177- { json: "nullable", js: "nullable", typ: u(null, "") },
178175 { json: "one", js: "one", typ: "" },
179176 { json: "optional", js: "optional", typ: u(undefined, "") },
177+ { json: "nullable", js: "nullable", typ: u(null, "") },
178+ { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
179+ { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
180180 { json: "unionWithInt", js: "unionWithInt", typ: u(0, "") },
181181 { json: "unionWithIntAndEnum", js: "unionWithIntAndEnum", typ: u(0, "") },
182182 ], "any"),
Mschema-javascript/test/inputs/schema/integer-type.schema/default/TopLevel.js+5 −5
@@ -172,15 +172,15 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175+ { json: "small_positive", js: "small_positive", typ: 0 },
176+ { json: "small_negative", js: "small_negative", typ: 0 },
177+ { json: "i32_range", js: "i32_range", typ: 0 },
175178 { json: "above_i32_max", js: "above_i32_max", typ: 0 },
176179 { json: "below_i32_min", js: "below_i32_min", typ: 0 },
177- { json: "i32_range", js: "i32_range", typ: 0 },
178- { json: "large_bounds", js: "large_bounds", typ: 0 },
179- { json: "only_maximum", js: "only_maximum", typ: 0 },
180180 { json: "only_minimum", js: "only_minimum", typ: 0 },
181- { json: "small_negative", js: "small_negative", typ: 0 },
182- { json: "small_positive", js: "small_positive", typ: 0 },
181+ { json: "only_maximum", js: "only_maximum", typ: 0 },
183182 { json: "unbounded", js: "unbounded", typ: 0 },
183+ { json: "large_bounds", js: "large_bounds", typ: 0 },
184184 ], "any"),
185185 };
Mschema-javascript/test/inputs/schema/light.schema/default/TopLevel.js+1 −1
@@ -175,8 +175,8 @@ const typeMap = {
175175 { json: "LightParams", js: "LightParams", typ: r("LightParams") },
176176 ], false),
177177 "LightParams": o([
178- { json: "app_id", js: "app_id", typ: "" },
179178 { json: "outlet_id", js: "outlet_id", typ: "" },
179+ { json: "app_id", js: "app_id", typ: "" },
180180 { json: "rgba", js: "rgba", typ: "" },
181181 ], false),
182182 };
Mschema-javascript/test/inputs/schema/min-max-items.schema/default/TopLevel.js+1 −1
@@ -172,9 +172,9 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175+ { json: "minOnly", js: "minOnly", typ: a("") },
175176 { json: "maxOnly", js: "maxOnly", typ: a(0) },
176177 { json: "minAndMax", js: "minAndMax", typ: a(3.14) },
177- { json: "minOnly", js: "minOnly", typ: a("") },
178178 { json: "plain", js: "plain", typ: a("") },
179179 { json: "unionItems", js: "unionItems", typ: a(u(0, "")) },
180180 ], "any"),
Mschema-javascript/test/inputs/schema/minmax-integer.schema/default/TopLevel.js+4 −4
@@ -173,13 +173,13 @@ function r(name) {
173173 const typeMap = {
174174 "TopLevel": o([
175175 { json: "free", js: "free", typ: 0 },
176- { json: "intersection", js: "intersection", typ: 0 },
177- { json: "max", js: "max", typ: 0 },
178176 { json: "min", js: "min", typ: 0 },
177+ { json: "max", js: "max", typ: 0 },
179178 { json: "minmax", js: "minmax", typ: 0 },
180- { json: "minMaxIntersection", js: "minMaxIntersection", typ: 0 },
181- { json: "minMaxUnion", js: "minMaxUnion", typ: 0 },
182179 { json: "union", js: "union", typ: 0 },
180+ { json: "minMaxUnion", js: "minMaxUnion", typ: 0 },
181+ { json: "intersection", js: "intersection", typ: 0 },
182+ { json: "minMaxIntersection", js: "minMaxIntersection", typ: 0 },
183183 ], "any"),
184184 };
Mschema-javascript/test/inputs/schema/minmax.schema/default/TopLevel.js+4 −4
@@ -173,13 +173,13 @@ function r(name) {
173173 const typeMap = {
174174 "TopLevel": o([
175175 { json: "free", js: "free", typ: 3.14 },
176- { json: "intersection", js: "intersection", typ: 3.14 },
177- { json: "max", js: "max", typ: 3.14 },
178176 { json: "min", js: "min", typ: 3.14 },
177+ { json: "max", js: "max", typ: 3.14 },
179178 { json: "minmax", js: "minmax", typ: 3.14 },
180- { json: "minMaxIntersection", js: "minMaxIntersection", typ: 3.14 },
181- { json: "minMaxUnion", js: "minMaxUnion", typ: 3.14 },
182179 { json: "union", js: "union", typ: 3.14 },
180+ { json: "minMaxUnion", js: "minMaxUnion", typ: 3.14 },
181+ { json: "intersection", js: "intersection", typ: 3.14 },
182+ { json: "minMaxIntersection", js: "minMaxIntersection", typ: 3.14 },
183183 ], "any"),
184184 };
Mschema-javascript/test/inputs/schema/minmaxlength.schema/default/TopLevel.js+5 −5
@@ -172,14 +172,14 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "intersection", js: "intersection", typ: "" },
176- { json: "inUnion", js: "inUnion", typ: u(3.14, "") },
177- { json: "maxlength", js: "maxlength", typ: "" },
178175 { json: "minlength", js: "minlength", typ: "" },
179- { json: "minMaxIntersection", js: "minMaxIntersection", typ: "" },
176+ { json: "maxlength", js: "maxlength", typ: "" },
180177 { json: "minmaxlength", js: "minmaxlength", typ: "" },
181- { json: "minMaxUnion", js: "minMaxUnion", typ: "" },
182178 { json: "union", js: "union", typ: "" },
179+ { json: "inUnion", js: "inUnion", typ: u(3.14, "") },
180+ { json: "minMaxUnion", js: "minMaxUnion", typ: "" },
181+ { json: "intersection", js: "intersection", typ: "" },
182+ { json: "minMaxIntersection", js: "minMaxIntersection", typ: "" },
183183 ], "any"),
184184 };
Mschema-javascript/test/inputs/schema/non-standard-ref.schema/default/TopLevel.js+1 −1
@@ -172,8 +172,8 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "bar", js: "bar", typ: 0 },
176175 { json: "foo", js: "foo", typ: 0 },
176+ { json: "bar", js: "bar", typ: 0 },
177177 { json: "quux", js: "quux", typ: true },
178178 ], "any"),
179179 };
Mschema-javascript/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.js+1 −1
@@ -172,8 +172,8 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "b", js: "b", typ: u(undefined, u(null, "")) },
176175 { json: "kind", js: "kind", typ: r("Kind") },
176+ { json: "b", js: "b", typ: u(undefined, u(null, "")) },
177177 ], "any"),
178178 "Kind": [
179179 "one",
Mschema-javascript/test/inputs/schema/optional-any.schema/default/TopLevel.js+1 −1
@@ -172,8 +172,8 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "bar", js: "bar", typ: true },
176175 { json: "foo", js: "foo", typ: u(undefined, "any") },
176+ { json: "bar", js: "bar", typ: true },
177177 ], false),
178178 };
Mschema-javascript/test/inputs/schema/optional-const-ref.schema/default/TopLevel.js+3 −3
@@ -173,12 +173,12 @@ function r(name) {
173173 const typeMap = {
174174 "TopLevel": o([
175175 { json: "coordinates", js: "coordinates", typ: u(undefined, a(r("Coordinate"))) },
176- { json: "count", js: "count", typ: u(undefined, 0) },
177- { json: "label", js: "label", typ: u(undefined, "") },
178176 { json: "requiredCoordinates", js: "requiredCoordinates", typ: a(r("Coordinate")) },
177+ { json: "count", js: "count", typ: u(undefined, 0) },
179178 { json: "requiredCount", js: "requiredCount", typ: 0 },
180- { json: "requiredLabel", js: "requiredLabel", typ: "" },
181179 { json: "weight", js: "weight", typ: u(undefined, 3.14) },
180+ { json: "label", js: "label", typ: u(undefined, "") },
181+ { json: "requiredLabel", js: "requiredLabel", typ: "" },
182182 ], false),
183183 "Coordinate": o([
184184 { json: "latitude", js: "latitude", typ: 3.14 },
Mschema-javascript/test/inputs/schema/optional-constraints.schema/default/TopLevel.js+3 −3
@@ -172,11 +172,11 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "optDouble", js: "optDouble", typ: u(undefined, 3.14) },
175+ { json: "reqZeroMin", js: "reqZeroMin", typ: 0 },
176176 { json: "optInt", js: "optInt", typ: u(undefined, 0) },
177- { json: "optPattern", js: "optPattern", typ: u(undefined, "") },
177+ { json: "optDouble", js: "optDouble", typ: u(undefined, 3.14) },
178178 { json: "optString", js: "optString", typ: u(undefined, "") },
179- { json: "reqZeroMin", js: "reqZeroMin", typ: 0 },
179+ { json: "optPattern", js: "optPattern", typ: u(undefined, "") },
180180 ], "any"),
181181 };
Mschema-javascript/test/inputs/schema/optional-date-time.schema/default/TopLevel.js+4 −4
@@ -172,12 +172,12 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "optional-date", js: "optional-date", typ: u(undefined, Date) },
176- { json: "optional-date-time", js: "optional-date-time", typ: u(undefined, Date) },
177- { json: "optional-time", js: "optional-time", typ: u(undefined, "") },
178175 { json: "required-date", js: "required-date", typ: Date },
179- { json: "required-date-time", js: "required-date-time", typ: Date },
180176 { json: "required-time", js: "required-time", typ: "" },
177+ { json: "required-date-time", js: "required-date-time", typ: Date },
178+ { json: "optional-date", js: "optional-date", typ: u(undefined, Date) },
179+ { json: "optional-time", js: "optional-time", typ: u(undefined, "") },
180+ { json: "optional-date-time", js: "optional-date-time", typ: u(undefined, Date) },
181181 ], false),
182182 };
Mschema-javascript/test/inputs/schema/prefix-items.schema/default/TopLevel.js+1 −1
@@ -172,8 +172,8 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "open", js: "open", typ: a(u(true, 0)) },
176175 { json: "tuple", js: "tuple", typ: a(u(true, 0)) },
176+ { json: "open", js: "open", typ: a(u(true, 0)) },
177177 ], "any"),
178178 };
Aschema-javascript/test/inputs/schema/property-order.schema/default/TopLevel.js+192 −0
@@ -0,0 +1,192 @@
1+// To parse this data:
2+//
3+// const Convert = require("./TopLevel");
4+//
5+// const topLevel = Convert.toTopLevel(json);
6+//
7+// These functions will throw an error if the JSON doesn't
8+// match the expected interface, even if the JSON is valid.
9+
10+// Converts JSON strings to/from your types
11+// and asserts the results of JSON.parse at runtime
12+function toTopLevel(json) {
13+ return cast(JSON.parse(json), r("TopLevel"));
14+}
15+
16+function topLevelToJson(value) {
17+ return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
18+}
19+
20+function invalidValue(typ, val, key, parent = '') {
21+ const prettyTyp = prettyTypeName(typ);
22+ const parentText = parent ? ` on ${parent}` : '';
23+ const keyText = key ? ` for key "${key}"` : '';
24+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
25+}
26+
27+function prettyTypeName(typ) {
28+ if (Array.isArray(typ)) {
29+ if (typ.length === 2 && typ[0] === undefined) {
30+ return `an optional ${prettyTypeName(typ[1])}`;
31+ } else {
32+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
33+ }
34+ } else if (typeof typ === "object" && typ.literal !== undefined) {
35+ return typ.literal;
36+ } else {
37+ return typeof typ;
38+ }
39+}
40+
41+function jsonToJSProps(typ) {
42+ if (typ.jsonToJS === undefined) {
43+ const map = {};
44+ typ.props.forEach((p) => map[p.json] = { key: p.js, typ: p.typ });
45+ typ.jsonToJS = map;
46+ }
47+ return typ.jsonToJS;
48+}
49+
50+function jsToJSONProps(typ) {
51+ if (typ.jsToJSON === undefined) {
52+ const map = {};
53+ typ.props.forEach((p) => map[p.js] = { key: p.json, typ: p.typ });
54+ typ.jsToJSON = map;
55+ }
56+ return typ.jsToJSON;
57+}
58+
59+function transform(val, typ, getProps, key = '', parent = '') {
60+ function transformPrimitive(typ, val) {
61+ if (typeof typ === typeof val) return val;
62+ return invalidValue(typ, val, key, parent);
63+ }
64+
65+ function transformUnion(typs, val) {
66+ // val must validate against one typ in typs
67+ const l = typs.length;
68+ for (let i = 0; i < l; i++) {
69+ const typ = typs[i];
70+ try {
71+ return transform(val, typ, getProps);
72+ } catch (_) {}
73+ }
74+ return invalidValue(typs, val, key, parent);
75+ }
76+
77+ function transformEnum(cases, val) {
78+ if (cases.indexOf(val) !== -1) return val;
79+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
80+ }
81+
82+ function transformArray(typ, val) {
83+ // val must be an array with no invalid elements
84+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
85+ return val.map(el => transform(el, typ, getProps));
86+ }
87+
88+ function transformDate(val) {
89+ if (val === null) {
90+ return null;
91+ }
92+ const d = new Date(val);
93+ if (isNaN(d.valueOf())) {
94+ return invalidValue(l("Date"), val, key, parent);
95+ }
96+ return d;
97+ }
98+
99+ function transformObject(props, additional, val) {
100+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
101+ return invalidValue(l(ref || "object"), val, key, parent);
102+ }
103+ const result = {};
104+ Object.getOwnPropertyNames(props).forEach(key => {
105+ const prop = props[key];
106+ const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
107+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
108+ });
109+ Object.getOwnPropertyNames(val).forEach(key => {
110+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
111+ result[key] = transform(val[key], additional, getProps, key, ref);
112+ }
113+ });
114+ return result;
115+ }
116+
117+ if (typ === "any") return val;
118+ if (typ === null) {
119+ if (val === null) return val;
120+ return invalidValue(typ, val, key, parent);
121+ }
122+ if (typ === false) return invalidValue(typ, val, key, parent);
123+ let ref = undefined;
124+ while (typeof typ === "object" && typ.ref !== undefined) {
125+ ref = typ.ref;
126+ typ = typeMap[typ.ref];
127+ }
128+ if (Array.isArray(typ)) return transformEnum(typ, val);
129+ if (typeof typ === "object") {
130+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
131+ : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
132+ : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
133+ : invalidValue(typ, val, key, parent);
134+ }
135+ // Numbers can be parsed by Date but shouldn't be.
136+ if (typ === Date && typeof val !== "number") return transformDate(val);
137+ return transformPrimitive(typ, val);
138+}
139+
140+function cast(val, typ) {
141+ return transform(val, typ, jsonToJSProps);
142+}
143+
144+function uncast(val, typ) {
145+ return transform(val, typ, jsToJSONProps);
146+}
147+
148+function l(typ) {
149+ return { literal: typ };
150+}
151+
152+function a(typ) {
153+ return { arrayItems: typ };
154+}
155+
156+function u(...typs) {
157+ return { unionMembers: typs };
158+}
159+
160+function o(props, additional) {
161+ return { props, additional };
162+}
163+
164+function m(additional) {
165+ const props = [];
166+ return { props, additional };
167+}
168+
169+function r(name) {
170+ return { ref: name };
171+}
172+
173+const typeMap = {
174+ "TopLevel": o([
175+ { json: "zebra", js: "zebra", typ: "" },
176+ { json: "mango", js: "mango", typ: 3.14 },
177+ { json: "apple", js: "apple", typ: true },
178+ { json: "delta", js: "delta", typ: "" },
179+ { json: "banana", js: "banana", typ: 0 },
180+ { json: "ordered", js: "ordered", typ: r("Ordered") },
181+ ], false),
182+ "Ordered": o([
183+ { json: "mango", js: "mango", typ: 3.14 },
184+ { json: "zebra", js: "zebra", typ: "" },
185+ { json: "apple", js: "apple", typ: true },
186+ ], false),
187+};
188+
189+module.exports = {
190+ "topLevelToJson": topLevelToJson,
191+ "toTopLevel": toTopLevel,
192+};
Mschema-javascript/test/inputs/schema/renaming-bug.schema/default/TopLevel.js+8 −8
@@ -178,20 +178,20 @@ const typeMap = {
178178 ], "any"),
179179 "Fruit": o([
180180 { json: "apple", js: "apple", typ: u(undefined, true) },
181- { json: "berries", js: "berries", typ: u(undefined, a(r("Berry"))) },
182181 { json: "orange", js: "orange", typ: u(undefined, true) },
182+ { json: "berries", js: "berries", typ: u(undefined, a(r("Berry"))) },
183183 ], "any"),
184184 "Berry": o([
185- { json: "color", js: "color", typ: u(undefined, r("Color")) },
186185 { json: "name", js: "name", typ: u(undefined, "") },
186+ { json: "color", js: "color", typ: u(undefined, r("Color")) },
187187 { json: "shapes", js: "shapes", typ: u(undefined, a(r("Shape"))) },
188188 ], "any"),
189189 "Color": o([
190190 { json: "rgb", js: "rgb", typ: u(undefined, 3.14) },
191191 ], "any"),
192192 "Shape": o([
193- { json: "geometry", js: "geometry", typ: u(undefined, r("Geometry")) },
194193 { json: "history", js: "history", typ: u(undefined, r("History")) },
194+ { json: "geometry", js: "geometry", typ: u(undefined, r("Geometry")) },
195195 ], "any"),
196196 "Geometry": o([
197197 { json: "rectShape", js: "rectShape", typ: u(undefined, r("RectShape")) },
@@ -204,27 +204,27 @@ const typeMap = {
204204 { json: "parts", js: "parts", typ: u(undefined, a(r("Part"))) },
205205 ], "any"),
206206 "Part": o([
207- { json: "depth", js: "depth", typ: u(undefined, "") },
208207 { json: "length", js: "length", typ: u(undefined, "") },
209208 { json: "width", js: "width", typ: u(undefined, "") },
209+ { json: "depth", js: "depth", typ: u(undefined, "") },
210210 ], "any"),
211211 "History": o([
212212 { json: "class", js: "class", typ: u(undefined, "") },
213213 ], "any"),
214214 "Vehicle": o([
215- { json: "brand", js: "brand", typ: u(undefined, "") },
216215 { json: "id", js: "id", typ: u(undefined, "") },
217- { json: "speed", js: "speed", typ: u(undefined, r("Speed")) },
218- { json: "subModule", js: "subModule", typ: u(undefined, true) },
219216 { json: "type", js: "type", typ: u(undefined, r("VehicleType")) },
217+ { json: "speed", js: "speed", typ: u(undefined, r("Speed")) },
220218 { json: "year", js: "year", typ: u(undefined, "") },
219+ { json: "brand", js: "brand", typ: u(undefined, "") },
220+ { json: "subModule", js: "subModule", typ: u(undefined, true) },
221221 ], "any"),
222222 "Speed": o([
223223 { json: "velocity", js: "velocity", typ: u(undefined, r("Limit")) },
224224 ], "any"),
225225 "Limit": o([
226- { json: "maximum", js: "maximum", typ: u(undefined, 3.14) },
227226 { json: "minimum", js: "minimum", typ: u(undefined, 3.14) },
227+ { json: "maximum", js: "maximum", typ: u(undefined, 3.14) },
228228 ], "any"),
229229 "VehicleType": o([
230230 { json: "name", js: "name", typ: u(undefined, r("Name")) },
Mschema-javascript/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.js+2 −2
@@ -172,12 +172,12 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
176175 { json: "value", js: "value", typ: "" },
176+ { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
177177 ], "any"),
178178 "Node": o([
179- { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
180179 { json: "value", js: "value", typ: "" },
180+ { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
181181 ], "any"),
182182 };
Mschema-javascript/test/inputs/schema/uuid.schema/default/TopLevel.js+3 −3
@@ -172,11 +172,11 @@ function r(name) {
172172
173173 const typeMap = {
174174 "TopLevel": o([
175- { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
176- { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
177- { json: "nullable", js: "nullable", typ: u(null, "") },
178175 { json: "one", js: "one", typ: "" },
179176 { json: "optional", js: "optional", typ: u(undefined, "") },
177+ { json: "nullable", js: "nullable", typ: u(null, "") },
178+ { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
179+ { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
180180 { json: "unionWithEnum", js: "unionWithEnum", typ: "" },
181181 ], "any"),
182182 };
Mschema-javascript/test/inputs/schema/vega-lite.schema/default/TopLevel.js+8 −8
@@ -249,8 +249,8 @@ const typeMap = {
249249 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
250250 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
251251 { json: "fill", js: "fill", typ: u(undefined, "") },
252- { json: "filled", js: "filled", typ: u(undefined, true) },
253252 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
253+ { json: "filled", js: "filled", typ: u(undefined, true) },
254254 { json: "font", js: "font", typ: u(undefined, "") },
255255 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
256256 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
@@ -297,9 +297,9 @@ const typeMap = {
297297 { json: "shortTimeLabels", js: "shortTimeLabels", typ: u(undefined, true) },
298298 { json: "tickColor", js: "tickColor", typ: u(undefined, "") },
299299 { json: "tickRound", js: "tickRound", typ: u(undefined, true) },
300- { json: "ticks", js: "ticks", typ: u(undefined, true) },
301300 { json: "tickSize", js: "tickSize", typ: u(undefined, 3.14) },
302301 { json: "tickWidth", js: "tickWidth", typ: u(undefined, 3.14) },
302+ { json: "ticks", js: "ticks", typ: u(undefined, true) },
303303 { json: "titleAlign", js: "titleAlign", typ: u(undefined, "") },
304304 { json: "titleAngle", js: "titleAngle", typ: u(undefined, 3.14) },
305305 { json: "titleBaseline", js: "titleBaseline", typ: u(undefined, "") },
@@ -337,9 +337,9 @@ const typeMap = {
337337 { json: "minExtent", js: "minExtent", typ: u(undefined, 3.14) },
338338 { json: "tickColor", js: "tickColor", typ: u(undefined, "") },
339339 { json: "tickRound", js: "tickRound", typ: u(undefined, true) },
340- { json: "ticks", js: "ticks", typ: u(undefined, true) },
341340 { json: "tickSize", js: "tickSize", typ: u(undefined, 3.14) },
342341 { json: "tickWidth", js: "tickWidth", typ: u(undefined, 3.14) },
342+ { json: "ticks", js: "ticks", typ: u(undefined, true) },
343343 { json: "titleAlign", js: "titleAlign", typ: u(undefined, "") },
344344 { json: "titleAngle", js: "titleAngle", typ: u(undefined, 3.14) },
345345 { json: "titleBaseline", js: "titleBaseline", typ: u(undefined, "") },
@@ -365,8 +365,8 @@ const typeMap = {
365365 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
366366 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
367367 { json: "fill", js: "fill", typ: u(undefined, "") },
368- { json: "filled", js: "filled", typ: u(undefined, true) },
369368 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
369+ { json: "filled", js: "filled", typ: u(undefined, true) },
370370 { json: "font", js: "font", typ: u(undefined, "") },
371371 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
372372 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
@@ -582,8 +582,8 @@ const typeMap = {
582582 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
583583 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
584584 { json: "fill", js: "fill", typ: u(undefined, "") },
585- { json: "filled", js: "filled", typ: u(undefined, true) },
586585 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
586+ { json: "filled", js: "filled", typ: u(undefined, true) },
587587 { json: "font", js: "font", typ: u(undefined, "") },
588588 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
589589 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
@@ -616,8 +616,8 @@ const typeMap = {
616616 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
617617 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
618618 { json: "fill", js: "fill", typ: u(undefined, "") },
619- { json: "filled", js: "filled", typ: u(undefined, true) },
620619 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
620+ { json: "filled", js: "filled", typ: u(undefined, true) },
621621 { json: "font", js: "font", typ: u(undefined, "") },
622622 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
623623 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
@@ -913,8 +913,8 @@ const typeMap = {
913913 { json: "orient", js: "orient", typ: u(undefined, r("TitleOrient")) },
914914 { json: "position", js: "position", typ: u(undefined, 3.14) },
915915 { json: "tickCount", js: "tickCount", typ: u(undefined, 3.14) },
916- { json: "ticks", js: "ticks", typ: u(undefined, true) },
917916 { json: "tickSize", js: "tickSize", typ: u(undefined, 3.14) },
917+ { json: "ticks", js: "ticks", typ: u(undefined, true) },
918918 { json: "title", js: "title", typ: u(undefined, u(null, "")) },
919919 { json: "titleMaxLength", js: "titleMaxLength", typ: u(undefined, 3.14) },
920920 { json: "titlePadding", js: "titlePadding", typ: u(undefined, 3.14) },
@@ -993,8 +993,8 @@ const typeMap = {
993993 { json: "dx", js: "dx", typ: u(undefined, 3.14) },
994994 { json: "dy", js: "dy", typ: u(undefined, 3.14) },
995995 { json: "fill", js: "fill", typ: u(undefined, "") },
996- { json: "filled", js: "filled", typ: u(undefined, true) },
997996 { json: "fillOpacity", js: "fillOpacity", typ: u(undefined, 3.14) },
997+ { json: "filled", js: "filled", typ: u(undefined, true) },
998998 { json: "font", js: "font", typ: u(undefined, "") },
999999 { json: "fontSize", js: "fontSize", typ: u(undefined, 3.14) },
10001000 { json: "fontStyle", js: "fontStyle", typ: u(undefined, r("FontStyle")) },
Mschema-kotlin-jackson/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.kt+2 −2
@@ -21,8 +21,8 @@ private val klaxon = Klaxon()
2121 data class TopLevel (
2222 val amount: Double,
2323 val frequency: Frequency,
24- val description: String? = null,
25- val type: Type
24+ val type: Type,
25+ val description: String? = null
2626 ) {
2727 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/boolean-subschema.schema/default/TopLevel.kt+1 −1
@@ -9,9 +9,9 @@ import com.beust.klaxon.*
99 private val klaxon = Klaxon()
1010
1111 data class TopLevel (
12+ val foo: String,
1213 val disallowed: Any? = null,
1314 val empty: List<Any?>,
14- val foo: String,
1515 val impossible: Any? = null
1616 ) {
1717 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/comment-injection.schema/default/TopLevel.kt+16 −16
@@ -23,21 +23,6 @@ private val klaxon = Klaxon()
2323 * }
2424 */
2525 data class TopLevel (
26- /**
27- * Ends with a backslash \
28- */
29- val trailingBackslash: String? = null,
30-
31- /**
32- * Ends with a quote "
33- */
34- val trailingQuote: String? = null,
35-
36- /**
37- * Ends with a triple quote """
38- */
39- val trailingTripleQuote: String? = null,
40-
4126 /**
4227 * Property delimiters:
4328 * * /
@@ -52,7 +37,22 @@ data class TopLevel (
5237 * }
5338 * }
5439 */
55- val value: String
40+ val value: String,
41+
42+ /**
43+ * Ends with a backslash \
44+ */
45+ val trailingBackslash: String? = null,
46+
47+ /**
48+ * Ends with a quote "
49+ */
50+ val trailingQuote: String? = null,
51+
52+ /**
53+ * Ends with a triple quote """
54+ */
55+ val trailingTripleQuote: String? = null
5656 ) {
5757 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/const-non-string.schema/default/TopLevel.kt+3 −3
@@ -18,11 +18,11 @@ private val klaxon = Klaxon()
1818 .convert(Kind::class, { Kind.fromValue(it.string!!) }, { "\"${it.value}\"" })
1919
2020 data class TopLevel (
21+ val version: Double,
2122 val amount: Long,
22- val enabled: Boolean,
23- val kind: Kind,
2423 val ratio: Double,
25- val version: Double
24+ val enabled: Boolean,
25+ val kind: Kind
2626 ) {
2727 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/date-time-or-string.schema/default/TopLevel.kt+2 −2
@@ -22,8 +22,8 @@ private val klaxon = Klaxon()
2222 .convert(BarUnion::class, { BarUnion.fromJson(it) }, { it.toJson() }, true)
2323
2424 data class TopLevel (
25- val bar: BarUnion,
26- val foo: String
25+ val foo: String,
26+ val bar: BarUnion
2727 ) {
2828 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/date-time.schema/default/TopLevel.kt+5 −6
@@ -27,18 +27,17 @@ private val klaxon = Klaxon()
2727 .convert(UnionArray::class, { UnionArray.fromJson(it) }, { it.toJson() }, true)
2828
2929 data class TopLevel (
30- @Json(name = "complex-union-array")
31- val complexUnionArray: List<ComplexUnionArrayElement>,
32-
3330 val date: LocalDate,
31+ val time: OffsetTime,
3432
3533 @Json(name = "date-time")
3634 val dateTime: OffsetDateTime,
3735
38- val time: OffsetTime,
39-
4036 @Json(name = "union-array")
41- val unionArray: List<UnionArray>
37+ val unionArray: List<UnionArray>,
38+
39+ @Json(name = "complex-union-array")
40+ val complexUnionArray: List<ComplexUnionArrayElement>
4241 ) {
4342 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/enum.schema/default/TopLevel.kt+4 −5
@@ -21,14 +21,13 @@ private val klaxon = Klaxon()
2121 .convert(Arr::class, { Arr.fromJson(it) }, { it.toJson() }, true)
2222
2323 data class TopLevel (
24+ val lvc: Lvc? = null,
25+ val gve: Gve,
2426 val arr: List<Arr>? = null,
27+ val otherArr: List<OtherArr>? = null,
2528
2629 @Json(name = "for")
27- val topLevelFor: String? = null,
28-
29- val gve: Gve,
30- val lvc: Lvc? = null,
31- val otherArr: List<OtherArr>? = null
30+ val topLevelFor: String? = null
3231 ) {
3332 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/integer-type.schema/default/TopLevel.kt+13 −13
@@ -9,31 +9,31 @@ import com.beust.klaxon.*
99 private val klaxon = Klaxon()
1010
1111 data class TopLevel (
12- @Json(name = "above_i32_max")
13- val aboveI32Max: Long,
12+ @Json(name = "small_positive")
13+ val smallPositive: Long,
1414
15- @Json(name = "below_i32_min")
16- val belowI32Min: Long,
15+ @Json(name = "small_negative")
16+ val smallNegative: Long,
1717
1818 @Json(name = "i32_range")
1919 val i32Range: Long,
2020
21- @Json(name = "large_bounds")
22- val largeBounds: Long,
21+ @Json(name = "above_i32_max")
22+ val aboveI32Max: Long,
2323
24- @Json(name = "only_maximum")
25- val onlyMaximum: Long,
24+ @Json(name = "below_i32_min")
25+ val belowI32Min: Long,
2626
2727 @Json(name = "only_minimum")
2828 val onlyMinimum: Long,
2929
30- @Json(name = "small_negative")
31- val smallNegative: Long,
30+ @Json(name = "only_maximum")
31+ val onlyMaximum: Long,
3232
33- @Json(name = "small_positive")
34- val smallPositive: Long,
33+ val unbounded: Long,
3534
36- val unbounded: Long
35+ @Json(name = "large_bounds")
36+ val largeBounds: Long
3737 ) {
3838 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/light.schema/default/TopLevel.kt+3 −3
@@ -20,11 +20,11 @@ data class TopLevel (
2020 }
2121
2222 data class LightParams (
23- @Json(name = "app_id")
24- val appID: String,
25-
2623 @Json(name = "outlet_id")
2724 val outletID: String,
2825
26+ @Json(name = "app_id")
27+ val appID: String,
28+
2929 val rgba: String
3030 )
Mschema-kotlin-jackson/test/inputs/schema/min-max-items.schema/default/TopLevel.kt+1 −1
@@ -18,9 +18,9 @@ private val klaxon = Klaxon()
1818 .convert(UnionItem::class, { UnionItem.fromJson(it) }, { it.toJson() }, true)
1919
2020 data class TopLevel (
21+ val minOnly: List<String>,
2122 val maxOnly: List<Long>,
2223 val minAndMax: List<Double>,
23- val minOnly: List<String>,
2424 val plain: List<String>,
2525 val unionItems: List<UnionItem>
2626 ) {
Mschema-kotlin-jackson/test/inputs/schema/minmax-integer.schema/default/TopLevel.kt+4 −4
@@ -10,13 +10,13 @@ private val klaxon = Klaxon()
1010
1111 data class TopLevel (
1212 val free: Long,
13- val intersection: Long,
14- val max: Long,
1513 val min: Long,
14+ val max: Long,
1615 val minmax: Long,
17- val minMaxIntersection: Long,
16+ val union: Long,
1817 val minMaxUnion: Long,
19- val union: Long
18+ val intersection: Long,
19+ val minMaxIntersection: Long
2020 ) {
2121 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/minmax.schema/default/TopLevel.kt+4 −4
@@ -10,13 +10,13 @@ private val klaxon = Klaxon()
1010
1111 data class TopLevel (
1212 val free: Double,
13- val intersection: Double,
14- val max: Double,
1513 val min: Double,
14+ val max: Double,
1615 val minmax: Double,
17- val minMaxIntersection: Double,
16+ val union: Double,
1817 val minMaxUnion: Double,
19- val union: Double
18+ val intersection: Double,
19+ val minMaxIntersection: Double
2020 ) {
2121 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/minmaxlength.schema/default/TopLevel.kt+5 −5
@@ -18,14 +18,14 @@ private val klaxon = Klaxon()
1818 .convert(InUnion::class, { InUnion.fromJson(it) }, { it.toJson() }, true)
1919
2020 data class TopLevel (
21- val intersection: String,
22- val inUnion: InUnion,
23- val maxlength: String,
2421 val minlength: String,
25- val minMaxIntersection: String,
22+ val maxlength: String,
2623 val minmaxlength: String,
24+ val union: String,
25+ val inUnion: InUnion,
2726 val minMaxUnion: String,
28- val union: String
27+ val intersection: String,
28+ val minMaxIntersection: String
2929 ) {
3030 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/non-standard-ref.schema/default/TopLevel.kt+1 −1
@@ -9,8 +9,8 @@ import com.beust.klaxon.*
99 private val klaxon = Klaxon()
1010
1111 data class TopLevel (
12- val bar: Long,
1312 val foo: Long,
13+ val bar: Long,
1414 val quux: Boolean
1515 ) {
1616 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.kt+2 −2
@@ -18,8 +18,8 @@ private val klaxon = Klaxon()
1818 .convert(Kind::class, { Kind.fromValue(it.string!!) }, { "\"${it.value}\"" })
1919
2020 data class TopLevel (
21- val b: String? = null,
22- val kind: Kind
21+ val kind: Kind,
22+ val b: String? = null
2323 ) {
2424 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/optional-any.schema/default/TopLevel.kt+2 −2
@@ -9,8 +9,8 @@ import com.beust.klaxon.*
99 private val klaxon = Klaxon()
1010
1111 data class TopLevel (
12- val bar: Boolean,
13- val foo: Any? = null
12+ val foo: Any? = null,
13+ val bar: Boolean
1414 ) {
1515 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/optional-const-ref.schema/default/TopLevel.kt+4 −4
@@ -10,12 +10,12 @@ private val klaxon = Klaxon()
1010
1111 data class TopLevel (
1212 val coordinates: List<Coordinate>? = null,
13- val count: Long? = null,
14- val label: String? = null,
1513 val requiredCoordinates: List<Coordinate>,
14+ val count: Long? = null,
1615 val requiredCount: Long,
17- val requiredLabel: String,
18- val weight: Double? = null
16+ val weight: Double? = null,
17+ val label: String? = null,
18+ val requiredLabel: String
1919 ) {
2020 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/optional-constraints.schema/default/TopLevel.kt+3 −3
@@ -9,11 +9,11 @@ import com.beust.klaxon.*
99 private val klaxon = Klaxon()
1010
1111 data class TopLevel (
12- val optDouble: Double? = null,
12+ val reqZeroMin: Long,
1313 val optInt: Long? = null,
14- val optPattern: String? = null,
14+ val optDouble: Double? = null,
1515 val optString: String? = null,
16- val reqZeroMin: Long
16+ val optPattern: String? = null
1717 ) {
1818 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/optional-date-time.schema/default/TopLevel.kt+11 −11
@@ -24,23 +24,23 @@ private val klaxon = Klaxon()
2424 .convert(OffsetTime::class, { OffsetTime.parse(it.string!!) }, { "\"${java.time.format.DateTimeFormatter.ISO_OFFSET_TIME.format(it)}\"" })
2525
2626 data class TopLevel (
27- @Json(name = "optional-date")
28- val optionalDate: LocalDate? = null,
29-
30- @Json(name = "optional-date-time")
31- val optionalDateTime: OffsetDateTime? = null,
32-
33- @Json(name = "optional-time")
34- val optionalTime: OffsetTime? = null,
35-
3627 @Json(name = "required-date")
3728 val requiredDate: LocalDate,
3829
30+ @Json(name = "required-time")
31+ val requiredTime: OffsetTime,
32+
3933 @Json(name = "required-date-time")
4034 val requiredDateTime: OffsetDateTime,
4135
42- @Json(name = "required-time")
43- val requiredTime: OffsetTime
36+ @Json(name = "optional-date")
37+ val optionalDate: LocalDate? = null,
38+
39+ @Json(name = "optional-time")
40+ val optionalTime: OffsetTime? = null,
41+
42+ @Json(name = "optional-date-time")
43+ val optionalDateTime: OffsetDateTime? = null
4444 ) {
4545 public fun toJson() = klaxon.toJsonString(this)
Mschema-kotlin-jackson/test/inputs/schema/prefix-items.schema/default/TopLevel.kt+2 −2
@@ -18,8 +18,8 @@ private val klaxon = Klaxon()
1818 .convert(Open::class, { Open.fromJson(it) }, { it.toJson() }, true)
1919
2020 data class TopLevel (
21- val open: List<Open>,
22- val tuple: List<Open>
21+ val tuple: List<Open>,
22+ val open: List<Open>
2323 ) {
2424 public fun toJson() = klaxon.toJsonString(this)
Aschema-kotlin-jackson/test/inputs/schema/property-order.schema/default/TopLevel.kt+30 −0
@@ -0,0 +1,30 @@
1+// To parse the JSON, install Klaxon and do:
2+//
3+// val topLevel = TopLevel.fromJson(jsonString)
4+
5+package quicktype
6+
7+import com.beust.klaxon.*
8+
9+private val klaxon = Klaxon()
10+
11+data class TopLevel (
12+ val zebra: String,
13+ val mango: Double,
14+ val apple: Boolean,
15+ val delta: String,
16+ val banana: Long,
17+ val ordered: Ordered
18+) {
19+ public fun toJson() = klaxon.toJsonString(this)
20+
21+ companion object {
22+ public fun fromJson(json: String) = klaxon.parse<TopLevel>(json)
23+ }
24+}
25+
26+data class Ordered (
27+ val mango: Double,
28+ val zebra: String,
29+ val apple: Boolean
30+)
Mschema-kotlin-jackson/test/inputs/schema/renaming-bug.schema/default/TopLevel.kt+13 −13
@@ -32,13 +32,13 @@ data class TopLevel (
3232
3333 data class Fruit (
3434 val apple: Boolean? = null,
35- val berries: List<Berry>? = null,
36- val orange: Boolean? = null
35+ val orange: Boolean? = null,
36+ val berries: List<Berry>? = null
3737 )
3838
3939 data class Berry (
40- val color: Color? = null,
4140 val name: String? = null,
41+ val color: Color? = null,
4242 val shapes: List<Shape>? = null
4343 )
4444
@@ -47,8 +47,8 @@ data class Color (
4747 )
4848
4949 data class Shape (
50- val geometry: Geometry? = null,
51- val history: History? = null
50+ val history: History? = null,
51+ val geometry: Geometry? = null
5252 )
5353
5454 data class Geometry (
@@ -65,9 +65,9 @@ data class RectShape (
6565 )
6666
6767 data class Part (
68- val depth: String? = null,
6968 val length: String? = null,
70- val width: String? = null
69+ val width: String? = null,
70+ val depth: String? = null
7171 )
7272
7373 data class History (
@@ -76,12 +76,12 @@ data class History (
7676 )
7777
7878 data class Vehicle (
79- val brand: String? = null,
8079 val id: String? = null,
81- val speed: Speed? = null,
82- val subModule: Boolean? = null,
8380 val type: VehicleType? = null,
84- val year: String? = null
81+ val speed: Speed? = null,
82+ val year: String? = null,
83+ val brand: String? = null,
84+ val subModule: Boolean? = null
8585 )
8686
8787 data class Speed (
@@ -89,8 +89,8 @@ data class Speed (
8989 )
9090
9191 data class Limit (
92- val maximum: Double? = null,
93- val minimum: Double? = null
92+ val minimum: Double? = null,
93+ val maximum: Double? = null
9494 )
9595
9696 data class VehicleType (
Mschema-kotlin-jackson/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.kt+4 −4
@@ -18,8 +18,8 @@ private val klaxon = Klaxon()
1818 .convert(Next::class, { Next.fromJson(it) }, { it.toJson() }, true)
1919
2020 data class TopLevel (
21- val next: Next? = null,
22- val value: String
21+ val value: String,
22+ val next: Next? = null
2323 ) {
2424 public fun toJson() = klaxon.toJsonString(this)
2525
@@ -29,8 +29,8 @@ data class TopLevel (
2929 }
3030
3131 data class Node (
32- val next: Next? = null,
33- val value: String
32+ val value: String,
33+ val next: Next? = null
3434 )
3535
3636 sealed class Next {
Mschema-kotlin-jackson/test/inputs/schema/vega-lite.schema/default/TopLevel.kt+49 −49
@@ -693,6 +693,13 @@ data class MarkConfig (
693693 */
694694 val fill: String? = null,
695695
696+ /**
697+ * The fill opacity (value between [0,1]).
698+ *
699+ * __Default value:__ `1`
700+ */
701+ val fillOpacity: Double? = null,
702+
696703 /**
697704 * Whether the mark's color should be used as fill color instead of stroke color.
698705 *
@@ -704,13 +711,6 @@ data class MarkConfig (
704711 */
705712 val filled: Boolean? = null,
706713
707- /**
708- * The fill opacity (value between [0,1]).
709- *
710- * __Default value:__ `1`
711- */
712- val fillOpacity: Double? = null,
713-
714714 /**
715715 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
716716 */
@@ -1285,11 +1285,6 @@ data class AxisConfig (
12851285 */
12861286 val tickRound: Boolean? = null,
12871287
1288- /**
1289- * Boolean value that determines whether the axis should include ticks.
1290- */
1291- val ticks: Boolean? = null,
1292-
12931288 /**
12941289 * The size in pixels of axis ticks.
12951290 */
@@ -1300,6 +1295,11 @@ data class AxisConfig (
13001295 */
13011296 val tickWidth: Double? = null,
13021297
1298+ /**
1299+ * Boolean value that determines whether the axis should include ticks.
1300+ */
1301+ val ticks: Boolean? = null,
1302+
13031303 /**
13041304 * Horizontal text alignment of axis titles.
13051305 */
@@ -1629,11 +1629,6 @@ data class VGAxisConfig (
16291629 */
16301630 val tickRound: Boolean? = null,
16311631
1632- /**
1633- * Boolean value that determines whether the axis should include ticks.
1634- */
1635- val ticks: Boolean? = null,
1636-
16371632 /**
16381633 * The size in pixels of axis ticks.
16391634 */
@@ -1644,6 +1639,11 @@ data class VGAxisConfig (
16441639 */
16451640 val tickWidth: Double? = null,
16461641
1642+ /**
1643+ * Boolean value that determines whether the axis should include ticks.
1644+ */
1645+ val ticks: Boolean? = null,
1646+
16471647 /**
16481648 * Horizontal text alignment of axis titles.
16491649 */
@@ -1783,6 +1783,13 @@ data class BarConfig (
17831783 */
17841784 val fill: String? = null,
17851785
1786+ /**
1787+ * The fill opacity (value between [0,1]).
1788+ *
1789+ * __Default value:__ `1`
1790+ */
1791+ val fillOpacity: Double? = null,
1792+
17861793 /**
17871794 * Whether the mark's color should be used as fill color instead of stroke color.
17881795 *
@@ -1794,13 +1801,6 @@ data class BarConfig (
17941801 */
17951802 val filled: Boolean? = null,
17961803
1797- /**
1798- * The fill opacity (value between [0,1]).
1799- *
1800- * __Default value:__ `1`
1801- */
1802- val fillOpacity: Double? = null,
1803-
18041804 /**
18051805 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
18061806 */
@@ -3239,6 +3239,13 @@ data class TextConfig (
32393239 */
32403240 val fill: String? = null,
32413241
3242+ /**
3243+ * The fill opacity (value between [0,1]).
3244+ *
3245+ * __Default value:__ `1`
3246+ */
3247+ val fillOpacity: Double? = null,
3248+
32423249 /**
32433250 * Whether the mark's color should be used as fill color instead of stroke color.
32443251 *
@@ -3250,13 +3257,6 @@ data class TextConfig (
32503257 */
32513258 val filled: Boolean? = null,
32523259
3253- /**
3254- * The fill opacity (value between [0,1]).
3255- *
3256- * __Default value:__ `1`
3257- */
3258- val fillOpacity: Double? = null,
3259-
32603260 /**
32613261 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
32623262 */
@@ -3470,6 +3470,13 @@ data class TickConfig (
34703470 */
34713471 val fill: String? = null,
34723472
3473+ /**
3474+ * The fill opacity (value between [0,1]).
3475+ *
3476+ * __Default value:__ `1`
3477+ */
3478+ val fillOpacity: Double? = null,
3479+
34733480 /**
34743481 * Whether the mark's color should be used as fill color instead of stroke color.
34753482 *
@@ -3481,13 +3488,6 @@ data class TickConfig (
34813488 */
34823489 val filled: Boolean? = null,
34833490
3484- /**
3485- * The fill opacity (value between [0,1]).
3486- *
3487- * __Default value:__ `1`
3488- */
3489- val fillOpacity: Double? = null,
3490-
34913491 /**
34923492 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
34933493 */
@@ -6603,14 +6603,14 @@ data class Axis (
66036603 val tickCount: Double? = null,
66046604
66056605 /**
6606- * Boolean value that determines whether the axis should include ticks.
6606+ * The size in pixels of axis ticks.
66076607 */
6608- val ticks: Boolean? = null,
6608+ val tickSize: Double? = null,
66096609
66106610 /**
6611- * The size in pixels of axis ticks.
6611+ * Boolean value that determines whether the axis should include ticks.
66126612 */
6613- val tickSize: Double? = null,
6613+ val ticks: Boolean? = null,
66146614
66156615 /**
66166616 * A title for the field. If `null`, the title will be removed.
@@ -7194,6 +7194,13 @@ data class MarkDef (
71947194 */
71957195 val fill: String? = null,
71967196
7197+ /**
7198+ * The fill opacity (value between [0,1]).
7199+ *
7200+ * __Default value:__ `1`
7201+ */
7202+ val fillOpacity: Double? = null,
7203+
71977204 /**
71987205 * Whether the mark's color should be used as fill color instead of stroke color.
71997206 *
@@ -7205,13 +7212,6 @@ data class MarkDef (
72057212 */
72067213 val filled: Boolean? = null,
72077214
7208- /**
7209- * The fill opacity (value between [0,1]).
7210- *
7211- * __Default value:__ `1`
7212- */
7213- val fillOpacity: Double? = null,
7214-
72157215 /**
72167216 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
72177217 */
Mschema-kotlin/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.kt+3 −3
@@ -38,10 +38,10 @@ data class TopLevel (
3838 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
3939 val frequency: Frequency,
4040
41- val description: String? = null,
42-
4341 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
44- val type: Type
42+ val type: Type,
43+
44+ val description: String? = null
4545 ) {
4646 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/boolean-subschema.schema/default/TopLevel.kt+3 −3
@@ -19,14 +19,14 @@ val mapper = jacksonObjectMapper().apply {
1919 }
2020
2121 data class TopLevel (
22+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
23+ val foo: String,
24+
2225 val disallowed: Any? = null,
2326
2427 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
2528 val empty: List<Any?>,
2629
27- @get:JsonProperty(required=true)@field:JsonProperty(required=true)
28- val foo: String,
29-
3030 val impossible: Any? = null
3131 ) {
3232 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/comment-injection.schema/default/TopLevel.kt+16 −16
@@ -33,21 +33,6 @@ val mapper = jacksonObjectMapper().apply {
3333 * }
3434 */
3535 data class TopLevel (
36- /**
37- * Ends with a backslash \
38- */
39- val trailingBackslash: String? = null,
40-
41- /**
42- * Ends with a quote "
43- */
44- val trailingQuote: String? = null,
45-
46- /**
47- * Ends with a triple quote """
48- */
49- val trailingTripleQuote: String? = null,
50-
5136 /**
5237 * Property delimiters:
5338 * * /
@@ -63,7 +48,22 @@ data class TopLevel (
6348 * }
6449 */
6550 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
66- val value: String
51+ val value: String,
52+
53+ /**
54+ * Ends with a backslash \
55+ */
56+ val trailingBackslash: String? = null,
57+
58+ /**
59+ * Ends with a quote "
60+ */
61+ val trailingQuote: String? = null,
62+
63+ /**
64+ * Ends with a triple quote """
65+ */
66+ val trailingTripleQuote: String? = null
6767 ) {
6868 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/const-non-string.schema/default/TopLevel.kt+5 −5
@@ -32,19 +32,19 @@ val mapper = jacksonObjectMapper().apply {
3232
3333 data class TopLevel (
3434 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
35- val amount: Long,
35+ val version: Double,
3636
3737 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
38- val enabled: Boolean,
38+ val amount: Long,
3939
4040 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
41- val kind: Kind,
41+ val ratio: Double,
4242
4343 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
44- val ratio: Double,
44+ val enabled: Boolean,
4545
4646 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
47- val version: Double
47+ val kind: Kind
4848 ) {
4949 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/date-time-or-string.schema/default/TopLevel.kt+2 −2
@@ -36,10 +36,10 @@ val mapper = jacksonObjectMapper().apply {
3636
3737 data class TopLevel (
3838 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
39- val bar: BarUnion,
39+ val foo: String,
4040
4141 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
42- val foo: String
42+ val bar: BarUnion
4343 ) {
4444 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/date-time.schema/default/TopLevel.kt+7 −7
@@ -40,20 +40,20 @@ val mapper = jacksonObjectMapper().apply {
4040 }
4141
4242 data class TopLevel (
43- @get:JsonProperty("complex-union-array", required=true)@field:JsonProperty("complex-union-array", required=true)
44- val complexUnionArray: List<ComplexUnionArrayElement>,
45-
4643 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
4744 val date: LocalDate,
4845
49- @get:JsonProperty("date-time", required=true)@field:JsonProperty("date-time", required=true)
50- val dateTime: OffsetDateTime,
51-
5246 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
5347 val time: OffsetTime,
5448
49+ @get:JsonProperty("date-time", required=true)@field:JsonProperty("date-time", required=true)
50+ val dateTime: OffsetDateTime,
51+
5552 @get:JsonProperty("union-array", required=true)@field:JsonProperty("union-array", required=true)
56- val unionArray: List<UnionArray>
53+ val unionArray: List<UnionArray>,
54+
55+ @get:JsonProperty("complex-union-array", required=true)@field:JsonProperty("complex-union-array", required=true)
56+ val complexUnionArray: List<ComplexUnionArrayElement>
5757 ) {
5858 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/enum.schema/default/TopLevel.kt+6 −6
@@ -34,16 +34,16 @@ val mapper = jacksonObjectMapper().apply {
3434 }
3535
3636 data class TopLevel (
37- val arr: List<Arr>? = null,
38-
39- @get:JsonProperty("for")@field:JsonProperty("for")
40- val topLevelFor: String? = null,
37+ val lvc: Lvc? = null,
4138
4239 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
4340 val gve: Gve,
4441
45- val lvc: Lvc? = null,
46- val otherArr: List<OtherArr>? = null
42+ val arr: List<Arr>? = null,
43+ val otherArr: List<OtherArr>? = null,
44+
45+ @get:JsonProperty("for")@field:JsonProperty("for")
46+ val topLevelFor: String? = null
4747 ) {
4848 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/integer-type.schema/default/TopLevel.kt+14 −14
@@ -19,32 +19,32 @@ val mapper = jacksonObjectMapper().apply {
1919 }
2020
2121 data class TopLevel (
22- @get:JsonProperty("above_i32_max", required=true)@field:JsonProperty("above_i32_max", required=true)
23- val aboveI32Max: Long,
22+ @get:JsonProperty("small_positive", required=true)@field:JsonProperty("small_positive", required=true)
23+ val smallPositive: Long,
2424
25- @get:JsonProperty("below_i32_min", required=true)@field:JsonProperty("below_i32_min", required=true)
26- val belowI32Min: Long,
25+ @get:JsonProperty("small_negative", required=true)@field:JsonProperty("small_negative", required=true)
26+ val smallNegative: Long,
2727
2828 @get:JsonProperty("i32_range", required=true)@field:JsonProperty("i32_range", required=true)
2929 val i32Range: Long,
3030
31- @get:JsonProperty("large_bounds", required=true)@field:JsonProperty("large_bounds", required=true)
32- val largeBounds: Long,
31+ @get:JsonProperty("above_i32_max", required=true)@field:JsonProperty("above_i32_max", required=true)
32+ val aboveI32Max: Long,
3333
34- @get:JsonProperty("only_maximum", required=true)@field:JsonProperty("only_maximum", required=true)
35- val onlyMaximum: Long,
34+ @get:JsonProperty("below_i32_min", required=true)@field:JsonProperty("below_i32_min", required=true)
35+ val belowI32Min: Long,
3636
3737 @get:JsonProperty("only_minimum", required=true)@field:JsonProperty("only_minimum", required=true)
3838 val onlyMinimum: Long,
3939
40- @get:JsonProperty("small_negative", required=true)@field:JsonProperty("small_negative", required=true)
41- val smallNegative: Long,
42-
43- @get:JsonProperty("small_positive", required=true)@field:JsonProperty("small_positive", required=true)
44- val smallPositive: Long,
40+ @get:JsonProperty("only_maximum", required=true)@field:JsonProperty("only_maximum", required=true)
41+ val onlyMaximum: Long,
4542
4643 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
47- val unbounded: Long
44+ val unbounded: Long,
45+
46+ @get:JsonProperty("large_bounds", required=true)@field:JsonProperty("large_bounds", required=true)
47+ val largeBounds: Long
4848 ) {
4949 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/light.schema/default/TopLevel.kt+3 −3
@@ -30,12 +30,12 @@ data class TopLevel (
3030 }
3131
3232 data class LightParams (
33- @get:JsonProperty("app_id", required=true)@field:JsonProperty("app_id", required=true)
34- val appID: String,
35-
3633 @get:JsonProperty("outlet_id", required=true)@field:JsonProperty("outlet_id", required=true)
3734 val outletID: String,
3835
36+ @get:JsonProperty("app_id", required=true)@field:JsonProperty("app_id", required=true)
37+ val appID: String,
38+
3939 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
4040 val rgba: String
4141 )
Mschema-kotlin/test/inputs/schema/min-max-items.schema/default/TopLevel.kt+3 −3
@@ -32,13 +32,13 @@ val mapper = jacksonObjectMapper().apply {
3232
3333 data class TopLevel (
3434 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
35- val maxOnly: List<Long>,
35+ val minOnly: List<String>,
3636
3737 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
38- val minAndMax: List<Double>,
38+ val maxOnly: List<Long>,
3939
4040 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
41- val minOnly: List<String>,
41+ val minAndMax: List<Double>,
4242
4343 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
4444 val plain: List<String>,
Mschema-kotlin/test/inputs/schema/minmax-integer.schema/default/TopLevel.kt+6 −6
@@ -23,25 +23,25 @@ data class TopLevel (
2323 val free: Long,
2424
2525 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
26- val intersection: Long,
26+ val min: Long,
2727
2828 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
2929 val max: Long,
3030
31- @get:JsonProperty(required=true)@field:JsonProperty(required=true)
32- val min: Long,
33-
3431 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
3532 val minmax: Long,
3633
3734 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
38- val minMaxIntersection: Long,
35+ val union: Long,
3936
4037 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
4138 val minMaxUnion: Long,
4239
4340 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
44- val union: Long
41+ val intersection: Long,
42+
43+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
44+ val minMaxIntersection: Long
4545 ) {
4646 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/minmax.schema/default/TopLevel.kt+6 −6
@@ -23,25 +23,25 @@ data class TopLevel (
2323 val free: Double,
2424
2525 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
26- val intersection: Double,
26+ val min: Double,
2727
2828 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
2929 val max: Double,
3030
31- @get:JsonProperty(required=true)@field:JsonProperty(required=true)
32- val min: Double,
33-
3431 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
3532 val minmax: Double,
3633
3734 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
38- val minMaxIntersection: Double,
35+ val union: Double,
3936
4037 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
4138 val minMaxUnion: Double,
4239
4340 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
44- val union: Double
41+ val intersection: Double,
42+
43+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
44+ val minMaxIntersection: Double
4545 ) {
4646 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/minmaxlength.schema/default/TopLevel.kt+8 −8
@@ -32,28 +32,28 @@ val mapper = jacksonObjectMapper().apply {
3232
3333 data class TopLevel (
3434 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
35- val intersection: String,
36-
37- @get:JsonProperty(required=true)@field:JsonProperty(required=true)
38- val inUnion: InUnion,
35+ val minlength: String,
3936
4037 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
4138 val maxlength: String,
4239
4340 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
44- val minlength: String,
41+ val minmaxlength: String,
4542
4643 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
47- val minMaxIntersection: String,
44+ val union: String,
4845
4946 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
50- val minmaxlength: String,
47+ val inUnion: InUnion,
5148
5249 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
5350 val minMaxUnion: String,
5451
5552 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
56- val union: String
53+ val intersection: String,
54+
55+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
56+ val minMaxIntersection: String
5757 ) {
5858 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/non-standard-ref.schema/default/TopLevel.kt+2 −2
@@ -20,10 +20,10 @@ val mapper = jacksonObjectMapper().apply {
2020
2121 data class TopLevel (
2222 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
23- val bar: Long,
23+ val foo: Long,
2424
2525 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
26- val foo: Long,
26+ val bar: Long,
2727
2828 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
2929 val quux: Boolean
Mschema-kotlin/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.kt+3 −3
@@ -31,10 +31,10 @@ val mapper = jacksonObjectMapper().apply {
3131 }
3232
3333 data class TopLevel (
34- val b: String? = null,
35-
3634 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
37- val kind: Kind
35+ val kind: Kind,
36+
37+ val b: String? = null
3838 ) {
3939 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/optional-any.schema/default/TopLevel.kt+3 −3
@@ -19,10 +19,10 @@ val mapper = jacksonObjectMapper().apply {
1919 }
2020
2121 data class TopLevel (
22- @get:JsonProperty(required=true)@field:JsonProperty(required=true)
23- val bar: Boolean,
22+ val foo: Any? = null,
2423
25- val foo: Any? = null
24+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
25+ val bar: Boolean
2626 ) {
2727 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/optional-const-ref.schema/default/TopLevel.kt+6 −5
@@ -20,19 +20,20 @@ val mapper = jacksonObjectMapper().apply {
2020
2121 data class TopLevel (
2222 val coordinates: List<Coordinate>? = null,
23- val count: Long? = null,
24- val label: String? = null,
2523
2624 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
2725 val requiredCoordinates: List<Coordinate>,
2826
27+ val count: Long? = null,
28+
2929 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
3030 val requiredCount: Long,
3131
32- @get:JsonProperty(required=true)@field:JsonProperty(required=true)
33- val requiredLabel: String,
32+ val weight: Double? = null,
33+ val label: String? = null,
3434
35- val weight: Double? = null
35+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
36+ val requiredLabel: String
3637 ) {
3738 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/optional-constraints.schema/default/TopLevel.kt+5 −5
@@ -19,13 +19,13 @@ val mapper = jacksonObjectMapper().apply {
1919 }
2020
2121 data class TopLevel (
22- val optDouble: Double? = null,
22+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
23+ val reqZeroMin: Long,
24+
2325 val optInt: Long? = null,
24- val optPattern: String? = null,
26+ val optDouble: Double? = null,
2527 val optString: String? = null,
26-
27- @get:JsonProperty(required=true)@field:JsonProperty(required=true)
28- val reqZeroMin: Long
28+ val optPattern: String? = null
2929 ) {
3030 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/optional-date-time.schema/default/TopLevel.kt+11 −11
@@ -37,23 +37,23 @@ val mapper = jacksonObjectMapper().apply {
3737 }
3838
3939 data class TopLevel (
40- @get:JsonProperty("optional-date")@field:JsonProperty("optional-date")
41- val optionalDate: LocalDate? = null,
42-
43- @get:JsonProperty("optional-date-time")@field:JsonProperty("optional-date-time")
44- val optionalDateTime: OffsetDateTime? = null,
45-
46- @get:JsonProperty("optional-time")@field:JsonProperty("optional-time")
47- val optionalTime: OffsetTime? = null,
48-
4940 @get:JsonProperty("required-date", required=true)@field:JsonProperty("required-date", required=true)
5041 val requiredDate: LocalDate,
5142
43+ @get:JsonProperty("required-time", required=true)@field:JsonProperty("required-time", required=true)
44+ val requiredTime: OffsetTime,
45+
5246 @get:JsonProperty("required-date-time", required=true)@field:JsonProperty("required-date-time", required=true)
5347 val requiredDateTime: OffsetDateTime,
5448
55- @get:JsonProperty("required-time", required=true)@field:JsonProperty("required-time", required=true)
56- val requiredTime: OffsetTime
49+ @get:JsonProperty("optional-date")@field:JsonProperty("optional-date")
50+ val optionalDate: LocalDate? = null,
51+
52+ @get:JsonProperty("optional-time")@field:JsonProperty("optional-time")
53+ val optionalTime: OffsetTime? = null,
54+
55+ @get:JsonProperty("optional-date-time")@field:JsonProperty("optional-date-time")
56+ val optionalDateTime: OffsetDateTime? = null
5757 ) {
5858 fun toJson() = mapper.writeValueAsString(this)
Mschema-kotlin/test/inputs/schema/prefix-items.schema/default/TopLevel.kt+2 −2
@@ -32,10 +32,10 @@ val mapper = jacksonObjectMapper().apply {
3232
3333 data class TopLevel (
3434 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
35- val open: List<Open>,
35+ val tuple: List<Open>,
3636
3737 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
38- val tuple: List<Open>
38+ val open: List<Open>
3939 ) {
4040 fun toJson() = mapper.writeValueAsString(this)
Aschema-kotlin/test/inputs/schema/property-order.schema/default/TopLevel.kt+56 −0
@@ -0,0 +1,56 @@
1+// To parse the JSON, install jackson-module-kotlin and do:
2+//
3+// val topLevel = TopLevel.fromJson(jsonString)
4+
5+package quicktype
6+
7+import com.fasterxml.jackson.annotation.*
8+import com.fasterxml.jackson.core.*
9+import com.fasterxml.jackson.databind.*
10+import com.fasterxml.jackson.databind.deser.std.StdDeserializer
11+import com.fasterxml.jackson.databind.module.SimpleModule
12+import com.fasterxml.jackson.databind.node.*
13+import com.fasterxml.jackson.databind.ser.std.StdSerializer
14+import com.fasterxml.jackson.module.kotlin.*
15+
16+val mapper = jacksonObjectMapper().apply {
17+ propertyNamingStrategy = PropertyNamingStrategy.LOWER_CAMEL_CASE
18+ setSerializationInclusion(JsonInclude.Include.NON_NULL)
19+}
20+
21+data class TopLevel (
22+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
23+ val zebra: String,
24+
25+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
26+ val mango: Double,
27+
28+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
29+ val apple: Boolean,
30+
31+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
32+ val delta: String,
33+
34+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
35+ val banana: Long,
36+
37+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
38+ val ordered: Ordered
39+) {
40+ fun toJson() = mapper.writeValueAsString(this)
41+
42+ companion object {
43+ fun fromJson(json: String) = mapper.readValue<TopLevel>(json)
44+ }
45+}
46+
47+data class Ordered (
48+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
49+ val mango: Double,
50+
51+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
52+ val zebra: String,
53+
54+ @get:JsonProperty(required=true)@field:JsonProperty(required=true)
55+ val apple: Boolean
56+)
Mschema-kotlin/test/inputs/schema/renaming-bug.schema/default/TopLevel.kt+13 −13
@@ -45,13 +45,13 @@ data class TopLevel (
4545
4646 data class Fruit (
4747 val apple: Boolean? = null,
48- val berries: List<Berry>? = null,
49- val orange: Boolean? = null
48+ val orange: Boolean? = null,
49+ val berries: List<Berry>? = null
5050 )
5151
5252 data class Berry (
53- val color: Color? = null,
5453 val name: String? = null,
54+ val color: Color? = null,
5555 val shapes: List<Shape>? = null
5656 )
5757
@@ -60,8 +60,8 @@ data class Color (
6060 )
6161
6262 data class Shape (
63- val geometry: Geometry? = null,
64- val history: History? = null
63+ val history: History? = null,
64+ val geometry: Geometry? = null
6565 )
6666
6767 data class Geometry (
@@ -78,9 +78,9 @@ data class RectShape (
7878 )
7979
8080 data class Part (
81- val depth: String? = null,
8281 val length: String? = null,
83- val width: String? = null
82+ val width: String? = null,
83+ val depth: String? = null
8484 )
8585
8686 data class History (
@@ -89,12 +89,12 @@ data class History (
8989 )
9090
9191 data class Vehicle (
92- val brand: String? = null,
9392 val id: String? = null,
94- val speed: Speed? = null,
95- val subModule: Boolean? = null,
9693 val type: VehicleType? = null,
97- val year: String? = null
94+ val speed: Speed? = null,
95+ val year: String? = null,
96+ val brand: String? = null,
97+ val subModule: Boolean? = null
9898 )
9999
100100 data class Speed (
@@ -102,8 +102,8 @@ data class Speed (
102102 )
103103
104104 data class Limit (
105- val maximum: Double? = null,
106- val minimum: Double? = null
105+ val minimum: Double? = null,
106+ val maximum: Double? = null
107107 )
108108
109109 data class VehicleType (
Mschema-kotlin/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.kt+6 −6
@@ -31,10 +31,10 @@ val mapper = jacksonObjectMapper().apply {
3131 }
3232
3333 data class TopLevel (
34- val next: Next? = null,
35-
3634 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
37- val value: String
35+ val value: String,
36+
37+ val next: Next? = null
3838 ) {
3939 fun toJson() = mapper.writeValueAsString(this)
4040
@@ -44,10 +44,10 @@ data class TopLevel (
4444 }
4545
4646 data class Node (
47- val next: Next? = null,
48-
4947 @get:JsonProperty(required=true)@field:JsonProperty(required=true)
50- val value: String
48+ val value: String,
49+
50+ val next: Next? = null
5151 )
5252
5353 sealed class Next {
Mschema-kotlin/test/inputs/schema/vega-lite.schema/default/TopLevel.kt+49 −49
@@ -706,6 +706,13 @@ data class MarkConfig (
706706 */
707707 val fill: String? = null,
708708
709+ /**
710+ * The fill opacity (value between [0,1]).
711+ *
712+ * __Default value:__ `1`
713+ */
714+ val fillOpacity: Double? = null,
715+
709716 /**
710717 * Whether the mark's color should be used as fill color instead of stroke color.
711718 *
@@ -717,13 +724,6 @@ data class MarkConfig (
717724 */
718725 val filled: Boolean? = null,
719726
720- /**
721- * The fill opacity (value between [0,1]).
722- *
723- * __Default value:__ `1`
724- */
725- val fillOpacity: Double? = null,
726-
727727 /**
728728 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
729729 */
@@ -1298,11 +1298,6 @@ data class AxisConfig (
12981298 */
12991299 val tickRound: Boolean? = null,
13001300
1301- /**
1302- * Boolean value that determines whether the axis should include ticks.
1303- */
1304- val ticks: Boolean? = null,
1305-
13061301 /**
13071302 * The size in pixels of axis ticks.
13081303 */
@@ -1313,6 +1308,11 @@ data class AxisConfig (
13131308 */
13141309 val tickWidth: Double? = null,
13151310
1311+ /**
1312+ * Boolean value that determines whether the axis should include ticks.
1313+ */
1314+ val ticks: Boolean? = null,
1315+
13161316 /**
13171317 * Horizontal text alignment of axis titles.
13181318 */
@@ -1642,11 +1642,6 @@ data class VGAxisConfig (
16421642 */
16431643 val tickRound: Boolean? = null,
16441644
1645- /**
1646- * Boolean value that determines whether the axis should include ticks.
1647- */
1648- val ticks: Boolean? = null,
1649-
16501645 /**
16511646 * The size in pixels of axis ticks.
16521647 */
@@ -1657,6 +1652,11 @@ data class VGAxisConfig (
16571652 */
16581653 val tickWidth: Double? = null,
16591654
1655+ /**
1656+ * Boolean value that determines whether the axis should include ticks.
1657+ */
1658+ val ticks: Boolean? = null,
1659+
16601660 /**
16611661 * Horizontal text alignment of axis titles.
16621662 */
@@ -1796,6 +1796,13 @@ data class BarConfig (
17961796 */
17971797 val fill: String? = null,
17981798
1799+ /**
1800+ * The fill opacity (value between [0,1]).
1801+ *
1802+ * __Default value:__ `1`
1803+ */
1804+ val fillOpacity: Double? = null,
1805+
17991806 /**
18001807 * Whether the mark's color should be used as fill color instead of stroke color.
18011808 *
@@ -1807,13 +1814,6 @@ data class BarConfig (
18071814 */
18081815 val filled: Boolean? = null,
18091816
1810- /**
1811- * The fill opacity (value between [0,1]).
1812- *
1813- * __Default value:__ `1`
1814- */
1815- val fillOpacity: Double? = null,
1816-
18171817 /**
18181818 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
18191819 */
@@ -3255,6 +3255,13 @@ data class TextConfig (
32553255 */
32563256 val fill: String? = null,
32573257
3258+ /**
3259+ * The fill opacity (value between [0,1]).
3260+ *
3261+ * __Default value:__ `1`
3262+ */
3263+ val fillOpacity: Double? = null,
3264+
32583265 /**
32593266 * Whether the mark's color should be used as fill color instead of stroke color.
32603267 *
@@ -3266,13 +3273,6 @@ data class TextConfig (
32663273 */
32673274 val filled: Boolean? = null,
32683275
3269- /**
3270- * The fill opacity (value between [0,1]).
3271- *
3272- * __Default value:__ `1`
3273- */
3274- val fillOpacity: Double? = null,
3275-
32763276 /**
32773277 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
32783278 */
@@ -3486,6 +3486,13 @@ data class TickConfig (
34863486 */
34873487 val fill: String? = null,
34883488
3489+ /**
3490+ * The fill opacity (value between [0,1]).
3491+ *
3492+ * __Default value:__ `1`
3493+ */
3494+ val fillOpacity: Double? = null,
3495+
34893496 /**
34903497 * Whether the mark's color should be used as fill color instead of stroke color.
34913498 *
@@ -3497,13 +3504,6 @@ data class TickConfig (
34973504 */
34983505 val filled: Boolean? = null,
34993506
3500- /**
3501- * The fill opacity (value between [0,1]).
3502- *
3503- * __Default value:__ `1`
3504- */
3505- val fillOpacity: Double? = null,
3506-
35073507 /**
35083508 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
35093509 */
@@ -6632,14 +6632,14 @@ data class Axis (
66326632 val tickCount: Double? = null,
66336633
66346634 /**
6635- * Boolean value that determines whether the axis should include ticks.
6635+ * The size in pixels of axis ticks.
66366636 */
6637- val ticks: Boolean? = null,
6637+ val tickSize: Double? = null,
66386638
66396639 /**
6640- * The size in pixels of axis ticks.
6640+ * Boolean value that determines whether the axis should include ticks.
66416641 */
6642- val tickSize: Double? = null,
6642+ val ticks: Boolean? = null,
66436643
66446644 /**
66456645 * A title for the field. If `null`, the title will be removed.
@@ -7223,6 +7223,13 @@ data class MarkDef (
72237223 */
72247224 val fill: String? = null,
72257225
7226+ /**
7227+ * The fill opacity (value between [0,1]).
7228+ *
7229+ * __Default value:__ `1`
7230+ */
7231+ val fillOpacity: Double? = null,
7232+
72267233 /**
72277234 * Whether the mark's color should be used as fill color instead of stroke color.
72287235 *
@@ -7234,13 +7241,6 @@ data class MarkDef (
72347241 */
72357242 val filled: Boolean? = null,
72367243
7237- /**
7238- * The fill opacity (value between [0,1]).
7239- *
7240- * __Default value:__ `1`
7241- */
7242- val fillOpacity: Double? = null,
7243-
72447244 /**
72457245 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
72467246 */
Mschema-kotlinx/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.kt+2 −2
@@ -14,8 +14,8 @@ import kotlinx.serialization.encoding.*
1414 data class TopLevel (
1515 val amount: Double,
1616 val frequency: Frequency,
17- val description: String? = null,
18- val type: Type
17+ val type: Type,
18+ val description: String? = null
1919 )
2020
2121 @Serializable
Mschema-kotlinx/test/inputs/schema/boolean-subschema.schema/default/TopLevel.kt+1 −1
@@ -12,8 +12,8 @@ import kotlinx.serialization.encoding.*
1212
1313 @Serializable
1414 data class TopLevel (
15+ val foo: String,
1516 val disallowed: JsonElement? = null,
1617 val empty: JsonArray,
17- val foo: String,
1818 val impossible: JsonElement? = null
1919 )
Mschema-kotlinx/test/inputs/schema/comment-injection.schema/default/TopLevel.kt+16 −16
@@ -26,21 +26,6 @@ import kotlinx.serialization.encoding.*
2626 */
2727 @Serializable
2828 data class TopLevel (
29- /**
30- * Ends with a backslash \
31- */
32- val trailingBackslash: String? = null,
33-
34- /**
35- * Ends with a quote "
36- */
37- val trailingQuote: String? = null,
38-
39- /**
40- * Ends with a triple quote """
41- */
42- val trailingTripleQuote: String? = null,
43-
4429 /**
4530 * Property delimiters:
4631 * * /
@@ -55,5 +40,20 @@ data class TopLevel (
5540 * }
5641 * }
5742 */
58- val value: String
43+ val value: String,
44+
45+ /**
46+ * Ends with a backslash \
47+ */
48+ val trailingBackslash: String? = null,
49+
50+ /**
51+ * Ends with a quote "
52+ */
53+ val trailingQuote: String? = null,
54+
55+ /**
56+ * Ends with a triple quote """
57+ */
58+ val trailingTripleQuote: String? = null
5959 )
Mschema-kotlinx/test/inputs/schema/const-non-string.schema/default/TopLevel.kt+3 −3
@@ -12,11 +12,11 @@ import kotlinx.serialization.encoding.*
1212
1313 @Serializable
1414 data class TopLevel (
15+ val version: Double,
1516 val amount: Long,
16- val enabled: Boolean,
17- val kind: Kind,
1817 val ratio: Double,
19- val version: Double
18+ val enabled: Boolean,
19+ val kind: Kind
2020 )
2121
2222 @Serializable
Mschema-kotlinx/test/inputs/schema/integer-type.schema/default/TopLevel.kt+13 −13
@@ -12,29 +12,29 @@ import kotlinx.serialization.encoding.*
1212
1313 @Serializable
1414 data class TopLevel (
15- @SerialName("above_i32_max")
16- val aboveI32Max: Long,
15+ @SerialName("small_positive")
16+ val smallPositive: Long,
1717
18- @SerialName("below_i32_min")
19- val belowI32Min: Long,
18+ @SerialName("small_negative")
19+ val smallNegative: Long,
2020
2121 @SerialName("i32_range")
2222 val i32Range: Long,
2323
24- @SerialName("large_bounds")
25- val largeBounds: Long,
24+ @SerialName("above_i32_max")
25+ val aboveI32Max: Long,
2626
27- @SerialName("only_maximum")
28- val onlyMaximum: Long,
27+ @SerialName("below_i32_min")
28+ val belowI32Min: Long,
2929
3030 @SerialName("only_minimum")
3131 val onlyMinimum: Long,
3232
33- @SerialName("small_negative")
34- val smallNegative: Long,
33+ @SerialName("only_maximum")
34+ val onlyMaximum: Long,
3535
36- @SerialName("small_positive")
37- val smallPositive: Long,
36+ val unbounded: Long,
3837
39- val unbounded: Long
38+ @SerialName("large_bounds")
39+ val largeBounds: Long
4040 )
Mschema-kotlinx/test/inputs/schema/light.schema/default/TopLevel.kt+3 −3
@@ -18,11 +18,11 @@ data class TopLevel (
1818
1919 @Serializable
2020 data class LightParams (
21- @SerialName("app_id")
22- val appID: String,
23-
2421 @SerialName("outlet_id")
2522 val outletID: String,
2623
24+ @SerialName("app_id")
25+ val appID: String,
26+
2727 val rgba: String
2828 )
Mschema-kotlinx/test/inputs/schema/minmax-integer.schema/default/TopLevel.kt+4 −4
@@ -13,11 +13,11 @@ import kotlinx.serialization.encoding.*
1313 @Serializable
1414 data class TopLevel (
1515 val free: Long,
16- val intersection: Long,
17- val max: Long,
1816 val min: Long,
17+ val max: Long,
1918 val minmax: Long,
20- val minMaxIntersection: Long,
19+ val union: Long,
2120 val minMaxUnion: Long,
22- val union: Long
21+ val intersection: Long,
22+ val minMaxIntersection: Long
2323 )
Mschema-kotlinx/test/inputs/schema/minmax.schema/default/TopLevel.kt+4 −4
@@ -13,11 +13,11 @@ import kotlinx.serialization.encoding.*
1313 @Serializable
1414 data class TopLevel (
1515 val free: Double,
16- val intersection: Double,
17- val max: Double,
1816 val min: Double,
17+ val max: Double,
1918 val minmax: Double,
20- val minMaxIntersection: Double,
19+ val union: Double,
2120 val minMaxUnion: Double,
22- val union: Double
21+ val intersection: Double,
22+ val minMaxIntersection: Double
2323 )
Mschema-kotlinx/test/inputs/schema/non-standard-ref.schema/default/TopLevel.kt+1 −1
@@ -12,7 +12,7 @@ import kotlinx.serialization.encoding.*
1212
1313 @Serializable
1414 data class TopLevel (
15- val bar: Long,
1615 val foo: Long,
16+ val bar: Long,
1717 val quux: Boolean
1818 )
Mschema-kotlinx/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.kt+2 −2
@@ -12,8 +12,8 @@ import kotlinx.serialization.encoding.*
1212
1313 @Serializable
1414 data class TopLevel (
15- val b: String? = null,
16- val kind: Kind
15+ val kind: Kind,
16+ val b: String? = null
1717 )
1818
1919 @Serializable
Mschema-kotlinx/test/inputs/schema/optional-any.schema/default/TopLevel.kt+2 −2
@@ -12,6 +12,6 @@ import kotlinx.serialization.encoding.*
1212
1313 @Serializable
1414 data class TopLevel (
15- val bar: Boolean,
16- val foo: JsonElement? = null
15+ val foo: JsonElement? = null,
16+ val bar: Boolean
1717 )
Mschema-kotlinx/test/inputs/schema/optional-const-ref.schema/default/TopLevel.kt+4 −4
@@ -13,12 +13,12 @@ import kotlinx.serialization.encoding.*
1313 @Serializable
1414 data class TopLevel (
1515 val coordinates: List<Coordinate>? = null,
16- val count: Long? = null,
17- val label: String? = null,
1816 val requiredCoordinates: List<Coordinate>,
17+ val count: Long? = null,
1918 val requiredCount: Long,
20- val requiredLabel: String,
21- val weight: Double? = null
19+ val weight: Double? = null,
20+ val label: String? = null,
21+ val requiredLabel: String
2222 )
2323
2424 @Serializable
Mschema-kotlinx/test/inputs/schema/optional-constraints.schema/default/TopLevel.kt+3 −3
@@ -12,9 +12,9 @@ import kotlinx.serialization.encoding.*
1212
1313 @Serializable
1414 data class TopLevel (
15- val optDouble: Double? = null,
15+ val reqZeroMin: Long,
1616 val optInt: Long? = null,
17- val optPattern: String? = null,
17+ val optDouble: Double? = null,
1818 val optString: String? = null,
19- val reqZeroMin: Long
19+ val optPattern: String? = null
2020 )
Mschema-kotlinx/test/inputs/schema/optional-date-time.schema/default/TopLevel.kt+11 −11
@@ -18,23 +18,23 @@ import kotlinx.serialization.encoding.*
1818
1919 @Serializable
2020 data class TopLevel (
21- @SerialName("optional-date")
22- val optionalDate: LocalDate? = null,
23-
24- @SerialName("optional-date-time")
25- val optionalDateTime: OffsetDateTime? = null,
26-
27- @SerialName("optional-time")
28- val optionalTime: OffsetTime? = null,
29-
3021 @SerialName("required-date")
3122 val requiredDate: LocalDate,
3223
24+ @SerialName("required-time")
25+ val requiredTime: OffsetTime,
26+
3327 @SerialName("required-date-time")
3428 val requiredDateTime: OffsetDateTime,
3529
36- @SerialName("required-time")
37- val requiredTime: OffsetTime
30+ @SerialName("optional-date")
31+ val optionalDate: LocalDate? = null,
32+
33+ @SerialName("optional-time")
34+ val optionalTime: OffsetTime? = null,
35+
36+ @SerialName("optional-date-time")
37+ val optionalDateTime: OffsetDateTime? = null
3838 )
3939
4040 object OffsetDateTimeSerializer : KSerializer<OffsetDateTime> {
Aschema-kotlinx/test/inputs/schema/property-order.schema/default/TopLevel.kt+28 −0
@@ -0,0 +1,28 @@
1+// To parse the JSON, install kotlin's serialization plugin and do:
2+//
3+// val json = Json { allowStructuredMapKeys = true }
4+// val topLevel = json.parse(TopLevel.serializer(), jsonString)
5+
6+package quicktype
7+
8+import kotlinx.serialization.*
9+import kotlinx.serialization.json.*
10+import kotlinx.serialization.descriptors.*
11+import kotlinx.serialization.encoding.*
12+
13+@Serializable
14+data class TopLevel (
15+ val zebra: String,
16+ val mango: Double,
17+ val apple: Boolean,
18+ val delta: String,
19+ val banana: Long,
20+ val ordered: Ordered
21+)
22+
23+@Serializable
24+data class Ordered (
25+ val mango: Double,
26+ val zebra: String,
27+ val apple: Boolean
28+)
Mschema-kotlinx/test/inputs/schema/renaming-bug.schema/default/TopLevel.kt+13 −13
@@ -20,14 +20,14 @@ data class TopLevel (
2020 @Serializable
2121 data class Fruit (
2222 val apple: Boolean? = null,
23- val berries: List<Berry>? = null,
24- val orange: Boolean? = null
23+ val orange: Boolean? = null,
24+ val berries: List<Berry>? = null
2525 )
2626
2727 @Serializable
2828 data class Berry (
29- val color: Color? = null,
3029 val name: String? = null,
30+ val color: Color? = null,
3131 val shapes: List<Shape>? = null
3232 )
3333
@@ -38,8 +38,8 @@ data class Color (
3838
3939 @Serializable
4040 data class Shape (
41- val geometry: Geometry? = null,
42- val history: History? = null
41+ val history: History? = null,
42+ val geometry: Geometry? = null
4343 )
4444
4545 @Serializable
@@ -60,9 +60,9 @@ data class RectShape (
6060
6161 @Serializable
6262 data class Part (
63- val depth: String? = null,
6463 val length: String? = null,
65- val width: String? = null
64+ val width: String? = null,
65+ val depth: String? = null
6666 )
6767
6868 @Serializable
@@ -73,12 +73,12 @@ data class History (
7373
7474 @Serializable
7575 data class Vehicle (
76- val brand: String? = null,
7776 val id: String? = null,
78- val speed: Speed? = null,
79- val subModule: Boolean? = null,
8077 val type: VehicleType? = null,
81- val year: String? = null
78+ val speed: Speed? = null,
79+ val year: String? = null,
80+ val brand: String? = null,
81+ val subModule: Boolean? = null
8282 )
8383
8484 @Serializable
@@ -88,8 +88,8 @@ data class Speed (
8888
8989 @Serializable
9090 data class Limit (
91- val maximum: Double? = null,
92- val minimum: Double? = null
91+ val minimum: Double? = null,
92+ val maximum: Double? = null
9393 )
9494
9595 @Serializable
Mschema-kotlinx/test/inputs/schema/uuid.schema/default/TopLevel.kt+3 −3
@@ -12,10 +12,10 @@ import kotlinx.serialization.encoding.*
1212
1313 @Serializable
1414 data class TopLevel (
15- val arrNullable: List<String?>? = null,
16- val arrOne: List<String>? = null,
17- val nullable: String? = null,
1815 val one: String,
1916 val optional: String? = null,
17+ val nullable: String? = null,
18+ val arrOne: List<String>? = null,
19+ val arrNullable: List<String?>? = null,
2020 val unionWithEnum: String
2121 )
Mschema-kotlinx/test/inputs/schema/vega-lite.schema/default/TopLevel.kt+49 −49
@@ -585,6 +585,13 @@ data class MarkConfig (
585585 */
586586 val fill: String? = null,
587587
588+ /**
589+ * The fill opacity (value between [0,1]).
590+ *
591+ * __Default value:__ `1`
592+ */
593+ val fillOpacity: Double? = null,
594+
588595 /**
589596 * Whether the mark's color should be used as fill color instead of stroke color.
590597 *
@@ -596,13 +603,6 @@ data class MarkConfig (
596603 */
597604 val filled: Boolean? = null,
598605
599- /**
600- * The fill opacity (value between [0,1]).
601- *
602- * __Default value:__ `1`
603- */
604- val fillOpacity: Double? = null,
605-
606606 /**
607607 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
608608 */
@@ -1070,11 +1070,6 @@ data class AxisConfig (
10701070 */
10711071 val tickRound: Boolean? = null,
10721072
1073- /**
1074- * Boolean value that determines whether the axis should include ticks.
1075- */
1076- val ticks: Boolean? = null,
1077-
10781073 /**
10791074 * The size in pixels of axis ticks.
10801075 */
@@ -1085,6 +1080,11 @@ data class AxisConfig (
10851080 */
10861081 val tickWidth: Double? = null,
10871082
1083+ /**
1084+ * Boolean value that determines whether the axis should include ticks.
1085+ */
1086+ val ticks: Boolean? = null,
1087+
10881088 /**
10891089 * Horizontal text alignment of axis titles.
10901090 */
@@ -1372,11 +1372,6 @@ data class VGAxisConfig (
13721372 */
13731373 val tickRound: Boolean? = null,
13741374
1375- /**
1376- * Boolean value that determines whether the axis should include ticks.
1377- */
1378- val ticks: Boolean? = null,
1379-
13801375 /**
13811376 * The size in pixels of axis ticks.
13821377 */
@@ -1387,6 +1382,11 @@ data class VGAxisConfig (
13871382 */
13881383 val tickWidth: Double? = null,
13891384
1385+ /**
1386+ * Boolean value that determines whether the axis should include ticks.
1387+ */
1388+ val ticks: Boolean? = null,
1389+
13901390 /**
13911391 * Horizontal text alignment of axis titles.
13921392 */
@@ -1527,6 +1527,13 @@ data class BarConfig (
15271527 */
15281528 val fill: String? = null,
15291529
1530+ /**
1531+ * The fill opacity (value between [0,1]).
1532+ *
1533+ * __Default value:__ `1`
1534+ */
1535+ val fillOpacity: Double? = null,
1536+
15301537 /**
15311538 * Whether the mark's color should be used as fill color instead of stroke color.
15321539 *
@@ -1538,13 +1545,6 @@ data class BarConfig (
15381545 */
15391546 val filled: Boolean? = null,
15401547
1541- /**
1542- * The fill opacity (value between [0,1]).
1543- *
1544- * __Default value:__ `1`
1545- */
1546- val fillOpacity: Double? = null,
1547-
15481548 /**
15491549 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
15501550 */
@@ -2869,6 +2869,13 @@ data class TextConfig (
28692869 */
28702870 val fill: String? = null,
28712871
2872+ /**
2873+ * The fill opacity (value between [0,1]).
2874+ *
2875+ * __Default value:__ `1`
2876+ */
2877+ val fillOpacity: Double? = null,
2878+
28722879 /**
28732880 * Whether the mark's color should be used as fill color instead of stroke color.
28742881 *
@@ -2880,13 +2887,6 @@ data class TextConfig (
28802887 */
28812888 val filled: Boolean? = null,
28822889
2883- /**
2884- * The fill opacity (value between [0,1]).
2885- *
2886- * __Default value:__ `1`
2887- */
2888- val fillOpacity: Double? = null,
2889-
28902890 /**
28912891 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
28922892 */
@@ -3101,6 +3101,13 @@ data class TickConfig (
31013101 */
31023102 val fill: String? = null,
31033103
3104+ /**
3105+ * The fill opacity (value between [0,1]).
3106+ *
3107+ * __Default value:__ `1`
3108+ */
3109+ val fillOpacity: Double? = null,
3110+
31043111 /**
31053112 * Whether the mark's color should be used as fill color instead of stroke color.
31063113 *
@@ -3112,13 +3119,6 @@ data class TickConfig (
31123119 */
31133120 val filled: Boolean? = null,
31143121
3115- /**
3116- * The fill opacity (value between [0,1]).
3117- *
3118- * __Default value:__ `1`
3119- */
3120- val fillOpacity: Double? = null,
3121-
31223122 /**
31233123 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
31243124 */
@@ -5769,14 +5769,14 @@ data class Axis (
57695769 val tickCount: Double? = null,
57705770
57715771 /**
5772- * Boolean value that determines whether the axis should include ticks.
5772+ * The size in pixels of axis ticks.
57735773 */
5774- val ticks: Boolean? = null,
5774+ val tickSize: Double? = null,
57755775
57765776 /**
5777- * The size in pixels of axis ticks.
5777+ * Boolean value that determines whether the axis should include ticks.
57785778 */
5779- val tickSize: Double? = null,
5779+ val ticks: Boolean? = null,
57805780
57815781 /**
57825782 * A title for the field. If `null`, the title will be removed.
@@ -6342,6 +6342,13 @@ data class MarkDef (
63426342 */
63436343 val fill: String? = null,
63446344
6345+ /**
6346+ * The fill opacity (value between [0,1]).
6347+ *
6348+ * __Default value:__ `1`
6349+ */
6350+ val fillOpacity: Double? = null,
6351+
63456352 /**
63466353 * Whether the mark's color should be used as fill color instead of stroke color.
63476354 *
@@ -6353,13 +6360,6 @@ data class MarkDef (
63536360 */
63546361 val filled: Boolean? = null,
63556362
6356- /**
6357- * The fill opacity (value between [0,1]).
6358- *
6359- * __Default value:__ `1`
6360- */
6361- val fillOpacity: Double? = null,
6362-
63636363 /**
63646364 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
63656365 */
Mschema-php/test/inputs/schema/accessors.schema/default/TopLevel.php+76 −76
@@ -4,69 +4,92 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private string $barre; // json:bar Required
7+ private bool|float $unionization; // json:union Required
88 private EnumEnum $enumerification; // json:enum Required
99 private string $foo; // json:foo Required
10- private bool|float $unionization; // json:union Required
10+ private string $barre; // json:bar Required
1111
1212 /**
13- * @param string $barre
13+ * @param bool|float $unionization
1414 * @param EnumEnum $enumerification
1515 * @param string $foo
16- * @param bool|float $unionization
16+ * @param string $barre
1717 */
18- public function __construct(string $barre, EnumEnum $enumerification, string $foo, bool|float $unionization) {
19- $this->barre = $barre;
18+ public function __construct(bool|float $unionization, EnumEnum $enumerification, string $foo, string $barre) {
19+ $this->unionization = $unionization;
2020 $this->enumerification = $enumerification;
2121 $this->foo = $foo;
22- $this->unionization = $unionization;
22+ $this->barre = $barre;
2323 }
2424
2525 /**
26- * @param string $value
26+ * @param bool|float $value
2727 * @throws Exception
28- * @return string
28+ * @return bool|float
2929 */
30- public static function fromBarre(string $value): string {
31- return $value; /*string*/
30+ public static function fromUnionization(bool|float $value): bool|float {
31+ if (is_bool($value)) {
32+ return $value; /*bool*/
33+ } elseif (is_float($value) || is_int($value)) {
34+ return $value; /*float*/
35+ } else {
36+ throw new Exception('Cannot deserialize union value in TopLevel');
37+ }
3238 }
3339
3440 /**
3541 * @throws Exception
36- * @return string
42+ * @return bool|float
3743 */
38- public function toBarre(): string {
39- if (TopLevel::validateBarre($this->barre)) {
40- return $this->barre; /*string*/
44+ public function toUnionization(): bool|float {
45+ if (TopLevel::validateUnionization($this->unionization)) {
46+ if (is_bool($this->unionization)) {
47+ return $this->unionization; /*bool*/
48+ } elseif (is_float($this->unionization) || is_int($this->unionization)) {
49+ return $this->unionization; /*float*/
50+ } else {
51+ throw new Exception('Union value has no matching member in TopLevel');
52+ }
4153 }
42- throw new Exception('never get to this TopLevel::barre');
54+ throw new Exception('never get to this TopLevel::unionization');
4355 }
4456
4557 /**
46- * @param string
58+ * @param bool|float
4759 * @return bool
4860 * @throws Exception
4961 */
50- public static function validateBarre(string $value): bool {
62+ public static function validateUnionization(bool|float $value): bool {
63+ if (is_bool($value)) {
64+ if (!is_bool($value)) {
65+ throw new Exception("Attribute Error:TopLevel::unionization");
66+ }
67+ } elseif (is_float($value) || is_int($value)) {
68+ if (!is_float($value) && !is_int($value)) {
69+ throw new Exception("Attribute Error:TopLevel::unionization");
70+ }
71+ } else {
72+ throw new Exception("Attribute Error:TopLevel::unionization");
73+ }
5174 return true;
5275 }
5376
5477 /**
5578 * @throws Exception
56- * @return string
79+ * @return bool|float
5780 */
58- public function getBarre(): string {
59- if (TopLevel::validateBarre($this->barre)) {
60- return $this->barre;
81+ public function getUnionization(): bool|float {
82+ if (TopLevel::validateUnionization($this->unionization)) {
83+ return $this->unionization;
6184 }
62- throw new Exception('never get to getBarre TopLevel::barre');
85+ throw new Exception('never get to getUnionization TopLevel::unionization');
6386 }
6487
6588 /**
66- * @return string
89+ * @return bool|float
6790 */
68- public static function sampleBarre(): string {
69- return 'TopLevel::barre::31'; /*31:barre*/
91+ public static function sampleUnionization(): bool|float {
92+ return true; /*31:unionization*/
7093 }
7194
7295 /**
@@ -165,73 +188,50 @@ class TopLevel {
165188 }
166189
167190 /**
168- * @param bool|float $value
191+ * @param string $value
169192 * @throws Exception
170- * @return bool|float
193+ * @return string
171194 */
172- public static function fromUnionization(bool|float $value): bool|float {
173- if (is_bool($value)) {
174- return $value; /*bool*/
175- } elseif (is_float($value) || is_int($value)) {
176- return $value; /*float*/
177- } else {
178- throw new Exception('Cannot deserialize union value in TopLevel');
179- }
195+ public static function fromBarre(string $value): string {
196+ return $value; /*string*/
180197 }
181198
182199 /**
183200 * @throws Exception
184- * @return bool|float
201+ * @return string
185202 */
186- public function toUnionization(): bool|float {
187- if (TopLevel::validateUnionization($this->unionization)) {
188- if (is_bool($this->unionization)) {
189- return $this->unionization; /*bool*/
190- } elseif (is_float($this->unionization) || is_int($this->unionization)) {
191- return $this->unionization; /*float*/
192- } else {
193- throw new Exception('Union value has no matching member in TopLevel');
194- }
203+ public function toBarre(): string {
204+ if (TopLevel::validateBarre($this->barre)) {
205+ return $this->barre; /*string*/
195206 }
196- throw new Exception('never get to this TopLevel::unionization');
207+ throw new Exception('never get to this TopLevel::barre');
197208 }
198209
199210 /**
200- * @param bool|float
211+ * @param string
201212 * @return bool
202213 * @throws Exception
203214 */
204- public static function validateUnionization(bool|float $value): bool {
205- if (is_bool($value)) {
206- if (!is_bool($value)) {
207- throw new Exception("Attribute Error:TopLevel::unionization");
208- }
209- } elseif (is_float($value) || is_int($value)) {
210- if (!is_float($value) && !is_int($value)) {
211- throw new Exception("Attribute Error:TopLevel::unionization");
212- }
213- } else {
214- throw new Exception("Attribute Error:TopLevel::unionization");
215- }
215+ public static function validateBarre(string $value): bool {
216216 return true;
217217 }
218218
219219 /**
220220 * @throws Exception
221- * @return bool|float
221+ * @return string
222222 */
223- public function getUnionization(): bool|float {
224- if (TopLevel::validateUnionization($this->unionization)) {
225- return $this->unionization;
223+ public function getBarre(): string {
224+ if (TopLevel::validateBarre($this->barre)) {
225+ return $this->barre;
226226 }
227- throw new Exception('never get to getUnionization TopLevel::unionization');
227+ throw new Exception('never get to getBarre TopLevel::barre');
228228 }
229229
230230 /**
231- * @return bool|float
231+ * @return string
232232 */
233- public static function sampleUnionization(): bool|float {
234- return true; /*34:unionization*/
233+ public static function sampleBarre(): string {
234+ return 'TopLevel::barre::34'; /*34:barre*/
235235 }
236236
237237 /**
@@ -239,10 +239,10 @@ class TopLevel {
239239 * @return bool
240240 */
241241 public function validate(): bool {
242- return TopLevel::validateBarre($this->barre)
242+ return TopLevel::validateUnionization($this->unionization)
243243 || TopLevel::validateEnumerification($this->enumerification)
244244 || TopLevel::validateFoo($this->foo)
245- || TopLevel::validateUnionization($this->unionization);
245+ || TopLevel::validateBarre($this->barre);
246246 }
247247
248248 /**
@@ -251,10 +251,10 @@ class TopLevel {
251251 */
252252 public function to(): stdClass {
253253 $out = new stdClass();
254- $out->{'bar'} = $this->toBarre();
254+ $out->{'union'} = $this->toUnionization();
255255 $out->{'enum'} = $this->toEnumerification();
256256 $out->{'foo'} = $this->toFoo();
257- $out->{'union'} = $this->toUnionization();
257+ $out->{'bar'} = $this->toBarre();
258258 return $out;
259259 }
260260
@@ -265,10 +265,10 @@ class TopLevel {
265265 */
266266 public static function from(stdClass $obj): TopLevel {
267267 return new TopLevel(
268- TopLevel::fromBarre($obj->{'bar'})
268+ TopLevel::fromUnionization($obj->{'union'})
269269 ,TopLevel::fromEnumerification($obj->{'enum'})
270270 ,TopLevel::fromFoo($obj->{'foo'})
271- ,TopLevel::fromUnionization($obj->{'union'})
271+ ,TopLevel::fromBarre($obj->{'bar'})
272272 );
273273 }
274274
@@ -277,10 +277,10 @@ class TopLevel {
277277 */
278278 public static function sample(): TopLevel {
279279 return new TopLevel(
280- TopLevel::sampleBarre()
280+ TopLevel::sampleUnionization()
281281 ,TopLevel::sampleEnumerification()
282282 ,TopLevel::sampleFoo()
283- ,TopLevel::sampleUnionization()
283+ ,TopLevel::sampleBarre()
284284 );
285285 }
286286 }
Mschema-php/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.php+58 −58
@@ -6,20 +6,20 @@ declare(strict_types=1);
66 class TopLevel {
77 private float $amount; // json:amount Required
88 private Frequency $frequency; // json:frequency Required
9- private ?string $description; // json:description Optional
109 private Type $type; // json:type Required
10+ private ?string $description; // json:description Optional
1111
1212 /**
1313 * @param float $amount
1414 * @param Frequency $frequency
15- * @param string|null $description
1615 * @param Type $type
16+ * @param string|null $description
1717 */
18- public function __construct(float $amount, Frequency $frequency, ?string $description, Type $type) {
18+ public function __construct(float $amount, Frequency $frequency, Type $type, ?string $description) {
1919 $this->amount = $amount;
2020 $this->frequency = $frequency;
21- $this->description = $description;
2221 $this->type = $type;
22+ $this->description = $description;
2323 }
2424
2525 /**
@@ -118,108 +118,108 @@ class TopLevel {
118118 }
119119
120120 /**
121- * @param ?string $value
121+ * @param string $value
122122 * @throws Exception
123- * @return ?string
123+ * @return Type
124124 */
125- public static function fromDescription(?string $value): ?string {
126- if (!is_null($value)) {
127- return $value; /*string*/
128- } else {
129- return null;
130- }
125+ public static function fromType(string $value): Type {
126+ return Type::from($value); /*enum*/
131127 }
132128
133129 /**
134130 * @throws Exception
135- * @return ?string
131+ * @return string
136132 */
137- public function toDescription(): ?string {
138- if (TopLevel::validateDescription($this->description)) {
139- if (!is_null($this->description)) {
140- return $this->description; /*string*/
141- } else {
142- return null;
143- }
133+ public function toType(): string {
134+ if (TopLevel::validateType($this->type)) {
135+ return Type::to($this->type); /*enum*/
144136 }
145- throw new Exception('never get to this TopLevel::description');
137+ throw new Exception('never get to this TopLevel::type');
146138 }
147139
148140 /**
149- * @param string|null
141+ * @param Type
150142 * @return bool
151143 * @throws Exception
152144 */
153- public static function validateDescription(?string $value): bool {
154- if (!is_null($value)) {
155- }
145+ public static function validateType(Type $value): bool {
146+ Type::to($value);
156147 return true;
157148 }
158149
159150 /**
160151 * @throws Exception
161- * @return ?string
152+ * @return Type
162153 */
163- public function getDescription(): ?string {
164- if (TopLevel::validateDescription($this->description)) {
165- return $this->description;
154+ public function getType(): Type {
155+ if (TopLevel::validateType($this->type)) {
156+ return $this->type;
166157 }
167- throw new Exception('never get to getDescription TopLevel::description');
158+ throw new Exception('never get to getType TopLevel::type');
168159 }
169160
170161 /**
171- * @return ?string
162+ * @return Type
172163 */
173- public static function sampleDescription(): ?string {
174- return 'TopLevel::description::33'; /*33:description*/
164+ public static function sampleType(): Type {
165+ return Type::sample(); /*enum*/
175166 }
176167
177168 /**
178- * @param string $value
169+ * @param ?string $value
179170 * @throws Exception
180- * @return Type
171+ * @return ?string
181172 */
182- public static function fromType(string $value): Type {
183- return Type::from($value); /*enum*/
173+ public static function fromDescription(?string $value): ?string {
174+ if (!is_null($value)) {
175+ return $value; /*string*/
176+ } else {
177+ return null;
178+ }
184179 }
185180
186181 /**
187182 * @throws Exception
188- * @return string
183+ * @return ?string
189184 */
190- public function toType(): string {
191- if (TopLevel::validateType($this->type)) {
192- return Type::to($this->type); /*enum*/
185+ public function toDescription(): ?string {
186+ if (TopLevel::validateDescription($this->description)) {
187+ if (!is_null($this->description)) {
188+ return $this->description; /*string*/
189+ } else {
190+ return null;
191+ }
193192 }
194- throw new Exception('never get to this TopLevel::type');
193+ throw new Exception('never get to this TopLevel::description');
195194 }
196195
197196 /**
198- * @param Type
197+ * @param string|null
199198 * @return bool
200199 * @throws Exception
201200 */
202- public static function validateType(Type $value): bool {
203- Type::to($value);
201+ public static function validateDescription(?string $value): bool {
202+ if (!is_null($value)) {
203+ }
204204 return true;
205205 }
206206
207207 /**
208208 * @throws Exception
209- * @return Type
209+ * @return ?string
210210 */
211- public function getType(): Type {
212- if (TopLevel::validateType($this->type)) {
213- return $this->type;
211+ public function getDescription(): ?string {
212+ if (TopLevel::validateDescription($this->description)) {
213+ return $this->description;
214214 }
215- throw new Exception('never get to getType TopLevel::type');
215+ throw new Exception('never get to getDescription TopLevel::description');
216216 }
217217
218218 /**
219- * @return Type
219+ * @return ?string
220220 */
221- public static function sampleType(): Type {
222- return Type::sample(); /*enum*/
221+ public static function sampleDescription(): ?string {
222+ return 'TopLevel::description::34'; /*34:description*/
223223 }
224224
225225 /**
@@ -229,8 +229,8 @@ class TopLevel {
229229 public function validate(): bool {
230230 return TopLevel::validateAmount($this->amount)
231231 || TopLevel::validateFrequency($this->frequency)
232- || TopLevel::validateDescription($this->description)
233- || TopLevel::validateType($this->type);
232+ || TopLevel::validateType($this->type)
233+ || TopLevel::validateDescription($this->description);
234234 }
235235
236236 /**
@@ -241,8 +241,8 @@ class TopLevel {
241241 $out = new stdClass();
242242 $out->{'amount'} = $this->toAmount();
243243 $out->{'frequency'} = $this->toFrequency();
244- $out->{'description'} = $this->toDescription();
245244 $out->{'type'} = $this->toType();
245+ $out->{'description'} = $this->toDescription();
246246 return $out;
247247 }
248248
@@ -255,8 +255,8 @@ class TopLevel {
255255 return new TopLevel(
256256 TopLevel::fromAmount($obj->{'amount'})
257257 ,TopLevel::fromFrequency($obj->{'frequency'})
258- ,TopLevel::fromDescription($obj->{'description'})
259258 ,TopLevel::fromType($obj->{'type'})
259+ ,TopLevel::fromDescription($obj->{'description'})
260260 );
261261 }
262262
@@ -267,8 +267,8 @@ class TopLevel {
267267 return new TopLevel(
268268 TopLevel::sampleAmount()
269269 ,TopLevel::sampleFrequency()
270- ,TopLevel::sampleDescription()
271270 ,TopLevel::sampleType()
271+ ,TopLevel::sampleDescription()
272272 );
273273 }
274274 }
Mschema-php/test/inputs/schema/bool-string.schema/default/TopLevel.php+151 −151
@@ -4,124 +4,88 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private ?array $arrNullable; // json:arrNullable Optional
8- private ?array $arrOne; // json:arrOne Optional
9- private ?string $nullable; // json:nullable Optional
107 private string $one; // json:one Required
118 private ?string $optional; // json:optional Optional
9+ private ?string $nullable; // json:nullable Optional
10+ private ?array $arrOne; // json:arrOne Optional
11+ private ?array $arrNullable; // json:arrNullable Optional
1212 private bool|string $unionWithBool; // json:unionWithBool Required
1313 private bool|string $unionWithBoolAndEnum; // json:unionWithBoolAndEnum Required
1414
1515 /**
16- * @param array|null $arrNullable
17- * @param array|null $arrOne
18- * @param string|null $nullable
1916 * @param string $one
2017 * @param string|null $optional
18+ * @param string|null $nullable
19+ * @param array|null $arrOne
20+ * @param array|null $arrNullable
2121 * @param bool|string $unionWithBool
2222 * @param bool|string $unionWithBoolAndEnum
2323 */
24- public function __construct(?array $arrNullable, ?array $arrOne, ?string $nullable, string $one, ?string $optional, bool|string $unionWithBool, bool|string $unionWithBoolAndEnum) {
25- $this->arrNullable = $arrNullable;
26- $this->arrOne = $arrOne;
27- $this->nullable = $nullable;
24+ public function __construct(string $one, ?string $optional, ?string $nullable, ?array $arrOne, ?array $arrNullable, bool|string $unionWithBool, bool|string $unionWithBoolAndEnum) {
2825 $this->one = $one;
2926 $this->optional = $optional;
27+ $this->nullable = $nullable;
28+ $this->arrOne = $arrOne;
29+ $this->arrNullable = $arrNullable;
3030 $this->unionWithBool = $unionWithBool;
3131 $this->unionWithBoolAndEnum = $unionWithBoolAndEnum;
3232 }
3333
3434 /**
35- * @param ?array $value
35+ * @param string $value
3636 * @throws Exception
37- * @return ?array
37+ * @return string
3838 */
39- public static function fromArrNullable(?array $value): ?array {
40- if (!is_null($value)) {
41- return array_map(function ($value) {
42- if (!is_null($value)) {
43- return $value; /*string*/
44- } else {
45- return null;
46- }
47- }, $value);
48- } else {
49- return null;
50- }
39+ public static function fromOne(string $value): string {
40+ return $value; /*string*/
5141 }
5242
5343 /**
5444 * @throws Exception
55- * @return ?array
45+ * @return string
5646 */
57- public function toArrNullable(): ?array {
58- if (TopLevel::validateArrNullable($this->arrNullable)) {
59- if (!is_null($this->arrNullable)) {
60- return array_map(function ($value) {
61- if (!is_null($value)) {
62- return $value; /*string*/
63- } else {
64- return null;
65- }
66- }, $this->arrNullable);
67- } else {
68- return null;
69- }
47+ public function toOne(): string {
48+ if (TopLevel::validateOne($this->one)) {
49+ return $this->one; /*string*/
7050 }
71- throw new Exception('never get to this TopLevel::arrNullable');
51+ throw new Exception('never get to this TopLevel::one');
7252 }
7353
7454 /**
75- * @param array|null
55+ * @param string
7656 * @return bool
7757 * @throws Exception
7858 */
79- public static function validateArrNullable(?array $value): bool {
80- if (!is_null($value)) {
81- if (!is_array($value)) {
82- throw new Exception("Attribute Error:TopLevel::arrNullable");
83- }
84- array_walk($value, function($value_v) {
85- if (!is_null($value_v)) {
86- if (!is_string($value_v)) {
87- throw new Exception("Attribute Error:TopLevel::arrNullable");
88- }
89- }
90- });
91- }
59+ public static function validateOne(string $value): bool {
9260 return true;
9361 }
9462
9563 /**
9664 * @throws Exception
97- * @return ?array
65+ * @return string
9866 */
99- public function getArrNullable(): ?array {
100- if (TopLevel::validateArrNullable($this->arrNullable)) {
101- return $this->arrNullable;
67+ public function getOne(): string {
68+ if (TopLevel::validateOne($this->one)) {
69+ return $this->one;
10270 }
103- throw new Exception('never get to getArrNullable TopLevel::arrNullable');
71+ throw new Exception('never get to getOne TopLevel::one');
10472 }
10573
10674 /**
107- * @return ?array
75+ * @return string
10876 */
109- public static function sampleArrNullable(): ?array {
110- return array(
111- 'TopLevel::::31' /*31:*/
112- ); /* 31:arrNullable*/
77+ public static function sampleOne(): string {
78+ return 'TopLevel::one::31'; /*31:one*/
11379 }
11480
11581 /**
116- * @param ?array $value
82+ * @param ?string $value
11783 * @throws Exception
118- * @return ?array
84+ * @return ?string
11985 */
120- public static function fromArrOne(?array $value): ?array {
86+ public static function fromOptional(?string $value): ?string {
12187 if (!is_null($value)) {
122- return array_map(function ($value) {
123- return $value; /*string*/
124- }, $value);
88+ return $value; /*string*/
12589 } else {
12690 return null;
12791 }
@@ -129,58 +93,46 @@ class TopLevel {
12993
13094 /**
13195 * @throws Exception
132- * @return ?array
96+ * @return ?string
13397 */
134- public function toArrOne(): ?array {
135- if (TopLevel::validateArrOne($this->arrOne)) {
136- if (!is_null($this->arrOne)) {
137- return array_map(function ($value) {
138- return $value; /*string*/
139- }, $this->arrOne);
98+ public function toOptional(): ?string {
99+ if (TopLevel::validateOptional($this->optional)) {
100+ if (!is_null($this->optional)) {
101+ return $this->optional; /*string*/
140102 } else {
141103 return null;
142104 }
143105 }
144- throw new Exception('never get to this TopLevel::arrOne');
106+ throw new Exception('never get to this TopLevel::optional');
145107 }
146108
147109 /**
148- * @param array|null
110+ * @param string|null
149111 * @return bool
150112 * @throws Exception
151113 */
152- public static function validateArrOne(?array $value): bool {
114+ public static function validateOptional(?string $value): bool {
153115 if (!is_null($value)) {
154- if (!is_array($value)) {
155- throw new Exception("Attribute Error:TopLevel::arrOne");
156- }
157- array_walk($value, function($value_v) {
158- if (!is_string($value_v)) {
159- throw new Exception("Attribute Error:TopLevel::arrOne");
160- }
161- });
162116 }
163117 return true;
164118 }
165119
166120 /**
167121 * @throws Exception
168- * @return ?array
122+ * @return ?string
169123 */
170- public function getArrOne(): ?array {
171- if (TopLevel::validateArrOne($this->arrOne)) {
172- return $this->arrOne;
124+ public function getOptional(): ?string {
125+ if (TopLevel::validateOptional($this->optional)) {
126+ return $this->optional;
173127 }
174- throw new Exception('never get to getArrOne TopLevel::arrOne');
128+ throw new Exception('never get to getOptional TopLevel::optional');
175129 }
176130
177131 /**
178- * @return ?array
132+ * @return ?string
179133 */
180- public static function sampleArrOne(): ?array {
181- return array(
182- 'TopLevel::::32' /*32:*/
183- ); /* 32:arrOne*/
134+ public static function sampleOptional(): ?string {
135+ return 'TopLevel::optional::32'; /*32:optional*/
184136 }
185137
186138 /**
@@ -241,60 +193,90 @@ class TopLevel {
241193 }
242194
243195 /**
244- * @param string $value
196+ * @param ?array $value
245197 * @throws Exception
246- * @return string
198+ * @return ?array
247199 */
248- public static function fromOne(string $value): string {
249- return $value; /*string*/
200+ public static function fromArrOne(?array $value): ?array {
201+ if (!is_null($value)) {
202+ return array_map(function ($value) {
203+ return $value; /*string*/
204+ }, $value);
205+ } else {
206+ return null;
207+ }
250208 }
251209
252210 /**
253211 * @throws Exception
254- * @return string
212+ * @return ?array
255213 */
256- public function toOne(): string {
257- if (TopLevel::validateOne($this->one)) {
258- return $this->one; /*string*/
214+ public function toArrOne(): ?array {
215+ if (TopLevel::validateArrOne($this->arrOne)) {
216+ if (!is_null($this->arrOne)) {
217+ return array_map(function ($value) {
218+ return $value; /*string*/
219+ }, $this->arrOne);
220+ } else {
221+ return null;
222+ }
259223 }
260- throw new Exception('never get to this TopLevel::one');
224+ throw new Exception('never get to this TopLevel::arrOne');
261225 }
262226
263227 /**
264- * @param string
228+ * @param array|null
265229 * @return bool
266230 * @throws Exception
267231 */
268- public static function validateOne(string $value): bool {
232+ public static function validateArrOne(?array $value): bool {
233+ if (!is_null($value)) {
234+ if (!is_array($value)) {
235+ throw new Exception("Attribute Error:TopLevel::arrOne");
236+ }
237+ array_walk($value, function($value_v) {
238+ if (!is_string($value_v)) {
239+ throw new Exception("Attribute Error:TopLevel::arrOne");
240+ }
241+ });
242+ }
269243 return true;
270244 }
271245
272246 /**
273247 * @throws Exception
274- * @return string
248+ * @return ?array
275249 */
276- public function getOne(): string {
277- if (TopLevel::validateOne($this->one)) {
278- return $this->one;
250+ public function getArrOne(): ?array {
251+ if (TopLevel::validateArrOne($this->arrOne)) {
252+ return $this->arrOne;
279253 }
280- throw new Exception('never get to getOne TopLevel::one');
254+ throw new Exception('never get to getArrOne TopLevel::arrOne');
281255 }
282256
283257 /**
284- * @return string
258+ * @return ?array
285259 */
286- public static function sampleOne(): string {
287- return 'TopLevel::one::34'; /*34:one*/
260+ public static function sampleArrOne(): ?array {
261+ return array(
262+ 'TopLevel::::34' /*34:*/
263+ ); /* 34:arrOne*/
288264 }
289265
290266 /**
291- * @param ?string $value
267+ * @param ?array $value
292268 * @throws Exception
293- * @return ?string
269+ * @return ?array
294270 */
295- public static function fromOptional(?string $value): ?string {
271+ public static function fromArrNullable(?array $value): ?array {
296272 if (!is_null($value)) {
297- return $value; /*string*/
273+ return array_map(function ($value) {
274+ if (!is_null($value)) {
275+ return $value; /*string*/
276+ } else {
277+ return null;
278+ }
279+ }, $value);
298280 } else {
299281 return null;
300282 }
@@ -302,46 +284,64 @@ class TopLevel {
302284
303285 /**
304286 * @throws Exception
305- * @return ?string
287+ * @return ?array
306288 */
307- public function toOptional(): ?string {
308- if (TopLevel::validateOptional($this->optional)) {
309- if (!is_null($this->optional)) {
310- return $this->optional; /*string*/
289+ public function toArrNullable(): ?array {
290+ if (TopLevel::validateArrNullable($this->arrNullable)) {
291+ if (!is_null($this->arrNullable)) {
292+ return array_map(function ($value) {
293+ if (!is_null($value)) {
294+ return $value; /*string*/
295+ } else {
296+ return null;
297+ }
298+ }, $this->arrNullable);
311299 } else {
312300 return null;
313301 }
314302 }
315- throw new Exception('never get to this TopLevel::optional');
303+ throw new Exception('never get to this TopLevel::arrNullable');
316304 }
317305
318306 /**
319- * @param string|null
307+ * @param array|null
320308 * @return bool
321309 * @throws Exception
322310 */
323- public static function validateOptional(?string $value): bool {
311+ public static function validateArrNullable(?array $value): bool {
324312 if (!is_null($value)) {
313+ if (!is_array($value)) {
314+ throw new Exception("Attribute Error:TopLevel::arrNullable");
315+ }
316+ array_walk($value, function($value_v) {
317+ if (!is_null($value_v)) {
318+ if (!is_string($value_v)) {
319+ throw new Exception("Attribute Error:TopLevel::arrNullable");
320+ }
321+ }
322+ });
325323 }
326324 return true;
327325 }
328326
329327 /**
330328 * @throws Exception
331- * @return ?string
329+ * @return ?array
332330 */
333- public function getOptional(): ?string {
334- if (TopLevel::validateOptional($this->optional)) {
335- return $this->optional;
331+ public function getArrNullable(): ?array {
332+ if (TopLevel::validateArrNullable($this->arrNullable)) {
333+ return $this->arrNullable;
336334 }
337- throw new Exception('never get to getOptional TopLevel::optional');
335+ throw new Exception('never get to getArrNullable TopLevel::arrNullable');
338336 }
339337
340338 /**
341- * @return ?string
339+ * @return ?array
342340 */
343- public static function sampleOptional(): ?string {
344- return 'TopLevel::optional::35'; /*35:optional*/
341+ public static function sampleArrNullable(): ?array {
342+ return array(
343+ 'TopLevel::::35' /*35:*/
344+ ); /* 35:arrNullable*/
345345 }
346346
347347 /**
@@ -489,11 +489,11 @@ class TopLevel {
489489 * @return bool
490490 */
491491 public function validate(): bool {
492- return TopLevel::validateArrNullable($this->arrNullable)
493- || TopLevel::validateArrOne($this->arrOne)
494- || TopLevel::validateNullable($this->nullable)
495- || TopLevel::validateOne($this->one)
492+ return TopLevel::validateOne($this->one)
496493 || TopLevel::validateOptional($this->optional)
494+ || TopLevel::validateNullable($this->nullable)
495+ || TopLevel::validateArrOne($this->arrOne)
496+ || TopLevel::validateArrNullable($this->arrNullable)
497497 || TopLevel::validateUnionWithBool($this->unionWithBool)
498498 || TopLevel::validateUnionWithBoolAndEnum($this->unionWithBoolAndEnum);
499499 }
@@ -504,11 +504,11 @@ class TopLevel {
504504 */
505505 public function to(): stdClass {
506506 $out = new stdClass();
507- $out->{'arrNullable'} = $this->toArrNullable();
508- $out->{'arrOne'} = $this->toArrOne();
509- $out->{'nullable'} = $this->toNullable();
510507 $out->{'one'} = $this->toOne();
511508 $out->{'optional'} = $this->toOptional();
509+ $out->{'nullable'} = $this->toNullable();
510+ $out->{'arrOne'} = $this->toArrOne();
511+ $out->{'arrNullable'} = $this->toArrNullable();
512512 $out->{'unionWithBool'} = $this->toUnionWithBool();
513513 $out->{'unionWithBoolAndEnum'} = $this->toUnionWithBoolAndEnum();
514514 return $out;
@@ -521,11 +521,11 @@ class TopLevel {
521521 */
522522 public static function from(stdClass $obj): TopLevel {
523523 return new TopLevel(
524- TopLevel::fromArrNullable($obj->{'arrNullable'})
525- ,TopLevel::fromArrOne($obj->{'arrOne'})
526- ,TopLevel::fromNullable($obj->{'nullable'})
527- ,TopLevel::fromOne($obj->{'one'})
524+ TopLevel::fromOne($obj->{'one'})
528525 ,TopLevel::fromOptional($obj->{'optional'})
526+ ,TopLevel::fromNullable($obj->{'nullable'})
527+ ,TopLevel::fromArrOne($obj->{'arrOne'})
528+ ,TopLevel::fromArrNullable($obj->{'arrNullable'})
529529 ,TopLevel::fromUnionWithBool($obj->{'unionWithBool'})
530530 ,TopLevel::fromUnionWithBoolAndEnum($obj->{'unionWithBoolAndEnum'})
531531 );
@@ -536,11 +536,11 @@ class TopLevel {
536536 */
537537 public static function sample(): TopLevel {
538538 return new TopLevel(
539- TopLevel::sampleArrNullable()
540- ,TopLevel::sampleArrOne()
541- ,TopLevel::sampleNullable()
542- ,TopLevel::sampleOne()
539+ TopLevel::sampleOne()
543540 ,TopLevel::sampleOptional()
541+ ,TopLevel::sampleNullable()
542+ ,TopLevel::sampleArrOne()
543+ ,TopLevel::sampleArrNullable()
544544 ,TopLevel::sampleUnionWithBool()
545545 ,TopLevel::sampleUnionWithBoolAndEnum()
546546 );
Mschema-php/test/inputs/schema/boolean-subschema.schema/default/TopLevel.php+61 −61
@@ -4,24 +4,71 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7+ private string $foo; // json:foo Required
78 private mixed $disallowed; // json:disallowed Optional
89 private array $empty; // json:empty Required
9- private string $foo; // json:foo Required
1010 private mixed $impossible; // json:impossible Optional
1111
1212 /**
13+ * @param string $foo
1314 * @param mixed $disallowed
1415 * @param array $empty
15- * @param string $foo
1616 * @param mixed $impossible
1717 */
18- public function __construct(mixed $disallowed, array $empty, string $foo, mixed $impossible) {
18+ public function __construct(string $foo, mixed $disallowed, array $empty, mixed $impossible) {
19+ $this->foo = $foo;
1920 $this->disallowed = $disallowed;
2021 $this->empty = $empty;
21- $this->foo = $foo;
2222 $this->impossible = $impossible;
2323 }
2424
25+ /**
26+ * @param string $value
27+ * @throws Exception
28+ * @return string
29+ */
30+ public static function fromFoo(string $value): string {
31+ return $value; /*string*/
32+ }
33+
34+ /**
35+ * @throws Exception
36+ * @return string
37+ */
38+ public function toFoo(): string {
39+ if (TopLevel::validateFoo($this->foo)) {
40+ return $this->foo; /*string*/
41+ }
42+ throw new Exception('never get to this TopLevel::foo');
43+ }
44+
45+ /**
46+ * @param string
47+ * @return bool
48+ * @throws Exception
49+ */
50+ public static function validateFoo(string $value): bool {
51+ return true;
52+ }
53+
54+ /**
55+ * @throws Exception
56+ * @return string
57+ */
58+ public function getFoo(): string {
59+ if (TopLevel::validateFoo($this->foo)) {
60+ return $this->foo;
61+ }
62+ throw new Exception('never get to getFoo TopLevel::foo');
63+ }
64+
65+ /**
66+ * @return string
67+ */
68+ public static function sampleFoo(): string {
69+ return 'TopLevel::foo::31'; /*31:foo*/
70+ }
71+
2572 /**
2673 * @param mixed $value
2774 * @throws Exception
@@ -66,7 +113,7 @@ class TopLevel {
66113 * @return mixed
67114 */
68115 public static function sampleDisallowed(): mixed {
69- return 'AnyType::TopLevel::disallowed::31';/*31:disallowed*/
116+ return 'AnyType::TopLevel::disallowed::32';/*32:disallowed*/
70117 }
71118
72119 /**
@@ -123,55 +170,8 @@ class TopLevel {
123170 */
124171 public static function sampleEmpty(): array {
125172 return array(
126- 'AnyType::TopLevel::::32'/*32:*/
127- ); /* 32:empty*/
128- }
129-
130- /**
131- * @param string $value
132- * @throws Exception
133- * @return string
134- */
135- public static function fromFoo(string $value): string {
136- return $value; /*string*/
137- }
138-
139- /**
140- * @throws Exception
141- * @return string
142- */
143- public function toFoo(): string {
144- if (TopLevel::validateFoo($this->foo)) {
145- return $this->foo; /*string*/
146- }
147- throw new Exception('never get to this TopLevel::foo');
148- }
149-
150- /**
151- * @param string
152- * @return bool
153- * @throws Exception
154- */
155- public static function validateFoo(string $value): bool {
156- return true;
157- }
158-
159- /**
160- * @throws Exception
161- * @return string
162- */
163- public function getFoo(): string {
164- if (TopLevel::validateFoo($this->foo)) {
165- return $this->foo;
166- }
167- throw new Exception('never get to getFoo TopLevel::foo');
168- }
169-
170- /**
171- * @return string
172- */
173- public static function sampleFoo(): string {
174- return 'TopLevel::foo::33'; /*33:foo*/
173+ 'AnyType::TopLevel::::33'/*33:*/
174+ ); /* 33:empty*/
175175 }
176176
177177 /**
@@ -226,9 +226,9 @@ class TopLevel {
226226 * @return bool
227227 */
228228 public function validate(): bool {
229- return TopLevel::validateDisallowed($this->disallowed)
229+ return TopLevel::validateFoo($this->foo)
230+ || TopLevel::validateDisallowed($this->disallowed)
230231 || TopLevel::validateEmpty($this->empty)
231- || TopLevel::validateFoo($this->foo)
232232 || TopLevel::validateImpossible($this->impossible);
233233 }
234234
@@ -238,9 +238,9 @@ class TopLevel {
238238 */
239239 public function to(): stdClass {
240240 $out = new stdClass();
241+ $out->{'foo'} = $this->toFoo();
241242 $out->{'disallowed'} = $this->toDisallowed();
242243 $out->{'empty'} = $this->toEmpty();
243- $out->{'foo'} = $this->toFoo();
244244 $out->{'impossible'} = $this->toImpossible();
245245 return $out;
246246 }
@@ -252,9 +252,9 @@ class TopLevel {
252252 */
253253 public static function from(stdClass $obj): TopLevel {
254254 return new TopLevel(
255- TopLevel::fromDisallowed($obj->{'disallowed'})
255+ TopLevel::fromFoo($obj->{'foo'})
256+ ,TopLevel::fromDisallowed($obj->{'disallowed'})
256257 ,TopLevel::fromEmpty($obj->{'empty'})
257- ,TopLevel::fromFoo($obj->{'foo'})
258258 ,TopLevel::fromImpossible($obj->{'impossible'})
259259 );
260260 }
@@ -264,9 +264,9 @@ class TopLevel {
264264 */
265265 public static function sample(): TopLevel {
266266 return new TopLevel(
267- TopLevel::sampleDisallowed()
267+ TopLevel::sampleFoo()
268+ ,TopLevel::sampleDisallowed()
268269 ,TopLevel::sampleEmpty()
269- ,TopLevel::sampleFoo()
270270 ,TopLevel::sampleImpossible()
271271 );
272272 }
Mschema-php/test/inputs/schema/comment-injection.schema/default/TopLevel.php+127 −127
@@ -4,22 +4,134 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7+ private string $value; // json:value Required
78 private ?string $trailingBackslash; // json:trailingBackslash Optional
89 private ?string $trailingQuote; // json:trailingQuote Optional
910 private ?string $trailingTripleQuote; // json:trailingTripleQuote Optional
10- private string $value; // json:value Required
1111
1212 /**
13+ * @param string $value
1314 * @param string|null $trailingBackslash
1415 * @param string|null $trailingQuote
1516 * @param string|null $trailingTripleQuote
16- * @param string $value
1717 */
18- public function __construct(?string $trailingBackslash, ?string $trailingQuote, ?string $trailingTripleQuote, string $value) {
18+ public function __construct(string $value, ?string $trailingBackslash, ?string $trailingQuote, ?string $trailingTripleQuote) {
19+ $this->value = $value;
1920 $this->trailingBackslash = $trailingBackslash;
2021 $this->trailingQuote = $trailingQuote;
2122 $this->trailingTripleQuote = $trailingTripleQuote;
22- $this->value = $value;
23+ }
24+
25+ /**
26+ * Property delimiters:
27+ * * /
28+ * / *
29+ * {-
30+ * -}
31+ * """
32+ * </summary> & <br>
33+ * }
34+ * }
35+ * }
36+ * }
37+ * }
38+ *
39+ * @param string $value
40+ * @throws Exception
41+ * @return string
42+ */
43+ public static function fromValue(string $value): string {
44+ return $value; /*string*/
45+ }
46+
47+ /**
48+ * Property delimiters:
49+ * * /
50+ * / *
51+ * {-
52+ * -}
53+ * """
54+ * </summary> & <br>
55+ * }
56+ * }
57+ * }
58+ * }
59+ * }
60+ *
61+ * @throws Exception
62+ * @return string
63+ */
64+ public function toValue(): string {
65+ if (TopLevel::validateValue($this->value)) {
66+ return $this->value; /*string*/
67+ }
68+ throw new Exception('never get to this TopLevel::value');
69+ }
70+
71+ /**
72+ * Property delimiters:
73+ * * /
74+ * / *
75+ * {-
76+ * -}
77+ * """
78+ * </summary> & <br>
79+ * }
80+ * }
81+ * }
82+ * }
83+ * }
84+ *
85+ * @param string
86+ * @return bool
87+ * @throws Exception
88+ */
89+ public static function validateValue(string $value): bool {
90+ return true;
91+ }
92+
93+ /**
94+ * Property delimiters:
95+ * * /
96+ * / *
97+ * {-
98+ * -}
99+ * """
100+ * </summary> & <br>
101+ * }
102+ * }
103+ * }
104+ * }
105+ * }
106+ *
107+ * @throws Exception
108+ * @return string
109+ */
110+ public function getValue(): string {
111+ if (TopLevel::validateValue($this->value)) {
112+ return $this->value;
113+ }
114+ throw new Exception('never get to getValue TopLevel::value');
115+ }
116+
117+ /**
118+ * Property delimiters:
119+ * * /
120+ * / *
121+ * {-
122+ * -}
123+ * """
124+ * </summary> & <br>
125+ * }
126+ * }
127+ * }
128+ * }
129+ * }
130+ *
131+ * @return string
132+ */
133+ public static function sampleValue(): string {
134+ return 'TopLevel::value::31'; /*31:value*/
23135 }
24136
25137 /**
@@ -86,7 +198,7 @@ class TopLevel {
86198 * @return ?string
87199 */
88200 public static function sampleTrailingBackslash(): ?string {
89- return 'TopLevel::trailingBackslash::31'; /*31:trailingBackslash*/
201+ return 'TopLevel::trailingBackslash::32'; /*32:trailingBackslash*/
90202 }
91203
92204 /**
@@ -153,7 +265,7 @@ class TopLevel {
153265 * @return ?string
154266 */
155267 public static function sampleTrailingQuote(): ?string {
156- return 'TopLevel::trailingQuote::32'; /*32:trailingQuote*/
268+ return 'TopLevel::trailingQuote::33'; /*33:trailingQuote*/
157269 }
158270
159271 /**
@@ -220,119 +332,7 @@ class TopLevel {
220332 * @return ?string
221333 */
222334 public static function sampleTrailingTripleQuote(): ?string {
223- return 'TopLevel::trailingTripleQuote::33'; /*33:trailingTripleQuote*/
224- }
225-
226- /**
227- * Property delimiters:
228- * * /
229- * / *
230- * {-
231- * -}
232- * """
233- * </summary> & <br>
234- * }
235- * }
236- * }
237- * }
238- * }
239- *
240- * @param string $value
241- * @throws Exception
242- * @return string
243- */
244- public static function fromValue(string $value): string {
245- return $value; /*string*/
246- }
247-
248- /**
249- * Property delimiters:
250- * * /
251- * / *
252- * {-
253- * -}
254- * """
255- * </summary> & <br>
256- * }
257- * }
258- * }
259- * }
260- * }
261- *
262- * @throws Exception
263- * @return string
264- */
265- public function toValue(): string {
266- if (TopLevel::validateValue($this->value)) {
267- return $this->value; /*string*/
268- }
269- throw new Exception('never get to this TopLevel::value');
270- }
271-
272- /**
273- * Property delimiters:
274- * * /
275- * / *
276- * {-
277- * -}
278- * """
279- * </summary> & <br>
280- * }
281- * }
282- * }
283- * }
284- * }
285- *
286- * @param string
287- * @return bool
288- * @throws Exception
289- */
290- public static function validateValue(string $value): bool {
291- return true;
292- }
293-
294- /**
295- * Property delimiters:
296- * * /
297- * / *
298- * {-
299- * -}
300- * """
301- * </summary> & <br>
302- * }
303- * }
304- * }
305- * }
306- * }
307- *
308- * @throws Exception
309- * @return string
310- */
311- public function getValue(): string {
312- if (TopLevel::validateValue($this->value)) {
313- return $this->value;
314- }
315- throw new Exception('never get to getValue TopLevel::value');
316- }
317-
318- /**
319- * Property delimiters:
320- * * /
321- * / *
322- * {-
323- * -}
324- * """
325- * </summary> & <br>
326- * }
327- * }
328- * }
329- * }
330- * }
331- *
332- * @return string
333- */
334- public static function sampleValue(): string {
335- return 'TopLevel::value::34'; /*34:value*/
335+ return 'TopLevel::trailingTripleQuote::34'; /*34:trailingTripleQuote*/
336336 }
337337
338338 /**
@@ -340,10 +340,10 @@ class TopLevel {
340340 * @return bool
341341 */
342342 public function validate(): bool {
343- return TopLevel::validateTrailingBackslash($this->trailingBackslash)
343+ return TopLevel::validateValue($this->value)
344+ || TopLevel::validateTrailingBackslash($this->trailingBackslash)
344345 || TopLevel::validateTrailingQuote($this->trailingQuote)
345- || TopLevel::validateTrailingTripleQuote($this->trailingTripleQuote)
346- || TopLevel::validateValue($this->value);
346+ || TopLevel::validateTrailingTripleQuote($this->trailingTripleQuote);
347347 }
348348
349349 /**
@@ -352,10 +352,10 @@ class TopLevel {
352352 */
353353 public function to(): stdClass {
354354 $out = new stdClass();
355+ $out->{'value'} = $this->toValue();
355356 $out->{'trailingBackslash'} = $this->toTrailingBackslash();
356357 $out->{'trailingQuote'} = $this->toTrailingQuote();
357358 $out->{'trailingTripleQuote'} = $this->toTrailingTripleQuote();
358- $out->{'value'} = $this->toValue();
359359 return $out;
360360 }
361361
@@ -366,10 +366,10 @@ class TopLevel {
366366 */
367367 public static function from(stdClass $obj): TopLevel {
368368 return new TopLevel(
369- TopLevel::fromTrailingBackslash($obj->{'trailingBackslash'})
369+ TopLevel::fromValue($obj->{'value'})
370+ ,TopLevel::fromTrailingBackslash($obj->{'trailingBackslash'})
370371 ,TopLevel::fromTrailingQuote($obj->{'trailingQuote'})
371372 ,TopLevel::fromTrailingTripleQuote($obj->{'trailingTripleQuote'})
372- ,TopLevel::fromValue($obj->{'value'})
373373 );
374374 }
375375
@@ -378,10 +378,10 @@ class TopLevel {
378378 */
379379 public static function sample(): TopLevel {
380380 return new TopLevel(
381- TopLevel::sampleTrailingBackslash()
381+ TopLevel::sampleValue()
382+ ,TopLevel::sampleTrailingBackslash()
382383 ,TopLevel::sampleTrailingQuote()
383384 ,TopLevel::sampleTrailingTripleQuote()
384- ,TopLevel::sampleValue()
385385 );
386386 }
387387 }
Mschema-php/test/inputs/schema/const-non-string.schema/default/TopLevel.php+115 −115
@@ -4,261 +4,261 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7+ private float $version; // json:version Required
78 private int $amount; // json:amount Required
9+ private float $ratio; // json:ratio Required
810 private bool $enabled; // json:enabled Required
911 private Kind $kind; // json:kind Required
10- private float $ratio; // json:ratio Required
11- private float $version; // json:version Required
1212
1313 /**
14+ * @param float $version
1415 * @param int $amount
16+ * @param float $ratio
1517 * @param bool $enabled
1618 * @param Kind $kind
17- * @param float $ratio
18- * @param float $version
1919 */
20- public function __construct(int $amount, bool $enabled, Kind $kind, float $ratio, float $version) {
20+ public function __construct(float $version, int $amount, float $ratio, bool $enabled, Kind $kind) {
21+ $this->version = $version;
2122 $this->amount = $amount;
23+ $this->ratio = $ratio;
2224 $this->enabled = $enabled;
2325 $this->kind = $kind;
24- $this->ratio = $ratio;
25- $this->version = $version;
2626 }
2727
2828 /**
29- * @param int $value
29+ * @param float $value
3030 * @throws Exception
31- * @return int
31+ * @return float
3232 */
33- public static function fromAmount(int $value): int {
34- return $value; /*int*/
33+ public static function fromVersion(float $value): float {
34+ return $value; /*float*/
3535 }
3636
3737 /**
3838 * @throws Exception
39- * @return int
39+ * @return float
4040 */
41- public function toAmount(): int {
42- if (TopLevel::validateAmount($this->amount)) {
43- return $this->amount; /*int*/
41+ public function toVersion(): float {
42+ if (TopLevel::validateVersion($this->version)) {
43+ return $this->version; /*float*/
4444 }
45- throw new Exception('never get to this TopLevel::amount');
45+ throw new Exception('never get to this TopLevel::version');
4646 }
4747
4848 /**
49- * @param int
49+ * @param float
5050 * @return bool
5151 * @throws Exception
5252 */
53- public static function validateAmount(int $value): bool {
53+ public static function validateVersion(float $value): bool {
5454 return true;
5555 }
5656
5757 /**
5858 * @throws Exception
59- * @return int
59+ * @return float
6060 */
61- public function getAmount(): int {
62- if (TopLevel::validateAmount($this->amount)) {
63- return $this->amount;
61+ public function getVersion(): float {
62+ if (TopLevel::validateVersion($this->version)) {
63+ return $this->version;
6464 }
65- throw new Exception('never get to getAmount TopLevel::amount');
65+ throw new Exception('never get to getVersion TopLevel::version');
6666 }
6767
6868 /**
69- * @return int
69+ * @return float
7070 */
71- public static function sampleAmount(): int {
72- return 31; /*31:amount*/
71+ public static function sampleVersion(): float {
72+ return 31.031; /*31:version*/
7373 }
7474
7575 /**
76- * @param bool $value
76+ * @param int $value
7777 * @throws Exception
78- * @return bool
78+ * @return int
7979 */
80- public static function fromEnabled(bool $value): bool {
81- return $value; /*bool*/
80+ public static function fromAmount(int $value): int {
81+ return $value; /*int*/
8282 }
8383
8484 /**
8585 * @throws Exception
86- * @return bool
86+ * @return int
8787 */
88- public function toEnabled(): bool {
89- if (TopLevel::validateEnabled($this->enabled)) {
90- return $this->enabled; /*bool*/
88+ public function toAmount(): int {
89+ if (TopLevel::validateAmount($this->amount)) {
90+ return $this->amount; /*int*/
9191 }
92- throw new Exception('never get to this TopLevel::enabled');
92+ throw new Exception('never get to this TopLevel::amount');
9393 }
9494
9595 /**
96- * @param bool
96+ * @param int
9797 * @return bool
9898 * @throws Exception
9999 */
100- public static function validateEnabled(bool $value): bool {
100+ public static function validateAmount(int $value): bool {
101101 return true;
102102 }
103103
104104 /**
105105 * @throws Exception
106- * @return bool
106+ * @return int
107107 */
108- public function getEnabled(): bool {
109- if (TopLevel::validateEnabled($this->enabled)) {
110- return $this->enabled;
108+ public function getAmount(): int {
109+ if (TopLevel::validateAmount($this->amount)) {
110+ return $this->amount;
111111 }
112- throw new Exception('never get to getEnabled TopLevel::enabled');
112+ throw new Exception('never get to getAmount TopLevel::amount');
113113 }
114114
115115 /**
116- * @return bool
116+ * @return int
117117 */
118- public static function sampleEnabled(): bool {
119- return true; /*32:enabled*/
118+ public static function sampleAmount(): int {
119+ return 32; /*32:amount*/
120120 }
121121
122122 /**
123- * @param string $value
123+ * @param float $value
124124 * @throws Exception
125- * @return Kind
125+ * @return float
126126 */
127- public static function fromKind(string $value): Kind {
128- return Kind::from($value); /*enum*/
127+ public static function fromRatio(float $value): float {
128+ return $value; /*float*/
129129 }
130130
131131 /**
132132 * @throws Exception
133- * @return string
133+ * @return float
134134 */
135- public function toKind(): string {
136- if (TopLevel::validateKind($this->kind)) {
137- return Kind::to($this->kind); /*enum*/
135+ public function toRatio(): float {
136+ if (TopLevel::validateRatio($this->ratio)) {
137+ return $this->ratio; /*float*/
138138 }
139- throw new Exception('never get to this TopLevel::kind');
139+ throw new Exception('never get to this TopLevel::ratio');
140140 }
141141
142142 /**
143- * @param Kind
143+ * @param float
144144 * @return bool
145145 * @throws Exception
146146 */
147- public static function validateKind(Kind $value): bool {
148- Kind::to($value);
147+ public static function validateRatio(float $value): bool {
149148 return true;
150149 }
151150
152151 /**
153152 * @throws Exception
154- * @return Kind
153+ * @return float
155154 */
156- public function getKind(): Kind {
157- if (TopLevel::validateKind($this->kind)) {
158- return $this->kind;
155+ public function getRatio(): float {
156+ if (TopLevel::validateRatio($this->ratio)) {
157+ return $this->ratio;
159158 }
160- throw new Exception('never get to getKind TopLevel::kind');
159+ throw new Exception('never get to getRatio TopLevel::ratio');
161160 }
162161
163162 /**
164- * @return Kind
163+ * @return float
165164 */
166- public static function sampleKind(): Kind {
167- return Kind::sample(); /*enum*/
165+ public static function sampleRatio(): float {
166+ return 33.033; /*33:ratio*/
168167 }
169168
170169 /**
171- * @param float $value
170+ * @param bool $value
172171 * @throws Exception
173- * @return float
172+ * @return bool
174173 */
175- public static function fromRatio(float $value): float {
176- return $value; /*float*/
174+ public static function fromEnabled(bool $value): bool {
175+ return $value; /*bool*/
177176 }
178177
179178 /**
180179 * @throws Exception
181- * @return float
180+ * @return bool
182181 */
183- public function toRatio(): float {
184- if (TopLevel::validateRatio($this->ratio)) {
185- return $this->ratio; /*float*/
182+ public function toEnabled(): bool {
183+ if (TopLevel::validateEnabled($this->enabled)) {
184+ return $this->enabled; /*bool*/
186185 }
187- throw new Exception('never get to this TopLevel::ratio');
186+ throw new Exception('never get to this TopLevel::enabled');
188187 }
189188
190189 /**
191- * @param float
190+ * @param bool
192191 * @return bool
193192 * @throws Exception
194193 */
195- public static function validateRatio(float $value): bool {
194+ public static function validateEnabled(bool $value): bool {
196195 return true;
197196 }
198197
199198 /**
200199 * @throws Exception
201- * @return float
200+ * @return bool
202201 */
203- public function getRatio(): float {
204- if (TopLevel::validateRatio($this->ratio)) {
205- return $this->ratio;
202+ public function getEnabled(): bool {
203+ if (TopLevel::validateEnabled($this->enabled)) {
204+ return $this->enabled;
206205 }
207- throw new Exception('never get to getRatio TopLevel::ratio');
206+ throw new Exception('never get to getEnabled TopLevel::enabled');
208207 }
209208
210209 /**
211- * @return float
210+ * @return bool
212211 */
213- public static function sampleRatio(): float {
214- return 34.034; /*34:ratio*/
212+ public static function sampleEnabled(): bool {
213+ return true; /*34:enabled*/
215214 }
216215
217216 /**
218- * @param float $value
217+ * @param string $value
219218 * @throws Exception
220- * @return float
219+ * @return Kind
221220 */
222- public static function fromVersion(float $value): float {
223- return $value; /*float*/
221+ public static function fromKind(string $value): Kind {
222+ return Kind::from($value); /*enum*/
224223 }
225224
226225 /**
227226 * @throws Exception
228- * @return float
227+ * @return string
229228 */
230- public function toVersion(): float {
231- if (TopLevel::validateVersion($this->version)) {
232- return $this->version; /*float*/
229+ public function toKind(): string {
230+ if (TopLevel::validateKind($this->kind)) {
231+ return Kind::to($this->kind); /*enum*/
233232 }
234- throw new Exception('never get to this TopLevel::version');
233+ throw new Exception('never get to this TopLevel::kind');
235234 }
236235
237236 /**
238- * @param float
237+ * @param Kind
239238 * @return bool
240239 * @throws Exception
241240 */
242- public static function validateVersion(float $value): bool {
241+ public static function validateKind(Kind $value): bool {
242+ Kind::to($value);
243243 return true;
244244 }
245245
246246 /**
247247 * @throws Exception
248- * @return float
248+ * @return Kind
249249 */
250- public function getVersion(): float {
251- if (TopLevel::validateVersion($this->version)) {
252- return $this->version;
250+ public function getKind(): Kind {
251+ if (TopLevel::validateKind($this->kind)) {
252+ return $this->kind;
253253 }
254- throw new Exception('never get to getVersion TopLevel::version');
254+ throw new Exception('never get to getKind TopLevel::kind');
255255 }
256256
257257 /**
258- * @return float
258+ * @return Kind
259259 */
260- public static function sampleVersion(): float {
261- return 35.035; /*35:version*/
260+ public static function sampleKind(): Kind {
261+ return Kind::sample(); /*enum*/
262262 }
263263
264264 /**
@@ -266,11 +266,11 @@ class TopLevel {
266266 * @return bool
267267 */
268268 public function validate(): bool {
269- return TopLevel::validateAmount($this->amount)
270- || TopLevel::validateEnabled($this->enabled)
271- || TopLevel::validateKind($this->kind)
269+ return TopLevel::validateVersion($this->version)
270+ || TopLevel::validateAmount($this->amount)
272271 || TopLevel::validateRatio($this->ratio)
273- || TopLevel::validateVersion($this->version);
272+ || TopLevel::validateEnabled($this->enabled)
273+ || TopLevel::validateKind($this->kind);
274274 }
275275
276276 /**
@@ -279,11 +279,11 @@ class TopLevel {
279279 */
280280 public function to(): stdClass {
281281 $out = new stdClass();
282+ $out->{'version'} = $this->toVersion();
282283 $out->{'amount'} = $this->toAmount();
284+ $out->{'ratio'} = $this->toRatio();
283285 $out->{'enabled'} = $this->toEnabled();
284286 $out->{'kind'} = $this->toKind();
285- $out->{'ratio'} = $this->toRatio();
286- $out->{'version'} = $this->toVersion();
287287 return $out;
288288 }
289289
@@ -294,11 +294,11 @@ class TopLevel {
294294 */
295295 public static function from(stdClass $obj): TopLevel {
296296 return new TopLevel(
297- TopLevel::fromAmount($obj->{'amount'})
297+ TopLevel::fromVersion($obj->{'version'})
298+ ,TopLevel::fromAmount($obj->{'amount'})
299+ ,TopLevel::fromRatio($obj->{'ratio'})
298300 ,TopLevel::fromEnabled($obj->{'enabled'})
299301 ,TopLevel::fromKind($obj->{'kind'})
300- ,TopLevel::fromRatio($obj->{'ratio'})
301- ,TopLevel::fromVersion($obj->{'version'})
302302 );
303303 }
304304
@@ -307,11 +307,11 @@ class TopLevel {
307307 */
308308 public static function sample(): TopLevel {
309309 return new TopLevel(
310- TopLevel::sampleAmount()
310+ TopLevel::sampleVersion()
311+ ,TopLevel::sampleAmount()
312+ ,TopLevel::sampleRatio()
311313 ,TopLevel::sampleEnabled()
312314 ,TopLevel::sampleKind()
313- ,TopLevel::sampleRatio()
314- ,TopLevel::sampleVersion()
315315 );
316316 }
317317 }
Mschema-php/test/inputs/schema/date-time-or-string.schema/default/TopLevel.php+58 −58
@@ -4,16 +4,63 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private Bar|DateTime $bar; // json:bar Required
87 private string $foo; // json:foo Required
8+ private Bar|DateTime $bar; // json:bar Required
99
1010 /**
11- * @param Bar|DateTime $bar
1211 * @param string $foo
12+ * @param Bar|DateTime $bar
1313 */
14- public function __construct(Bar|DateTime $bar, string $foo) {
15- $this->bar = $bar;
14+ public function __construct(string $foo, Bar|DateTime $bar) {
1615 $this->foo = $foo;
16+ $this->bar = $bar;
17+ }
18+
19+ /**
20+ * @param string $value
21+ * @throws Exception
22+ * @return string
23+ */
24+ public static function fromFoo(string $value): string {
25+ return $value; /*string*/
26+ }
27+
28+ /**
29+ * @throws Exception
30+ * @return string
31+ */
32+ public function toFoo(): string {
33+ if (TopLevel::validateFoo($this->foo)) {
34+ return $this->foo; /*string*/
35+ }
36+ throw new Exception('never get to this TopLevel::foo');
37+ }
38+
39+ /**
40+ * @param string
41+ * @return bool
42+ * @throws Exception
43+ */
44+ public static function validateFoo(string $value): bool {
45+ return true;
46+ }
47+
48+ /**
49+ * @throws Exception
50+ * @return string
51+ */
52+ public function getFoo(): string {
53+ if (TopLevel::validateFoo($this->foo)) {
54+ return $this->foo;
55+ }
56+ throw new Exception('never get to getFoo TopLevel::foo');
57+ }
58+
59+ /**
60+ * @return string
61+ */
62+ public static function sampleFoo(): string {
63+ return 'TopLevel::foo::31'; /*31:foo*/
1764 }
1865
1966 /**
@@ -88,60 +135,13 @@ class TopLevel {
88135 return Bar::sample(); /*enum*/
89136 }
90137
91- /**
92- * @param string $value
93- * @throws Exception
94- * @return string
95- */
96- public static function fromFoo(string $value): string {
97- return $value; /*string*/
98- }
99-
100- /**
101- * @throws Exception
102- * @return string
103- */
104- public function toFoo(): string {
105- if (TopLevel::validateFoo($this->foo)) {
106- return $this->foo; /*string*/
107- }
108- throw new Exception('never get to this TopLevel::foo');
109- }
110-
111- /**
112- * @param string
113- * @return bool
114- * @throws Exception
115- */
116- public static function validateFoo(string $value): bool {
117- return true;
118- }
119-
120- /**
121- * @throws Exception
122- * @return string
123- */
124- public function getFoo(): string {
125- if (TopLevel::validateFoo($this->foo)) {
126- return $this->foo;
127- }
128- throw new Exception('never get to getFoo TopLevel::foo');
129- }
130-
131- /**
132- * @return string
133- */
134- public static function sampleFoo(): string {
135- return 'TopLevel::foo::32'; /*32:foo*/
136- }
137-
138138 /**
139139 * @throws Exception
140140 * @return bool
141141 */
142142 public function validate(): bool {
143- return TopLevel::validateBar($this->bar)
144- || TopLevel::validateFoo($this->foo);
143+ return TopLevel::validateFoo($this->foo)
144+ || TopLevel::validateBar($this->bar);
145145 }
146146
147147 /**
@@ -150,8 +150,8 @@ class TopLevel {
150150 */
151151 public function to(): stdClass {
152152 $out = new stdClass();
153- $out->{'bar'} = $this->toBar();
154153 $out->{'foo'} = $this->toFoo();
154+ $out->{'bar'} = $this->toBar();
155155 return $out;
156156 }
157157
@@ -162,8 +162,8 @@ class TopLevel {
162162 */
163163 public static function from(stdClass $obj): TopLevel {
164164 return new TopLevel(
165- TopLevel::fromBar($obj->{'bar'})
166- ,TopLevel::fromFoo($obj->{'foo'})
165+ TopLevel::fromFoo($obj->{'foo'})
166+ ,TopLevel::fromBar($obj->{'bar'})
167167 );
168168 }
169169
@@ -172,8 +172,8 @@ class TopLevel {
172172 */
173173 public static function sample(): TopLevel {
174174 return new TopLevel(
175- TopLevel::sampleBar()
176- ,TopLevel::sampleFoo()
175+ TopLevel::sampleFoo()
176+ ,TopLevel::sampleBar()
177177 );
178178 }
179179 }
Mschema-php/test/inputs/schema/date-time.schema/default/TopLevel.php+131 −131
@@ -4,116 +4,72 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private array $complexUnionArray; // json:complex-union-array Required
87 private string $date; // json:date Required
9- private DateTime $dateTime; // json:date-time Required
108 private string $time; // json:time Required
9+ private DateTime $dateTime; // json:date-time Required
1110 private array $unionArray; // json:union-array Required
11+ private array $complexUnionArray; // json:complex-union-array Required
1212
1313 /**
14- * @param array $complexUnionArray
1514 * @param string $date
16- * @param DateTime $dateTime
1715 * @param string $time
16+ * @param DateTime $dateTime
1817 * @param array $unionArray
18+ * @param array $complexUnionArray
1919 */
20- public function __construct(array $complexUnionArray, string $date, DateTime $dateTime, string $time, array $unionArray) {
21- $this->complexUnionArray = $complexUnionArray;
20+ public function __construct(string $date, string $time, DateTime $dateTime, array $unionArray, array $complexUnionArray) {
2221 $this->date = $date;
23- $this->dateTime = $dateTime;
2422 $this->time = $time;
23+ $this->dateTime = $dateTime;
2524 $this->unionArray = $unionArray;
25+ $this->complexUnionArray = $complexUnionArray;
2626 }
2727
2828 /**
29- * @param array $value
29+ * @param string $value
3030 * @throws Exception
31- * @return array
31+ * @return string
3232 */
33- public static function fromComplexUnionArray(array $value): array {
34- return array_map(function ($value) {
35- if (is_string($value) && in_array($value, ['foo', 'bar'], true)) {
36- return ComplexUnionArray::from($value); /*enum*/
37- } elseif (is_string($value)) {
38- $tmp = DateTime::createFromFormat(DateTimeInterface::ISO8601, $value);
39- if (!is_a($tmp, 'DateTime')) {
40- throw new Exception('Attribute Error:TopLevel::');
41- }
42- return $tmp;
43- } elseif (is_int($value)) {
44- return $value; /*int*/
45- } else {
46- throw new Exception('Cannot deserialize union value in TopLevel');
47- }
48- }, $value);
33+ public static function fromDate(string $value): string {
34+ return $value; /*string*/
4935 }
5036
5137 /**
5238 * @throws Exception
53- * @return array
39+ * @return string
5440 */
55- public function toComplexUnionArray(): array {
56- if (TopLevel::validateComplexUnionArray($this->complexUnionArray)) {
57- return array_map(function ($value) {
58- if ($value instanceof ComplexUnionArray) {
59- return ComplexUnionArray::to($value); /*enum*/
60- } elseif ($value instanceof DateTime) {
61- return $value->format(DateTimeInterface::ISO8601);
62- } elseif (is_int($value)) {
63- return $value; /*int*/
64- } else {
65- throw new Exception('Union value has no matching member in TopLevel');
66- }
67- }, $this->complexUnionArray);
41+ public function toDate(): string {
42+ if (TopLevel::validateDate($this->date)) {
43+ return $this->date; /*string*/
6844 }
69- throw new Exception('never get to this TopLevel::complexUnionArray');
45+ throw new Exception('never get to this TopLevel::date');
7046 }
7147
7248 /**
73- * @param array
49+ * @param string
7450 * @return bool
7551 * @throws Exception
7652 */
77- public static function validateComplexUnionArray(array $value): bool {
78- if (!is_array($value)) {
79- throw new Exception("Attribute Error:TopLevel::complexUnionArray");
80- }
81- array_walk($value, function($value_v) {
82- if ($value_v instanceof ComplexUnionArray) {
83- ComplexUnionArray::to($value_v);
84- } elseif ($value_v instanceof DateTime) {
85- if (!is_a($value_v, 'DateTime')) {
86- throw new Exception('Attribute Error:TopLevel::complexUnionArray');
87- }
88- } elseif (is_int($value_v)) {
89- if (!is_integer($value_v)) {
90- throw new Exception("Attribute Error:TopLevel::complexUnionArray");
91- }
92- } else {
93- throw new Exception("Attribute Error:TopLevel::complexUnionArray");
94- }
95- });
53+ public static function validateDate(string $value): bool {
9654 return true;
9755 }
9856
9957 /**
10058 * @throws Exception
101- * @return array
59+ * @return string
10260 */
103- public function getComplexUnionArray(): array {
104- if (TopLevel::validateComplexUnionArray($this->complexUnionArray)) {
105- return $this->complexUnionArray;
61+ public function getDate(): string {
62+ if (TopLevel::validateDate($this->date)) {
63+ return $this->date;
10664 }
107- throw new Exception('never get to getComplexUnionArray TopLevel::complexUnionArray');
65+ throw new Exception('never get to getDate TopLevel::date');
10866 }
10967
11068 /**
111- * @return array
69+ * @return string
11270 */
113- public static function sampleComplexUnionArray(): array {
114- return array(
115- ComplexUnionArray::sample() /*enum*/
116- ); /* 31:complexUnionArray*/
71+ public static function sampleDate(): string {
72+ return 'TopLevel::date::31'; /*31:date*/
11773 }
11874
11975 /**
@@ -121,7 +77,7 @@ class TopLevel {
12177 * @throws Exception
12278 * @return string
12379 */
124- public static function fromDate(string $value): string {
80+ public static function fromTime(string $value): string {
12581 return $value; /*string*/
12682 }
12783
@@ -129,11 +85,11 @@ class TopLevel {
12985 * @throws Exception
13086 * @return string
13187 */
132- public function toDate(): string {
133- if (TopLevel::validateDate($this->date)) {
134- return $this->date; /*string*/
88+ public function toTime(): string {
89+ if (TopLevel::validateTime($this->time)) {
90+ return $this->time; /*string*/
13591 }
136- throw new Exception('never get to this TopLevel::date');
92+ throw new Exception('never get to this TopLevel::time');
13793 }
13894
13995 /**
@@ -141,7 +97,7 @@ class TopLevel {
14197 * @return bool
14298 * @throws Exception
14399 */
144- public static function validateDate(string $value): bool {
100+ public static function validateTime(string $value): bool {
145101 return true;
146102 }
147103
@@ -149,18 +105,18 @@ class TopLevel {
149105 * @throws Exception
150106 * @return string
151107 */
152- public function getDate(): string {
153- if (TopLevel::validateDate($this->date)) {
154- return $this->date;
108+ public function getTime(): string {
109+ if (TopLevel::validateTime($this->time)) {
110+ return $this->time;
155111 }
156- throw new Exception('never get to getDate TopLevel::date');
112+ throw new Exception('never get to getTime TopLevel::time');
157113 }
158114
159115 /**
160116 * @return string
161117 */
162- public static function sampleDate(): string {
163- return 'TopLevel::date::32'; /*32:date*/
118+ public static function sampleTime(): string {
119+ return 'TopLevel::time::32'; /*32:time*/
164120 }
165121
166122 /**
@@ -218,50 +174,64 @@ class TopLevel {
218174 }
219175
220176 /**
221- * @param string $value
177+ * @param array $value
222178 * @throws Exception
223- * @return string
179+ * @return array
224180 */
225- public static function fromTime(string $value): string {
226- return $value; /*string*/
181+ public static function fromUnionArray(array $value): array {
182+ return array_map(function ($value) {
183+ return $value; /*string*/
184+ }, $value);
227185 }
228186
229187 /**
230188 * @throws Exception
231- * @return string
189+ * @return array
232190 */
233- public function toTime(): string {
234- if (TopLevel::validateTime($this->time)) {
235- return $this->time; /*string*/
191+ public function toUnionArray(): array {
192+ if (TopLevel::validateUnionArray($this->unionArray)) {
193+ return array_map(function ($value) {
194+ return $value; /*string*/
195+ }, $this->unionArray);
236196 }
237- throw new Exception('never get to this TopLevel::time');
197+ throw new Exception('never get to this TopLevel::unionArray');
238198 }
239199
240200 /**
241- * @param string
201+ * @param array
242202 * @return bool
243203 * @throws Exception
244204 */
245- public static function validateTime(string $value): bool {
205+ public static function validateUnionArray(array $value): bool {
206+ if (!is_array($value)) {
207+ throw new Exception("Attribute Error:TopLevel::unionArray");
208+ }
209+ array_walk($value, function($value_v) {
210+ if (!is_string($value_v)) {
211+ throw new Exception("Attribute Error:TopLevel::unionArray");
212+ }
213+ });
246214 return true;
247215 }
248216
249217 /**
250218 * @throws Exception
251- * @return string
219+ * @return array
252220 */
253- public function getTime(): string {
254- if (TopLevel::validateTime($this->time)) {
255- return $this->time;
221+ public function getUnionArray(): array {
222+ if (TopLevel::validateUnionArray($this->unionArray)) {
223+ return $this->unionArray;
256224 }
257- throw new Exception('never get to getTime TopLevel::time');
225+ throw new Exception('never get to getUnionArray TopLevel::unionArray');
258226 }
259227
260228 /**
261- * @return string
229+ * @return array
262230 */
263- public static function sampleTime(): string {
264- return 'TopLevel::time::34'; /*34:time*/
231+ public static function sampleUnionArray(): array {
232+ return array(
233+ 'TopLevel::::34' /*34:*/
234+ ); /* 34:unionArray*/
265235 }
266236
267237 /**
@@ -269,9 +239,21 @@ class TopLevel {
269239 * @throws Exception
270240 * @return array
271241 */
272- public static function fromUnionArray(array $value): array {
242+ public static function fromComplexUnionArray(array $value): array {
273243 return array_map(function ($value) {
274- return $value; /*string*/
244+ if (is_string($value) && in_array($value, ['foo', 'bar'], true)) {
245+ return ComplexUnionArray::from($value); /*enum*/
246+ } elseif (is_string($value)) {
247+ $tmp = DateTime::createFromFormat(DateTimeInterface::ISO8601, $value);
248+ if (!is_a($tmp, 'DateTime')) {
249+ throw new Exception('Attribute Error:TopLevel::');
250+ }
251+ return $tmp;
252+ } elseif (is_int($value)) {
253+ return $value; /*int*/
254+ } else {
255+ throw new Exception('Cannot deserialize union value in TopLevel');
256+ }
275257 }, $value);
276258 }
277259
@@ -279,13 +261,21 @@ class TopLevel {
279261 * @throws Exception
280262 * @return array
281263 */
282- public function toUnionArray(): array {
283- if (TopLevel::validateUnionArray($this->unionArray)) {
264+ public function toComplexUnionArray(): array {
265+ if (TopLevel::validateComplexUnionArray($this->complexUnionArray)) {
284266 return array_map(function ($value) {
285- return $value; /*string*/
286- }, $this->unionArray);
267+ if ($value instanceof ComplexUnionArray) {
268+ return ComplexUnionArray::to($value); /*enum*/
269+ } elseif ($value instanceof DateTime) {
270+ return $value->format(DateTimeInterface::ISO8601);
271+ } elseif (is_int($value)) {
272+ return $value; /*int*/
273+ } else {
274+ throw new Exception('Union value has no matching member in TopLevel');
275+ }
276+ }, $this->complexUnionArray);
287277 }
288- throw new Exception('never get to this TopLevel::unionArray');
278+ throw new Exception('never get to this TopLevel::complexUnionArray');
289279 }
290280
291281 /**
@@ -293,13 +283,23 @@ class TopLevel {
293283 * @return bool
294284 * @throws Exception
295285 */
296- public static function validateUnionArray(array $value): bool {
286+ public static function validateComplexUnionArray(array $value): bool {
297287 if (!is_array($value)) {
298- throw new Exception("Attribute Error:TopLevel::unionArray");
288+ throw new Exception("Attribute Error:TopLevel::complexUnionArray");
299289 }
300290 array_walk($value, function($value_v) {
301- if (!is_string($value_v)) {
302- throw new Exception("Attribute Error:TopLevel::unionArray");
291+ if ($value_v instanceof ComplexUnionArray) {
292+ ComplexUnionArray::to($value_v);
293+ } elseif ($value_v instanceof DateTime) {
294+ if (!is_a($value_v, 'DateTime')) {
295+ throw new Exception('Attribute Error:TopLevel::complexUnionArray');
296+ }
297+ } elseif (is_int($value_v)) {
298+ if (!is_integer($value_v)) {
299+ throw new Exception("Attribute Error:TopLevel::complexUnionArray");
300+ }
301+ } else {
302+ throw new Exception("Attribute Error:TopLevel::complexUnionArray");
303303 }
304304 });
305305 return true;
@@ -309,20 +309,20 @@ class TopLevel {
309309 * @throws Exception
310310 * @return array
311311 */
312- public function getUnionArray(): array {
313- if (TopLevel::validateUnionArray($this->unionArray)) {
314- return $this->unionArray;
312+ public function getComplexUnionArray(): array {
313+ if (TopLevel::validateComplexUnionArray($this->complexUnionArray)) {
314+ return $this->complexUnionArray;
315315 }
316- throw new Exception('never get to getUnionArray TopLevel::unionArray');
316+ throw new Exception('never get to getComplexUnionArray TopLevel::complexUnionArray');
317317 }
318318
319319 /**
320320 * @return array
321321 */
322- public static function sampleUnionArray(): array {
322+ public static function sampleComplexUnionArray(): array {
323323 return array(
324- 'TopLevel::::35' /*35:*/
325- ); /* 35:unionArray*/
324+ ComplexUnionArray::sample() /*enum*/
325+ ); /* 35:complexUnionArray*/
326326 }
327327
328328 /**
@@ -330,11 +330,11 @@ class TopLevel {
330330 * @return bool
331331 */
332332 public function validate(): bool {
333- return TopLevel::validateComplexUnionArray($this->complexUnionArray)
334- || TopLevel::validateDate($this->date)
335- || TopLevel::validateDateTime($this->dateTime)
333+ return TopLevel::validateDate($this->date)
336334 || TopLevel::validateTime($this->time)
337- || TopLevel::validateUnionArray($this->unionArray);
335+ || TopLevel::validateDateTime($this->dateTime)
336+ || TopLevel::validateUnionArray($this->unionArray)
337+ || TopLevel::validateComplexUnionArray($this->complexUnionArray);
338338 }
339339
340340 /**
@@ -343,11 +343,11 @@ class TopLevel {
343343 */
344344 public function to(): stdClass {
345345 $out = new stdClass();
346- $out->{'complex-union-array'} = $this->toComplexUnionArray();
347346 $out->{'date'} = $this->toDate();
348- $out->{'date-time'} = $this->toDateTime();
349347 $out->{'time'} = $this->toTime();
348+ $out->{'date-time'} = $this->toDateTime();
350349 $out->{'union-array'} = $this->toUnionArray();
350+ $out->{'complex-union-array'} = $this->toComplexUnionArray();
351351 return $out;
352352 }
353353
@@ -358,11 +358,11 @@ class TopLevel {
358358 */
359359 public static function from(stdClass $obj): TopLevel {
360360 return new TopLevel(
361- TopLevel::fromComplexUnionArray($obj->{'complex-union-array'})
362- ,TopLevel::fromDate($obj->{'date'})
363- ,TopLevel::fromDateTime($obj->{'date-time'})
361+ TopLevel::fromDate($obj->{'date'})
364362 ,TopLevel::fromTime($obj->{'time'})
363+ ,TopLevel::fromDateTime($obj->{'date-time'})
365364 ,TopLevel::fromUnionArray($obj->{'union-array'})
365+ ,TopLevel::fromComplexUnionArray($obj->{'complex-union-array'})
366366 );
367367 }
368368
@@ -371,11 +371,11 @@ class TopLevel {
371371 */
372372 public static function sample(): TopLevel {
373373 return new TopLevel(
374- TopLevel::sampleComplexUnionArray()
375- ,TopLevel::sampleDate()
376- ,TopLevel::sampleDateTime()
374+ TopLevel::sampleDate()
377375 ,TopLevel::sampleTime()
376+ ,TopLevel::sampleDateTime()
378377 ,TopLevel::sampleUnionArray()
378+ ,TopLevel::sampleComplexUnionArray()
379379 );
380380 }
381381 }
Mschema-php/test/inputs/schema/description.schema/default/TopLevel.php+119 −119
@@ -4,92 +4,105 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private ?bool $bar; // json:bar Optional
7+ private float|string $union; // json:union Required
88 private EnumEnum $enum; // json:enum Required
99 private ?float $foo; // json:foo Optional
10+ private ?bool $bar; // json:bar Optional
1011 private ObjectOrString|string $objectOrString; // json:object-or-string Required
11- private float|string $union; // json:union Required
1212
1313 /**
14- * @param bool|null $bar
14+ * @param float|string $union
1515 * @param EnumEnum $enum
1616 * @param float|null $foo
17+ * @param bool|null $bar
1718 * @param ObjectOrString|string $objectOrString
18- * @param float|string $union
1919 */
20- public function __construct(?bool $bar, EnumEnum $enum, ?float $foo, ObjectOrString|string $objectOrString, float|string $union) {
21- $this->bar = $bar;
20+ public function __construct(float|string $union, EnumEnum $enum, ?float $foo, ?bool $bar, ObjectOrString|string $objectOrString) {
21+ $this->union = $union;
2222 $this->enum = $enum;
2323 $this->foo = $foo;
24+ $this->bar = $bar;
2425 $this->objectOrString = $objectOrString;
25- $this->union = $union;
2626 }
2727
2828 /**
29- * A pretty boolean
29+ * Either a number or a string
3030 *
31- * @param ?bool $value
31+ * @param float|string $value
3232 * @throws Exception
33- * @return ?bool
33+ * @return float|string
3434 */
35- public static function fromBar(?bool $value): ?bool {
36- if (!is_null($value)) {
37- return $value; /*bool*/
35+ public static function fromUnion(float|string $value): float|string {
36+ if (is_float($value) || is_int($value)) {
37+ return $value; /*float*/
38+ } elseif (is_string($value)) {
39+ return $value; /*string*/
3840 } else {
39- return null;
41+ throw new Exception('Cannot deserialize union value in TopLevel');
4042 }
4143 }
4244
4345 /**
44- * A pretty boolean
46+ * Either a number or a string
4547 *
4648 * @throws Exception
47- * @return ?bool
49+ * @return float|string
4850 */
49- public function toBar(): ?bool {
50- if (TopLevel::validateBar($this->bar)) {
51- if (!is_null($this->bar)) {
52- return $this->bar; /*bool*/
51+ public function toUnion(): float|string {
52+ if (TopLevel::validateUnion($this->union)) {
53+ if (is_float($this->union) || is_int($this->union)) {
54+ return $this->union; /*float*/
55+ } elseif (is_string($this->union)) {
56+ return $this->union; /*string*/
5357 } else {
54- return null;
58+ throw new Exception('Union value has no matching member in TopLevel');
5559 }
5660 }
57- throw new Exception('never get to this TopLevel::bar');
61+ throw new Exception('never get to this TopLevel::union');
5862 }
5963
6064 /**
61- * A pretty boolean
65+ * Either a number or a string
6266 *
63- * @param bool|null
67+ * @param float|string
6468 * @return bool
6569 * @throws Exception
6670 */
67- public static function validateBar(?bool $value): bool {
68- if (!is_null($value)) {
71+ public static function validateUnion(float|string $value): bool {
72+ if (is_float($value) || is_int($value)) {
73+ if (!is_float($value) && !is_int($value)) {
74+ throw new Exception("Attribute Error:TopLevel::union");
75+ }
76+ } elseif (is_string($value)) {
77+ if (!is_string($value)) {
78+ throw new Exception("Attribute Error:TopLevel::union");
79+ }
80+ } else {
81+ throw new Exception("Attribute Error:TopLevel::union");
6982 }
7083 return true;
7184 }
7285
7386 /**
74- * A pretty boolean
87+ * Either a number or a string
7588 *
7689 * @throws Exception
77- * @return ?bool
90+ * @return float|string
7891 */
79- public function getBar(): ?bool {
80- if (TopLevel::validateBar($this->bar)) {
81- return $this->bar;
92+ public function getUnion(): float|string {
93+ if (TopLevel::validateUnion($this->union)) {
94+ return $this->union;
8295 }
83- throw new Exception('never get to getBar TopLevel::bar');
96+ throw new Exception('never get to getUnion TopLevel::union');
8497 }
8598
8699 /**
87- * A pretty boolean
100+ * Either a number or a string
88101 *
89- * @return ?bool
102+ * @return float|string
90103 */
91- public static function sampleBar(): ?bool {
92- return true; /*31:bar*/
104+ public static function sampleUnion(): float|string {
105+ return 31.031; /*31:union*/
93106 }
94107
95108 /**
@@ -208,83 +221,80 @@ class TopLevel {
208221 }
209222
210223 /**
211- * @param stdClass|string $value
224+ * A pretty boolean
225+ *
226+ * @param ?bool $value
212227 * @throws Exception
213- * @return ObjectOrString|string
228+ * @return ?bool
214229 */
215- public static function fromObjectOrString(stdClass|string $value): ObjectOrString|string {
216- if (is_object($value)) {
217- return ObjectOrString::from($value); /*class*/
218- } elseif (is_string($value)) {
219- return $value; /*string*/
230+ public static function fromBar(?bool $value): ?bool {
231+ if (!is_null($value)) {
232+ return $value; /*bool*/
220233 } else {
221- throw new Exception('Cannot deserialize union value in TopLevel');
234+ return null;
222235 }
223236 }
224237
225238 /**
239+ * A pretty boolean
240+ *
226241 * @throws Exception
227- * @return stdClass|string
242+ * @return ?bool
228243 */
229- public function toObjectOrString(): stdClass|string {
230- if (TopLevel::validateObjectOrString($this->objectOrString)) {
231- if ($this->objectOrString instanceof ObjectOrString) {
232- return $this->objectOrString->to(); /*class*/
233- } elseif (is_string($this->objectOrString)) {
234- return $this->objectOrString; /*string*/
244+ public function toBar(): ?bool {
245+ if (TopLevel::validateBar($this->bar)) {
246+ if (!is_null($this->bar)) {
247+ return $this->bar; /*bool*/
235248 } else {
236- throw new Exception('Union value has no matching member in TopLevel');
249+ return null;
237250 }
238251 }
239- throw new Exception('never get to this TopLevel::objectOrString');
252+ throw new Exception('never get to this TopLevel::bar');
240253 }
241254
242255 /**
243- * @param ObjectOrString|string
256+ * A pretty boolean
257+ *
258+ * @param bool|null
244259 * @return bool
245260 * @throws Exception
246261 */
247- public static function validateObjectOrString(ObjectOrString|string $value): bool {
248- if ($value instanceof ObjectOrString) {
249- $value->validate();
250- } elseif (is_string($value)) {
251- if (!is_string($value)) {
252- throw new Exception("Attribute Error:TopLevel::objectOrString");
253- }
254- } else {
255- throw new Exception("Attribute Error:TopLevel::objectOrString");
262+ public static function validateBar(?bool $value): bool {
263+ if (!is_null($value)) {
256264 }
257265 return true;
258266 }
259267
260268 /**
269+ * A pretty boolean
270+ *
261271 * @throws Exception
262- * @return ObjectOrString|string
272+ * @return ?bool
263273 */
264- public function getObjectOrString(): ObjectOrString|string {
265- if (TopLevel::validateObjectOrString($this->objectOrString)) {
266- return $this->objectOrString;
274+ public function getBar(): ?bool {
275+ if (TopLevel::validateBar($this->bar)) {
276+ return $this->bar;
267277 }
268- throw new Exception('never get to getObjectOrString TopLevel::objectOrString');
278+ throw new Exception('never get to getBar TopLevel::bar');
269279 }
270280
271281 /**
272- * @return ObjectOrString|string
282+ * A pretty boolean
283+ *
284+ * @return ?bool
273285 */
274- public static function sampleObjectOrString(): ObjectOrString|string {
275- return ObjectOrString::sample(); /*34:objectOrString*/
286+ public static function sampleBar(): ?bool {
287+ return true; /*34:bar*/
276288 }
277289
278290 /**
279- * Either a number or a string
280- *
281- * @param float|string $value
291+ * @param stdClass|string $value
282292 * @throws Exception
283- * @return float|string
293+ * @return ObjectOrString|string
284294 */
285- public static function fromUnion(float|string $value): float|string {
286- if (is_float($value) || is_int($value)) {
287- return $value; /*float*/
295+ public static function fromObjectOrString(stdClass|string $value): ObjectOrString|string {
296+ if (is_object($value)) {
297+ return ObjectOrString::from($value); /*class*/
288298 } elseif (is_string($value)) {
289299 return $value; /*string*/
290300 } else {
@@ -293,66 +303,56 @@ class TopLevel {
293303 }
294304
295305 /**
296- * Either a number or a string
297- *
298306 * @throws Exception
299- * @return float|string
307+ * @return stdClass|string
300308 */
301- public function toUnion(): float|string {
302- if (TopLevel::validateUnion($this->union)) {
303- if (is_float($this->union) || is_int($this->union)) {
304- return $this->union; /*float*/
305- } elseif (is_string($this->union)) {
306- return $this->union; /*string*/
309+ public function toObjectOrString(): stdClass|string {
310+ if (TopLevel::validateObjectOrString($this->objectOrString)) {
311+ if ($this->objectOrString instanceof ObjectOrString) {
312+ return $this->objectOrString->to(); /*class*/
313+ } elseif (is_string($this->objectOrString)) {
314+ return $this->objectOrString; /*string*/
307315 } else {
308316 throw new Exception('Union value has no matching member in TopLevel');
309317 }
310318 }
311- throw new Exception('never get to this TopLevel::union');
319+ throw new Exception('never get to this TopLevel::objectOrString');
312320 }
313321
314322 /**
315- * Either a number or a string
316- *
317- * @param float|string
323+ * @param ObjectOrString|string
318324 * @return bool
319325 * @throws Exception
320326 */
321- public static function validateUnion(float|string $value): bool {
322- if (is_float($value) || is_int($value)) {
323- if (!is_float($value) && !is_int($value)) {
324- throw new Exception("Attribute Error:TopLevel::union");
325- }
327+ public static function validateObjectOrString(ObjectOrString|string $value): bool {
328+ if ($value instanceof ObjectOrString) {
329+ $value->validate();
326330 } elseif (is_string($value)) {
327331 if (!is_string($value)) {
328- throw new Exception("Attribute Error:TopLevel::union");
332+ throw new Exception("Attribute Error:TopLevel::objectOrString");
329333 }
330334 } else {
331- throw new Exception("Attribute Error:TopLevel::union");
335+ throw new Exception("Attribute Error:TopLevel::objectOrString");
332336 }
333337 return true;
334338 }
335339
336340 /**
337- * Either a number or a string
338- *
339341 * @throws Exception
340- * @return float|string
342+ * @return ObjectOrString|string
341343 */
342- public function getUnion(): float|string {
343- if (TopLevel::validateUnion($this->union)) {
344- return $this->union;
344+ public function getObjectOrString(): ObjectOrString|string {
345+ if (TopLevel::validateObjectOrString($this->objectOrString)) {
346+ return $this->objectOrString;
345347 }
346- throw new Exception('never get to getUnion TopLevel::union');
348+ throw new Exception('never get to getObjectOrString TopLevel::objectOrString');
347349 }
348350
349351 /**
350- * Either a number or a string
351- *
352- * @return float|string
352+ * @return ObjectOrString|string
353353 */
354- public static function sampleUnion(): float|string {
355- return 35.035; /*35:union*/
354+ public static function sampleObjectOrString(): ObjectOrString|string {
355+ return ObjectOrString::sample(); /*35:objectOrString*/
356356 }
357357
358358 /**
@@ -360,11 +360,11 @@ class TopLevel {
360360 * @return bool
361361 */
362362 public function validate(): bool {
363- return TopLevel::validateBar($this->bar)
363+ return TopLevel::validateUnion($this->union)
364364 || TopLevel::validateEnum($this->enum)
365365 || TopLevel::validateFoo($this->foo)
366- || TopLevel::validateObjectOrString($this->objectOrString)
367- || TopLevel::validateUnion($this->union);
366+ || TopLevel::validateBar($this->bar)
367+ || TopLevel::validateObjectOrString($this->objectOrString);
368368 }
369369
370370 /**
@@ -373,11 +373,11 @@ class TopLevel {
373373 */
374374 public function to(): stdClass {
375375 $out = new stdClass();
376- $out->{'bar'} = $this->toBar();
376+ $out->{'union'} = $this->toUnion();
377377 $out->{'enum'} = $this->toEnum();
378378 $out->{'foo'} = $this->toFoo();
379+ $out->{'bar'} = $this->toBar();
379380 $out->{'object-or-string'} = $this->toObjectOrString();
380- $out->{'union'} = $this->toUnion();
381381 return $out;
382382 }
383383
@@ -388,11 +388,11 @@ class TopLevel {
388388 */
389389 public static function from(stdClass $obj): TopLevel {
390390 return new TopLevel(
391- TopLevel::fromBar($obj->{'bar'})
391+ TopLevel::fromUnion($obj->{'union'})
392392 ,TopLevel::fromEnum($obj->{'enum'})
393393 ,TopLevel::fromFoo($obj->{'foo'})
394+ ,TopLevel::fromBar($obj->{'bar'})
394395 ,TopLevel::fromObjectOrString($obj->{'object-or-string'})
395- ,TopLevel::fromUnion($obj->{'union'})
396396 );
397397 }
398398
@@ -401,11 +401,11 @@ class TopLevel {
401401 */
402402 public static function sample(): TopLevel {
403403 return new TopLevel(
404- TopLevel::sampleBar()
404+ TopLevel::sampleUnion()
405405 ,TopLevel::sampleEnum()
406406 ,TopLevel::sampleFoo()
407+ ,TopLevel::sampleBar()
407408 ,TopLevel::sampleObjectOrString()
408- ,TopLevel::sampleUnion()
409409 );
410410 }
411411 }
Mschema-php/test/inputs/schema/direct-union.schema/default/TopLevel.php+77 −77
@@ -117,16 +117,16 @@ class TopLevel {
117117 // This is an autogenerated file:Thing
118118
119119 class Thing {
120- private stdClass|array|bool|int|float|string|null $optional; // json:optional Optional
121120 private stdClass|array|bool|int|float|string|null $required; // json:required Optional
121+ private stdClass|array|bool|int|float|string|null $optional; // json:optional Optional
122122
123123 /**
124- * @param stdClass|array|bool|int|float|string|null $optional
125124 * @param stdClass|array|bool|int|float|string|null $required
125+ * @param stdClass|array|bool|int|float|string|null $optional
126126 */
127- public function __construct(stdClass|array|bool|int|float|string|null $optional, stdClass|array|bool|int|float|string|null $required) {
128- $this->optional = $optional;
127+ public function __construct(stdClass|array|bool|int|float|string|null $required, stdClass|array|bool|int|float|string|null $optional) {
129128 $this->required = $required;
129+ $this->optional = $optional;
130130 }
131131
132132 /**
@@ -134,7 +134,7 @@ class Thing {
134134 * @throws Exception
135135 * @return stdClass|array|bool|int|float|string|null
136136 */
137- public static function fromOptional(stdClass|array|bool|int|float|string|null $value): stdClass|array|bool|int|float|string|null {
137+ public static function fromRequired(stdClass|array|bool|int|float|string|null $value): stdClass|array|bool|int|float|string|null {
138138 if (is_null($value)) {
139139 return $value; /*null*/
140140 } elseif (is_object($value)) {
@@ -164,33 +164,33 @@ class Thing {
164164 * @throws Exception
165165 * @return stdClass|array|bool|int|float|string|null
166166 */
167- public function toOptional(): stdClass|array|bool|int|float|string|null {
168- if (Thing::validateOptional($this->optional)) {
169- if (is_null($this->optional)) {
170- return $this->optional; /*null*/
171- } elseif ($this->optional instanceof stdClass) {
167+ public function toRequired(): stdClass|array|bool|int|float|string|null {
168+ if (Thing::validateRequired($this->required)) {
169+ if (is_null($this->required)) {
170+ return $this->required; /*null*/
171+ } elseif ($this->required instanceof stdClass) {
172172 $out = new stdClass();
173- foreach ($this->optional as $k => $v) {
173+ foreach ($this->required as $k => $v) {
174174 $out->$k = $v; /*any*/
175175 }
176176 return $out;
177- } elseif (is_array($this->optional)) {
177+ } elseif (is_array($this->required)) {
178178 return array_map(function ($value) {
179179 return $value; /*any*/
180- }, $this->optional);
181- } elseif (is_bool($this->optional)) {
182- return $this->optional; /*bool*/
183- } elseif (is_int($this->optional)) {
184- return $this->optional; /*int*/
185- } elseif (is_float($this->optional) || is_int($this->optional)) {
186- return $this->optional; /*float*/
187- } elseif (is_string($this->optional)) {
188- return $this->optional; /*string*/
180+ }, $this->required);
181+ } elseif (is_bool($this->required)) {
182+ return $this->required; /*bool*/
183+ } elseif (is_int($this->required)) {
184+ return $this->required; /*int*/
185+ } elseif (is_float($this->required) || is_int($this->required)) {
186+ return $this->required; /*float*/
187+ } elseif (is_string($this->required)) {
188+ return $this->required; /*string*/
189189 } else {
190190 throw new Exception('Union value has no matching member in Thing');
191191 }
192192 }
193- throw new Exception('never get to this Thing::optional');
193+ throw new Exception('never get to this Thing::required');
194194 }
195195
196196 /**
@@ -198,38 +198,38 @@ class Thing {
198198 * @return bool
199199 * @throws Exception
200200 */
201- public static function validateOptional(stdClass|array|bool|int|float|string|null $value): bool {
201+ public static function validateRequired(stdClass|array|bool|int|float|string|null $value): bool {
202202 if (is_null($value)) {
203203 if (!is_null($value)) {
204- throw new Exception("Attribute Error:Thing::optional");
204+ throw new Exception("Attribute Error:Thing::required");
205205 }
206206 } elseif ($value instanceof stdClass) {
207207 foreach ($value as $k => $v) {
208208 }
209209 } elseif (is_array($value)) {
210210 if (!is_array($value)) {
211- throw new Exception("Attribute Error:Thing::optional");
211+ throw new Exception("Attribute Error:Thing::required");
212212 }
213213 array_walk($value, function($value_v) {
214214 });
215215 } elseif (is_bool($value)) {
216216 if (!is_bool($value)) {
217- throw new Exception("Attribute Error:Thing::optional");
217+ throw new Exception("Attribute Error:Thing::required");
218218 }
219219 } elseif (is_int($value)) {
220220 if (!is_integer($value)) {
221- throw new Exception("Attribute Error:Thing::optional");
221+ throw new Exception("Attribute Error:Thing::required");
222222 }
223223 } elseif (is_float($value) || is_int($value)) {
224224 if (!is_float($value) && !is_int($value)) {
225- throw new Exception("Attribute Error:Thing::optional");
225+ throw new Exception("Attribute Error:Thing::required");
226226 }
227227 } elseif (is_string($value)) {
228228 if (!is_string($value)) {
229- throw new Exception("Attribute Error:Thing::optional");
229+ throw new Exception("Attribute Error:Thing::required");
230230 }
231231 } else {
232- throw new Exception("Attribute Error:Thing::optional");
232+ throw new Exception("Attribute Error:Thing::required");
233233 }
234234 return true;
235235 }
@@ -238,22 +238,22 @@ class Thing {
238238 * @throws Exception
239239 * @return stdClass|array|bool|int|float|string|null
240240 */
241- public function getOptional(): stdClass|array|bool|int|float|string|null {
242- if (Thing::validateOptional($this->optional)) {
243- return $this->optional;
241+ public function getRequired(): stdClass|array|bool|int|float|string|null {
242+ if (Thing::validateRequired($this->required)) {
243+ return $this->required;
244244 }
245- throw new Exception('never get to getOptional Thing::optional');
245+ throw new Exception('never get to getRequired Thing::required');
246246 }
247247
248248 /**
249249 * @return stdClass|array|bool|int|float|string|null
250250 */
251- public static function sampleOptional(): stdClass|array|bool|int|float|string|null {
251+ public static function sampleRequired(): stdClass|array|bool|int|float|string|null {
252252 return (function () {
253253 $out = new stdClass();
254- $out->{'Thing'} = 'AnyType::Thing::optional::31';/*31:optional*/
254+ $out->{'Thing'} = 'AnyType::Thing::required::31';/*31:required*/
255255 return $out;
256- })(); /* 31:optional*/
256+ })(); /* 31:required*/
257257 }
258258
259259 /**
@@ -261,7 +261,7 @@ class Thing {
261261 * @throws Exception
262262 * @return stdClass|array|bool|int|float|string|null
263263 */
264- public static function fromRequired(stdClass|array|bool|int|float|string|null $value): stdClass|array|bool|int|float|string|null {
264+ public static function fromOptional(stdClass|array|bool|int|float|string|null $value): stdClass|array|bool|int|float|string|null {
265265 if (is_null($value)) {
266266 return $value; /*null*/
267267 } elseif (is_object($value)) {
@@ -291,33 +291,33 @@ class Thing {
291291 * @throws Exception
292292 * @return stdClass|array|bool|int|float|string|null
293293 */
294- public function toRequired(): stdClass|array|bool|int|float|string|null {
295- if (Thing::validateRequired($this->required)) {
296- if (is_null($this->required)) {
297- return $this->required; /*null*/
298- } elseif ($this->required instanceof stdClass) {
294+ public function toOptional(): stdClass|array|bool|int|float|string|null {
295+ if (Thing::validateOptional($this->optional)) {
296+ if (is_null($this->optional)) {
297+ return $this->optional; /*null*/
298+ } elseif ($this->optional instanceof stdClass) {
299299 $out = new stdClass();
300- foreach ($this->required as $k => $v) {
300+ foreach ($this->optional as $k => $v) {
301301 $out->$k = $v; /*any*/
302302 }
303303 return $out;
304- } elseif (is_array($this->required)) {
304+ } elseif (is_array($this->optional)) {
305305 return array_map(function ($value) {
306306 return $value; /*any*/
307- }, $this->required);
308- } elseif (is_bool($this->required)) {
309- return $this->required; /*bool*/
310- } elseif (is_int($this->required)) {
311- return $this->required; /*int*/
312- } elseif (is_float($this->required) || is_int($this->required)) {
313- return $this->required; /*float*/
314- } elseif (is_string($this->required)) {
315- return $this->required; /*string*/
307+ }, $this->optional);
308+ } elseif (is_bool($this->optional)) {
309+ return $this->optional; /*bool*/
310+ } elseif (is_int($this->optional)) {
311+ return $this->optional; /*int*/
312+ } elseif (is_float($this->optional) || is_int($this->optional)) {
313+ return $this->optional; /*float*/
314+ } elseif (is_string($this->optional)) {
315+ return $this->optional; /*string*/
316316 } else {
317317 throw new Exception('Union value has no matching member in Thing');
318318 }
319319 }
320- throw new Exception('never get to this Thing::required');
320+ throw new Exception('never get to this Thing::optional');
321321 }
322322
323323 /**
@@ -325,38 +325,38 @@ class Thing {
325325 * @return bool
326326 * @throws Exception
327327 */
328- public static function validateRequired(stdClass|array|bool|int|float|string|null $value): bool {
328+ public static function validateOptional(stdClass|array|bool|int|float|string|null $value): bool {
329329 if (is_null($value)) {
330330 if (!is_null($value)) {
331- throw new Exception("Attribute Error:Thing::required");
331+ throw new Exception("Attribute Error:Thing::optional");
332332 }
333333 } elseif ($value instanceof stdClass) {
334334 foreach ($value as $k => $v) {
335335 }
336336 } elseif (is_array($value)) {
337337 if (!is_array($value)) {
338- throw new Exception("Attribute Error:Thing::required");
338+ throw new Exception("Attribute Error:Thing::optional");
339339 }
340340 array_walk($value, function($value_v) {
341341 });
342342 } elseif (is_bool($value)) {
343343 if (!is_bool($value)) {
344- throw new Exception("Attribute Error:Thing::required");
344+ throw new Exception("Attribute Error:Thing::optional");
345345 }
346346 } elseif (is_int($value)) {
347347 if (!is_integer($value)) {
348- throw new Exception("Attribute Error:Thing::required");
348+ throw new Exception("Attribute Error:Thing::optional");
349349 }
350350 } elseif (is_float($value) || is_int($value)) {
351351 if (!is_float($value) && !is_int($value)) {
352- throw new Exception("Attribute Error:Thing::required");
352+ throw new Exception("Attribute Error:Thing::optional");
353353 }
354354 } elseif (is_string($value)) {
355355 if (!is_string($value)) {
356- throw new Exception("Attribute Error:Thing::required");
356+ throw new Exception("Attribute Error:Thing::optional");
357357 }
358358 } else {
359- throw new Exception("Attribute Error:Thing::required");
359+ throw new Exception("Attribute Error:Thing::optional");
360360 }
361361 return true;
362362 }
@@ -365,22 +365,22 @@ class Thing {
365365 * @throws Exception
366366 * @return stdClass|array|bool|int|float|string|null
367367 */
368- public function getRequired(): stdClass|array|bool|int|float|string|null {
369- if (Thing::validateRequired($this->required)) {
370- return $this->required;
368+ public function getOptional(): stdClass|array|bool|int|float|string|null {
369+ if (Thing::validateOptional($this->optional)) {
370+ return $this->optional;
371371 }
372- throw new Exception('never get to getRequired Thing::required');
372+ throw new Exception('never get to getOptional Thing::optional');
373373 }
374374
375375 /**
376376 * @return stdClass|array|bool|int|float|string|null
377377 */
378- public static function sampleRequired(): stdClass|array|bool|int|float|string|null {
378+ public static function sampleOptional(): stdClass|array|bool|int|float|string|null {
379379 return (function () {
380380 $out = new stdClass();
381- $out->{'Thing'} = 'AnyType::Thing::required::32';/*32:required*/
381+ $out->{'Thing'} = 'AnyType::Thing::optional::32';/*32:optional*/
382382 return $out;
383- })(); /* 32:required*/
383+ })(); /* 32:optional*/
384384 }
385385
386386 /**
@@ -388,8 +388,8 @@ class Thing {
388388 * @return bool
389389 */
390390 public function validate(): bool {
391- return Thing::validateOptional($this->optional)
392- || Thing::validateRequired($this->required);
391+ return Thing::validateRequired($this->required)
392+ || Thing::validateOptional($this->optional);
393393 }
394394
395395 /**
@@ -398,8 +398,8 @@ class Thing {
398398 */
399399 public function to(): stdClass {
400400 $out = new stdClass();
401- $out->{'optional'} = $this->toOptional();
402401 $out->{'required'} = $this->toRequired();
402+ $out->{'optional'} = $this->toOptional();
403403 return $out;
404404 }
405405
@@ -410,8 +410,8 @@ class Thing {
410410 */
411411 public static function from(stdClass $obj): Thing {
412412 return new Thing(
413- Thing::fromOptional($obj->{'optional'})
414- ,Thing::fromRequired($obj->{'required'})
413+ Thing::fromRequired($obj->{'required'})
414+ ,Thing::fromOptional($obj->{'optional'})
415415 );
416416 }
417417
@@ -420,8 +420,8 @@ class Thing {
420420 */
421421 public static function sample(): Thing {
422422 return new Thing(
423- Thing::sampleOptional()
424- ,Thing::sampleRequired()
423+ Thing::sampleRequired()
424+ ,Thing::sampleOptional()
425425 );
426426 }
427427 }
Mschema-php/test/inputs/schema/enum.schema/default/TopLevel.php+152 −152
@@ -4,124 +4,35 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private ?array $arr; // json:arr Optional
8- private ?string $for; // json:for Optional
9- private Gve $gve; // json:gve Required
107 private ?Lvc $lvc; // json:lvc Optional
8+ private Gve $gve; // json:gve Required
9+ private ?array $arr; // json:arr Optional
1110 private ?array $otherArr; // json:otherArr Optional
11+ private ?string $for; // json:for Optional
1212
1313 /**
14- * @param array|null $arr
15- * @param string|null $for
16- * @param Gve $gve
1714 * @param Lvc|null $lvc
15+ * @param Gve $gve
16+ * @param array|null $arr
1817 * @param array|null $otherArr
18+ * @param string|null $for
1919 */
20- public function __construct(?array $arr, ?string $for, Gve $gve, ?Lvc $lvc, ?array $otherArr) {
21- $this->arr = $arr;
22- $this->for = $for;
23- $this->gve = $gve;
20+ public function __construct(?Lvc $lvc, Gve $gve, ?array $arr, ?array $otherArr, ?string $for) {
2421 $this->lvc = $lvc;
22+ $this->gve = $gve;
23+ $this->arr = $arr;
2524 $this->otherArr = $otherArr;
26- }
27-
28- /**
29- * @param ?array $value
30- * @throws Exception
31- * @return ?array
32- */
33- public static function fromArr(?array $value): ?array {
34- if (!is_null($value)) {
35- return array_map(function ($value) {
36- if (is_string($value) && in_array($value, ['foo', 'bar', 'if'], true)) {
37- return OtherArr::from($value); /*enum*/
38- } elseif (is_int($value)) {
39- return $value; /*int*/
40- } else {
41- throw new Exception('Cannot deserialize union value in TopLevel');
42- }
43- }, $value);
44- } else {
45- return null;
46- }
47- }
48-
49- /**
50- * @throws Exception
51- * @return ?array
52- */
53- public function toArr(): ?array {
54- if (TopLevel::validateArr($this->arr)) {
55- if (!is_null($this->arr)) {
56- return array_map(function ($value) {
57- if ($value instanceof OtherArr) {
58- return OtherArr::to($value); /*enum*/
59- } elseif (is_int($value)) {
60- return $value; /*int*/
61- } else {
62- throw new Exception('Union value has no matching member in TopLevel');
63- }
64- }, $this->arr);
65- } else {
66- return null;
67- }
68- }
69- throw new Exception('never get to this TopLevel::arr');
70- }
71-
72- /**
73- * @param array|null
74- * @return bool
75- * @throws Exception
76- */
77- public static function validateArr(?array $value): bool {
78- if (!is_null($value)) {
79- if (!is_array($value)) {
80- throw new Exception("Attribute Error:TopLevel::arr");
81- }
82- array_walk($value, function($value_v) {
83- if ($value_v instanceof OtherArr) {
84- OtherArr::to($value_v);
85- } elseif (is_int($value_v)) {
86- if (!is_integer($value_v)) {
87- throw new Exception("Attribute Error:TopLevel::arr");
88- }
89- } else {
90- throw new Exception("Attribute Error:TopLevel::arr");
91- }
92- });
93- }
94- return true;
95- }
96-
97- /**
98- * @throws Exception
99- * @return ?array
100- */
101- public function getArr(): ?array {
102- if (TopLevel::validateArr($this->arr)) {
103- return $this->arr;
104- }
105- throw new Exception('never get to getArr TopLevel::arr');
106- }
107-
108- /**
109- * @return ?array
110- */
111- public static function sampleArr(): ?array {
112- return array(
113- OtherArr::sample() /*enum*/
114- ); /* 31:arr*/
25+ $this->for = $for;
11526 }
11627
11728 /**
11829 * @param ?string $value
11930 * @throws Exception
120- * @return ?string
31+ * @return ?Lvc
12132 */
122- public static function fromFor(?string $value): ?string {
33+ public static function fromLvc(?string $value): ?Lvc {
12334 if (!is_null($value)) {
124- return $value; /*string*/
35+ return Lvc::from($value); /*enum*/
12536 } else {
12637 return null;
12738 }
@@ -131,44 +42,45 @@ class TopLevel {
13142 * @throws Exception
13243 * @return ?string
13344 */
134- public function toFor(): ?string {
135- if (TopLevel::validateFor($this->for)) {
136- if (!is_null($this->for)) {
137- return $this->for; /*string*/
45+ public function toLvc(): ?string {
46+ if (TopLevel::validateLvc($this->lvc)) {
47+ if (!is_null($this->lvc)) {
48+ return Lvc::to($this->lvc); /*enum*/
13849 } else {
13950 return null;
14051 }
14152 }
142- throw new Exception('never get to this TopLevel::for');
53+ throw new Exception('never get to this TopLevel::lvc');
14354 }
14455
14556 /**
146- * @param string|null
57+ * @param Lvc|null
14758 * @return bool
14859 * @throws Exception
14960 */
150- public static function validateFor(?string $value): bool {
61+ public static function validateLvc(?Lvc $value): bool {
15162 if (!is_null($value)) {
63+ Lvc::to($value);
15264 }
15365 return true;
15466 }
15567
15668 /**
15769 * @throws Exception
158- * @return ?string
70+ * @return ?Lvc
15971 */
160- public function getFor(): ?string {
161- if (TopLevel::validateFor($this->for)) {
162- return $this->for;
72+ public function getLvc(): ?Lvc {
73+ if (TopLevel::validateLvc($this->lvc)) {
74+ return $this->lvc;
16375 }
164- throw new Exception('never get to getFor TopLevel::for');
76+ throw new Exception('never get to getLvc TopLevel::lvc');
16577 }
16678
16779 /**
168- * @return ?string
80+ * @return ?Lvc
16981 */
170- public static function sampleFor(): ?string {
171- return 'TopLevel::for::32'; /*32:for*/
82+ public static function sampleLvc(): ?Lvc {
83+ return Lvc::sample(); /*enum*/
17284 }
17385
17486 /**
@@ -220,13 +132,21 @@ class TopLevel {
220132 }
221133
222134 /**
223- * @param ?string $value
135+ * @param ?array $value
224136 * @throws Exception
225- * @return ?Lvc
137+ * @return ?array
226138 */
227- public static function fromLvc(?string $value): ?Lvc {
139+ public static function fromArr(?array $value): ?array {
228140 if (!is_null($value)) {
229- return Lvc::from($value); /*enum*/
141+ return array_map(function ($value) {
142+ if (is_string($value) && in_array($value, ['foo', 'bar', 'if'], true)) {
143+ return OtherArr::from($value); /*enum*/
144+ } elseif (is_int($value)) {
145+ return $value; /*int*/
146+ } else {
147+ throw new Exception('Cannot deserialize union value in TopLevel');
148+ }
149+ }, $value);
230150 } else {
231151 return null;
232152 }
@@ -234,47 +154,70 @@ class TopLevel {
234154
235155 /**
236156 * @throws Exception
237- * @return ?string
157+ * @return ?array
238158 */
239- public function toLvc(): ?string {
240- if (TopLevel::validateLvc($this->lvc)) {
241- if (!is_null($this->lvc)) {
242- return Lvc::to($this->lvc); /*enum*/
159+ public function toArr(): ?array {
160+ if (TopLevel::validateArr($this->arr)) {
161+ if (!is_null($this->arr)) {
162+ return array_map(function ($value) {
163+ if ($value instanceof OtherArr) {
164+ return OtherArr::to($value); /*enum*/
165+ } elseif (is_int($value)) {
166+ return $value; /*int*/
167+ } else {
168+ throw new Exception('Union value has no matching member in TopLevel');
169+ }
170+ }, $this->arr);
243171 } else {
244172 return null;
245173 }
246174 }
247- throw new Exception('never get to this TopLevel::lvc');
175+ throw new Exception('never get to this TopLevel::arr');
248176 }
249177
250178 /**
251- * @param Lvc|null
179+ * @param array|null
252180 * @return bool
253181 * @throws Exception
254182 */
255- public static function validateLvc(?Lvc $value): bool {
183+ public static function validateArr(?array $value): bool {
256184 if (!is_null($value)) {
257- Lvc::to($value);
185+ if (!is_array($value)) {
186+ throw new Exception("Attribute Error:TopLevel::arr");
187+ }
188+ array_walk($value, function($value_v) {
189+ if ($value_v instanceof OtherArr) {
190+ OtherArr::to($value_v);
191+ } elseif (is_int($value_v)) {
192+ if (!is_integer($value_v)) {
193+ throw new Exception("Attribute Error:TopLevel::arr");
194+ }
195+ } else {
196+ throw new Exception("Attribute Error:TopLevel::arr");
197+ }
198+ });
258199 }
259200 return true;
260201 }
261202
262203 /**
263204 * @throws Exception
264- * @return ?Lvc
205+ * @return ?array
265206 */
266- public function getLvc(): ?Lvc {
267- if (TopLevel::validateLvc($this->lvc)) {
268- return $this->lvc;
207+ public function getArr(): ?array {
208+ if (TopLevel::validateArr($this->arr)) {
209+ return $this->arr;
269210 }
270- throw new Exception('never get to getLvc TopLevel::lvc');
211+ throw new Exception('never get to getArr TopLevel::arr');
271212 }
272213
273214 /**
274- * @return ?Lvc
215+ * @return ?array
275216 */
276- public static function sampleLvc(): ?Lvc {
277- return Lvc::sample(); /*enum*/
217+ public static function sampleArr(): ?array {
218+ return array(
219+ OtherArr::sample() /*enum*/
220+ ); /* 33:arr*/
278221 }
279222
280223 /**
@@ -343,7 +286,64 @@ class TopLevel {
343286 public static function sampleOtherArr(): ?array {
344287 return array(
345288 OtherArr::sample() /*enum*/
346- ); /* 35:otherArr*/
289+ ); /* 34:otherArr*/
290+ }
291+
292+ /**
293+ * @param ?string $value
294+ * @throws Exception
295+ * @return ?string
296+ */
297+ public static function fromFor(?string $value): ?string {
298+ if (!is_null($value)) {
299+ return $value; /*string*/
300+ } else {
301+ return null;
302+ }
303+ }
304+
305+ /**
306+ * @throws Exception
307+ * @return ?string
308+ */
309+ public function toFor(): ?string {
310+ if (TopLevel::validateFor($this->for)) {
311+ if (!is_null($this->for)) {
312+ return $this->for; /*string*/
313+ } else {
314+ return null;
315+ }
316+ }
317+ throw new Exception('never get to this TopLevel::for');
318+ }
319+
320+ /**
321+ * @param string|null
322+ * @return bool
323+ * @throws Exception
324+ */
325+ public static function validateFor(?string $value): bool {
326+ if (!is_null($value)) {
327+ }
328+ return true;
329+ }
330+
331+ /**
332+ * @throws Exception
333+ * @return ?string
334+ */
335+ public function getFor(): ?string {
336+ if (TopLevel::validateFor($this->for)) {
337+ return $this->for;
338+ }
339+ throw new Exception('never get to getFor TopLevel::for');
340+ }
341+
342+ /**
343+ * @return ?string
344+ */
345+ public static function sampleFor(): ?string {
346+ return 'TopLevel::for::35'; /*35:for*/
347347 }
348348
349349 /**
@@ -351,11 +351,11 @@ class TopLevel {
351351 * @return bool
352352 */
353353 public function validate(): bool {
354- return TopLevel::validateArr($this->arr)
355- || TopLevel::validateFor($this->for)
354+ return TopLevel::validateLvc($this->lvc)
356355 || TopLevel::validateGve($this->gve)
357- || TopLevel::validateLvc($this->lvc)
358- || TopLevel::validateOtherArr($this->otherArr);
356+ || TopLevel::validateArr($this->arr)
357+ || TopLevel::validateOtherArr($this->otherArr)
358+ || TopLevel::validateFor($this->for);
359359 }
360360
361361 /**
@@ -364,11 +364,11 @@ class TopLevel {
364364 */
365365 public function to(): stdClass {
366366 $out = new stdClass();
367- $out->{'arr'} = $this->toArr();
368- $out->{'for'} = $this->toFor();
369- $out->{'gve'} = $this->toGve();
370367 $out->{'lvc'} = $this->toLvc();
368+ $out->{'gve'} = $this->toGve();
369+ $out->{'arr'} = $this->toArr();
371370 $out->{'otherArr'} = $this->toOtherArr();
371+ $out->{'for'} = $this->toFor();
372372 return $out;
373373 }
374374
@@ -379,11 +379,11 @@ class TopLevel {
379379 */
380380 public static function from(stdClass $obj): TopLevel {
381381 return new TopLevel(
382- TopLevel::fromArr($obj->{'arr'})
383- ,TopLevel::fromFor($obj->{'for'})
382+ TopLevel::fromLvc($obj->{'lvc'})
384383 ,TopLevel::fromGve($obj->{'gve'})
385- ,TopLevel::fromLvc($obj->{'lvc'})
384+ ,TopLevel::fromArr($obj->{'arr'})
386385 ,TopLevel::fromOtherArr($obj->{'otherArr'})
386+ ,TopLevel::fromFor($obj->{'for'})
387387 );
388388 }
389389
@@ -392,11 +392,11 @@ class TopLevel {
392392 */
393393 public static function sample(): TopLevel {
394394 return new TopLevel(
395- TopLevel::sampleArr()
396- ,TopLevel::sampleFor()
395+ TopLevel::sampleLvc()
397396 ,TopLevel::sampleGve()
398- ,TopLevel::sampleLvc()
397+ ,TopLevel::sampleArr()
399398 ,TopLevel::sampleOtherArr()
399+ ,TopLevel::sampleFor()
400400 );
401401 }
402402 }
Mschema-php/test/inputs/schema/integer-string.schema/default/TopLevel.php+151 −151
@@ -4,124 +4,88 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private ?array $arrNullable; // json:arrNullable Optional
8- private ?array $arrOne; // json:arrOne Optional
9- private ?string $nullable; // json:nullable Optional
107 private string $one; // json:one Required
118 private ?string $optional; // json:optional Optional
9+ private ?string $nullable; // json:nullable Optional
10+ private ?array $arrOne; // json:arrOne Optional
11+ private ?array $arrNullable; // json:arrNullable Optional
1212 private int|string $unionWithInt; // json:unionWithInt Required
1313 private int|string $unionWithIntAndEnum; // json:unionWithIntAndEnum Required
1414
1515 /**
16- * @param array|null $arrNullable
17- * @param array|null $arrOne
18- * @param string|null $nullable
1916 * @param string $one
2017 * @param string|null $optional
18+ * @param string|null $nullable
19+ * @param array|null $arrOne
20+ * @param array|null $arrNullable
2121 * @param int|string $unionWithInt
2222 * @param int|string $unionWithIntAndEnum
2323 */
24- public function __construct(?array $arrNullable, ?array $arrOne, ?string $nullable, string $one, ?string $optional, int|string $unionWithInt, int|string $unionWithIntAndEnum) {
25- $this->arrNullable = $arrNullable;
26- $this->arrOne = $arrOne;
27- $this->nullable = $nullable;
24+ public function __construct(string $one, ?string $optional, ?string $nullable, ?array $arrOne, ?array $arrNullable, int|string $unionWithInt, int|string $unionWithIntAndEnum) {
2825 $this->one = $one;
2926 $this->optional = $optional;
27+ $this->nullable = $nullable;
28+ $this->arrOne = $arrOne;
29+ $this->arrNullable = $arrNullable;
3030 $this->unionWithInt = $unionWithInt;
3131 $this->unionWithIntAndEnum = $unionWithIntAndEnum;
3232 }
3333
3434 /**
35- * @param ?array $value
35+ * @param string $value
3636 * @throws Exception
37- * @return ?array
37+ * @return string
3838 */
39- public static function fromArrNullable(?array $value): ?array {
40- if (!is_null($value)) {
41- return array_map(function ($value) {
42- if (!is_null($value)) {
43- return $value; /*string*/
44- } else {
45- return null;
46- }
47- }, $value);
48- } else {
49- return null;
50- }
39+ public static function fromOne(string $value): string {
40+ return $value; /*string*/
5141 }
5242
5343 /**
5444 * @throws Exception
55- * @return ?array
45+ * @return string
5646 */
57- public function toArrNullable(): ?array {
58- if (TopLevel::validateArrNullable($this->arrNullable)) {
59- if (!is_null($this->arrNullable)) {
60- return array_map(function ($value) {
61- if (!is_null($value)) {
62- return $value; /*string*/
63- } else {
64- return null;
65- }
66- }, $this->arrNullable);
67- } else {
68- return null;
69- }
47+ public function toOne(): string {
48+ if (TopLevel::validateOne($this->one)) {
49+ return $this->one; /*string*/
7050 }
71- throw new Exception('never get to this TopLevel::arrNullable');
51+ throw new Exception('never get to this TopLevel::one');
7252 }
7353
7454 /**
75- * @param array|null
55+ * @param string
7656 * @return bool
7757 * @throws Exception
7858 */
79- public static function validateArrNullable(?array $value): bool {
80- if (!is_null($value)) {
81- if (!is_array($value)) {
82- throw new Exception("Attribute Error:TopLevel::arrNullable");
83- }
84- array_walk($value, function($value_v) {
85- if (!is_null($value_v)) {
86- if (!is_string($value_v)) {
87- throw new Exception("Attribute Error:TopLevel::arrNullable");
88- }
89- }
90- });
91- }
59+ public static function validateOne(string $value): bool {
9260 return true;
9361 }
9462
9563 /**
9664 * @throws Exception
97- * @return ?array
65+ * @return string
9866 */
99- public function getArrNullable(): ?array {
100- if (TopLevel::validateArrNullable($this->arrNullable)) {
101- return $this->arrNullable;
67+ public function getOne(): string {
68+ if (TopLevel::validateOne($this->one)) {
69+ return $this->one;
10270 }
103- throw new Exception('never get to getArrNullable TopLevel::arrNullable');
71+ throw new Exception('never get to getOne TopLevel::one');
10472 }
10573
10674 /**
107- * @return ?array
75+ * @return string
10876 */
109- public static function sampleArrNullable(): ?array {
110- return array(
111- 'TopLevel::::31' /*31:*/
112- ); /* 31:arrNullable*/
77+ public static function sampleOne(): string {
78+ return 'TopLevel::one::31'; /*31:one*/
11379 }
11480
11581 /**
116- * @param ?array $value
82+ * @param ?string $value
11783 * @throws Exception
118- * @return ?array
84+ * @return ?string
11985 */
120- public static function fromArrOne(?array $value): ?array {
86+ public static function fromOptional(?string $value): ?string {
12187 if (!is_null($value)) {
122- return array_map(function ($value) {
123- return $value; /*string*/
124- }, $value);
88+ return $value; /*string*/
12589 } else {
12690 return null;
12791 }
@@ -129,58 +93,46 @@ class TopLevel {
12993
13094 /**
13195 * @throws Exception
132- * @return ?array
96+ * @return ?string
13397 */
134- public function toArrOne(): ?array {
135- if (TopLevel::validateArrOne($this->arrOne)) {
136- if (!is_null($this->arrOne)) {
137- return array_map(function ($value) {
138- return $value; /*string*/
139- }, $this->arrOne);
98+ public function toOptional(): ?string {
99+ if (TopLevel::validateOptional($this->optional)) {
100+ if (!is_null($this->optional)) {
101+ return $this->optional; /*string*/
140102 } else {
141103 return null;
142104 }
143105 }
144- throw new Exception('never get to this TopLevel::arrOne');
106+ throw new Exception('never get to this TopLevel::optional');
145107 }
146108
147109 /**
148- * @param array|null
110+ * @param string|null
149111 * @return bool
150112 * @throws Exception
151113 */
152- public static function validateArrOne(?array $value): bool {
114+ public static function validateOptional(?string $value): bool {
153115 if (!is_null($value)) {
154- if (!is_array($value)) {
155- throw new Exception("Attribute Error:TopLevel::arrOne");
156- }
157- array_walk($value, function($value_v) {
158- if (!is_string($value_v)) {
159- throw new Exception("Attribute Error:TopLevel::arrOne");
160- }
161- });
162116 }
163117 return true;
164118 }
165119
166120 /**
167121 * @throws Exception
168- * @return ?array
122+ * @return ?string
169123 */
170- public function getArrOne(): ?array {
171- if (TopLevel::validateArrOne($this->arrOne)) {
172- return $this->arrOne;
124+ public function getOptional(): ?string {
125+ if (TopLevel::validateOptional($this->optional)) {
126+ return $this->optional;
173127 }
174- throw new Exception('never get to getArrOne TopLevel::arrOne');
128+ throw new Exception('never get to getOptional TopLevel::optional');
175129 }
176130
177131 /**
178- * @return ?array
132+ * @return ?string
179133 */
180- public static function sampleArrOne(): ?array {
181- return array(
182- 'TopLevel::::32' /*32:*/
183- ); /* 32:arrOne*/
134+ public static function sampleOptional(): ?string {
135+ return 'TopLevel::optional::32'; /*32:optional*/
184136 }
185137
186138 /**
@@ -241,60 +193,90 @@ class TopLevel {
241193 }
242194
243195 /**
244- * @param string $value
196+ * @param ?array $value
245197 * @throws Exception
246- * @return string
198+ * @return ?array
247199 */
248- public static function fromOne(string $value): string {
249- return $value; /*string*/
200+ public static function fromArrOne(?array $value): ?array {
201+ if (!is_null($value)) {
202+ return array_map(function ($value) {
203+ return $value; /*string*/
204+ }, $value);
205+ } else {
206+ return null;
207+ }
250208 }
251209
252210 /**
253211 * @throws Exception
254- * @return string
212+ * @return ?array
255213 */
256- public function toOne(): string {
257- if (TopLevel::validateOne($this->one)) {
258- return $this->one; /*string*/
214+ public function toArrOne(): ?array {
215+ if (TopLevel::validateArrOne($this->arrOne)) {
216+ if (!is_null($this->arrOne)) {
217+ return array_map(function ($value) {
218+ return $value; /*string*/
219+ }, $this->arrOne);
220+ } else {
221+ return null;
222+ }
259223 }
260- throw new Exception('never get to this TopLevel::one');
224+ throw new Exception('never get to this TopLevel::arrOne');
261225 }
262226
263227 /**
264- * @param string
228+ * @param array|null
265229 * @return bool
266230 * @throws Exception
267231 */
268- public static function validateOne(string $value): bool {
232+ public static function validateArrOne(?array $value): bool {
233+ if (!is_null($value)) {
234+ if (!is_array($value)) {
235+ throw new Exception("Attribute Error:TopLevel::arrOne");
236+ }
237+ array_walk($value, function($value_v) {
238+ if (!is_string($value_v)) {
239+ throw new Exception("Attribute Error:TopLevel::arrOne");
240+ }
241+ });
242+ }
269243 return true;
270244 }
271245
272246 /**
273247 * @throws Exception
274- * @return string
248+ * @return ?array
275249 */
276- public function getOne(): string {
277- if (TopLevel::validateOne($this->one)) {
278- return $this->one;
250+ public function getArrOne(): ?array {
251+ if (TopLevel::validateArrOne($this->arrOne)) {
252+ return $this->arrOne;
279253 }
280- throw new Exception('never get to getOne TopLevel::one');
254+ throw new Exception('never get to getArrOne TopLevel::arrOne');
281255 }
282256
283257 /**
284- * @return string
258+ * @return ?array
285259 */
286- public static function sampleOne(): string {
287- return 'TopLevel::one::34'; /*34:one*/
260+ public static function sampleArrOne(): ?array {
261+ return array(
262+ 'TopLevel::::34' /*34:*/
263+ ); /* 34:arrOne*/
288264 }
289265
290266 /**
291- * @param ?string $value
267+ * @param ?array $value
292268 * @throws Exception
293- * @return ?string
269+ * @return ?array
294270 */
295- public static function fromOptional(?string $value): ?string {
271+ public static function fromArrNullable(?array $value): ?array {
296272 if (!is_null($value)) {
297- return $value; /*string*/
273+ return array_map(function ($value) {
274+ if (!is_null($value)) {
275+ return $value; /*string*/
276+ } else {
277+ return null;
278+ }
279+ }, $value);
298280 } else {
299281 return null;
300282 }
@@ -302,46 +284,64 @@ class TopLevel {
302284
303285 /**
304286 * @throws Exception
305- * @return ?string
287+ * @return ?array
306288 */
307- public function toOptional(): ?string {
308- if (TopLevel::validateOptional($this->optional)) {
309- if (!is_null($this->optional)) {
310- return $this->optional; /*string*/
289+ public function toArrNullable(): ?array {
290+ if (TopLevel::validateArrNullable($this->arrNullable)) {
291+ if (!is_null($this->arrNullable)) {
292+ return array_map(function ($value) {
293+ if (!is_null($value)) {
294+ return $value; /*string*/
295+ } else {
296+ return null;
297+ }
298+ }, $this->arrNullable);
311299 } else {
312300 return null;
313301 }
314302 }
315- throw new Exception('never get to this TopLevel::optional');
303+ throw new Exception('never get to this TopLevel::arrNullable');
316304 }
317305
318306 /**
319- * @param string|null
307+ * @param array|null
320308 * @return bool
321309 * @throws Exception
322310 */
323- public static function validateOptional(?string $value): bool {
311+ public static function validateArrNullable(?array $value): bool {
324312 if (!is_null($value)) {
313+ if (!is_array($value)) {
314+ throw new Exception("Attribute Error:TopLevel::arrNullable");
315+ }
316+ array_walk($value, function($value_v) {
317+ if (!is_null($value_v)) {
318+ if (!is_string($value_v)) {
319+ throw new Exception("Attribute Error:TopLevel::arrNullable");
320+ }
321+ }
322+ });
325323 }
326324 return true;
327325 }
328326
329327 /**
330328 * @throws Exception
331- * @return ?string
329+ * @return ?array
332330 */
333- public function getOptional(): ?string {
334- if (TopLevel::validateOptional($this->optional)) {
335- return $this->optional;
331+ public function getArrNullable(): ?array {
332+ if (TopLevel::validateArrNullable($this->arrNullable)) {
333+ return $this->arrNullable;
336334 }
337- throw new Exception('never get to getOptional TopLevel::optional');
335+ throw new Exception('never get to getArrNullable TopLevel::arrNullable');
338336 }
339337
340338 /**
341- * @return ?string
339+ * @return ?array
342340 */
343- public static function sampleOptional(): ?string {
344- return 'TopLevel::optional::35'; /*35:optional*/
341+ public static function sampleArrNullable(): ?array {
342+ return array(
343+ 'TopLevel::::35' /*35:*/
344+ ); /* 35:arrNullable*/
345345 }
346346
347347 /**
@@ -489,11 +489,11 @@ class TopLevel {
489489 * @return bool
490490 */
491491 public function validate(): bool {
492- return TopLevel::validateArrNullable($this->arrNullable)
493- || TopLevel::validateArrOne($this->arrOne)
494- || TopLevel::validateNullable($this->nullable)
495- || TopLevel::validateOne($this->one)
492+ return TopLevel::validateOne($this->one)
496493 || TopLevel::validateOptional($this->optional)
494+ || TopLevel::validateNullable($this->nullable)
495+ || TopLevel::validateArrOne($this->arrOne)
496+ || TopLevel::validateArrNullable($this->arrNullable)
497497 || TopLevel::validateUnionWithInt($this->unionWithInt)
498498 || TopLevel::validateUnionWithIntAndEnum($this->unionWithIntAndEnum);
499499 }
@@ -504,11 +504,11 @@ class TopLevel {
504504 */
505505 public function to(): stdClass {
506506 $out = new stdClass();
507- $out->{'arrNullable'} = $this->toArrNullable();
508- $out->{'arrOne'} = $this->toArrOne();
509- $out->{'nullable'} = $this->toNullable();
510507 $out->{'one'} = $this->toOne();
511508 $out->{'optional'} = $this->toOptional();
509+ $out->{'nullable'} = $this->toNullable();
510+ $out->{'arrOne'} = $this->toArrOne();
511+ $out->{'arrNullable'} = $this->toArrNullable();
512512 $out->{'unionWithInt'} = $this->toUnionWithInt();
513513 $out->{'unionWithIntAndEnum'} = $this->toUnionWithIntAndEnum();
514514 return $out;
@@ -521,11 +521,11 @@ class TopLevel {
521521 */
522522 public static function from(stdClass $obj): TopLevel {
523523 return new TopLevel(
524- TopLevel::fromArrNullable($obj->{'arrNullable'})
525- ,TopLevel::fromArrOne($obj->{'arrOne'})
526- ,TopLevel::fromNullable($obj->{'nullable'})
527- ,TopLevel::fromOne($obj->{'one'})
524+ TopLevel::fromOne($obj->{'one'})
528525 ,TopLevel::fromOptional($obj->{'optional'})
526+ ,TopLevel::fromNullable($obj->{'nullable'})
527+ ,TopLevel::fromArrOne($obj->{'arrOne'})
528+ ,TopLevel::fromArrNullable($obj->{'arrNullable'})
529529 ,TopLevel::fromUnionWithInt($obj->{'unionWithInt'})
530530 ,TopLevel::fromUnionWithIntAndEnum($obj->{'unionWithIntAndEnum'})
531531 );
@@ -536,11 +536,11 @@ class TopLevel {
536536 */
537537 public static function sample(): TopLevel {
538538 return new TopLevel(
539- TopLevel::sampleArrNullable()
540- ,TopLevel::sampleArrOne()
541- ,TopLevel::sampleNullable()
542- ,TopLevel::sampleOne()
539+ TopLevel::sampleOne()
543540 ,TopLevel::sampleOptional()
541+ ,TopLevel::sampleNullable()
542+ ,TopLevel::sampleArrOne()
543+ ,TopLevel::sampleArrNullable()
544544 ,TopLevel::sampleUnionWithInt()
545545 ,TopLevel::sampleUnionWithIntAndEnum()
546546 );
Mschema-php/test/inputs/schema/integer-type.schema/default/TopLevel.php+124 −124
@@ -4,37 +4,37 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7+ private int $smallPositive; // json:small_positive Required
8+ private int $smallNegative; // json:small_negative Required
9+ private int $i32Range; // json:i32_range Required
710 private int $aboveI32Max; // json:above_i32_max Required
811 private int $belowI32Min; // json:below_i32_min Required
9- private int $i32Range; // json:i32_range Required
10- private int $largeBounds; // json:large_bounds Required
11- private int $onlyMaximum; // json:only_maximum Required
1212 private int $onlyMinimum; // json:only_minimum Required
13- private int $smallNegative; // json:small_negative Required
14- private int $smallPositive; // json:small_positive Required
13+ private int $onlyMaximum; // json:only_maximum Required
1514 private int $unbounded; // json:unbounded Required
15+ private int $largeBounds; // json:large_bounds Required
1616
1717 /**
18+ * @param int $smallPositive
19+ * @param int $smallNegative
20+ * @param int $i32Range
1821 * @param int $aboveI32Max
1922 * @param int $belowI32Min
20- * @param int $i32Range
21- * @param int $largeBounds
22- * @param int $onlyMaximum
2323 * @param int $onlyMinimum
24- * @param int $smallNegative
25- * @param int $smallPositive
24+ * @param int $onlyMaximum
2625 * @param int $unbounded
26+ * @param int $largeBounds
2727 */
28- public function __construct(int $aboveI32Max, int $belowI32Min, int $i32Range, int $largeBounds, int $onlyMaximum, int $onlyMinimum, int $smallNegative, int $smallPositive, int $unbounded) {
28+ public function __construct(int $smallPositive, int $smallNegative, int $i32Range, int $aboveI32Max, int $belowI32Min, int $onlyMinimum, int $onlyMaximum, int $unbounded, int $largeBounds) {
29+ $this->smallPositive = $smallPositive;
30+ $this->smallNegative = $smallNegative;
31+ $this->i32Range = $i32Range;
2932 $this->aboveI32Max = $aboveI32Max;
3033 $this->belowI32Min = $belowI32Min;
31- $this->i32Range = $i32Range;
32- $this->largeBounds = $largeBounds;
33- $this->onlyMaximum = $onlyMaximum;
3434 $this->onlyMinimum = $onlyMinimum;
35- $this->smallNegative = $smallNegative;
36- $this->smallPositive = $smallPositive;
35+ $this->onlyMaximum = $onlyMaximum;
3736 $this->unbounded = $unbounded;
37+ $this->largeBounds = $largeBounds;
3838 }
3939
4040 /**
@@ -42,7 +42,7 @@ class TopLevel {
4242 * @throws Exception
4343 * @return int
4444 */
45- public static function fromAboveI32Max(int $value): int {
45+ public static function fromSmallPositive(int $value): int {
4646 return $value; /*int*/
4747 }
4848
@@ -50,11 +50,11 @@ class TopLevel {
5050 * @throws Exception
5151 * @return int
5252 */
53- public function toAboveI32Max(): int {
54- if (TopLevel::validateAboveI32Max($this->aboveI32Max)) {
55- return $this->aboveI32Max; /*int*/
53+ public function toSmallPositive(): int {
54+ if (TopLevel::validateSmallPositive($this->smallPositive)) {
55+ return $this->smallPositive; /*int*/
5656 }
57- throw new Exception('never get to this TopLevel::aboveI32Max');
57+ throw new Exception('never get to this TopLevel::smallPositive');
5858 }
5959
6060 /**
@@ -62,7 +62,7 @@ class TopLevel {
6262 * @return bool
6363 * @throws Exception
6464 */
65- public static function validateAboveI32Max(int $value): bool {
65+ public static function validateSmallPositive(int $value): bool {
6666 return true;
6767 }
6868
@@ -70,18 +70,18 @@ class TopLevel {
7070 * @throws Exception
7171 * @return int
7272 */
73- public function getAboveI32Max(): int {
74- if (TopLevel::validateAboveI32Max($this->aboveI32Max)) {
75- return $this->aboveI32Max;
73+ public function getSmallPositive(): int {
74+ if (TopLevel::validateSmallPositive($this->smallPositive)) {
75+ return $this->smallPositive;
7676 }
77- throw new Exception('never get to getAboveI32Max TopLevel::aboveI32Max');
77+ throw new Exception('never get to getSmallPositive TopLevel::smallPositive');
7878 }
7979
8080 /**
8181 * @return int
8282 */
83- public static function sampleAboveI32Max(): int {
84- return 31; /*31:aboveI32Max*/
83+ public static function sampleSmallPositive(): int {
84+ return 31; /*31:smallPositive*/
8585 }
8686
8787 /**
@@ -89,7 +89,7 @@ class TopLevel {
8989 * @throws Exception
9090 * @return int
9191 */
92- public static function fromBelowI32Min(int $value): int {
92+ public static function fromSmallNegative(int $value): int {
9393 return $value; /*int*/
9494 }
9595
@@ -97,11 +97,11 @@ class TopLevel {
9797 * @throws Exception
9898 * @return int
9999 */
100- public function toBelowI32Min(): int {
101- if (TopLevel::validateBelowI32Min($this->belowI32Min)) {
102- return $this->belowI32Min; /*int*/
100+ public function toSmallNegative(): int {
101+ if (TopLevel::validateSmallNegative($this->smallNegative)) {
102+ return $this->smallNegative; /*int*/
103103 }
104- throw new Exception('never get to this TopLevel::belowI32Min');
104+ throw new Exception('never get to this TopLevel::smallNegative');
105105 }
106106
107107 /**
@@ -109,7 +109,7 @@ class TopLevel {
109109 * @return bool
110110 * @throws Exception
111111 */
112- public static function validateBelowI32Min(int $value): bool {
112+ public static function validateSmallNegative(int $value): bool {
113113 return true;
114114 }
115115
@@ -117,18 +117,18 @@ class TopLevel {
117117 * @throws Exception
118118 * @return int
119119 */
120- public function getBelowI32Min(): int {
121- if (TopLevel::validateBelowI32Min($this->belowI32Min)) {
122- return $this->belowI32Min;
120+ public function getSmallNegative(): int {
121+ if (TopLevel::validateSmallNegative($this->smallNegative)) {
122+ return $this->smallNegative;
123123 }
124- throw new Exception('never get to getBelowI32Min TopLevel::belowI32Min');
124+ throw new Exception('never get to getSmallNegative TopLevel::smallNegative');
125125 }
126126
127127 /**
128128 * @return int
129129 */
130- public static function sampleBelowI32Min(): int {
131- return 32; /*32:belowI32Min*/
130+ public static function sampleSmallNegative(): int {
131+ return 32; /*32:smallNegative*/
132132 }
133133
134134 /**
@@ -183,7 +183,7 @@ class TopLevel {
183183 * @throws Exception
184184 * @return int
185185 */
186- public static function fromLargeBounds(int $value): int {
186+ public static function fromAboveI32Max(int $value): int {
187187 return $value; /*int*/
188188 }
189189
@@ -191,11 +191,11 @@ class TopLevel {
191191 * @throws Exception
192192 * @return int
193193 */
194- public function toLargeBounds(): int {
195- if (TopLevel::validateLargeBounds($this->largeBounds)) {
196- return $this->largeBounds; /*int*/
194+ public function toAboveI32Max(): int {
195+ if (TopLevel::validateAboveI32Max($this->aboveI32Max)) {
196+ return $this->aboveI32Max; /*int*/
197197 }
198- throw new Exception('never get to this TopLevel::largeBounds');
198+ throw new Exception('never get to this TopLevel::aboveI32Max');
199199 }
200200
201201 /**
@@ -203,7 +203,7 @@ class TopLevel {
203203 * @return bool
204204 * @throws Exception
205205 */
206- public static function validateLargeBounds(int $value): bool {
206+ public static function validateAboveI32Max(int $value): bool {
207207 return true;
208208 }
209209
@@ -211,18 +211,18 @@ class TopLevel {
211211 * @throws Exception
212212 * @return int
213213 */
214- public function getLargeBounds(): int {
215- if (TopLevel::validateLargeBounds($this->largeBounds)) {
216- return $this->largeBounds;
214+ public function getAboveI32Max(): int {
215+ if (TopLevel::validateAboveI32Max($this->aboveI32Max)) {
216+ return $this->aboveI32Max;
217217 }
218- throw new Exception('never get to getLargeBounds TopLevel::largeBounds');
218+ throw new Exception('never get to getAboveI32Max TopLevel::aboveI32Max');
219219 }
220220
221221 /**
222222 * @return int
223223 */
224- public static function sampleLargeBounds(): int {
225- return 34; /*34:largeBounds*/
224+ public static function sampleAboveI32Max(): int {
225+ return 34; /*34:aboveI32Max*/
226226 }
227227
228228 /**
@@ -230,7 +230,7 @@ class TopLevel {
230230 * @throws Exception
231231 * @return int
232232 */
233- public static function fromOnlyMaximum(int $value): int {
233+ public static function fromBelowI32Min(int $value): int {
234234 return $value; /*int*/
235235 }
236236
@@ -238,11 +238,11 @@ class TopLevel {
238238 * @throws Exception
239239 * @return int
240240 */
241- public function toOnlyMaximum(): int {
242- if (TopLevel::validateOnlyMaximum($this->onlyMaximum)) {
243- return $this->onlyMaximum; /*int*/
241+ public function toBelowI32Min(): int {
242+ if (TopLevel::validateBelowI32Min($this->belowI32Min)) {
243+ return $this->belowI32Min; /*int*/
244244 }
245- throw new Exception('never get to this TopLevel::onlyMaximum');
245+ throw new Exception('never get to this TopLevel::belowI32Min');
246246 }
247247
248248 /**
@@ -250,7 +250,7 @@ class TopLevel {
250250 * @return bool
251251 * @throws Exception
252252 */
253- public static function validateOnlyMaximum(int $value): bool {
253+ public static function validateBelowI32Min(int $value): bool {
254254 return true;
255255 }
256256
@@ -258,18 +258,18 @@ class TopLevel {
258258 * @throws Exception
259259 * @return int
260260 */
261- public function getOnlyMaximum(): int {
262- if (TopLevel::validateOnlyMaximum($this->onlyMaximum)) {
263- return $this->onlyMaximum;
261+ public function getBelowI32Min(): int {
262+ if (TopLevel::validateBelowI32Min($this->belowI32Min)) {
263+ return $this->belowI32Min;
264264 }
265- throw new Exception('never get to getOnlyMaximum TopLevel::onlyMaximum');
265+ throw new Exception('never get to getBelowI32Min TopLevel::belowI32Min');
266266 }
267267
268268 /**
269269 * @return int
270270 */
271- public static function sampleOnlyMaximum(): int {
272- return 35; /*35:onlyMaximum*/
271+ public static function sampleBelowI32Min(): int {
272+ return 35; /*35:belowI32Min*/
273273 }
274274
275275 /**
@@ -324,7 +324,7 @@ class TopLevel {
324324 * @throws Exception
325325 * @return int
326326 */
327- public static function fromSmallNegative(int $value): int {
327+ public static function fromOnlyMaximum(int $value): int {
328328 return $value; /*int*/
329329 }
330330
@@ -332,11 +332,11 @@ class TopLevel {
332332 * @throws Exception
333333 * @return int
334334 */
335- public function toSmallNegative(): int {
336- if (TopLevel::validateSmallNegative($this->smallNegative)) {
337- return $this->smallNegative; /*int*/
335+ public function toOnlyMaximum(): int {
336+ if (TopLevel::validateOnlyMaximum($this->onlyMaximum)) {
337+ return $this->onlyMaximum; /*int*/
338338 }
339- throw new Exception('never get to this TopLevel::smallNegative');
339+ throw new Exception('never get to this TopLevel::onlyMaximum');
340340 }
341341
342342 /**
@@ -344,7 +344,7 @@ class TopLevel {
344344 * @return bool
345345 * @throws Exception
346346 */
347- public static function validateSmallNegative(int $value): bool {
347+ public static function validateOnlyMaximum(int $value): bool {
348348 return true;
349349 }
350350
@@ -352,18 +352,18 @@ class TopLevel {
352352 * @throws Exception
353353 * @return int
354354 */
355- public function getSmallNegative(): int {
356- if (TopLevel::validateSmallNegative($this->smallNegative)) {
357- return $this->smallNegative;
355+ public function getOnlyMaximum(): int {
356+ if (TopLevel::validateOnlyMaximum($this->onlyMaximum)) {
357+ return $this->onlyMaximum;
358358 }
359- throw new Exception('never get to getSmallNegative TopLevel::smallNegative');
359+ throw new Exception('never get to getOnlyMaximum TopLevel::onlyMaximum');
360360 }
361361
362362 /**
363363 * @return int
364364 */
365- public static function sampleSmallNegative(): int {
366- return 37; /*37:smallNegative*/
365+ public static function sampleOnlyMaximum(): int {
366+ return 37; /*37:onlyMaximum*/
367367 }
368368
369369 /**
@@ -371,7 +371,7 @@ class TopLevel {
371371 * @throws Exception
372372 * @return int
373373 */
374- public static function fromSmallPositive(int $value): int {
374+ public static function fromUnbounded(int $value): int {
375375 return $value; /*int*/
376376 }
377377
@@ -379,11 +379,11 @@ class TopLevel {
379379 * @throws Exception
380380 * @return int
381381 */
382- public function toSmallPositive(): int {
383- if (TopLevel::validateSmallPositive($this->smallPositive)) {
384- return $this->smallPositive; /*int*/
382+ public function toUnbounded(): int {
383+ if (TopLevel::validateUnbounded($this->unbounded)) {
384+ return $this->unbounded; /*int*/
385385 }
386- throw new Exception('never get to this TopLevel::smallPositive');
386+ throw new Exception('never get to this TopLevel::unbounded');
387387 }
388388
389389 /**
@@ -391,7 +391,7 @@ class TopLevel {
391391 * @return bool
392392 * @throws Exception
393393 */
394- public static function validateSmallPositive(int $value): bool {
394+ public static function validateUnbounded(int $value): bool {
395395 return true;
396396 }
397397
@@ -399,18 +399,18 @@ class TopLevel {
399399 * @throws Exception
400400 * @return int
401401 */
402- public function getSmallPositive(): int {
403- if (TopLevel::validateSmallPositive($this->smallPositive)) {
404- return $this->smallPositive;
402+ public function getUnbounded(): int {
403+ if (TopLevel::validateUnbounded($this->unbounded)) {
404+ return $this->unbounded;
405405 }
406- throw new Exception('never get to getSmallPositive TopLevel::smallPositive');
406+ throw new Exception('never get to getUnbounded TopLevel::unbounded');
407407 }
408408
409409 /**
410410 * @return int
411411 */
412- public static function sampleSmallPositive(): int {
413- return 38; /*38:smallPositive*/
412+ public static function sampleUnbounded(): int {
413+ return 38; /*38:unbounded*/
414414 }
415415
416416 /**
@@ -418,7 +418,7 @@ class TopLevel {
418418 * @throws Exception
419419 * @return int
420420 */
421- public static function fromUnbounded(int $value): int {
421+ public static function fromLargeBounds(int $value): int {
422422 return $value; /*int*/
423423 }
424424
@@ -426,11 +426,11 @@ class TopLevel {
426426 * @throws Exception
427427 * @return int
428428 */
429- public function toUnbounded(): int {
430- if (TopLevel::validateUnbounded($this->unbounded)) {
431- return $this->unbounded; /*int*/
429+ public function toLargeBounds(): int {
430+ if (TopLevel::validateLargeBounds($this->largeBounds)) {
431+ return $this->largeBounds; /*int*/
432432 }
433- throw new Exception('never get to this TopLevel::unbounded');
433+ throw new Exception('never get to this TopLevel::largeBounds');
434434 }
435435
436436 /**
@@ -438,7 +438,7 @@ class TopLevel {
438438 * @return bool
439439 * @throws Exception
440440 */
441- public static function validateUnbounded(int $value): bool {
441+ public static function validateLargeBounds(int $value): bool {
442442 return true;
443443 }
444444
@@ -446,18 +446,18 @@ class TopLevel {
446446 * @throws Exception
447447 * @return int
448448 */
449- public function getUnbounded(): int {
450- if (TopLevel::validateUnbounded($this->unbounded)) {
451- return $this->unbounded;
449+ public function getLargeBounds(): int {
450+ if (TopLevel::validateLargeBounds($this->largeBounds)) {
451+ return $this->largeBounds;
452452 }
453- throw new Exception('never get to getUnbounded TopLevel::unbounded');
453+ throw new Exception('never get to getLargeBounds TopLevel::largeBounds');
454454 }
455455
456456 /**
457457 * @return int
458458 */
459- public static function sampleUnbounded(): int {
460- return 39; /*39:unbounded*/
459+ public static function sampleLargeBounds(): int {
460+ return 39; /*39:largeBounds*/
461461 }
462462
463463 /**
@@ -465,15 +465,15 @@ class TopLevel {
465465 * @return bool
466466 */
467467 public function validate(): bool {
468- return TopLevel::validateAboveI32Max($this->aboveI32Max)
469- || TopLevel::validateBelowI32Min($this->belowI32Min)
468+ return TopLevel::validateSmallPositive($this->smallPositive)
469+ || TopLevel::validateSmallNegative($this->smallNegative)
470470 || TopLevel::validateI32Range($this->i32Range)
471- || TopLevel::validateLargeBounds($this->largeBounds)
472- || TopLevel::validateOnlyMaximum($this->onlyMaximum)
471+ || TopLevel::validateAboveI32Max($this->aboveI32Max)
472+ || TopLevel::validateBelowI32Min($this->belowI32Min)
473473 || TopLevel::validateOnlyMinimum($this->onlyMinimum)
474- || TopLevel::validateSmallNegative($this->smallNegative)
475- || TopLevel::validateSmallPositive($this->smallPositive)
476- || TopLevel::validateUnbounded($this->unbounded);
474+ || TopLevel::validateOnlyMaximum($this->onlyMaximum)
475+ || TopLevel::validateUnbounded($this->unbounded)
476+ || TopLevel::validateLargeBounds($this->largeBounds);
477477 }
478478
479479 /**
@@ -482,15 +482,15 @@ class TopLevel {
482482 */
483483 public function to(): stdClass {
484484 $out = new stdClass();
485+ $out->{'small_positive'} = $this->toSmallPositive();
486+ $out->{'small_negative'} = $this->toSmallNegative();
487+ $out->{'i32_range'} = $this->toI32Range();
485488 $out->{'above_i32_max'} = $this->toAboveI32Max();
486489 $out->{'below_i32_min'} = $this->toBelowI32Min();
487- $out->{'i32_range'} = $this->toI32Range();
488- $out->{'large_bounds'} = $this->toLargeBounds();
489- $out->{'only_maximum'} = $this->toOnlyMaximum();
490490 $out->{'only_minimum'} = $this->toOnlyMinimum();
491- $out->{'small_negative'} = $this->toSmallNegative();
492- $out->{'small_positive'} = $this->toSmallPositive();
491+ $out->{'only_maximum'} = $this->toOnlyMaximum();
493492 $out->{'unbounded'} = $this->toUnbounded();
493+ $out->{'large_bounds'} = $this->toLargeBounds();
494494 return $out;
495495 }
496496
@@ -501,15 +501,15 @@ class TopLevel {
501501 */
502502 public static function from(stdClass $obj): TopLevel {
503503 return new TopLevel(
504- TopLevel::fromAboveI32Max($obj->{'above_i32_max'})
505- ,TopLevel::fromBelowI32Min($obj->{'below_i32_min'})
504+ TopLevel::fromSmallPositive($obj->{'small_positive'})
505+ ,TopLevel::fromSmallNegative($obj->{'small_negative'})
506506 ,TopLevel::fromI32Range($obj->{'i32_range'})
507- ,TopLevel::fromLargeBounds($obj->{'large_bounds'})
508- ,TopLevel::fromOnlyMaximum($obj->{'only_maximum'})
507+ ,TopLevel::fromAboveI32Max($obj->{'above_i32_max'})
508+ ,TopLevel::fromBelowI32Min($obj->{'below_i32_min'})
509509 ,TopLevel::fromOnlyMinimum($obj->{'only_minimum'})
510- ,TopLevel::fromSmallNegative($obj->{'small_negative'})
511- ,TopLevel::fromSmallPositive($obj->{'small_positive'})
510+ ,TopLevel::fromOnlyMaximum($obj->{'only_maximum'})
512511 ,TopLevel::fromUnbounded($obj->{'unbounded'})
512+ ,TopLevel::fromLargeBounds($obj->{'large_bounds'})
513513 );
514514 }
515515
@@ -518,15 +518,15 @@ class TopLevel {
518518 */
519519 public static function sample(): TopLevel {
520520 return new TopLevel(
521- TopLevel::sampleAboveI32Max()
522- ,TopLevel::sampleBelowI32Min()
521+ TopLevel::sampleSmallPositive()
522+ ,TopLevel::sampleSmallNegative()
523523 ,TopLevel::sampleI32Range()
524- ,TopLevel::sampleLargeBounds()
525- ,TopLevel::sampleOnlyMaximum()
524+ ,TopLevel::sampleAboveI32Max()
525+ ,TopLevel::sampleBelowI32Min()
526526 ,TopLevel::sampleOnlyMinimum()
527- ,TopLevel::sampleSmallNegative()
528- ,TopLevel::sampleSmallPositive()
527+ ,TopLevel::sampleOnlyMaximum()
529528 ,TopLevel::sampleUnbounded()
529+ ,TopLevel::sampleLargeBounds()
530530 );
531531 }
532532 }
Mschema-php/test/inputs/schema/light.schema/default/TopLevel.php+35 −35
@@ -103,18 +103,18 @@ class TopLevel {
103103 // This is an autogenerated file:LightParams
104104
105105 class LightParams {
106- private string $appID; // json:app_id Required
107106 private string $outletID; // json:outlet_id Required
107+ private string $appID; // json:app_id Required
108108 private string $rgba; // json:rgba Required
109109
110110 /**
111- * @param string $appID
112111 * @param string $outletID
112+ * @param string $appID
113113 * @param string $rgba
114114 */
115- public function __construct(string $appID, string $outletID, string $rgba) {
116- $this->appID = $appID;
115+ public function __construct(string $outletID, string $appID, string $rgba) {
117116 $this->outletID = $outletID;
117+ $this->appID = $appID;
118118 $this->rgba = $rgba;
119119 }
120120
@@ -123,7 +123,7 @@ class LightParams {
123123 * @throws Exception
124124 * @return string
125125 */
126- public static function fromAppID(string $value): string {
126+ public static function fromOutletID(string $value): string {
127127 return $value; /*string*/
128128 }
129129
@@ -131,11 +131,11 @@ class LightParams {
131131 * @throws Exception
132132 * @return string
133133 */
134- public function toAppID(): string {
135- if (LightParams::validateAppID($this->appID)) {
136- return $this->appID; /*string*/
134+ public function toOutletID(): string {
135+ if (LightParams::validateOutletID($this->outletID)) {
136+ return $this->outletID; /*string*/
137137 }
138- throw new Exception('never get to this LightParams::appID');
138+ throw new Exception('never get to this LightParams::outletID');
139139 }
140140
141141 /**
@@ -143,7 +143,7 @@ class LightParams {
143143 * @return bool
144144 * @throws Exception
145145 */
146- public static function validateAppID(string $value): bool {
146+ public static function validateOutletID(string $value): bool {
147147 return true;
148148 }
149149
@@ -151,18 +151,18 @@ class LightParams {
151151 * @throws Exception
152152 * @return string
153153 */
154- public function getAppID(): string {
155- if (LightParams::validateAppID($this->appID)) {
156- return $this->appID;
154+ public function getOutletID(): string {
155+ if (LightParams::validateOutletID($this->outletID)) {
156+ return $this->outletID;
157157 }
158- throw new Exception('never get to getAppID LightParams::appID');
158+ throw new Exception('never get to getOutletID LightParams::outletID');
159159 }
160160
161161 /**
162162 * @return string
163163 */
164- public static function sampleAppID(): string {
165- return 'LightParams::appID::31'; /*31:appID*/
164+ public static function sampleOutletID(): string {
165+ return 'LightParams::outletID::31'; /*31:outletID*/
166166 }
167167
168168 /**
@@ -170,7 +170,7 @@ class LightParams {
170170 * @throws Exception
171171 * @return string
172172 */
173- public static function fromOutletID(string $value): string {
173+ public static function fromAppID(string $value): string {
174174 return $value; /*string*/
175175 }
176176
@@ -178,11 +178,11 @@ class LightParams {
178178 * @throws Exception
179179 * @return string
180180 */
181- public function toOutletID(): string {
182- if (LightParams::validateOutletID($this->outletID)) {
183- return $this->outletID; /*string*/
181+ public function toAppID(): string {
182+ if (LightParams::validateAppID($this->appID)) {
183+ return $this->appID; /*string*/
184184 }
185- throw new Exception('never get to this LightParams::outletID');
185+ throw new Exception('never get to this LightParams::appID');
186186 }
187187
188188 /**
@@ -190,7 +190,7 @@ class LightParams {
190190 * @return bool
191191 * @throws Exception
192192 */
193- public static function validateOutletID(string $value): bool {
193+ public static function validateAppID(string $value): bool {
194194 return true;
195195 }
196196
@@ -198,18 +198,18 @@ class LightParams {
198198 * @throws Exception
199199 * @return string
200200 */
201- public function getOutletID(): string {
202- if (LightParams::validateOutletID($this->outletID)) {
203- return $this->outletID;
201+ public function getAppID(): string {
202+ if (LightParams::validateAppID($this->appID)) {
203+ return $this->appID;
204204 }
205- throw new Exception('never get to getOutletID LightParams::outletID');
205+ throw new Exception('never get to getAppID LightParams::appID');
206206 }
207207
208208 /**
209209 * @return string
210210 */
211- public static function sampleOutletID(): string {
212- return 'LightParams::outletID::32'; /*32:outletID*/
211+ public static function sampleAppID(): string {
212+ return 'LightParams::appID::32'; /*32:appID*/
213213 }
214214
215215 /**
@@ -264,8 +264,8 @@ class LightParams {
264264 * @return bool
265265 */
266266 public function validate(): bool {
267- return LightParams::validateAppID($this->appID)
268- || LightParams::validateOutletID($this->outletID)
267+ return LightParams::validateOutletID($this->outletID)
268+ || LightParams::validateAppID($this->appID)
269269 || LightParams::validateRGBA($this->rgba);
270270 }
271271
@@ -275,8 +275,8 @@ class LightParams {
275275 */
276276 public function to(): stdClass {
277277 $out = new stdClass();
278- $out->{'app_id'} = $this->toAppID();
279278 $out->{'outlet_id'} = $this->toOutletID();
279+ $out->{'app_id'} = $this->toAppID();
280280 $out->{'rgba'} = $this->toRGBA();
281281 return $out;
282282 }
@@ -288,8 +288,8 @@ class LightParams {
288288 */
289289 public static function from(stdClass $obj): LightParams {
290290 return new LightParams(
291- LightParams::fromAppID($obj->{'app_id'})
292- ,LightParams::fromOutletID($obj->{'outlet_id'})
291+ LightParams::fromOutletID($obj->{'outlet_id'})
292+ ,LightParams::fromAppID($obj->{'app_id'})
293293 ,LightParams::fromRGBA($obj->{'rgba'})
294294 );
295295 }
@@ -299,8 +299,8 @@ class LightParams {
299299 */
300300 public static function sample(): LightParams {
301301 return new LightParams(
302- LightParams::sampleAppID()
303- ,LightParams::sampleOutletID()
302+ LightParams::sampleOutletID()
303+ ,LightParams::sampleAppID()
304304 ,LightParams::sampleRGBA()
305305 );
306306 }
Mschema-php/test/inputs/schema/min-max-items.schema/default/TopLevel.php+65 −65
@@ -4,23 +4,23 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7+ private array $minOnly; // json:minOnly Required
78 private array $maxOnly; // json:maxOnly Required
89 private array $minAndMax; // json:minAndMax Required
9- private array $minOnly; // json:minOnly Required
1010 private array $plain; // json:plain Required
1111 private array $unionItems; // json:unionItems Required
1212
1313 /**
14+ * @param array $minOnly
1415 * @param array $maxOnly
1516 * @param array $minAndMax
16- * @param array $minOnly
1717 * @param array $plain
1818 * @param array $unionItems
1919 */
20- public function __construct(array $maxOnly, array $minAndMax, array $minOnly, array $plain, array $unionItems) {
20+ public function __construct(array $minOnly, array $maxOnly, array $minAndMax, array $plain, array $unionItems) {
21+ $this->minOnly = $minOnly;
2122 $this->maxOnly = $maxOnly;
2223 $this->minAndMax = $minAndMax;
23- $this->minOnly = $minOnly;
2424 $this->plain = $plain;
2525 $this->unionItems = $unionItems;
2626 }
@@ -30,9 +30,9 @@ class TopLevel {
3030 * @throws Exception
3131 * @return array
3232 */
33- public static function fromMaxOnly(array $value): array {
33+ public static function fromMinOnly(array $value): array {
3434 return array_map(function ($value) {
35- return $value; /*int*/
35+ return $value; /*string*/
3636 }, $value);
3737 }
3838
@@ -40,13 +40,13 @@ class TopLevel {
4040 * @throws Exception
4141 * @return array
4242 */
43- public function toMaxOnly(): array {
44- if (TopLevel::validateMaxOnly($this->maxOnly)) {
43+ public function toMinOnly(): array {
44+ if (TopLevel::validateMinOnly($this->minOnly)) {
4545 return array_map(function ($value) {
46- return $value; /*int*/
47- }, $this->maxOnly);
46+ return $value; /*string*/
47+ }, $this->minOnly);
4848 }
49- throw new Exception('never get to this TopLevel::maxOnly');
49+ throw new Exception('never get to this TopLevel::minOnly');
5050 }
5151
5252 /**
@@ -54,13 +54,13 @@ class TopLevel {
5454 * @return bool
5555 * @throws Exception
5656 */
57- public static function validateMaxOnly(array $value): bool {
57+ public static function validateMinOnly(array $value): bool {
5858 if (!is_array($value)) {
59- throw new Exception("Attribute Error:TopLevel::maxOnly");
59+ throw new Exception("Attribute Error:TopLevel::minOnly");
6060 }
6161 array_walk($value, function($value_v) {
62- if (!is_integer($value_v)) {
63- throw new Exception("Attribute Error:TopLevel::maxOnly");
62+ if (!is_string($value_v)) {
63+ throw new Exception("Attribute Error:TopLevel::minOnly");
6464 }
6565 });
6666 return true;
@@ -70,20 +70,20 @@ class TopLevel {
7070 * @throws Exception
7171 * @return array
7272 */
73- public function getMaxOnly(): array {
74- if (TopLevel::validateMaxOnly($this->maxOnly)) {
75- return $this->maxOnly;
73+ public function getMinOnly(): array {
74+ if (TopLevel::validateMinOnly($this->minOnly)) {
75+ return $this->minOnly;
7676 }
77- throw new Exception('never get to getMaxOnly TopLevel::maxOnly');
77+ throw new Exception('never get to getMinOnly TopLevel::minOnly');
7878 }
7979
8080 /**
8181 * @return array
8282 */
83- public static function sampleMaxOnly(): array {
83+ public static function sampleMinOnly(): array {
8484 return array(
85- 31 /*31:*/
86- ); /* 31:maxOnly*/
85+ 'TopLevel::::31' /*31:*/
86+ ); /* 31:minOnly*/
8787 }
8888
8989 /**
@@ -91,9 +91,9 @@ class TopLevel {
9191 * @throws Exception
9292 * @return array
9393 */
94- public static function fromMinAndMax(array $value): array {
94+ public static function fromMaxOnly(array $value): array {
9595 return array_map(function ($value) {
96- return $value; /*float*/
96+ return $value; /*int*/
9797 }, $value);
9898 }
9999
@@ -101,13 +101,13 @@ class TopLevel {
101101 * @throws Exception
102102 * @return array
103103 */
104- public function toMinAndMax(): array {
105- if (TopLevel::validateMinAndMax($this->minAndMax)) {
104+ public function toMaxOnly(): array {
105+ if (TopLevel::validateMaxOnly($this->maxOnly)) {
106106 return array_map(function ($value) {
107- return $value; /*float*/
108- }, $this->minAndMax);
107+ return $value; /*int*/
108+ }, $this->maxOnly);
109109 }
110- throw new Exception('never get to this TopLevel::minAndMax');
110+ throw new Exception('never get to this TopLevel::maxOnly');
111111 }
112112
113113 /**
@@ -115,13 +115,13 @@ class TopLevel {
115115 * @return bool
116116 * @throws Exception
117117 */
118- public static function validateMinAndMax(array $value): bool {
118+ public static function validateMaxOnly(array $value): bool {
119119 if (!is_array($value)) {
120- throw new Exception("Attribute Error:TopLevel::minAndMax");
120+ throw new Exception("Attribute Error:TopLevel::maxOnly");
121121 }
122122 array_walk($value, function($value_v) {
123- if (!is_float($value_v) && !is_int($value_v)) {
124- throw new Exception("Attribute Error:TopLevel::minAndMax");
123+ if (!is_integer($value_v)) {
124+ throw new Exception("Attribute Error:TopLevel::maxOnly");
125125 }
126126 });
127127 return true;
@@ -131,20 +131,20 @@ class TopLevel {
131131 * @throws Exception
132132 * @return array
133133 */
134- public function getMinAndMax(): array {
135- if (TopLevel::validateMinAndMax($this->minAndMax)) {
136- return $this->minAndMax;
134+ public function getMaxOnly(): array {
135+ if (TopLevel::validateMaxOnly($this->maxOnly)) {
136+ return $this->maxOnly;
137137 }
138- throw new Exception('never get to getMinAndMax TopLevel::minAndMax');
138+ throw new Exception('never get to getMaxOnly TopLevel::maxOnly');
139139 }
140140
141141 /**
142142 * @return array
143143 */
144- public static function sampleMinAndMax(): array {
144+ public static function sampleMaxOnly(): array {
145145 return array(
146- 32.032 /*32:*/
147- ); /* 32:minAndMax*/
146+ 32 /*32:*/
147+ ); /* 32:maxOnly*/
148148 }
149149
150150 /**
@@ -152,9 +152,9 @@ class TopLevel {
152152 * @throws Exception
153153 * @return array
154154 */
155- public static function fromMinOnly(array $value): array {
155+ public static function fromMinAndMax(array $value): array {
156156 return array_map(function ($value) {
157- return $value; /*string*/
157+ return $value; /*float*/
158158 }, $value);
159159 }
160160
@@ -162,13 +162,13 @@ class TopLevel {
162162 * @throws Exception
163163 * @return array
164164 */
165- public function toMinOnly(): array {
166- if (TopLevel::validateMinOnly($this->minOnly)) {
165+ public function toMinAndMax(): array {
166+ if (TopLevel::validateMinAndMax($this->minAndMax)) {
167167 return array_map(function ($value) {
168- return $value; /*string*/
169- }, $this->minOnly);
168+ return $value; /*float*/
169+ }, $this->minAndMax);
170170 }
171- throw new Exception('never get to this TopLevel::minOnly');
171+ throw new Exception('never get to this TopLevel::minAndMax');
172172 }
173173
174174 /**
@@ -176,13 +176,13 @@ class TopLevel {
176176 * @return bool
177177 * @throws Exception
178178 */
179- public static function validateMinOnly(array $value): bool {
179+ public static function validateMinAndMax(array $value): bool {
180180 if (!is_array($value)) {
181- throw new Exception("Attribute Error:TopLevel::minOnly");
181+ throw new Exception("Attribute Error:TopLevel::minAndMax");
182182 }
183183 array_walk($value, function($value_v) {
184- if (!is_string($value_v)) {
185- throw new Exception("Attribute Error:TopLevel::minOnly");
184+ if (!is_float($value_v) && !is_int($value_v)) {
185+ throw new Exception("Attribute Error:TopLevel::minAndMax");
186186 }
187187 });
188188 return true;
@@ -192,20 +192,20 @@ class TopLevel {
192192 * @throws Exception
193193 * @return array
194194 */
195- public function getMinOnly(): array {
196- if (TopLevel::validateMinOnly($this->minOnly)) {
197- return $this->minOnly;
195+ public function getMinAndMax(): array {
196+ if (TopLevel::validateMinAndMax($this->minAndMax)) {
197+ return $this->minAndMax;
198198 }
199- throw new Exception('never get to getMinOnly TopLevel::minOnly');
199+ throw new Exception('never get to getMinAndMax TopLevel::minAndMax');
200200 }
201201
202202 /**
203203 * @return array
204204 */
205- public static function sampleMinOnly(): array {
205+ public static function sampleMinAndMax(): array {
206206 return array(
207- 'TopLevel::::33' /*33:*/
208- ); /* 33:minOnly*/
207+ 33.033 /*33:*/
208+ ); /* 33:minAndMax*/
209209 }
210210
211211 /**
@@ -355,9 +355,9 @@ class TopLevel {
355355 * @return bool
356356 */
357357 public function validate(): bool {
358- return TopLevel::validateMaxOnly($this->maxOnly)
358+ return TopLevel::validateMinOnly($this->minOnly)
359+ || TopLevel::validateMaxOnly($this->maxOnly)
359360 || TopLevel::validateMinAndMax($this->minAndMax)
360- || TopLevel::validateMinOnly($this->minOnly)
361361 || TopLevel::validatePlain($this->plain)
362362 || TopLevel::validateUnionItems($this->unionItems);
363363 }
@@ -368,9 +368,9 @@ class TopLevel {
368368 */
369369 public function to(): stdClass {
370370 $out = new stdClass();
371+ $out->{'minOnly'} = $this->toMinOnly();
371372 $out->{'maxOnly'} = $this->toMaxOnly();
372373 $out->{'minAndMax'} = $this->toMinAndMax();
373- $out->{'minOnly'} = $this->toMinOnly();
374374 $out->{'plain'} = $this->toPlain();
375375 $out->{'unionItems'} = $this->toUnionItems();
376376 return $out;
@@ -383,9 +383,9 @@ class TopLevel {
383383 */
384384 public static function from(stdClass $obj): TopLevel {
385385 return new TopLevel(
386- TopLevel::fromMaxOnly($obj->{'maxOnly'})
386+ TopLevel::fromMinOnly($obj->{'minOnly'})
387+ ,TopLevel::fromMaxOnly($obj->{'maxOnly'})
387388 ,TopLevel::fromMinAndMax($obj->{'minAndMax'})
388- ,TopLevel::fromMinOnly($obj->{'minOnly'})
389389 ,TopLevel::fromPlain($obj->{'plain'})
390390 ,TopLevel::fromUnionItems($obj->{'unionItems'})
391391 );
@@ -396,9 +396,9 @@ class TopLevel {
396396 */
397397 public static function sample(): TopLevel {
398398 return new TopLevel(
399- TopLevel::sampleMaxOnly()
399+ TopLevel::sampleMinOnly()
400+ ,TopLevel::sampleMaxOnly()
400401 ,TopLevel::sampleMinAndMax()
401- ,TopLevel::sampleMinOnly()
402402 ,TopLevel::samplePlain()
403403 ,TopLevel::sampleUnionItems()
404404 );
Mschema-php/test/inputs/schema/minmax-integer.schema/default/TopLevel.php+101 −101
@@ -5,33 +5,33 @@ declare(strict_types=1);
55
66 class TopLevel {
77 private int $free; // json:free Required
8- private int $intersection; // json:intersection Required
9- private int $max; // json:max Required
108 private int $min; // json:min Required
9+ private int $max; // json:max Required
1110 private int $minmax; // json:minmax Required
12- private int $minMaxIntersection; // json:minMaxIntersection Required
13- private int $minMaxUnion; // json:minMaxUnion Required
1411 private int $union; // json:union Required
12+ private int $minMaxUnion; // json:minMaxUnion Required
13+ private int $intersection; // json:intersection Required
14+ private int $minMaxIntersection; // json:minMaxIntersection Required
1515
1616 /**
1717 * @param int $free
18- * @param int $intersection
19- * @param int $max
2018 * @param int $min
19+ * @param int $max
2120 * @param int $minmax
22- * @param int $minMaxIntersection
23- * @param int $minMaxUnion
2421 * @param int $union
22+ * @param int $minMaxUnion
23+ * @param int $intersection
24+ * @param int $minMaxIntersection
2525 */
26- public function __construct(int $free, int $intersection, int $max, int $min, int $minmax, int $minMaxIntersection, int $minMaxUnion, int $union) {
26+ public function __construct(int $free, int $min, int $max, int $minmax, int $union, int $minMaxUnion, int $intersection, int $minMaxIntersection) {
2727 $this->free = $free;
28- $this->intersection = $intersection;
29- $this->max = $max;
3028 $this->min = $min;
29+ $this->max = $max;
3130 $this->minmax = $minmax;
32- $this->minMaxIntersection = $minMaxIntersection;
33- $this->minMaxUnion = $minMaxUnion;
3431 $this->union = $union;
32+ $this->minMaxUnion = $minMaxUnion;
33+ $this->intersection = $intersection;
34+ $this->minMaxIntersection = $minMaxIntersection;
3535 }
3636
3737 /**
@@ -86,7 +86,7 @@ class TopLevel {
8686 * @throws Exception
8787 * @return int
8888 */
89- public static function fromIntersection(int $value): int {
89+ public static function fromMin(int $value): int {
9090 return $value; /*int*/
9191 }
9292
@@ -94,11 +94,11 @@ class TopLevel {
9494 * @throws Exception
9595 * @return int
9696 */
97- public function toIntersection(): int {
98- if (TopLevel::validateIntersection($this->intersection)) {
99- return $this->intersection; /*int*/
97+ public function toMin(): int {
98+ if (TopLevel::validateMin($this->min)) {
99+ return $this->min; /*int*/
100100 }
101- throw new Exception('never get to this TopLevel::intersection');
101+ throw new Exception('never get to this TopLevel::min');
102102 }
103103
104104 /**
@@ -106,7 +106,7 @@ class TopLevel {
106106 * @return bool
107107 * @throws Exception
108108 */
109- public static function validateIntersection(int $value): bool {
109+ public static function validateMin(int $value): bool {
110110 return true;
111111 }
112112
@@ -114,18 +114,18 @@ class TopLevel {
114114 * @throws Exception
115115 * @return int
116116 */
117- public function getIntersection(): int {
118- if (TopLevel::validateIntersection($this->intersection)) {
119- return $this->intersection;
117+ public function getMin(): int {
118+ if (TopLevel::validateMin($this->min)) {
119+ return $this->min;
120120 }
121- throw new Exception('never get to getIntersection TopLevel::intersection');
121+ throw new Exception('never get to getMin TopLevel::min');
122122 }
123123
124124 /**
125125 * @return int
126126 */
127- public static function sampleIntersection(): int {
128- return 32; /*32:intersection*/
127+ public static function sampleMin(): int {
128+ return 32; /*32:min*/
129129 }
130130
131131 /**
@@ -180,7 +180,7 @@ class TopLevel {
180180 * @throws Exception
181181 * @return int
182182 */
183- public static function fromMin(int $value): int {
183+ public static function fromMinmax(int $value): int {
184184 return $value; /*int*/
185185 }
186186
@@ -188,11 +188,11 @@ class TopLevel {
188188 * @throws Exception
189189 * @return int
190190 */
191- public function toMin(): int {
192- if (TopLevel::validateMin($this->min)) {
193- return $this->min; /*int*/
191+ public function toMinmax(): int {
192+ if (TopLevel::validateMinmax($this->minmax)) {
193+ return $this->minmax; /*int*/
194194 }
195- throw new Exception('never get to this TopLevel::min');
195+ throw new Exception('never get to this TopLevel::minmax');
196196 }
197197
198198 /**
@@ -200,7 +200,7 @@ class TopLevel {
200200 * @return bool
201201 * @throws Exception
202202 */
203- public static function validateMin(int $value): bool {
203+ public static function validateMinmax(int $value): bool {
204204 return true;
205205 }
206206
@@ -208,18 +208,18 @@ class TopLevel {
208208 * @throws Exception
209209 * @return int
210210 */
211- public function getMin(): int {
212- if (TopLevel::validateMin($this->min)) {
213- return $this->min;
211+ public function getMinmax(): int {
212+ if (TopLevel::validateMinmax($this->minmax)) {
213+ return $this->minmax;
214214 }
215- throw new Exception('never get to getMin TopLevel::min');
215+ throw new Exception('never get to getMinmax TopLevel::minmax');
216216 }
217217
218218 /**
219219 * @return int
220220 */
221- public static function sampleMin(): int {
222- return 34; /*34:min*/
221+ public static function sampleMinmax(): int {
222+ return 34; /*34:minmax*/
223223 }
224224
225225 /**
@@ -227,7 +227,7 @@ class TopLevel {
227227 * @throws Exception
228228 * @return int
229229 */
230- public static function fromMinmax(int $value): int {
230+ public static function fromUnion(int $value): int {
231231 return $value; /*int*/
232232 }
233233
@@ -235,11 +235,11 @@ class TopLevel {
235235 * @throws Exception
236236 * @return int
237237 */
238- public function toMinmax(): int {
239- if (TopLevel::validateMinmax($this->minmax)) {
240- return $this->minmax; /*int*/
238+ public function toUnion(): int {
239+ if (TopLevel::validateUnion($this->union)) {
240+ return $this->union; /*int*/
241241 }
242- throw new Exception('never get to this TopLevel::minmax');
242+ throw new Exception('never get to this TopLevel::union');
243243 }
244244
245245 /**
@@ -247,7 +247,7 @@ class TopLevel {
247247 * @return bool
248248 * @throws Exception
249249 */
250- public static function validateMinmax(int $value): bool {
250+ public static function validateUnion(int $value): bool {
251251 return true;
252252 }
253253
@@ -255,18 +255,18 @@ class TopLevel {
255255 * @throws Exception
256256 * @return int
257257 */
258- public function getMinmax(): int {
259- if (TopLevel::validateMinmax($this->minmax)) {
260- return $this->minmax;
258+ public function getUnion(): int {
259+ if (TopLevel::validateUnion($this->union)) {
260+ return $this->union;
261261 }
262- throw new Exception('never get to getMinmax TopLevel::minmax');
262+ throw new Exception('never get to getUnion TopLevel::union');
263263 }
264264
265265 /**
266266 * @return int
267267 */
268- public static function sampleMinmax(): int {
269- return 35; /*35:minmax*/
268+ public static function sampleUnion(): int {
269+ return 35; /*35:union*/
270270 }
271271
272272 /**
@@ -274,7 +274,7 @@ class TopLevel {
274274 * @throws Exception
275275 * @return int
276276 */
277- public static function fromMinMaxIntersection(int $value): int {
277+ public static function fromMinMaxUnion(int $value): int {
278278 return $value; /*int*/
279279 }
280280
@@ -282,11 +282,11 @@ class TopLevel {
282282 * @throws Exception
283283 * @return int
284284 */
285- public function toMinMaxIntersection(): int {
286- if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
287- return $this->minMaxIntersection; /*int*/
285+ public function toMinMaxUnion(): int {
286+ if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
287+ return $this->minMaxUnion; /*int*/
288288 }
289- throw new Exception('never get to this TopLevel::minMaxIntersection');
289+ throw new Exception('never get to this TopLevel::minMaxUnion');
290290 }
291291
292292 /**
@@ -294,7 +294,7 @@ class TopLevel {
294294 * @return bool
295295 * @throws Exception
296296 */
297- public static function validateMinMaxIntersection(int $value): bool {
297+ public static function validateMinMaxUnion(int $value): bool {
298298 return true;
299299 }
300300
@@ -302,18 +302,18 @@ class TopLevel {
302302 * @throws Exception
303303 * @return int
304304 */
305- public function getMinMaxIntersection(): int {
306- if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
307- return $this->minMaxIntersection;
305+ public function getMinMaxUnion(): int {
306+ if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
307+ return $this->minMaxUnion;
308308 }
309- throw new Exception('never get to getMinMaxIntersection TopLevel::minMaxIntersection');
309+ throw new Exception('never get to getMinMaxUnion TopLevel::minMaxUnion');
310310 }
311311
312312 /**
313313 * @return int
314314 */
315- public static function sampleMinMaxIntersection(): int {
316- return 36; /*36:minMaxIntersection*/
315+ public static function sampleMinMaxUnion(): int {
316+ return 36; /*36:minMaxUnion*/
317317 }
318318
319319 /**
@@ -321,7 +321,7 @@ class TopLevel {
321321 * @throws Exception
322322 * @return int
323323 */
324- public static function fromMinMaxUnion(int $value): int {
324+ public static function fromIntersection(int $value): int {
325325 return $value; /*int*/
326326 }
327327
@@ -329,11 +329,11 @@ class TopLevel {
329329 * @throws Exception
330330 * @return int
331331 */
332- public function toMinMaxUnion(): int {
333- if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
334- return $this->minMaxUnion; /*int*/
332+ public function toIntersection(): int {
333+ if (TopLevel::validateIntersection($this->intersection)) {
334+ return $this->intersection; /*int*/
335335 }
336- throw new Exception('never get to this TopLevel::minMaxUnion');
336+ throw new Exception('never get to this TopLevel::intersection');
337337 }
338338
339339 /**
@@ -341,7 +341,7 @@ class TopLevel {
341341 * @return bool
342342 * @throws Exception
343343 */
344- public static function validateMinMaxUnion(int $value): bool {
344+ public static function validateIntersection(int $value): bool {
345345 return true;
346346 }
347347
@@ -349,18 +349,18 @@ class TopLevel {
349349 * @throws Exception
350350 * @return int
351351 */
352- public function getMinMaxUnion(): int {
353- if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
354- return $this->minMaxUnion;
352+ public function getIntersection(): int {
353+ if (TopLevel::validateIntersection($this->intersection)) {
354+ return $this->intersection;
355355 }
356- throw new Exception('never get to getMinMaxUnion TopLevel::minMaxUnion');
356+ throw new Exception('never get to getIntersection TopLevel::intersection');
357357 }
358358
359359 /**
360360 * @return int
361361 */
362- public static function sampleMinMaxUnion(): int {
363- return 37; /*37:minMaxUnion*/
362+ public static function sampleIntersection(): int {
363+ return 37; /*37:intersection*/
364364 }
365365
366366 /**
@@ -368,7 +368,7 @@ class TopLevel {
368368 * @throws Exception
369369 * @return int
370370 */
371- public static function fromUnion(int $value): int {
371+ public static function fromMinMaxIntersection(int $value): int {
372372 return $value; /*int*/
373373 }
374374
@@ -376,11 +376,11 @@ class TopLevel {
376376 * @throws Exception
377377 * @return int
378378 */
379- public function toUnion(): int {
380- if (TopLevel::validateUnion($this->union)) {
381- return $this->union; /*int*/
379+ public function toMinMaxIntersection(): int {
380+ if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
381+ return $this->minMaxIntersection; /*int*/
382382 }
383- throw new Exception('never get to this TopLevel::union');
383+ throw new Exception('never get to this TopLevel::minMaxIntersection');
384384 }
385385
386386 /**
@@ -388,7 +388,7 @@ class TopLevel {
388388 * @return bool
389389 * @throws Exception
390390 */
391- public static function validateUnion(int $value): bool {
391+ public static function validateMinMaxIntersection(int $value): bool {
392392 return true;
393393 }
394394
@@ -396,18 +396,18 @@ class TopLevel {
396396 * @throws Exception
397397 * @return int
398398 */
399- public function getUnion(): int {
400- if (TopLevel::validateUnion($this->union)) {
401- return $this->union;
399+ public function getMinMaxIntersection(): int {
400+ if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
401+ return $this->minMaxIntersection;
402402 }
403- throw new Exception('never get to getUnion TopLevel::union');
403+ throw new Exception('never get to getMinMaxIntersection TopLevel::minMaxIntersection');
404404 }
405405
406406 /**
407407 * @return int
408408 */
409- public static function sampleUnion(): int {
410- return 38; /*38:union*/
409+ public static function sampleMinMaxIntersection(): int {
410+ return 38; /*38:minMaxIntersection*/
411411 }
412412
413413 /**
@@ -416,13 +416,13 @@ class TopLevel {
416416 */
417417 public function validate(): bool {
418418 return TopLevel::validateFree($this->free)
419- || TopLevel::validateIntersection($this->intersection)
420- || TopLevel::validateMax($this->max)
421419 || TopLevel::validateMin($this->min)
420+ || TopLevel::validateMax($this->max)
422421 || TopLevel::validateMinmax($this->minmax)
423- || TopLevel::validateMinMaxIntersection($this->minMaxIntersection)
422+ || TopLevel::validateUnion($this->union)
424423 || TopLevel::validateMinMaxUnion($this->minMaxUnion)
425- || TopLevel::validateUnion($this->union);
424+ || TopLevel::validateIntersection($this->intersection)
425+ || TopLevel::validateMinMaxIntersection($this->minMaxIntersection);
426426 }
427427
428428 /**
@@ -432,13 +432,13 @@ class TopLevel {
432432 public function to(): stdClass {
433433 $out = new stdClass();
434434 $out->{'free'} = $this->toFree();
435- $out->{'intersection'} = $this->toIntersection();
436- $out->{'max'} = $this->toMax();
437435 $out->{'min'} = $this->toMin();
436+ $out->{'max'} = $this->toMax();
438437 $out->{'minmax'} = $this->toMinmax();
439- $out->{'minMaxIntersection'} = $this->toMinMaxIntersection();
440- $out->{'minMaxUnion'} = $this->toMinMaxUnion();
441438 $out->{'union'} = $this->toUnion();
439+ $out->{'minMaxUnion'} = $this->toMinMaxUnion();
440+ $out->{'intersection'} = $this->toIntersection();
441+ $out->{'minMaxIntersection'} = $this->toMinMaxIntersection();
442442 return $out;
443443 }
444444
@@ -450,13 +450,13 @@ class TopLevel {
450450 public static function from(stdClass $obj): TopLevel {
451451 return new TopLevel(
452452 TopLevel::fromFree($obj->{'free'})
453- ,TopLevel::fromIntersection($obj->{'intersection'})
454- ,TopLevel::fromMax($obj->{'max'})
455453 ,TopLevel::fromMin($obj->{'min'})
454+ ,TopLevel::fromMax($obj->{'max'})
456455 ,TopLevel::fromMinmax($obj->{'minmax'})
457- ,TopLevel::fromMinMaxIntersection($obj->{'minMaxIntersection'})
458- ,TopLevel::fromMinMaxUnion($obj->{'minMaxUnion'})
459456 ,TopLevel::fromUnion($obj->{'union'})
457+ ,TopLevel::fromMinMaxUnion($obj->{'minMaxUnion'})
458+ ,TopLevel::fromIntersection($obj->{'intersection'})
459+ ,TopLevel::fromMinMaxIntersection($obj->{'minMaxIntersection'})
460460 );
461461 }
462462
@@ -466,13 +466,13 @@ class TopLevel {
466466 public static function sample(): TopLevel {
467467 return new TopLevel(
468468 TopLevel::sampleFree()
469- ,TopLevel::sampleIntersection()
470- ,TopLevel::sampleMax()
471469 ,TopLevel::sampleMin()
470+ ,TopLevel::sampleMax()
472471 ,TopLevel::sampleMinmax()
473- ,TopLevel::sampleMinMaxIntersection()
474- ,TopLevel::sampleMinMaxUnion()
475472 ,TopLevel::sampleUnion()
473+ ,TopLevel::sampleMinMaxUnion()
474+ ,TopLevel::sampleIntersection()
475+ ,TopLevel::sampleMinMaxIntersection()
476476 );
477477 }
478478 }
Mschema-php/test/inputs/schema/minmax.schema/default/TopLevel.php+101 −101
@@ -5,33 +5,33 @@ declare(strict_types=1);
55
66 class TopLevel {
77 private float $free; // json:free Required
8- private float $intersection; // json:intersection Required
9- private float $max; // json:max Required
108 private float $min; // json:min Required
9+ private float $max; // json:max Required
1110 private float $minmax; // json:minmax Required
12- private float $minMaxIntersection; // json:minMaxIntersection Required
13- private float $minMaxUnion; // json:minMaxUnion Required
1411 private float $union; // json:union Required
12+ private float $minMaxUnion; // json:minMaxUnion Required
13+ private float $intersection; // json:intersection Required
14+ private float $minMaxIntersection; // json:minMaxIntersection Required
1515
1616 /**
1717 * @param float $free
18- * @param float $intersection
19- * @param float $max
2018 * @param float $min
19+ * @param float $max
2120 * @param float $minmax
22- * @param float $minMaxIntersection
23- * @param float $minMaxUnion
2421 * @param float $union
22+ * @param float $minMaxUnion
23+ * @param float $intersection
24+ * @param float $minMaxIntersection
2525 */
26- public function __construct(float $free, float $intersection, float $max, float $min, float $minmax, float $minMaxIntersection, float $minMaxUnion, float $union) {
26+ public function __construct(float $free, float $min, float $max, float $minmax, float $union, float $minMaxUnion, float $intersection, float $minMaxIntersection) {
2727 $this->free = $free;
28- $this->intersection = $intersection;
29- $this->max = $max;
3028 $this->min = $min;
29+ $this->max = $max;
3130 $this->minmax = $minmax;
32- $this->minMaxIntersection = $minMaxIntersection;
33- $this->minMaxUnion = $minMaxUnion;
3431 $this->union = $union;
32+ $this->minMaxUnion = $minMaxUnion;
33+ $this->intersection = $intersection;
34+ $this->minMaxIntersection = $minMaxIntersection;
3535 }
3636
3737 /**
@@ -86,7 +86,7 @@ class TopLevel {
8686 * @throws Exception
8787 * @return float
8888 */
89- public static function fromIntersection(float $value): float {
89+ public static function fromMin(float $value): float {
9090 return $value; /*float*/
9191 }
9292
@@ -94,11 +94,11 @@ class TopLevel {
9494 * @throws Exception
9595 * @return float
9696 */
97- public function toIntersection(): float {
98- if (TopLevel::validateIntersection($this->intersection)) {
99- return $this->intersection; /*float*/
97+ public function toMin(): float {
98+ if (TopLevel::validateMin($this->min)) {
99+ return $this->min; /*float*/
100100 }
101- throw new Exception('never get to this TopLevel::intersection');
101+ throw new Exception('never get to this TopLevel::min');
102102 }
103103
104104 /**
@@ -106,7 +106,7 @@ class TopLevel {
106106 * @return bool
107107 * @throws Exception
108108 */
109- public static function validateIntersection(float $value): bool {
109+ public static function validateMin(float $value): bool {
110110 return true;
111111 }
112112
@@ -114,18 +114,18 @@ class TopLevel {
114114 * @throws Exception
115115 * @return float
116116 */
117- public function getIntersection(): float {
118- if (TopLevel::validateIntersection($this->intersection)) {
119- return $this->intersection;
117+ public function getMin(): float {
118+ if (TopLevel::validateMin($this->min)) {
119+ return $this->min;
120120 }
121- throw new Exception('never get to getIntersection TopLevel::intersection');
121+ throw new Exception('never get to getMin TopLevel::min');
122122 }
123123
124124 /**
125125 * @return float
126126 */
127- public static function sampleIntersection(): float {
128- return 32.032; /*32:intersection*/
127+ public static function sampleMin(): float {
128+ return 32.032; /*32:min*/
129129 }
130130
131131 /**
@@ -180,7 +180,7 @@ class TopLevel {
180180 * @throws Exception
181181 * @return float
182182 */
183- public static function fromMin(float $value): float {
183+ public static function fromMinmax(float $value): float {
184184 return $value; /*float*/
185185 }
186186
@@ -188,11 +188,11 @@ class TopLevel {
188188 * @throws Exception
189189 * @return float
190190 */
191- public function toMin(): float {
192- if (TopLevel::validateMin($this->min)) {
193- return $this->min; /*float*/
191+ public function toMinmax(): float {
192+ if (TopLevel::validateMinmax($this->minmax)) {
193+ return $this->minmax; /*float*/
194194 }
195- throw new Exception('never get to this TopLevel::min');
195+ throw new Exception('never get to this TopLevel::minmax');
196196 }
197197
198198 /**
@@ -200,7 +200,7 @@ class TopLevel {
200200 * @return bool
201201 * @throws Exception
202202 */
203- public static function validateMin(float $value): bool {
203+ public static function validateMinmax(float $value): bool {
204204 return true;
205205 }
206206
@@ -208,18 +208,18 @@ class TopLevel {
208208 * @throws Exception
209209 * @return float
210210 */
211- public function getMin(): float {
212- if (TopLevel::validateMin($this->min)) {
213- return $this->min;
211+ public function getMinmax(): float {
212+ if (TopLevel::validateMinmax($this->minmax)) {
213+ return $this->minmax;
214214 }
215- throw new Exception('never get to getMin TopLevel::min');
215+ throw new Exception('never get to getMinmax TopLevel::minmax');
216216 }
217217
218218 /**
219219 * @return float
220220 */
221- public static function sampleMin(): float {
222- return 34.034; /*34:min*/
221+ public static function sampleMinmax(): float {
222+ return 34.034; /*34:minmax*/
223223 }
224224
225225 /**
@@ -227,7 +227,7 @@ class TopLevel {
227227 * @throws Exception
228228 * @return float
229229 */
230- public static function fromMinmax(float $value): float {
230+ public static function fromUnion(float $value): float {
231231 return $value; /*float*/
232232 }
233233
@@ -235,11 +235,11 @@ class TopLevel {
235235 * @throws Exception
236236 * @return float
237237 */
238- public function toMinmax(): float {
239- if (TopLevel::validateMinmax($this->minmax)) {
240- return $this->minmax; /*float*/
238+ public function toUnion(): float {
239+ if (TopLevel::validateUnion($this->union)) {
240+ return $this->union; /*float*/
241241 }
242- throw new Exception('never get to this TopLevel::minmax');
242+ throw new Exception('never get to this TopLevel::union');
243243 }
244244
245245 /**
@@ -247,7 +247,7 @@ class TopLevel {
247247 * @return bool
248248 * @throws Exception
249249 */
250- public static function validateMinmax(float $value): bool {
250+ public static function validateUnion(float $value): bool {
251251 return true;
252252 }
253253
@@ -255,18 +255,18 @@ class TopLevel {
255255 * @throws Exception
256256 * @return float
257257 */
258- public function getMinmax(): float {
259- if (TopLevel::validateMinmax($this->minmax)) {
260- return $this->minmax;
258+ public function getUnion(): float {
259+ if (TopLevel::validateUnion($this->union)) {
260+ return $this->union;
261261 }
262- throw new Exception('never get to getMinmax TopLevel::minmax');
262+ throw new Exception('never get to getUnion TopLevel::union');
263263 }
264264
265265 /**
266266 * @return float
267267 */
268- public static function sampleMinmax(): float {
269- return 35.035; /*35:minmax*/
268+ public static function sampleUnion(): float {
269+ return 35.035; /*35:union*/
270270 }
271271
272272 /**
@@ -274,7 +274,7 @@ class TopLevel {
274274 * @throws Exception
275275 * @return float
276276 */
277- public static function fromMinMaxIntersection(float $value): float {
277+ public static function fromMinMaxUnion(float $value): float {
278278 return $value; /*float*/
279279 }
280280
@@ -282,11 +282,11 @@ class TopLevel {
282282 * @throws Exception
283283 * @return float
284284 */
285- public function toMinMaxIntersection(): float {
286- if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
287- return $this->minMaxIntersection; /*float*/
285+ public function toMinMaxUnion(): float {
286+ if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
287+ return $this->minMaxUnion; /*float*/
288288 }
289- throw new Exception('never get to this TopLevel::minMaxIntersection');
289+ throw new Exception('never get to this TopLevel::minMaxUnion');
290290 }
291291
292292 /**
@@ -294,7 +294,7 @@ class TopLevel {
294294 * @return bool
295295 * @throws Exception
296296 */
297- public static function validateMinMaxIntersection(float $value): bool {
297+ public static function validateMinMaxUnion(float $value): bool {
298298 return true;
299299 }
300300
@@ -302,18 +302,18 @@ class TopLevel {
302302 * @throws Exception
303303 * @return float
304304 */
305- public function getMinMaxIntersection(): float {
306- if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
307- return $this->minMaxIntersection;
305+ public function getMinMaxUnion(): float {
306+ if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
307+ return $this->minMaxUnion;
308308 }
309- throw new Exception('never get to getMinMaxIntersection TopLevel::minMaxIntersection');
309+ throw new Exception('never get to getMinMaxUnion TopLevel::minMaxUnion');
310310 }
311311
312312 /**
313313 * @return float
314314 */
315- public static function sampleMinMaxIntersection(): float {
316- return 36.036; /*36:minMaxIntersection*/
315+ public static function sampleMinMaxUnion(): float {
316+ return 36.036; /*36:minMaxUnion*/
317317 }
318318
319319 /**
@@ -321,7 +321,7 @@ class TopLevel {
321321 * @throws Exception
322322 * @return float
323323 */
324- public static function fromMinMaxUnion(float $value): float {
324+ public static function fromIntersection(float $value): float {
325325 return $value; /*float*/
326326 }
327327
@@ -329,11 +329,11 @@ class TopLevel {
329329 * @throws Exception
330330 * @return float
331331 */
332- public function toMinMaxUnion(): float {
333- if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
334- return $this->minMaxUnion; /*float*/
332+ public function toIntersection(): float {
333+ if (TopLevel::validateIntersection($this->intersection)) {
334+ return $this->intersection; /*float*/
335335 }
336- throw new Exception('never get to this TopLevel::minMaxUnion');
336+ throw new Exception('never get to this TopLevel::intersection');
337337 }
338338
339339 /**
@@ -341,7 +341,7 @@ class TopLevel {
341341 * @return bool
342342 * @throws Exception
343343 */
344- public static function validateMinMaxUnion(float $value): bool {
344+ public static function validateIntersection(float $value): bool {
345345 return true;
346346 }
347347
@@ -349,18 +349,18 @@ class TopLevel {
349349 * @throws Exception
350350 * @return float
351351 */
352- public function getMinMaxUnion(): float {
353- if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
354- return $this->minMaxUnion;
352+ public function getIntersection(): float {
353+ if (TopLevel::validateIntersection($this->intersection)) {
354+ return $this->intersection;
355355 }
356- throw new Exception('never get to getMinMaxUnion TopLevel::minMaxUnion');
356+ throw new Exception('never get to getIntersection TopLevel::intersection');
357357 }
358358
359359 /**
360360 * @return float
361361 */
362- public static function sampleMinMaxUnion(): float {
363- return 37.037; /*37:minMaxUnion*/
362+ public static function sampleIntersection(): float {
363+ return 37.037; /*37:intersection*/
364364 }
365365
366366 /**
@@ -368,7 +368,7 @@ class TopLevel {
368368 * @throws Exception
369369 * @return float
370370 */
371- public static function fromUnion(float $value): float {
371+ public static function fromMinMaxIntersection(float $value): float {
372372 return $value; /*float*/
373373 }
374374
@@ -376,11 +376,11 @@ class TopLevel {
376376 * @throws Exception
377377 * @return float
378378 */
379- public function toUnion(): float {
380- if (TopLevel::validateUnion($this->union)) {
381- return $this->union; /*float*/
379+ public function toMinMaxIntersection(): float {
380+ if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
381+ return $this->minMaxIntersection; /*float*/
382382 }
383- throw new Exception('never get to this TopLevel::union');
383+ throw new Exception('never get to this TopLevel::minMaxIntersection');
384384 }
385385
386386 /**
@@ -388,7 +388,7 @@ class TopLevel {
388388 * @return bool
389389 * @throws Exception
390390 */
391- public static function validateUnion(float $value): bool {
391+ public static function validateMinMaxIntersection(float $value): bool {
392392 return true;
393393 }
394394
@@ -396,18 +396,18 @@ class TopLevel {
396396 * @throws Exception
397397 * @return float
398398 */
399- public function getUnion(): float {
400- if (TopLevel::validateUnion($this->union)) {
401- return $this->union;
399+ public function getMinMaxIntersection(): float {
400+ if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
401+ return $this->minMaxIntersection;
402402 }
403- throw new Exception('never get to getUnion TopLevel::union');
403+ throw new Exception('never get to getMinMaxIntersection TopLevel::minMaxIntersection');
404404 }
405405
406406 /**
407407 * @return float
408408 */
409- public static function sampleUnion(): float {
410- return 38.038; /*38:union*/
409+ public static function sampleMinMaxIntersection(): float {
410+ return 38.038; /*38:minMaxIntersection*/
411411 }
412412
413413 /**
@@ -416,13 +416,13 @@ class TopLevel {
416416 */
417417 public function validate(): bool {
418418 return TopLevel::validateFree($this->free)
419- || TopLevel::validateIntersection($this->intersection)
420- || TopLevel::validateMax($this->max)
421419 || TopLevel::validateMin($this->min)
420+ || TopLevel::validateMax($this->max)
422421 || TopLevel::validateMinmax($this->minmax)
423- || TopLevel::validateMinMaxIntersection($this->minMaxIntersection)
422+ || TopLevel::validateUnion($this->union)
424423 || TopLevel::validateMinMaxUnion($this->minMaxUnion)
425- || TopLevel::validateUnion($this->union);
424+ || TopLevel::validateIntersection($this->intersection)
425+ || TopLevel::validateMinMaxIntersection($this->minMaxIntersection);
426426 }
427427
428428 /**
@@ -432,13 +432,13 @@ class TopLevel {
432432 public function to(): stdClass {
433433 $out = new stdClass();
434434 $out->{'free'} = $this->toFree();
435- $out->{'intersection'} = $this->toIntersection();
436- $out->{'max'} = $this->toMax();
437435 $out->{'min'} = $this->toMin();
436+ $out->{'max'} = $this->toMax();
438437 $out->{'minmax'} = $this->toMinmax();
439- $out->{'minMaxIntersection'} = $this->toMinMaxIntersection();
440- $out->{'minMaxUnion'} = $this->toMinMaxUnion();
441438 $out->{'union'} = $this->toUnion();
439+ $out->{'minMaxUnion'} = $this->toMinMaxUnion();
440+ $out->{'intersection'} = $this->toIntersection();
441+ $out->{'minMaxIntersection'} = $this->toMinMaxIntersection();
442442 return $out;
443443 }
444444
@@ -450,13 +450,13 @@ class TopLevel {
450450 public static function from(stdClass $obj): TopLevel {
451451 return new TopLevel(
452452 TopLevel::fromFree($obj->{'free'})
453- ,TopLevel::fromIntersection($obj->{'intersection'})
454- ,TopLevel::fromMax($obj->{'max'})
455453 ,TopLevel::fromMin($obj->{'min'})
454+ ,TopLevel::fromMax($obj->{'max'})
456455 ,TopLevel::fromMinmax($obj->{'minmax'})
457- ,TopLevel::fromMinMaxIntersection($obj->{'minMaxIntersection'})
458- ,TopLevel::fromMinMaxUnion($obj->{'minMaxUnion'})
459456 ,TopLevel::fromUnion($obj->{'union'})
457+ ,TopLevel::fromMinMaxUnion($obj->{'minMaxUnion'})
458+ ,TopLevel::fromIntersection($obj->{'intersection'})
459+ ,TopLevel::fromMinMaxIntersection($obj->{'minMaxIntersection'})
460460 );
461461 }
462462
@@ -466,13 +466,13 @@ class TopLevel {
466466 public static function sample(): TopLevel {
467467 return new TopLevel(
468468 TopLevel::sampleFree()
469- ,TopLevel::sampleIntersection()
470- ,TopLevel::sampleMax()
471469 ,TopLevel::sampleMin()
470+ ,TopLevel::sampleMax()
472471 ,TopLevel::sampleMinmax()
473- ,TopLevel::sampleMinMaxIntersection()
474- ,TopLevel::sampleMinMaxUnion()
475472 ,TopLevel::sampleUnion()
473+ ,TopLevel::sampleMinMaxUnion()
474+ ,TopLevel::sampleIntersection()
475+ ,TopLevel::sampleMinMaxIntersection()
476476 );
477477 }
478478 }
Mschema-php/test/inputs/schema/minmaxlength.schema/default/TopLevel.php+169 −169
@@ -4,34 +4,34 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private string $intersection; // json:intersection Required
8- private float|string $inUnion; // json:inUnion Required
9- private string $maxlength; // json:maxlength Required
107 private string $minlength; // json:minlength Required
11- private string $minMaxIntersection; // json:minMaxIntersection Required
8+ private string $maxlength; // json:maxlength Required
129 private string $minmaxlength; // json:minmaxlength Required
13- private string $minMaxUnion; // json:minMaxUnion Required
1410 private string $union; // json:union Required
11+ private float|string $inUnion; // json:inUnion Required
12+ private string $minMaxUnion; // json:minMaxUnion Required
13+ private string $intersection; // json:intersection Required
14+ private string $minMaxIntersection; // json:minMaxIntersection Required
1515
1616 /**
17- * @param string $intersection
18- * @param float|string $inUnion
19- * @param string $maxlength
2017 * @param string $minlength
21- * @param string $minMaxIntersection
18+ * @param string $maxlength
2219 * @param string $minmaxlength
23- * @param string $minMaxUnion
2420 * @param string $union
21+ * @param float|string $inUnion
22+ * @param string $minMaxUnion
23+ * @param string $intersection
24+ * @param string $minMaxIntersection
2525 */
26- public function __construct(string $intersection, float|string $inUnion, string $maxlength, string $minlength, string $minMaxIntersection, string $minmaxlength, string $minMaxUnion, string $union) {
27- $this->intersection = $intersection;
28- $this->inUnion = $inUnion;
29- $this->maxlength = $maxlength;
26+ public function __construct(string $minlength, string $maxlength, string $minmaxlength, string $union, float|string $inUnion, string $minMaxUnion, string $intersection, string $minMaxIntersection) {
3027 $this->minlength = $minlength;
31- $this->minMaxIntersection = $minMaxIntersection;
28+ $this->maxlength = $maxlength;
3229 $this->minmaxlength = $minmaxlength;
33- $this->minMaxUnion = $minMaxUnion;
3430 $this->union = $union;
31+ $this->inUnion = $inUnion;
32+ $this->minMaxUnion = $minMaxUnion;
33+ $this->intersection = $intersection;
34+ $this->minMaxIntersection = $minMaxIntersection;
3535 }
3636
3737 /**
@@ -39,7 +39,7 @@ class TopLevel {
3939 * @throws Exception
4040 * @return string
4141 */
42- public static function fromIntersection(string $value): string {
42+ public static function fromMinlength(string $value): string {
4343 return $value; /*string*/
4444 }
4545
@@ -47,11 +47,11 @@ class TopLevel {
4747 * @throws Exception
4848 * @return string
4949 */
50- public function toIntersection(): string {
51- if (TopLevel::validateIntersection($this->intersection)) {
52- return $this->intersection; /*string*/
50+ public function toMinlength(): string {
51+ if (TopLevel::validateMinlength($this->minlength)) {
52+ return $this->minlength; /*string*/
5353 }
54- throw new Exception('never get to this TopLevel::intersection');
54+ throw new Exception('never get to this TopLevel::minlength');
5555 }
5656
5757 /**
@@ -59,7 +59,7 @@ class TopLevel {
5959 * @return bool
6060 * @throws Exception
6161 */
62- public static function validateIntersection(string $value): bool {
62+ public static function validateMinlength(string $value): bool {
6363 return true;
6464 }
6565
@@ -67,88 +67,65 @@ class TopLevel {
6767 * @throws Exception
6868 * @return string
6969 */
70- public function getIntersection(): string {
71- if (TopLevel::validateIntersection($this->intersection)) {
72- return $this->intersection;
70+ public function getMinlength(): string {
71+ if (TopLevel::validateMinlength($this->minlength)) {
72+ return $this->minlength;
7373 }
74- throw new Exception('never get to getIntersection TopLevel::intersection');
74+ throw new Exception('never get to getMinlength TopLevel::minlength');
7575 }
7676
7777 /**
7878 * @return string
7979 */
80- public static function sampleIntersection(): string {
81- return 'TopLevel::intersection::31'; /*31:intersection*/
80+ public static function sampleMinlength(): string {
81+ return 'TopLevel::minlength::31'; /*31:minlength*/
8282 }
8383
8484 /**
85- * @param float|string $value
85+ * @param string $value
8686 * @throws Exception
87- * @return float|string
87+ * @return string
8888 */
89- public static function fromInUnion(float|string $value): float|string {
90- if (is_float($value) || is_int($value)) {
91- return $value; /*float*/
92- } elseif (is_string($value)) {
93- return $value; /*string*/
94- } else {
95- throw new Exception('Cannot deserialize union value in TopLevel');
96- }
89+ public static function fromMaxlength(string $value): string {
90+ return $value; /*string*/
9791 }
9892
9993 /**
10094 * @throws Exception
101- * @return float|string
95+ * @return string
10296 */
103- public function toInUnion(): float|string {
104- if (TopLevel::validateInUnion($this->inUnion)) {
105- if (is_float($this->inUnion) || is_int($this->inUnion)) {
106- return $this->inUnion; /*float*/
107- } elseif (is_string($this->inUnion)) {
108- return $this->inUnion; /*string*/
109- } else {
110- throw new Exception('Union value has no matching member in TopLevel');
111- }
97+ public function toMaxlength(): string {
98+ if (TopLevel::validateMaxlength($this->maxlength)) {
99+ return $this->maxlength; /*string*/
112100 }
113- throw new Exception('never get to this TopLevel::inUnion');
101+ throw new Exception('never get to this TopLevel::maxlength');
114102 }
115103
116104 /**
117- * @param float|string
105+ * @param string
118106 * @return bool
119107 * @throws Exception
120108 */
121- public static function validateInUnion(float|string $value): bool {
122- if (is_float($value) || is_int($value)) {
123- if (!is_float($value) && !is_int($value)) {
124- throw new Exception("Attribute Error:TopLevel::inUnion");
125- }
126- } elseif (is_string($value)) {
127- if (!is_string($value)) {
128- throw new Exception("Attribute Error:TopLevel::inUnion");
129- }
130- } else {
131- throw new Exception("Attribute Error:TopLevel::inUnion");
132- }
109+ public static function validateMaxlength(string $value): bool {
133110 return true;
134111 }
135112
136113 /**
137114 * @throws Exception
138- * @return float|string
115+ * @return string
139116 */
140- public function getInUnion(): float|string {
141- if (TopLevel::validateInUnion($this->inUnion)) {
142- return $this->inUnion;
117+ public function getMaxlength(): string {
118+ if (TopLevel::validateMaxlength($this->maxlength)) {
119+ return $this->maxlength;
143120 }
144- throw new Exception('never get to getInUnion TopLevel::inUnion');
121+ throw new Exception('never get to getMaxlength TopLevel::maxlength');
145122 }
146123
147124 /**
148- * @return float|string
125+ * @return string
149126 */
150- public static function sampleInUnion(): float|string {
151- return 32.032; /*32:inUnion*/
127+ public static function sampleMaxlength(): string {
128+ return 'TopLevel::maxlength::32'; /*32:maxlength*/
152129 }
153130
154131 /**
@@ -156,7 +133,7 @@ class TopLevel {
156133 * @throws Exception
157134 * @return string
158135 */
159- public static function fromMaxlength(string $value): string {
136+ public static function fromMinmaxlength(string $value): string {
160137 return $value; /*string*/
161138 }
162139
@@ -164,11 +141,11 @@ class TopLevel {
164141 * @throws Exception
165142 * @return string
166143 */
167- public function toMaxlength(): string {
168- if (TopLevel::validateMaxlength($this->maxlength)) {
169- return $this->maxlength; /*string*/
144+ public function toMinmaxlength(): string {
145+ if (TopLevel::validateMinmaxlength($this->minmaxlength)) {
146+ return $this->minmaxlength; /*string*/
170147 }
171- throw new Exception('never get to this TopLevel::maxlength');
148+ throw new Exception('never get to this TopLevel::minmaxlength');
172149 }
173150
174151 /**
@@ -176,7 +153,7 @@ class TopLevel {
176153 * @return bool
177154 * @throws Exception
178155 */
179- public static function validateMaxlength(string $value): bool {
156+ public static function validateMinmaxlength(string $value): bool {
180157 return true;
181158 }
182159
@@ -184,18 +161,18 @@ class TopLevel {
184161 * @throws Exception
185162 * @return string
186163 */
187- public function getMaxlength(): string {
188- if (TopLevel::validateMaxlength($this->maxlength)) {
189- return $this->maxlength;
164+ public function getMinmaxlength(): string {
165+ if (TopLevel::validateMinmaxlength($this->minmaxlength)) {
166+ return $this->minmaxlength;
190167 }
191- throw new Exception('never get to getMaxlength TopLevel::maxlength');
168+ throw new Exception('never get to getMinmaxlength TopLevel::minmaxlength');
192169 }
193170
194171 /**
195172 * @return string
196173 */
197- public static function sampleMaxlength(): string {
198- return 'TopLevel::maxlength::33'; /*33:maxlength*/
174+ public static function sampleMinmaxlength(): string {
175+ return 'TopLevel::minmaxlength::33'; /*33:minmaxlength*/
199176 }
200177
201178 /**
@@ -203,7 +180,7 @@ class TopLevel {
203180 * @throws Exception
204181 * @return string
205182 */
206- public static function fromMinlength(string $value): string {
183+ public static function fromUnion(string $value): string {
207184 return $value; /*string*/
208185 }
209186
@@ -211,11 +188,11 @@ class TopLevel {
211188 * @throws Exception
212189 * @return string
213190 */
214- public function toMinlength(): string {
215- if (TopLevel::validateMinlength($this->minlength)) {
216- return $this->minlength; /*string*/
191+ public function toUnion(): string {
192+ if (TopLevel::validateUnion($this->union)) {
193+ return $this->union; /*string*/
217194 }
218- throw new Exception('never get to this TopLevel::minlength');
195+ throw new Exception('never get to this TopLevel::union');
219196 }
220197
221198 /**
@@ -223,7 +200,7 @@ class TopLevel {
223200 * @return bool
224201 * @throws Exception
225202 */
226- public static function validateMinlength(string $value): bool {
203+ public static function validateUnion(string $value): bool {
227204 return true;
228205 }
229206
@@ -231,65 +208,88 @@ class TopLevel {
231208 * @throws Exception
232209 * @return string
233210 */
234- public function getMinlength(): string {
235- if (TopLevel::validateMinlength($this->minlength)) {
236- return $this->minlength;
211+ public function getUnion(): string {
212+ if (TopLevel::validateUnion($this->union)) {
213+ return $this->union;
237214 }
238- throw new Exception('never get to getMinlength TopLevel::minlength');
215+ throw new Exception('never get to getUnion TopLevel::union');
239216 }
240217
241218 /**
242219 * @return string
243220 */
244- public static function sampleMinlength(): string {
245- return 'TopLevel::minlength::34'; /*34:minlength*/
221+ public static function sampleUnion(): string {
222+ return 'TopLevel::union::34'; /*34:union*/
246223 }
247224
248225 /**
249- * @param string $value
226+ * @param float|string $value
250227 * @throws Exception
251- * @return string
228+ * @return float|string
252229 */
253- public static function fromMinMaxIntersection(string $value): string {
254- return $value; /*string*/
230+ public static function fromInUnion(float|string $value): float|string {
231+ if (is_float($value) || is_int($value)) {
232+ return $value; /*float*/
233+ } elseif (is_string($value)) {
234+ return $value; /*string*/
235+ } else {
236+ throw new Exception('Cannot deserialize union value in TopLevel');
237+ }
255238 }
256239
257240 /**
258241 * @throws Exception
259- * @return string
242+ * @return float|string
260243 */
261- public function toMinMaxIntersection(): string {
262- if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
263- return $this->minMaxIntersection; /*string*/
244+ public function toInUnion(): float|string {
245+ if (TopLevel::validateInUnion($this->inUnion)) {
246+ if (is_float($this->inUnion) || is_int($this->inUnion)) {
247+ return $this->inUnion; /*float*/
248+ } elseif (is_string($this->inUnion)) {
249+ return $this->inUnion; /*string*/
250+ } else {
251+ throw new Exception('Union value has no matching member in TopLevel');
252+ }
264253 }
265- throw new Exception('never get to this TopLevel::minMaxIntersection');
254+ throw new Exception('never get to this TopLevel::inUnion');
266255 }
267256
268257 /**
269- * @param string
258+ * @param float|string
270259 * @return bool
271260 * @throws Exception
272261 */
273- public static function validateMinMaxIntersection(string $value): bool {
262+ public static function validateInUnion(float|string $value): bool {
263+ if (is_float($value) || is_int($value)) {
264+ if (!is_float($value) && !is_int($value)) {
265+ throw new Exception("Attribute Error:TopLevel::inUnion");
266+ }
267+ } elseif (is_string($value)) {
268+ if (!is_string($value)) {
269+ throw new Exception("Attribute Error:TopLevel::inUnion");
270+ }
271+ } else {
272+ throw new Exception("Attribute Error:TopLevel::inUnion");
273+ }
274274 return true;
275275 }
276276
277277 /**
278278 * @throws Exception
279- * @return string
279+ * @return float|string
280280 */
281- public function getMinMaxIntersection(): string {
282- if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
283- return $this->minMaxIntersection;
281+ public function getInUnion(): float|string {
282+ if (TopLevel::validateInUnion($this->inUnion)) {
283+ return $this->inUnion;
284284 }
285- throw new Exception('never get to getMinMaxIntersection TopLevel::minMaxIntersection');
285+ throw new Exception('never get to getInUnion TopLevel::inUnion');
286286 }
287287
288288 /**
289- * @return string
289+ * @return float|string
290290 */
291- public static function sampleMinMaxIntersection(): string {
292- return 'TopLevel::minMaxIntersection::35'; /*35:minMaxIntersection*/
291+ public static function sampleInUnion(): float|string {
292+ return 35.035; /*35:inUnion*/
293293 }
294294
295295 /**
@@ -297,7 +297,7 @@ class TopLevel {
297297 * @throws Exception
298298 * @return string
299299 */
300- public static function fromMinmaxlength(string $value): string {
300+ public static function fromMinMaxUnion(string $value): string {
301301 return $value; /*string*/
302302 }
303303
@@ -305,11 +305,11 @@ class TopLevel {
305305 * @throws Exception
306306 * @return string
307307 */
308- public function toMinmaxlength(): string {
309- if (TopLevel::validateMinmaxlength($this->minmaxlength)) {
310- return $this->minmaxlength; /*string*/
308+ public function toMinMaxUnion(): string {
309+ if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
310+ return $this->minMaxUnion; /*string*/
311311 }
312- throw new Exception('never get to this TopLevel::minmaxlength');
312+ throw new Exception('never get to this TopLevel::minMaxUnion');
313313 }
314314
315315 /**
@@ -317,7 +317,7 @@ class TopLevel {
317317 * @return bool
318318 * @throws Exception
319319 */
320- public static function validateMinmaxlength(string $value): bool {
320+ public static function validateMinMaxUnion(string $value): bool {
321321 return true;
322322 }
323323
@@ -325,18 +325,18 @@ class TopLevel {
325325 * @throws Exception
326326 * @return string
327327 */
328- public function getMinmaxlength(): string {
329- if (TopLevel::validateMinmaxlength($this->minmaxlength)) {
330- return $this->minmaxlength;
328+ public function getMinMaxUnion(): string {
329+ if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
330+ return $this->minMaxUnion;
331331 }
332- throw new Exception('never get to getMinmaxlength TopLevel::minmaxlength');
332+ throw new Exception('never get to getMinMaxUnion TopLevel::minMaxUnion');
333333 }
334334
335335 /**
336336 * @return string
337337 */
338- public static function sampleMinmaxlength(): string {
339- return 'TopLevel::minmaxlength::36'; /*36:minmaxlength*/
338+ public static function sampleMinMaxUnion(): string {
339+ return 'TopLevel::minMaxUnion::36'; /*36:minMaxUnion*/
340340 }
341341
342342 /**
@@ -344,7 +344,7 @@ class TopLevel {
344344 * @throws Exception
345345 * @return string
346346 */
347- public static function fromMinMaxUnion(string $value): string {
347+ public static function fromIntersection(string $value): string {
348348 return $value; /*string*/
349349 }
350350
@@ -352,11 +352,11 @@ class TopLevel {
352352 * @throws Exception
353353 * @return string
354354 */
355- public function toMinMaxUnion(): string {
356- if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
357- return $this->minMaxUnion; /*string*/
355+ public function toIntersection(): string {
356+ if (TopLevel::validateIntersection($this->intersection)) {
357+ return $this->intersection; /*string*/
358358 }
359- throw new Exception('never get to this TopLevel::minMaxUnion');
359+ throw new Exception('never get to this TopLevel::intersection');
360360 }
361361
362362 /**
@@ -364,7 +364,7 @@ class TopLevel {
364364 * @return bool
365365 * @throws Exception
366366 */
367- public static function validateMinMaxUnion(string $value): bool {
367+ public static function validateIntersection(string $value): bool {
368368 return true;
369369 }
370370
@@ -372,18 +372,18 @@ class TopLevel {
372372 * @throws Exception
373373 * @return string
374374 */
375- public function getMinMaxUnion(): string {
376- if (TopLevel::validateMinMaxUnion($this->minMaxUnion)) {
377- return $this->minMaxUnion;
375+ public function getIntersection(): string {
376+ if (TopLevel::validateIntersection($this->intersection)) {
377+ return $this->intersection;
378378 }
379- throw new Exception('never get to getMinMaxUnion TopLevel::minMaxUnion');
379+ throw new Exception('never get to getIntersection TopLevel::intersection');
380380 }
381381
382382 /**
383383 * @return string
384384 */
385- public static function sampleMinMaxUnion(): string {
386- return 'TopLevel::minMaxUnion::37'; /*37:minMaxUnion*/
385+ public static function sampleIntersection(): string {
386+ return 'TopLevel::intersection::37'; /*37:intersection*/
387387 }
388388
389389 /**
@@ -391,7 +391,7 @@ class TopLevel {
391391 * @throws Exception
392392 * @return string
393393 */
394- public static function fromUnion(string $value): string {
394+ public static function fromMinMaxIntersection(string $value): string {
395395 return $value; /*string*/
396396 }
397397
@@ -399,11 +399,11 @@ class TopLevel {
399399 * @throws Exception
400400 * @return string
401401 */
402- public function toUnion(): string {
403- if (TopLevel::validateUnion($this->union)) {
404- return $this->union; /*string*/
402+ public function toMinMaxIntersection(): string {
403+ if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
404+ return $this->minMaxIntersection; /*string*/
405405 }
406- throw new Exception('never get to this TopLevel::union');
406+ throw new Exception('never get to this TopLevel::minMaxIntersection');
407407 }
408408
409409 /**
@@ -411,7 +411,7 @@ class TopLevel {
411411 * @return bool
412412 * @throws Exception
413413 */
414- public static function validateUnion(string $value): bool {
414+ public static function validateMinMaxIntersection(string $value): bool {
415415 return true;
416416 }
417417
@@ -419,18 +419,18 @@ class TopLevel {
419419 * @throws Exception
420420 * @return string
421421 */
422- public function getUnion(): string {
423- if (TopLevel::validateUnion($this->union)) {
424- return $this->union;
422+ public function getMinMaxIntersection(): string {
423+ if (TopLevel::validateMinMaxIntersection($this->minMaxIntersection)) {
424+ return $this->minMaxIntersection;
425425 }
426- throw new Exception('never get to getUnion TopLevel::union');
426+ throw new Exception('never get to getMinMaxIntersection TopLevel::minMaxIntersection');
427427 }
428428
429429 /**
430430 * @return string
431431 */
432- public static function sampleUnion(): string {
433- return 'TopLevel::union::38'; /*38:union*/
432+ public static function sampleMinMaxIntersection(): string {
433+ return 'TopLevel::minMaxIntersection::38'; /*38:minMaxIntersection*/
434434 }
435435
436436 /**
@@ -438,14 +438,14 @@ class TopLevel {
438438 * @return bool
439439 */
440440 public function validate(): bool {
441- return TopLevel::validateIntersection($this->intersection)
442- || TopLevel::validateInUnion($this->inUnion)
441+ return TopLevel::validateMinlength($this->minlength)
443442 || TopLevel::validateMaxlength($this->maxlength)
444- || TopLevel::validateMinlength($this->minlength)
445- || TopLevel::validateMinMaxIntersection($this->minMaxIntersection)
446443 || TopLevel::validateMinmaxlength($this->minmaxlength)
444+ || TopLevel::validateUnion($this->union)
445+ || TopLevel::validateInUnion($this->inUnion)
447446 || TopLevel::validateMinMaxUnion($this->minMaxUnion)
448- || TopLevel::validateUnion($this->union);
447+ || TopLevel::validateIntersection($this->intersection)
448+ || TopLevel::validateMinMaxIntersection($this->minMaxIntersection);
449449 }
450450
451451 /**
@@ -454,14 +454,14 @@ class TopLevel {
454454 */
455455 public function to(): stdClass {
456456 $out = new stdClass();
457- $out->{'intersection'} = $this->toIntersection();
458- $out->{'inUnion'} = $this->toInUnion();
459- $out->{'maxlength'} = $this->toMaxlength();
460457 $out->{'minlength'} = $this->toMinlength();
461- $out->{'minMaxIntersection'} = $this->toMinMaxIntersection();
458+ $out->{'maxlength'} = $this->toMaxlength();
462459 $out->{'minmaxlength'} = $this->toMinmaxlength();
463- $out->{'minMaxUnion'} = $this->toMinMaxUnion();
464460 $out->{'union'} = $this->toUnion();
461+ $out->{'inUnion'} = $this->toInUnion();
462+ $out->{'minMaxUnion'} = $this->toMinMaxUnion();
463+ $out->{'intersection'} = $this->toIntersection();
464+ $out->{'minMaxIntersection'} = $this->toMinMaxIntersection();
465465 return $out;
466466 }
467467
@@ -472,14 +472,14 @@ class TopLevel {
472472 */
473473 public static function from(stdClass $obj): TopLevel {
474474 return new TopLevel(
475- TopLevel::fromIntersection($obj->{'intersection'})
476- ,TopLevel::fromInUnion($obj->{'inUnion'})
475+ TopLevel::fromMinlength($obj->{'minlength'})
477476 ,TopLevel::fromMaxlength($obj->{'maxlength'})
478- ,TopLevel::fromMinlength($obj->{'minlength'})
479- ,TopLevel::fromMinMaxIntersection($obj->{'minMaxIntersection'})
480477 ,TopLevel::fromMinmaxlength($obj->{'minmaxlength'})
481- ,TopLevel::fromMinMaxUnion($obj->{'minMaxUnion'})
482478 ,TopLevel::fromUnion($obj->{'union'})
479+ ,TopLevel::fromInUnion($obj->{'inUnion'})
480+ ,TopLevel::fromMinMaxUnion($obj->{'minMaxUnion'})
481+ ,TopLevel::fromIntersection($obj->{'intersection'})
482+ ,TopLevel::fromMinMaxIntersection($obj->{'minMaxIntersection'})
483483 );
484484 }
485485
@@ -488,14 +488,14 @@ class TopLevel {
488488 */
489489 public static function sample(): TopLevel {
490490 return new TopLevel(
491- TopLevel::sampleIntersection()
492- ,TopLevel::sampleInUnion()
491+ TopLevel::sampleMinlength()
493492 ,TopLevel::sampleMaxlength()
494- ,TopLevel::sampleMinlength()
495- ,TopLevel::sampleMinMaxIntersection()
496493 ,TopLevel::sampleMinmaxlength()
497- ,TopLevel::sampleMinMaxUnion()
498494 ,TopLevel::sampleUnion()
495+ ,TopLevel::sampleInUnion()
496+ ,TopLevel::sampleMinMaxUnion()
497+ ,TopLevel::sampleIntersection()
498+ ,TopLevel::sampleMinMaxIntersection()
499499 );
500500 }
501501 }
Mschema-php/test/inputs/schema/non-standard-ref.schema/default/TopLevel.php+35 −35
@@ -4,18 +4,18 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private int $bar; // json:bar Required
87 private int $foo; // json:foo Required
8+ private int $bar; // json:bar Required
99 private bool $quux; // json:quux Required
1010
1111 /**
12- * @param int $bar
1312 * @param int $foo
13+ * @param int $bar
1414 * @param bool $quux
1515 */
16- public function __construct(int $bar, int $foo, bool $quux) {
17- $this->bar = $bar;
16+ public function __construct(int $foo, int $bar, bool $quux) {
1817 $this->foo = $foo;
18+ $this->bar = $bar;
1919 $this->quux = $quux;
2020 }
2121
@@ -24,7 +24,7 @@ class TopLevel {
2424 * @throws Exception
2525 * @return int
2626 */
27- public static function fromBar(int $value): int {
27+ public static function fromFoo(int $value): int {
2828 return $value; /*int*/
2929 }
3030
@@ -32,11 +32,11 @@ class TopLevel {
3232 * @throws Exception
3333 * @return int
3434 */
35- public function toBar(): int {
36- if (TopLevel::validateBar($this->bar)) {
37- return $this->bar; /*int*/
35+ public function toFoo(): int {
36+ if (TopLevel::validateFoo($this->foo)) {
37+ return $this->foo; /*int*/
3838 }
39- throw new Exception('never get to this TopLevel::bar');
39+ throw new Exception('never get to this TopLevel::foo');
4040 }
4141
4242 /**
@@ -44,7 +44,7 @@ class TopLevel {
4444 * @return bool
4545 * @throws Exception
4646 */
47- public static function validateBar(int $value): bool {
47+ public static function validateFoo(int $value): bool {
4848 return true;
4949 }
5050
@@ -52,18 +52,18 @@ class TopLevel {
5252 * @throws Exception
5353 * @return int
5454 */
55- public function getBar(): int {
56- if (TopLevel::validateBar($this->bar)) {
57- return $this->bar;
55+ public function getFoo(): int {
56+ if (TopLevel::validateFoo($this->foo)) {
57+ return $this->foo;
5858 }
59- throw new Exception('never get to getBar TopLevel::bar');
59+ throw new Exception('never get to getFoo TopLevel::foo');
6060 }
6161
6262 /**
6363 * @return int
6464 */
65- public static function sampleBar(): int {
66- return 31; /*31:bar*/
65+ public static function sampleFoo(): int {
66+ return 31; /*31:foo*/
6767 }
6868
6969 /**
@@ -71,7 +71,7 @@ class TopLevel {
7171 * @throws Exception
7272 * @return int
7373 */
74- public static function fromFoo(int $value): int {
74+ public static function fromBar(int $value): int {
7575 return $value; /*int*/
7676 }
7777
@@ -79,11 +79,11 @@ class TopLevel {
7979 * @throws Exception
8080 * @return int
8181 */
82- public function toFoo(): int {
83- if (TopLevel::validateFoo($this->foo)) {
84- return $this->foo; /*int*/
82+ public function toBar(): int {
83+ if (TopLevel::validateBar($this->bar)) {
84+ return $this->bar; /*int*/
8585 }
86- throw new Exception('never get to this TopLevel::foo');
86+ throw new Exception('never get to this TopLevel::bar');
8787 }
8888
8989 /**
@@ -91,7 +91,7 @@ class TopLevel {
9191 * @return bool
9292 * @throws Exception
9393 */
94- public static function validateFoo(int $value): bool {
94+ public static function validateBar(int $value): bool {
9595 return true;
9696 }
9797
@@ -99,18 +99,18 @@ class TopLevel {
9999 * @throws Exception
100100 * @return int
101101 */
102- public function getFoo(): int {
103- if (TopLevel::validateFoo($this->foo)) {
104- return $this->foo;
102+ public function getBar(): int {
103+ if (TopLevel::validateBar($this->bar)) {
104+ return $this->bar;
105105 }
106- throw new Exception('never get to getFoo TopLevel::foo');
106+ throw new Exception('never get to getBar TopLevel::bar');
107107 }
108108
109109 /**
110110 * @return int
111111 */
112- public static function sampleFoo(): int {
113- return 32; /*32:foo*/
112+ public static function sampleBar(): int {
113+ return 32; /*32:bar*/
114114 }
115115
116116 /**
@@ -165,8 +165,8 @@ class TopLevel {
165165 * @return bool
166166 */
167167 public function validate(): bool {
168- return TopLevel::validateBar($this->bar)
169- || TopLevel::validateFoo($this->foo)
168+ return TopLevel::validateFoo($this->foo)
169+ || TopLevel::validateBar($this->bar)
170170 || TopLevel::validateQuux($this->quux);
171171 }
172172
@@ -176,8 +176,8 @@ class TopLevel {
176176 */
177177 public function to(): stdClass {
178178 $out = new stdClass();
179- $out->{'bar'} = $this->toBar();
180179 $out->{'foo'} = $this->toFoo();
180+ $out->{'bar'} = $this->toBar();
181181 $out->{'quux'} = $this->toQuux();
182182 return $out;
183183 }
@@ -189,8 +189,8 @@ class TopLevel {
189189 */
190190 public static function from(stdClass $obj): TopLevel {
191191 return new TopLevel(
192- TopLevel::fromBar($obj->{'bar'})
193- ,TopLevel::fromFoo($obj->{'foo'})
192+ TopLevel::fromFoo($obj->{'foo'})
193+ ,TopLevel::fromBar($obj->{'bar'})
194194 ,TopLevel::fromQuux($obj->{'quux'})
195195 );
196196 }
@@ -200,8 +200,8 @@ class TopLevel {
200200 */
201201 public static function sample(): TopLevel {
202202 return new TopLevel(
203- TopLevel::sampleBar()
204- ,TopLevel::sampleFoo()
203+ TopLevel::sampleFoo()
204+ ,TopLevel::sampleBar()
205205 ,TopLevel::sampleQuux()
206206 );
207207 }
Mschema-php/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.php+60 −60
@@ -4,121 +4,121 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private ?string $b; // json:b Optional
87 private Kind $kind; // json:kind Required
8+ private ?string $b; // json:b Optional
99
1010 /**
11- * @param string|null $b
1211 * @param Kind $kind
12+ * @param string|null $b
1313 */
14- public function __construct(?string $b, Kind $kind) {
15- $this->b = $b;
14+ public function __construct(Kind $kind, ?string $b) {
1615 $this->kind = $kind;
16+ $this->b = $b;
1717 }
1818
1919 /**
20- * @param ?string $value
20+ * @param string $value
2121 * @throws Exception
22- * @return ?string
22+ * @return Kind
2323 */
24- public static function fromB(?string $value): ?string {
25- if (!is_null($value)) {
26- return $value; /*string*/
27- } else {
28- return null;
29- }
24+ public static function fromKind(string $value): Kind {
25+ return Kind::from($value); /*enum*/
3026 }
3127
3228 /**
3329 * @throws Exception
34- * @return ?string
30+ * @return string
3531 */
36- public function toB(): ?string {
37- if (TopLevel::validateB($this->b)) {
38- if (!is_null($this->b)) {
39- return $this->b; /*string*/
40- } else {
41- return null;
42- }
32+ public function toKind(): string {
33+ if (TopLevel::validateKind($this->kind)) {
34+ return Kind::to($this->kind); /*enum*/
4335 }
44- throw new Exception('never get to this TopLevel::b');
36+ throw new Exception('never get to this TopLevel::kind');
4537 }
4638
4739 /**
48- * @param string|null
40+ * @param Kind
4941 * @return bool
5042 * @throws Exception
5143 */
52- public static function validateB(?string $value): bool {
53- if (!is_null($value)) {
54- }
44+ public static function validateKind(Kind $value): bool {
45+ Kind::to($value);
5546 return true;
5647 }
5748
5849 /**
5950 * @throws Exception
60- * @return ?string
51+ * @return Kind
6152 */
62- public function getB(): ?string {
63- if (TopLevel::validateB($this->b)) {
64- return $this->b;
53+ public function getKind(): Kind {
54+ if (TopLevel::validateKind($this->kind)) {
55+ return $this->kind;
6556 }
66- throw new Exception('never get to getB TopLevel::b');
57+ throw new Exception('never get to getKind TopLevel::kind');
6758 }
6859
6960 /**
70- * @return ?string
61+ * @return Kind
7162 */
72- public static function sampleB(): ?string {
73- return 'TopLevel::b::31'; /*31:b*/
63+ public static function sampleKind(): Kind {
64+ return Kind::sample(); /*enum*/
7465 }
7566
7667 /**
77- * @param string $value
68+ * @param ?string $value
7869 * @throws Exception
79- * @return Kind
70+ * @return ?string
8071 */
81- public static function fromKind(string $value): Kind {
82- return Kind::from($value); /*enum*/
72+ public static function fromB(?string $value): ?string {
73+ if (!is_null($value)) {
74+ return $value; /*string*/
75+ } else {
76+ return null;
77+ }
8378 }
8479
8580 /**
8681 * @throws Exception
87- * @return string
82+ * @return ?string
8883 */
89- public function toKind(): string {
90- if (TopLevel::validateKind($this->kind)) {
91- return Kind::to($this->kind); /*enum*/
84+ public function toB(): ?string {
85+ if (TopLevel::validateB($this->b)) {
86+ if (!is_null($this->b)) {
87+ return $this->b; /*string*/
88+ } else {
89+ return null;
90+ }
9291 }
93- throw new Exception('never get to this TopLevel::kind');
92+ throw new Exception('never get to this TopLevel::b');
9493 }
9594
9695 /**
97- * @param Kind
96+ * @param string|null
9897 * @return bool
9998 * @throws Exception
10099 */
101- public static function validateKind(Kind $value): bool {
102- Kind::to($value);
100+ public static function validateB(?string $value): bool {
101+ if (!is_null($value)) {
102+ }
103103 return true;
104104 }
105105
106106 /**
107107 * @throws Exception
108- * @return Kind
108+ * @return ?string
109109 */
110- public function getKind(): Kind {
111- if (TopLevel::validateKind($this->kind)) {
112- return $this->kind;
110+ public function getB(): ?string {
111+ if (TopLevel::validateB($this->b)) {
112+ return $this->b;
113113 }
114- throw new Exception('never get to getKind TopLevel::kind');
114+ throw new Exception('never get to getB TopLevel::b');
115115 }
116116
117117 /**
118- * @return Kind
118+ * @return ?string
119119 */
120- public static function sampleKind(): Kind {
121- return Kind::sample(); /*enum*/
120+ public static function sampleB(): ?string {
121+ return 'TopLevel::b::32'; /*32:b*/
122122 }
123123
124124 /**
@@ -126,8 +126,8 @@ class TopLevel {
126126 * @return bool
127127 */
128128 public function validate(): bool {
129- return TopLevel::validateB($this->b)
130- || TopLevel::validateKind($this->kind);
129+ return TopLevel::validateKind($this->kind)
130+ || TopLevel::validateB($this->b);
131131 }
132132
133133 /**
@@ -136,8 +136,8 @@ class TopLevel {
136136 */
137137 public function to(): stdClass {
138138 $out = new stdClass();
139- $out->{'b'} = $this->toB();
140139 $out->{'kind'} = $this->toKind();
140+ $out->{'b'} = $this->toB();
141141 return $out;
142142 }
143143
@@ -148,8 +148,8 @@ class TopLevel {
148148 */
149149 public static function from(stdClass $obj): TopLevel {
150150 return new TopLevel(
151- TopLevel::fromB($obj->{'b'})
152- ,TopLevel::fromKind($obj->{'kind'})
151+ TopLevel::fromKind($obj->{'kind'})
152+ ,TopLevel::fromB($obj->{'b'})
153153 );
154154 }
155155
@@ -158,8 +158,8 @@ class TopLevel {
158158 */
159159 public static function sample(): TopLevel {
160160 return new TopLevel(
161- TopLevel::sampleB()
162- ,TopLevel::sampleKind()
161+ TopLevel::sampleKind()
162+ ,TopLevel::sampleB()
163163 );
164164 }
165165 }
Mschema-php/test/inputs/schema/optional-any.schema/default/TopLevel.php+49 −49
@@ -4,110 +4,110 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private bool $bar; // json:bar Required
87 private mixed $foo; // json:foo Optional
8+ private bool $bar; // json:bar Required
99
1010 /**
11- * @param bool $bar
1211 * @param mixed $foo
12+ * @param bool $bar
1313 */
14- public function __construct(bool $bar, mixed $foo) {
15- $this->bar = $bar;
14+ public function __construct(mixed $foo, bool $bar) {
1615 $this->foo = $foo;
16+ $this->bar = $bar;
1717 }
1818
1919 /**
20- * @param bool $value
20+ * @param mixed $value
2121 * @throws Exception
22- * @return bool
22+ * @return mixed
2323 */
24- public static function fromBar(bool $value): bool {
25- return $value; /*bool*/
24+ public static function fromFoo(mixed $value): mixed {
25+ return $value; /*any*/
2626 }
2727
2828 /**
2929 * @throws Exception
30- * @return bool
30+ * @return mixed
3131 */
32- public function toBar(): bool {
33- if (TopLevel::validateBar($this->bar)) {
34- return $this->bar; /*bool*/
32+ public function toFoo(): mixed {
33+ if (TopLevel::validateFoo($this->foo)) {
34+ return $this->foo; /*any*/
3535 }
36- throw new Exception('never get to this TopLevel::bar');
36+ throw new Exception('never get to this TopLevel::foo');
3737 }
3838
3939 /**
40- * @param bool
40+ * @param mixed
4141 * @return bool
4242 * @throws Exception
4343 */
44- public static function validateBar(bool $value): bool {
44+ public static function validateFoo(mixed $value): bool {
4545 return true;
4646 }
4747
4848 /**
4949 * @throws Exception
50- * @return bool
50+ * @return mixed
5151 */
52- public function getBar(): bool {
53- if (TopLevel::validateBar($this->bar)) {
54- return $this->bar;
52+ public function getFoo(): mixed {
53+ if (TopLevel::validateFoo($this->foo)) {
54+ return $this->foo;
5555 }
56- throw new Exception('never get to getBar TopLevel::bar');
56+ throw new Exception('never get to getFoo TopLevel::foo');
5757 }
5858
5959 /**
60- * @return bool
60+ * @return mixed
6161 */
62- public static function sampleBar(): bool {
63- return true; /*31:bar*/
62+ public static function sampleFoo(): mixed {
63+ return 'AnyType::TopLevel::foo::31';/*31:foo*/
6464 }
6565
6666 /**
67- * @param mixed $value
67+ * @param bool $value
6868 * @throws Exception
69- * @return mixed
69+ * @return bool
7070 */
71- public static function fromFoo(mixed $value): mixed {
72- return $value; /*any*/
71+ public static function fromBar(bool $value): bool {
72+ return $value; /*bool*/
7373 }
7474
7575 /**
7676 * @throws Exception
77- * @return mixed
77+ * @return bool
7878 */
79- public function toFoo(): mixed {
80- if (TopLevel::validateFoo($this->foo)) {
81- return $this->foo; /*any*/
79+ public function toBar(): bool {
80+ if (TopLevel::validateBar($this->bar)) {
81+ return $this->bar; /*bool*/
8282 }
83- throw new Exception('never get to this TopLevel::foo');
83+ throw new Exception('never get to this TopLevel::bar');
8484 }
8585
8686 /**
87- * @param mixed
87+ * @param bool
8888 * @return bool
8989 * @throws Exception
9090 */
91- public static function validateFoo(mixed $value): bool {
91+ public static function validateBar(bool $value): bool {
9292 return true;
9393 }
9494
9595 /**
9696 * @throws Exception
97- * @return mixed
97+ * @return bool
9898 */
99- public function getFoo(): mixed {
100- if (TopLevel::validateFoo($this->foo)) {
101- return $this->foo;
99+ public function getBar(): bool {
100+ if (TopLevel::validateBar($this->bar)) {
101+ return $this->bar;
102102 }
103- throw new Exception('never get to getFoo TopLevel::foo');
103+ throw new Exception('never get to getBar TopLevel::bar');
104104 }
105105
106106 /**
107- * @return mixed
107+ * @return bool
108108 */
109- public static function sampleFoo(): mixed {
110- return 'AnyType::TopLevel::foo::32';/*32:foo*/
109+ public static function sampleBar(): bool {
110+ return true; /*32:bar*/
111111 }
112112
113113 /**
@@ -115,8 +115,8 @@ class TopLevel {
115115 * @return bool
116116 */
117117 public function validate(): bool {
118- return TopLevel::validateBar($this->bar)
119- || TopLevel::validateFoo($this->foo);
118+ return TopLevel::validateFoo($this->foo)
119+ || TopLevel::validateBar($this->bar);
120120 }
121121
122122 /**
@@ -125,8 +125,8 @@ class TopLevel {
125125 */
126126 public function to(): stdClass {
127127 $out = new stdClass();
128- $out->{'bar'} = $this->toBar();
129128 $out->{'foo'} = $this->toFoo();
129+ $out->{'bar'} = $this->toBar();
130130 return $out;
131131 }
132132
@@ -137,8 +137,8 @@ class TopLevel {
137137 */
138138 public static function from(stdClass $obj): TopLevel {
139139 return new TopLevel(
140- TopLevel::fromBar($obj->{'bar'})
141- ,TopLevel::fromFoo($obj->{'foo'})
140+ TopLevel::fromFoo($obj->{'foo'})
141+ ,TopLevel::fromBar($obj->{'bar'})
142142 );
143143 }
144144
@@ -147,8 +147,8 @@ class TopLevel {
147147 */
148148 public static function sample(): TopLevel {
149149 return new TopLevel(
150- TopLevel::sampleBar()
151- ,TopLevel::sampleFoo()
150+ TopLevel::sampleFoo()
151+ ,TopLevel::sampleBar()
152152 );
153153 }
154154 }
Mschema-php/test/inputs/schema/optional-const-ref.schema/default/TopLevel.php+160 −160
@@ -5,30 +5,30 @@ declare(strict_types=1);
55
66 class TopLevel {
77 private ?array $coordinates; // json:coordinates Optional
8- private ?int $count; // json:count Optional
9- private ?string $label; // json:label Optional
108 private array $requiredCoordinates; // json:requiredCoordinates Required
9+ private ?int $count; // json:count Optional
1110 private int $requiredCount; // json:requiredCount Required
12- private string $requiredLabel; // json:requiredLabel Required
1311 private ?float $weight; // json:weight Optional
12+ private ?string $label; // json:label Optional
13+ private string $requiredLabel; // json:requiredLabel Required
1414
1515 /**
1616 * @param array|null $coordinates
17- * @param int|null $count
18- * @param string|null $label
1917 * @param array $requiredCoordinates
18+ * @param int|null $count
2019 * @param int $requiredCount
21- * @param string $requiredLabel
2220 * @param float|null $weight
21+ * @param string|null $label
22+ * @param string $requiredLabel
2323 */
24- public function __construct(?array $coordinates, ?int $count, ?string $label, array $requiredCoordinates, int $requiredCount, string $requiredLabel, ?float $weight) {
24+ public function __construct(?array $coordinates, array $requiredCoordinates, ?int $count, int $requiredCount, ?float $weight, ?string $label, string $requiredLabel) {
2525 $this->coordinates = $coordinates;
26- $this->count = $count;
27- $this->label = $label;
2826 $this->requiredCoordinates = $requiredCoordinates;
27+ $this->count = $count;
2928 $this->requiredCount = $requiredCount;
30- $this->requiredLabel = $requiredLabel;
3129 $this->weight = $weight;
30+ $this->label = $label;
31+ $this->requiredLabel = $requiredLabel;
3232 }
3333
3434 /**
@@ -100,6 +100,65 @@ class TopLevel {
100100 ); /* 31:coordinates*/
101101 }
102102
103+ /**
104+ * @param array $value
105+ * @throws Exception
106+ * @return array
107+ */
108+ public static function fromRequiredCoordinates(array $value): array {
109+ return array_map(function ($value) {
110+ return Coordinate::from($value); /*class*/
111+ }, $value);
112+ }
113+
114+ /**
115+ * @throws Exception
116+ * @return array
117+ */
118+ public function toRequiredCoordinates(): array {
119+ if (TopLevel::validateRequiredCoordinates($this->requiredCoordinates)) {
120+ return array_map(function ($value) {
121+ return $value->to(); /*class*/
122+ }, $this->requiredCoordinates);
123+ }
124+ throw new Exception('never get to this TopLevel::requiredCoordinates');
125+ }
126+
127+ /**
128+ * @param array
129+ * @return bool
130+ * @throws Exception
131+ */
132+ public static function validateRequiredCoordinates(array $value): bool {
133+ if (!is_array($value)) {
134+ throw new Exception("Attribute Error:TopLevel::requiredCoordinates");
135+ }
136+ array_walk($value, function($value_v) {
137+ $value_v->validate();
138+ });
139+ return true;
140+ }
141+
142+ /**
143+ * @throws Exception
144+ * @return array
145+ */
146+ public function getRequiredCoordinates(): array {
147+ if (TopLevel::validateRequiredCoordinates($this->requiredCoordinates)) {
148+ return $this->requiredCoordinates;
149+ }
150+ throw new Exception('never get to getRequiredCoordinates TopLevel::requiredCoordinates');
151+ }
152+
153+ /**
154+ * @return array
155+ */
156+ public static function sampleRequiredCoordinates(): array {
157+ return array(
158+ Coordinate::sample() /*32:*/
159+ ); /* 32:requiredCoordinates*/
160+ }
161+
103162 /**
104163 * @param ?int $value
105164 * @throws Exception
@@ -154,170 +213,168 @@ class TopLevel {
154213 * @return ?int
155214 */
156215 public static function sampleCount(): ?int {
157- return 32; /*32:count*/
216+ return 33; /*33:count*/
158217 }
159218
160219 /**
161- * @param ?string $value
220+ * @param int $value
162221 * @throws Exception
163- * @return ?string
222+ * @return int
164223 */
165- public static function fromLabel(?string $value): ?string {
166- if (!is_null($value)) {
167- return $value; /*string*/
168- } else {
169- return null;
170- }
224+ public static function fromRequiredCount(int $value): int {
225+ return $value; /*int*/
171226 }
172227
173228 /**
174229 * @throws Exception
175- * @return ?string
230+ * @return int
176231 */
177- public function toLabel(): ?string {
178- if (TopLevel::validateLabel($this->label)) {
179- if (!is_null($this->label)) {
180- return $this->label; /*string*/
181- } else {
182- return null;
183- }
232+ public function toRequiredCount(): int {
233+ if (TopLevel::validateRequiredCount($this->requiredCount)) {
234+ return $this->requiredCount; /*int*/
184235 }
185- throw new Exception('never get to this TopLevel::label');
236+ throw new Exception('never get to this TopLevel::requiredCount');
186237 }
187238
188239 /**
189- * @param string|null
240+ * @param int
190241 * @return bool
191242 * @throws Exception
192243 */
193- public static function validateLabel(?string $value): bool {
194- if (!is_null($value)) {
195- }
244+ public static function validateRequiredCount(int $value): bool {
196245 return true;
197246 }
198247
199248 /**
200249 * @throws Exception
201- * @return ?string
250+ * @return int
202251 */
203- public function getLabel(): ?string {
204- if (TopLevel::validateLabel($this->label)) {
205- return $this->label;
252+ public function getRequiredCount(): int {
253+ if (TopLevel::validateRequiredCount($this->requiredCount)) {
254+ return $this->requiredCount;
206255 }
207- throw new Exception('never get to getLabel TopLevel::label');
256+ throw new Exception('never get to getRequiredCount TopLevel::requiredCount');
208257 }
209258
210259 /**
211- * @return ?string
260+ * @return int
212261 */
213- public static function sampleLabel(): ?string {
214- return 'TopLevel::label::33'; /*33:label*/
262+ public static function sampleRequiredCount(): int {
263+ return 34; /*34:requiredCount*/
215264 }
216265
217266 /**
218- * @param array $value
267+ * @param ?float $value
219268 * @throws Exception
220- * @return array
269+ * @return ?float
221270 */
222- public static function fromRequiredCoordinates(array $value): array {
223- return array_map(function ($value) {
224- return Coordinate::from($value); /*class*/
225- }, $value);
271+ public static function fromWeight(?float $value): ?float {
272+ if (!is_null($value)) {
273+ return $value; /*float*/
274+ } else {
275+ return null;
276+ }
226277 }
227278
228279 /**
229280 * @throws Exception
230- * @return array
281+ * @return ?float
231282 */
232- public function toRequiredCoordinates(): array {
233- if (TopLevel::validateRequiredCoordinates($this->requiredCoordinates)) {
234- return array_map(function ($value) {
235- return $value->to(); /*class*/
236- }, $this->requiredCoordinates);
283+ public function toWeight(): ?float {
284+ if (TopLevel::validateWeight($this->weight)) {
285+ if (!is_null($this->weight)) {
286+ return $this->weight; /*float*/
287+ } else {
288+ return null;
289+ }
237290 }
238- throw new Exception('never get to this TopLevel::requiredCoordinates');
291+ throw new Exception('never get to this TopLevel::weight');
239292 }
240293
241294 /**
242- * @param array
295+ * @param float|null
243296 * @return bool
244297 * @throws Exception
245298 */
246- public static function validateRequiredCoordinates(array $value): bool {
247- if (!is_array($value)) {
248- throw new Exception("Attribute Error:TopLevel::requiredCoordinates");
299+ public static function validateWeight(?float $value): bool {
300+ if (!is_null($value)) {
249301 }
250- array_walk($value, function($value_v) {
251- $value_v->validate();
252- });
253302 return true;
254303 }
255304
256305 /**
257306 * @throws Exception
258- * @return array
307+ * @return ?float
259308 */
260- public function getRequiredCoordinates(): array {
261- if (TopLevel::validateRequiredCoordinates($this->requiredCoordinates)) {
262- return $this->requiredCoordinates;
309+ public function getWeight(): ?float {
310+ if (TopLevel::validateWeight($this->weight)) {
311+ return $this->weight;
263312 }
264- throw new Exception('never get to getRequiredCoordinates TopLevel::requiredCoordinates');
313+ throw new Exception('never get to getWeight TopLevel::weight');
265314 }
266315
267316 /**
268- * @return array
317+ * @return ?float
269318 */
270- public static function sampleRequiredCoordinates(): array {
271- return array(
272- Coordinate::sample() /*34:*/
273- ); /* 34:requiredCoordinates*/
319+ public static function sampleWeight(): ?float {
320+ return 35.035; /*35:weight*/
274321 }
275322
276323 /**
277- * @param int $value
324+ * @param ?string $value
278325 * @throws Exception
279- * @return int
326+ * @return ?string
280327 */
281- public static function fromRequiredCount(int $value): int {
282- return $value; /*int*/
328+ public static function fromLabel(?string $value): ?string {
329+ if (!is_null($value)) {
330+ return $value; /*string*/
331+ } else {
332+ return null;
333+ }
283334 }
284335
285336 /**
286337 * @throws Exception
287- * @return int
338+ * @return ?string
288339 */
289- public function toRequiredCount(): int {
290- if (TopLevel::validateRequiredCount($this->requiredCount)) {
291- return $this->requiredCount; /*int*/
340+ public function toLabel(): ?string {
341+ if (TopLevel::validateLabel($this->label)) {
342+ if (!is_null($this->label)) {
343+ return $this->label; /*string*/
344+ } else {
345+ return null;
346+ }
292347 }
293- throw new Exception('never get to this TopLevel::requiredCount');
348+ throw new Exception('never get to this TopLevel::label');
294349 }
295350
296351 /**
297- * @param int
352+ * @param string|null
298353 * @return bool
299354 * @throws Exception
300355 */
301- public static function validateRequiredCount(int $value): bool {
356+ public static function validateLabel(?string $value): bool {
357+ if (!is_null($value)) {
358+ }
302359 return true;
303360 }
304361
305362 /**
306363 * @throws Exception
307- * @return int
364+ * @return ?string
308365 */
309- public function getRequiredCount(): int {
310- if (TopLevel::validateRequiredCount($this->requiredCount)) {
311- return $this->requiredCount;
366+ public function getLabel(): ?string {
367+ if (TopLevel::validateLabel($this->label)) {
368+ return $this->label;
312369 }
313- throw new Exception('never get to getRequiredCount TopLevel::requiredCount');
370+ throw new Exception('never get to getLabel TopLevel::label');
314371 }
315372
316373 /**
317- * @return int
374+ * @return ?string
318375 */
319- public static function sampleRequiredCount(): int {
320- return 35; /*35:requiredCount*/
376+ public static function sampleLabel(): ?string {
377+ return 'TopLevel::label::36'; /*36:label*/
321378 }
322379
323380 /**
@@ -364,64 +421,7 @@ class TopLevel {
364421 * @return string
365422 */
366423 public static function sampleRequiredLabel(): string {
367- return 'TopLevel::requiredLabel::36'; /*36:requiredLabel*/
368- }
369-
370- /**
371- * @param ?float $value
372- * @throws Exception
373- * @return ?float
374- */
375- public static function fromWeight(?float $value): ?float {
376- if (!is_null($value)) {
377- return $value; /*float*/
378- } else {
379- return null;
380- }
381- }
382-
383- /**
384- * @throws Exception
385- * @return ?float
386- */
387- public function toWeight(): ?float {
388- if (TopLevel::validateWeight($this->weight)) {
389- if (!is_null($this->weight)) {
390- return $this->weight; /*float*/
391- } else {
392- return null;
393- }
394- }
395- throw new Exception('never get to this TopLevel::weight');
396- }
397-
398- /**
399- * @param float|null
400- * @return bool
401- * @throws Exception
402- */
403- public static function validateWeight(?float $value): bool {
404- if (!is_null($value)) {
405- }
406- return true;
407- }
408-
409- /**
410- * @throws Exception
411- * @return ?float
412- */
413- public function getWeight(): ?float {
414- if (TopLevel::validateWeight($this->weight)) {
415- return $this->weight;
416- }
417- throw new Exception('never get to getWeight TopLevel::weight');
418- }
419-
420- /**
421- * @return ?float
422- */
423- public static function sampleWeight(): ?float {
424- return 37.037; /*37:weight*/
424+ return 'TopLevel::requiredLabel::37'; /*37:requiredLabel*/
425425 }
426426
427427 /**
@@ -430,12 +430,12 @@ class TopLevel {
430430 */
431431 public function validate(): bool {
432432 return TopLevel::validateCoordinates($this->coordinates)
433- || TopLevel::validateCount($this->count)
434- || TopLevel::validateLabel($this->label)
435433 || TopLevel::validateRequiredCoordinates($this->requiredCoordinates)
434+ || TopLevel::validateCount($this->count)
436435 || TopLevel::validateRequiredCount($this->requiredCount)
437- || TopLevel::validateRequiredLabel($this->requiredLabel)
438- || TopLevel::validateWeight($this->weight);
436+ || TopLevel::validateWeight($this->weight)
437+ || TopLevel::validateLabel($this->label)
438+ || TopLevel::validateRequiredLabel($this->requiredLabel);
439439 }
440440
441441 /**
@@ -445,12 +445,12 @@ class TopLevel {
445445 public function to(): stdClass {
446446 $out = new stdClass();
447447 $out->{'coordinates'} = $this->toCoordinates();
448- $out->{'count'} = $this->toCount();
449- $out->{'label'} = $this->toLabel();
450448 $out->{'requiredCoordinates'} = $this->toRequiredCoordinates();
449+ $out->{'count'} = $this->toCount();
451450 $out->{'requiredCount'} = $this->toRequiredCount();
452- $out->{'requiredLabel'} = $this->toRequiredLabel();
453451 $out->{'weight'} = $this->toWeight();
452+ $out->{'label'} = $this->toLabel();
453+ $out->{'requiredLabel'} = $this->toRequiredLabel();
454454 return $out;
455455 }
456456
@@ -462,12 +462,12 @@ class TopLevel {
462462 public static function from(stdClass $obj): TopLevel {
463463 return new TopLevel(
464464 TopLevel::fromCoordinates($obj->{'coordinates'})
465- ,TopLevel::fromCount($obj->{'count'})
466- ,TopLevel::fromLabel($obj->{'label'})
467465 ,TopLevel::fromRequiredCoordinates($obj->{'requiredCoordinates'})
466+ ,TopLevel::fromCount($obj->{'count'})
468467 ,TopLevel::fromRequiredCount($obj->{'requiredCount'})
469- ,TopLevel::fromRequiredLabel($obj->{'requiredLabel'})
470468 ,TopLevel::fromWeight($obj->{'weight'})
469+ ,TopLevel::fromLabel($obj->{'label'})
470+ ,TopLevel::fromRequiredLabel($obj->{'requiredLabel'})
471471 );
472472 }
473473
@@ -477,12 +477,12 @@ class TopLevel {
477477 public static function sample(): TopLevel {
478478 return new TopLevel(
479479 TopLevel::sampleCoordinates()
480- ,TopLevel::sampleCount()
481- ,TopLevel::sampleLabel()
482480 ,TopLevel::sampleRequiredCoordinates()
481+ ,TopLevel::sampleCount()
483482 ,TopLevel::sampleRequiredCount()
484- ,TopLevel::sampleRequiredLabel()
485483 ,TopLevel::sampleWeight()
484+ ,TopLevel::sampleLabel()
485+ ,TopLevel::sampleRequiredLabel()
486486 );
487487 }
488488 }
Mschema-php/test/inputs/schema/optional-constraints.schema/default/TopLevel.php+90 −90
@@ -4,82 +4,72 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private ?float $optDouble; // json:optDouble Optional
7+ private int $reqZeroMin; // json:reqZeroMin Required
88 private ?int $optInt; // json:optInt Optional
9- private ?string $optPattern; // json:optPattern Optional
9+ private ?float $optDouble; // json:optDouble Optional
1010 private ?string $optString; // json:optString Optional
11- private int $reqZeroMin; // json:reqZeroMin Required
11+ private ?string $optPattern; // json:optPattern Optional
1212
1313 /**
14- * @param float|null $optDouble
14+ * @param int $reqZeroMin
1515 * @param int|null $optInt
16- * @param string|null $optPattern
16+ * @param float|null $optDouble
1717 * @param string|null $optString
18- * @param int $reqZeroMin
18+ * @param string|null $optPattern
1919 */
20- public function __construct(?float $optDouble, ?int $optInt, ?string $optPattern, ?string $optString, int $reqZeroMin) {
21- $this->optDouble = $optDouble;
20+ public function __construct(int $reqZeroMin, ?int $optInt, ?float $optDouble, ?string $optString, ?string $optPattern) {
21+ $this->reqZeroMin = $reqZeroMin;
2222 $this->optInt = $optInt;
23- $this->optPattern = $optPattern;
23+ $this->optDouble = $optDouble;
2424 $this->optString = $optString;
25- $this->reqZeroMin = $reqZeroMin;
25+ $this->optPattern = $optPattern;
2626 }
2727
2828 /**
29- * @param ?float $value
29+ * @param int $value
3030 * @throws Exception
31- * @return ?float
31+ * @return int
3232 */
33- public static function fromOptDouble(?float $value): ?float {
34- if (!is_null($value)) {
35- return $value; /*float*/
36- } else {
37- return null;
38- }
33+ public static function fromReqZeroMin(int $value): int {
34+ return $value; /*int*/
3935 }
4036
4137 /**
4238 * @throws Exception
43- * @return ?float
39+ * @return int
4440 */
45- public function toOptDouble(): ?float {
46- if (TopLevel::validateOptDouble($this->optDouble)) {
47- if (!is_null($this->optDouble)) {
48- return $this->optDouble; /*float*/
49- } else {
50- return null;
51- }
41+ public function toReqZeroMin(): int {
42+ if (TopLevel::validateReqZeroMin($this->reqZeroMin)) {
43+ return $this->reqZeroMin; /*int*/
5244 }
53- throw new Exception('never get to this TopLevel::optDouble');
45+ throw new Exception('never get to this TopLevel::reqZeroMin');
5446 }
5547
5648 /**
57- * @param float|null
49+ * @param int
5850 * @return bool
5951 * @throws Exception
6052 */
61- public static function validateOptDouble(?float $value): bool {
62- if (!is_null($value)) {
63- }
53+ public static function validateReqZeroMin(int $value): bool {
6454 return true;
6555 }
6656
6757 /**
6858 * @throws Exception
69- * @return ?float
59+ * @return int
7060 */
71- public function getOptDouble(): ?float {
72- if (TopLevel::validateOptDouble($this->optDouble)) {
73- return $this->optDouble;
61+ public function getReqZeroMin(): int {
62+ if (TopLevel::validateReqZeroMin($this->reqZeroMin)) {
63+ return $this->reqZeroMin;
7464 }
75- throw new Exception('never get to getOptDouble TopLevel::optDouble');
65+ throw new Exception('never get to getReqZeroMin TopLevel::reqZeroMin');
7666 }
7767
7868 /**
79- * @return ?float
69+ * @return int
8070 */
81- public static function sampleOptDouble(): ?float {
82- return 31.031; /*31:optDouble*/
71+ public static function sampleReqZeroMin(): int {
72+ return 31; /*31:reqZeroMin*/
8373 }
8474
8575 /**
@@ -140,13 +130,13 @@ class TopLevel {
140130 }
141131
142132 /**
143- * @param ?string $value
133+ * @param ?float $value
144134 * @throws Exception
145- * @return ?string
135+ * @return ?float
146136 */
147- public static function fromOptPattern(?string $value): ?string {
137+ public static function fromOptDouble(?float $value): ?float {
148138 if (!is_null($value)) {
149- return $value; /*string*/
139+ return $value; /*float*/
150140 } else {
151141 return null;
152142 }
@@ -154,25 +144,25 @@ class TopLevel {
154144
155145 /**
156146 * @throws Exception
157- * @return ?string
147+ * @return ?float
158148 */
159- public function toOptPattern(): ?string {
160- if (TopLevel::validateOptPattern($this->optPattern)) {
161- if (!is_null($this->optPattern)) {
162- return $this->optPattern; /*string*/
149+ public function toOptDouble(): ?float {
150+ if (TopLevel::validateOptDouble($this->optDouble)) {
151+ if (!is_null($this->optDouble)) {
152+ return $this->optDouble; /*float*/
163153 } else {
164154 return null;
165155 }
166156 }
167- throw new Exception('never get to this TopLevel::optPattern');
157+ throw new Exception('never get to this TopLevel::optDouble');
168158 }
169159
170160 /**
171- * @param string|null
161+ * @param float|null
172162 * @return bool
173163 * @throws Exception
174164 */
175- public static function validateOptPattern(?string $value): bool {
165+ public static function validateOptDouble(?float $value): bool {
176166 if (!is_null($value)) {
177167 }
178168 return true;
@@ -180,20 +170,20 @@ class TopLevel {
180170
181171 /**
182172 * @throws Exception
183- * @return ?string
173+ * @return ?float
184174 */
185- public function getOptPattern(): ?string {
186- if (TopLevel::validateOptPattern($this->optPattern)) {
187- return $this->optPattern;
175+ public function getOptDouble(): ?float {
176+ if (TopLevel::validateOptDouble($this->optDouble)) {
177+ return $this->optDouble;
188178 }
189- throw new Exception('never get to getOptPattern TopLevel::optPattern');
179+ throw new Exception('never get to getOptDouble TopLevel::optDouble');
190180 }
191181
192182 /**
193- * @return ?string
183+ * @return ?float
194184 */
195- public static function sampleOptPattern(): ?string {
196- return 'TopLevel::optPattern::33'; /*33:optPattern*/
185+ public static function sampleOptDouble(): ?float {
186+ return 33.033; /*33:optDouble*/
197187 }
198188
199189 /**
@@ -254,50 +244,60 @@ class TopLevel {
254244 }
255245
256246 /**
257- * @param int $value
247+ * @param ?string $value
258248 * @throws Exception
259- * @return int
249+ * @return ?string
260250 */
261- public static function fromReqZeroMin(int $value): int {
262- return $value; /*int*/
251+ public static function fromOptPattern(?string $value): ?string {
252+ if (!is_null($value)) {
253+ return $value; /*string*/
254+ } else {
255+ return null;
256+ }
263257 }
264258
265259 /**
266260 * @throws Exception
267- * @return int
261+ * @return ?string
268262 */
269- public function toReqZeroMin(): int {
270- if (TopLevel::validateReqZeroMin($this->reqZeroMin)) {
271- return $this->reqZeroMin; /*int*/
263+ public function toOptPattern(): ?string {
264+ if (TopLevel::validateOptPattern($this->optPattern)) {
265+ if (!is_null($this->optPattern)) {
266+ return $this->optPattern; /*string*/
267+ } else {
268+ return null;
269+ }
272270 }
273- throw new Exception('never get to this TopLevel::reqZeroMin');
271+ throw new Exception('never get to this TopLevel::optPattern');
274272 }
275273
276274 /**
277- * @param int
275+ * @param string|null
278276 * @return bool
279277 * @throws Exception
280278 */
281- public static function validateReqZeroMin(int $value): bool {
279+ public static function validateOptPattern(?string $value): bool {
280+ if (!is_null($value)) {
281+ }
282282 return true;
283283 }
284284
285285 /**
286286 * @throws Exception
287- * @return int
287+ * @return ?string
288288 */
289- public function getReqZeroMin(): int {
290- if (TopLevel::validateReqZeroMin($this->reqZeroMin)) {
291- return $this->reqZeroMin;
289+ public function getOptPattern(): ?string {
290+ if (TopLevel::validateOptPattern($this->optPattern)) {
291+ return $this->optPattern;
292292 }
293- throw new Exception('never get to getReqZeroMin TopLevel::reqZeroMin');
293+ throw new Exception('never get to getOptPattern TopLevel::optPattern');
294294 }
295295
296296 /**
297- * @return int
297+ * @return ?string
298298 */
299- public static function sampleReqZeroMin(): int {
300- return 35; /*35:reqZeroMin*/
299+ public static function sampleOptPattern(): ?string {
300+ return 'TopLevel::optPattern::35'; /*35:optPattern*/
301301 }
302302
303303 /**
@@ -305,11 +305,11 @@ class TopLevel {
305305 * @return bool
306306 */
307307 public function validate(): bool {
308- return TopLevel::validateOptDouble($this->optDouble)
308+ return TopLevel::validateReqZeroMin($this->reqZeroMin)
309309 || TopLevel::validateOptInt($this->optInt)
310- || TopLevel::validateOptPattern($this->optPattern)
310+ || TopLevel::validateOptDouble($this->optDouble)
311311 || TopLevel::validateOptString($this->optString)
312- || TopLevel::validateReqZeroMin($this->reqZeroMin);
312+ || TopLevel::validateOptPattern($this->optPattern);
313313 }
314314
315315 /**
@@ -318,11 +318,11 @@ class TopLevel {
318318 */
319319 public function to(): stdClass {
320320 $out = new stdClass();
321- $out->{'optDouble'} = $this->toOptDouble();
321+ $out->{'reqZeroMin'} = $this->toReqZeroMin();
322322 $out->{'optInt'} = $this->toOptInt();
323- $out->{'optPattern'} = $this->toOptPattern();
323+ $out->{'optDouble'} = $this->toOptDouble();
324324 $out->{'optString'} = $this->toOptString();
325- $out->{'reqZeroMin'} = $this->toReqZeroMin();
325+ $out->{'optPattern'} = $this->toOptPattern();
326326 return $out;
327327 }
328328
@@ -333,11 +333,11 @@ class TopLevel {
333333 */
334334 public static function from(stdClass $obj): TopLevel {
335335 return new TopLevel(
336- TopLevel::fromOptDouble($obj->{'optDouble'})
336+ TopLevel::fromReqZeroMin($obj->{'reqZeroMin'})
337337 ,TopLevel::fromOptInt($obj->{'optInt'})
338- ,TopLevel::fromOptPattern($obj->{'optPattern'})
338+ ,TopLevel::fromOptDouble($obj->{'optDouble'})
339339 ,TopLevel::fromOptString($obj->{'optString'})
340- ,TopLevel::fromReqZeroMin($obj->{'reqZeroMin'})
340+ ,TopLevel::fromOptPattern($obj->{'optPattern'})
341341 );
342342 }
343343
@@ -346,11 +346,11 @@ class TopLevel {
346346 */
347347 public static function sample(): TopLevel {
348348 return new TopLevel(
349- TopLevel::sampleOptDouble()
349+ TopLevel::sampleReqZeroMin()
350350 ,TopLevel::sampleOptInt()
351- ,TopLevel::sampleOptPattern()
351+ ,TopLevel::sampleOptDouble()
352352 ,TopLevel::sampleOptString()
353- ,TopLevel::sampleReqZeroMin()
353+ ,TopLevel::sampleOptPattern()
354354 );
355355 }
356356 }
Mschema-php/test/inputs/schema/optional-date-time.schema/default/TopLevel.php+186 −186
@@ -4,354 +4,354 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private ?string $optionalDate; // json:optional-date Optional
8- private ?DateTime $optionalDateTime; // json:optional-date-time Optional
9- private ?string $optionalTime; // json:optional-time Optional
107 private string $requiredDate; // json:required-date Required
11- private DateTime $requiredDateTime; // json:required-date-time Required
128 private string $requiredTime; // json:required-time Required
9+ private DateTime $requiredDateTime; // json:required-date-time Required
10+ private ?string $optionalDate; // json:optional-date Optional
11+ private ?string $optionalTime; // json:optional-time Optional
12+ private ?DateTime $optionalDateTime; // json:optional-date-time Optional
1313
1414 /**
15- * @param string|null $optionalDate
16- * @param DateTime|null $optionalDateTime
17- * @param string|null $optionalTime
1815 * @param string $requiredDate
19- * @param DateTime $requiredDateTime
2016 * @param string $requiredTime
17+ * @param DateTime $requiredDateTime
18+ * @param string|null $optionalDate
19+ * @param string|null $optionalTime
20+ * @param DateTime|null $optionalDateTime
2121 */
22- public function __construct(?string $optionalDate, ?DateTime $optionalDateTime, ?string $optionalTime, string $requiredDate, DateTime $requiredDateTime, string $requiredTime) {
23- $this->optionalDate = $optionalDate;
24- $this->optionalDateTime = $optionalDateTime;
25- $this->optionalTime = $optionalTime;
22+ public function __construct(string $requiredDate, string $requiredTime, DateTime $requiredDateTime, ?string $optionalDate, ?string $optionalTime, ?DateTime $optionalDateTime) {
2623 $this->requiredDate = $requiredDate;
27- $this->requiredDateTime = $requiredDateTime;
2824 $this->requiredTime = $requiredTime;
25+ $this->requiredDateTime = $requiredDateTime;
26+ $this->optionalDate = $optionalDate;
27+ $this->optionalTime = $optionalTime;
28+ $this->optionalDateTime = $optionalDateTime;
2929 }
3030
3131 /**
32- * @param ?string $value
32+ * @param string $value
3333 * @throws Exception
34- * @return ?string
34+ * @return string
3535 */
36- public static function fromOptionalDate(?string $value): ?string {
37- if (!is_null($value)) {
38- return $value; /*string*/
39- } else {
40- return null;
41- }
36+ public static function fromRequiredDate(string $value): string {
37+ return $value; /*string*/
4238 }
4339
4440 /**
4541 * @throws Exception
46- * @return ?string
42+ * @return string
4743 */
48- public function toOptionalDate(): ?string {
49- if (TopLevel::validateOptionalDate($this->optionalDate)) {
50- if (!is_null($this->optionalDate)) {
51- return $this->optionalDate; /*string*/
52- } else {
53- return null;
54- }
44+ public function toRequiredDate(): string {
45+ if (TopLevel::validateRequiredDate($this->requiredDate)) {
46+ return $this->requiredDate; /*string*/
5547 }
56- throw new Exception('never get to this TopLevel::optionalDate');
48+ throw new Exception('never get to this TopLevel::requiredDate');
5749 }
5850
5951 /**
60- * @param string|null
52+ * @param string
6153 * @return bool
6254 * @throws Exception
6355 */
64- public static function validateOptionalDate(?string $value): bool {
65- if (!is_null($value)) {
66- }
56+ public static function validateRequiredDate(string $value): bool {
6757 return true;
6858 }
6959
7060 /**
7161 * @throws Exception
72- * @return ?string
62+ * @return string
7363 */
74- public function getOptionalDate(): ?string {
75- if (TopLevel::validateOptionalDate($this->optionalDate)) {
76- return $this->optionalDate;
64+ public function getRequiredDate(): string {
65+ if (TopLevel::validateRequiredDate($this->requiredDate)) {
66+ return $this->requiredDate;
7767 }
78- throw new Exception('never get to getOptionalDate TopLevel::optionalDate');
68+ throw new Exception('never get to getRequiredDate TopLevel::requiredDate');
7969 }
8070
8171 /**
82- * @return ?string
72+ * @return string
8373 */
84- public static function sampleOptionalDate(): ?string {
85- return 'TopLevel::optionalDate::31'; /*31:optionalDate*/
74+ public static function sampleRequiredDate(): string {
75+ return 'TopLevel::requiredDate::31'; /*31:requiredDate*/
8676 }
8777
8878 /**
89- * @param ?string $value
79+ * @param string $value
9080 * @throws Exception
91- * @return ?DateTime
81+ * @return string
9282 */
93- public static function fromOptionalDateTime(?string $value): ?DateTime {
94- if (!is_null($value)) {
95- $tmp = DateTime::createFromFormat(DateTimeInterface::ISO8601, $value);
96- if (!is_a($tmp, 'DateTime')) {
97- throw new Exception('Attribute Error:TopLevel::');
98- }
99- return $tmp;
100- } else {
101- return null;
102- }
83+ public static function fromRequiredTime(string $value): string {
84+ return $value; /*string*/
10385 }
10486
10587 /**
10688 * @throws Exception
107- * @return ?string
89+ * @return string
10890 */
109- public function toOptionalDateTime(): ?string {
110- if (TopLevel::validateOptionalDateTime($this->optionalDateTime)) {
111- if (!is_null($this->optionalDateTime)) {
112- return $this->optionalDateTime->format(DateTimeInterface::ISO8601);
113- } else {
114- return null;
115- }
91+ public function toRequiredTime(): string {
92+ if (TopLevel::validateRequiredTime($this->requiredTime)) {
93+ return $this->requiredTime; /*string*/
11694 }
117- throw new Exception('never get to this TopLevel::optionalDateTime');
95+ throw new Exception('never get to this TopLevel::requiredTime');
11896 }
11997
12098 /**
121- * @param DateTime|null
99+ * @param string
122100 * @return bool
123101 * @throws Exception
124102 */
125- public static function validateOptionalDateTime(?DateTime $value): bool {
126- if (!is_null($value)) {
127- if (!is_a($value, 'DateTime')) {
128- throw new Exception('Attribute Error:TopLevel::optionalDateTime');
129- }
130- }
103+ public static function validateRequiredTime(string $value): bool {
131104 return true;
132105 }
133106
134107 /**
135108 * @throws Exception
136- * @return ?DateTime
109+ * @return string
137110 */
138- public function getOptionalDateTime(): ?DateTime {
139- if (TopLevel::validateOptionalDateTime($this->optionalDateTime)) {
140- return $this->optionalDateTime;
111+ public function getRequiredTime(): string {
112+ if (TopLevel::validateRequiredTime($this->requiredTime)) {
113+ return $this->requiredTime;
141114 }
142- throw new Exception('never get to getOptionalDateTime TopLevel::optionalDateTime');
115+ throw new Exception('never get to getRequiredTime TopLevel::requiredTime');
143116 }
144117
145118 /**
146- * @return ?DateTime
119+ * @return string
147120 */
148- public static function sampleOptionalDateTime(): ?DateTime {
149- return DateTime::createFromFormat(DateTimeInterface::ISO8601, '2020-12-20T12:20:20+00:00');
121+ public static function sampleRequiredTime(): string {
122+ return 'TopLevel::requiredTime::32'; /*32:requiredTime*/
150123 }
151124
152125 /**
153- * @param ?string $value
126+ * @param string $value
154127 * @throws Exception
155- * @return ?string
128+ * @return DateTime
156129 */
157- public static function fromOptionalTime(?string $value): ?string {
158- if (!is_null($value)) {
159- return $value; /*string*/
160- } else {
161- return null;
130+ public static function fromRequiredDateTime(string $value): DateTime {
131+ $tmp = DateTime::createFromFormat(DateTimeInterface::ISO8601, $value);
132+ if (!is_a($tmp, 'DateTime')) {
133+ throw new Exception('Attribute Error:TopLevel::');
162134 }
135+ return $tmp;
163136 }
164137
165138 /**
166139 * @throws Exception
167- * @return ?string
140+ * @return string
168141 */
169- public function toOptionalTime(): ?string {
170- if (TopLevel::validateOptionalTime($this->optionalTime)) {
171- if (!is_null($this->optionalTime)) {
172- return $this->optionalTime; /*string*/
173- } else {
174- return null;
175- }
142+ public function toRequiredDateTime(): string {
143+ if (TopLevel::validateRequiredDateTime($this->requiredDateTime)) {
144+ return $this->requiredDateTime->format(DateTimeInterface::ISO8601);
176145 }
177- throw new Exception('never get to this TopLevel::optionalTime');
146+ throw new Exception('never get to this TopLevel::requiredDateTime');
178147 }
179148
180149 /**
181- * @param string|null
150+ * @param DateTime
182151 * @return bool
183152 * @throws Exception
184153 */
185- public static function validateOptionalTime(?string $value): bool {
186- if (!is_null($value)) {
154+ public static function validateRequiredDateTime(DateTime $value): bool {
155+ if (!is_a($value, 'DateTime')) {
156+ throw new Exception('Attribute Error:TopLevel::requiredDateTime');
187157 }
188158 return true;
189159 }
190160
191161 /**
192162 * @throws Exception
193- * @return ?string
163+ * @return DateTime
194164 */
195- public function getOptionalTime(): ?string {
196- if (TopLevel::validateOptionalTime($this->optionalTime)) {
197- return $this->optionalTime;
165+ public function getRequiredDateTime(): DateTime {
166+ if (TopLevel::validateRequiredDateTime($this->requiredDateTime)) {
167+ return $this->requiredDateTime;
198168 }
199- throw new Exception('never get to getOptionalTime TopLevel::optionalTime');
169+ throw new Exception('never get to getRequiredDateTime TopLevel::requiredDateTime');
200170 }
201171
202172 /**
203- * @return ?string
173+ * @return DateTime
204174 */
205- public static function sampleOptionalTime(): ?string {
206- return 'TopLevel::optionalTime::33'; /*33:optionalTime*/
175+ public static function sampleRequiredDateTime(): DateTime {
176+ return DateTime::createFromFormat(DateTimeInterface::ISO8601, '2020-12-30T12:30:30+00:00');
207177 }
208178
209179 /**
210- * @param string $value
180+ * @param ?string $value
211181 * @throws Exception
212- * @return string
182+ * @return ?string
213183 */
214- public static function fromRequiredDate(string $value): string {
215- return $value; /*string*/
184+ public static function fromOptionalDate(?string $value): ?string {
185+ if (!is_null($value)) {
186+ return $value; /*string*/
187+ } else {
188+ return null;
189+ }
216190 }
217191
218192 /**
219193 * @throws Exception
220- * @return string
194+ * @return ?string
221195 */
222- public function toRequiredDate(): string {
223- if (TopLevel::validateRequiredDate($this->requiredDate)) {
224- return $this->requiredDate; /*string*/
196+ public function toOptionalDate(): ?string {
197+ if (TopLevel::validateOptionalDate($this->optionalDate)) {
198+ if (!is_null($this->optionalDate)) {
199+ return $this->optionalDate; /*string*/
200+ } else {
201+ return null;
202+ }
225203 }
226- throw new Exception('never get to this TopLevel::requiredDate');
204+ throw new Exception('never get to this TopLevel::optionalDate');
227205 }
228206
229207 /**
230- * @param string
208+ * @param string|null
231209 * @return bool
232210 * @throws Exception
233211 */
234- public static function validateRequiredDate(string $value): bool {
212+ public static function validateOptionalDate(?string $value): bool {
213+ if (!is_null($value)) {
214+ }
235215 return true;
236216 }
237217
238218 /**
239219 * @throws Exception
240- * @return string
220+ * @return ?string
241221 */
242- public function getRequiredDate(): string {
243- if (TopLevel::validateRequiredDate($this->requiredDate)) {
244- return $this->requiredDate;
222+ public function getOptionalDate(): ?string {
223+ if (TopLevel::validateOptionalDate($this->optionalDate)) {
224+ return $this->optionalDate;
245225 }
246- throw new Exception('never get to getRequiredDate TopLevel::requiredDate');
226+ throw new Exception('never get to getOptionalDate TopLevel::optionalDate');
247227 }
248228
249229 /**
250- * @return string
230+ * @return ?string
251231 */
252- public static function sampleRequiredDate(): string {
253- return 'TopLevel::requiredDate::34'; /*34:requiredDate*/
232+ public static function sampleOptionalDate(): ?string {
233+ return 'TopLevel::optionalDate::34'; /*34:optionalDate*/
254234 }
255235
256236 /**
257- * @param string $value
237+ * @param ?string $value
258238 * @throws Exception
259- * @return DateTime
239+ * @return ?string
260240 */
261- public static function fromRequiredDateTime(string $value): DateTime {
262- $tmp = DateTime::createFromFormat(DateTimeInterface::ISO8601, $value);
263- if (!is_a($tmp, 'DateTime')) {
264- throw new Exception('Attribute Error:TopLevel::');
241+ public static function fromOptionalTime(?string $value): ?string {
242+ if (!is_null($value)) {
243+ return $value; /*string*/
244+ } else {
245+ return null;
265246 }
266- return $tmp;
267247 }
268248
269249 /**
270250 * @throws Exception
271- * @return string
251+ * @return ?string
272252 */
273- public function toRequiredDateTime(): string {
274- if (TopLevel::validateRequiredDateTime($this->requiredDateTime)) {
275- return $this->requiredDateTime->format(DateTimeInterface::ISO8601);
253+ public function toOptionalTime(): ?string {
254+ if (TopLevel::validateOptionalTime($this->optionalTime)) {
255+ if (!is_null($this->optionalTime)) {
256+ return $this->optionalTime; /*string*/
257+ } else {
258+ return null;
259+ }
276260 }
277- throw new Exception('never get to this TopLevel::requiredDateTime');
261+ throw new Exception('never get to this TopLevel::optionalTime');
278262 }
279263
280264 /**
281- * @param DateTime
265+ * @param string|null
282266 * @return bool
283267 * @throws Exception
284268 */
285- public static function validateRequiredDateTime(DateTime $value): bool {
286- if (!is_a($value, 'DateTime')) {
287- throw new Exception('Attribute Error:TopLevel::requiredDateTime');
269+ public static function validateOptionalTime(?string $value): bool {
270+ if (!is_null($value)) {
288271 }
289272 return true;
290273 }
291274
292275 /**
293276 * @throws Exception
294- * @return DateTime
277+ * @return ?string
295278 */
296- public function getRequiredDateTime(): DateTime {
297- if (TopLevel::validateRequiredDateTime($this->requiredDateTime)) {
298- return $this->requiredDateTime;
279+ public function getOptionalTime(): ?string {
280+ if (TopLevel::validateOptionalTime($this->optionalTime)) {
281+ return $this->optionalTime;
299282 }
300- throw new Exception('never get to getRequiredDateTime TopLevel::requiredDateTime');
283+ throw new Exception('never get to getOptionalTime TopLevel::optionalTime');
301284 }
302285
303286 /**
304- * @return DateTime
287+ * @return ?string
305288 */
306- public static function sampleRequiredDateTime(): DateTime {
307- return DateTime::createFromFormat(DateTimeInterface::ISO8601, '2020-12-50T12:50:50+00:00');
289+ public static function sampleOptionalTime(): ?string {
290+ return 'TopLevel::optionalTime::35'; /*35:optionalTime*/
308291 }
309292
310293 /**
311- * @param string $value
294+ * @param ?string $value
312295 * @throws Exception
313- * @return string
296+ * @return ?DateTime
314297 */
315- public static function fromRequiredTime(string $value): string {
316- return $value; /*string*/
298+ public static function fromOptionalDateTime(?string $value): ?DateTime {
299+ if (!is_null($value)) {
300+ $tmp = DateTime::createFromFormat(DateTimeInterface::ISO8601, $value);
301+ if (!is_a($tmp, 'DateTime')) {
302+ throw new Exception('Attribute Error:TopLevel::');
303+ }
304+ return $tmp;
305+ } else {
306+ return null;
307+ }
317308 }
318309
319310 /**
320311 * @throws Exception
321- * @return string
312+ * @return ?string
322313 */
323- public function toRequiredTime(): string {
324- if (TopLevel::validateRequiredTime($this->requiredTime)) {
325- return $this->requiredTime; /*string*/
314+ public function toOptionalDateTime(): ?string {
315+ if (TopLevel::validateOptionalDateTime($this->optionalDateTime)) {
316+ if (!is_null($this->optionalDateTime)) {
317+ return $this->optionalDateTime->format(DateTimeInterface::ISO8601);
318+ } else {
319+ return null;
320+ }
326321 }
327- throw new Exception('never get to this TopLevel::requiredTime');
322+ throw new Exception('never get to this TopLevel::optionalDateTime');
328323 }
329324
330325 /**
331- * @param string
326+ * @param DateTime|null
332327 * @return bool
333328 * @throws Exception
334329 */
335- public static function validateRequiredTime(string $value): bool {
330+ public static function validateOptionalDateTime(?DateTime $value): bool {
331+ if (!is_null($value)) {
332+ if (!is_a($value, 'DateTime')) {
333+ throw new Exception('Attribute Error:TopLevel::optionalDateTime');
334+ }
335+ }
336336 return true;
337337 }
338338
339339 /**
340340 * @throws Exception
341- * @return string
341+ * @return ?DateTime
342342 */
343- public function getRequiredTime(): string {
344- if (TopLevel::validateRequiredTime($this->requiredTime)) {
345- return $this->requiredTime;
343+ public function getOptionalDateTime(): ?DateTime {
344+ if (TopLevel::validateOptionalDateTime($this->optionalDateTime)) {
345+ return $this->optionalDateTime;
346346 }
347- throw new Exception('never get to getRequiredTime TopLevel::requiredTime');
347+ throw new Exception('never get to getOptionalDateTime TopLevel::optionalDateTime');
348348 }
349349
350350 /**
351- * @return string
351+ * @return ?DateTime
352352 */
353- public static function sampleRequiredTime(): string {
354- return 'TopLevel::requiredTime::36'; /*36:requiredTime*/
353+ public static function sampleOptionalDateTime(): ?DateTime {
354+ return DateTime::createFromFormat(DateTimeInterface::ISO8601, '2020-12-60T12:60:60+00:00');
355355 }
356356
357357 /**
@@ -359,12 +359,12 @@ class TopLevel {
359359 * @return bool
360360 */
361361 public function validate(): bool {
362- return TopLevel::validateOptionalDate($this->optionalDate)
363- || TopLevel::validateOptionalDateTime($this->optionalDateTime)
364- || TopLevel::validateOptionalTime($this->optionalTime)
365- || TopLevel::validateRequiredDate($this->requiredDate)
362+ return TopLevel::validateRequiredDate($this->requiredDate)
363+ || TopLevel::validateRequiredTime($this->requiredTime)
366364 || TopLevel::validateRequiredDateTime($this->requiredDateTime)
367- || TopLevel::validateRequiredTime($this->requiredTime);
365+ || TopLevel::validateOptionalDate($this->optionalDate)
366+ || TopLevel::validateOptionalTime($this->optionalTime)
367+ || TopLevel::validateOptionalDateTime($this->optionalDateTime);
368368 }
369369
370370 /**
@@ -373,12 +373,12 @@ class TopLevel {
373373 */
374374 public function to(): stdClass {
375375 $out = new stdClass();
376- $out->{'optional-date'} = $this->toOptionalDate();
377- $out->{'optional-date-time'} = $this->toOptionalDateTime();
378- $out->{'optional-time'} = $this->toOptionalTime();
379376 $out->{'required-date'} = $this->toRequiredDate();
380- $out->{'required-date-time'} = $this->toRequiredDateTime();
381377 $out->{'required-time'} = $this->toRequiredTime();
378+ $out->{'required-date-time'} = $this->toRequiredDateTime();
379+ $out->{'optional-date'} = $this->toOptionalDate();
380+ $out->{'optional-time'} = $this->toOptionalTime();
381+ $out->{'optional-date-time'} = $this->toOptionalDateTime();
382382 return $out;
383383 }
384384
@@ -389,12 +389,12 @@ class TopLevel {
389389 */
390390 public static function from(stdClass $obj): TopLevel {
391391 return new TopLevel(
392- TopLevel::fromOptionalDate($obj->{'optional-date'})
393- ,TopLevel::fromOptionalDateTime($obj->{'optional-date-time'})
394- ,TopLevel::fromOptionalTime($obj->{'optional-time'})
395- ,TopLevel::fromRequiredDate($obj->{'required-date'})
396- ,TopLevel::fromRequiredDateTime($obj->{'required-date-time'})
392+ TopLevel::fromRequiredDate($obj->{'required-date'})
397393 ,TopLevel::fromRequiredTime($obj->{'required-time'})
394+ ,TopLevel::fromRequiredDateTime($obj->{'required-date-time'})
395+ ,TopLevel::fromOptionalDate($obj->{'optional-date'})
396+ ,TopLevel::fromOptionalTime($obj->{'optional-time'})
397+ ,TopLevel::fromOptionalDateTime($obj->{'optional-date-time'})
398398 );
399399 }
400400
@@ -403,12 +403,12 @@ class TopLevel {
403403 */
404404 public static function sample(): TopLevel {
405405 return new TopLevel(
406- TopLevel::sampleOptionalDate()
407- ,TopLevel::sampleOptionalDateTime()
408- ,TopLevel::sampleOptionalTime()
409- ,TopLevel::sampleRequiredDate()
410- ,TopLevel::sampleRequiredDateTime()
406+ TopLevel::sampleRequiredDate()
411407 ,TopLevel::sampleRequiredTime()
408+ ,TopLevel::sampleRequiredDateTime()
409+ ,TopLevel::sampleOptionalDate()
410+ ,TopLevel::sampleOptionalTime()
411+ ,TopLevel::sampleOptionalDateTime()
412412 );
413413 }
414414 }
Mschema-php/test/inputs/schema/prefix-items.schema/default/TopLevel.php+43 −43
@@ -4,16 +4,16 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private array $open; // json:open Required
87 private array $tuple; // json:tuple Required
8+ private array $open; // json:open Required
99
1010 /**
11- * @param array $open
1211 * @param array $tuple
12+ * @param array $open
1313 */
14- public function __construct(array $open, array $tuple) {
15- $this->open = $open;
14+ public function __construct(array $tuple, array $open) {
1615 $this->tuple = $tuple;
16+ $this->open = $open;
1717 }
1818
1919 /**
@@ -21,7 +21,7 @@ class TopLevel {
2121 * @throws Exception
2222 * @return array
2323 */
24- public static function fromOpen(array $value): array {
24+ public static function fromTuple(array $value): array {
2525 return array_map(function ($value) {
2626 if (is_bool($value)) {
2727 return $value; /*bool*/
@@ -37,8 +37,8 @@ class TopLevel {
3737 * @throws Exception
3838 * @return array
3939 */
40- public function toOpen(): array {
41- if (TopLevel::validateOpen($this->open)) {
40+ public function toTuple(): array {
41+ if (TopLevel::validateTuple($this->tuple)) {
4242 return array_map(function ($value) {
4343 if (is_bool($value)) {
4444 return $value; /*bool*/
@@ -47,9 +47,9 @@ class TopLevel {
4747 } else {
4848 throw new Exception('Union value has no matching member in TopLevel');
4949 }
50- }, $this->open);
50+ }, $this->tuple);
5151 }
52- throw new Exception('never get to this TopLevel::open');
52+ throw new Exception('never get to this TopLevel::tuple');
5353 }
5454
5555 /**
@@ -57,21 +57,21 @@ class TopLevel {
5757 * @return bool
5858 * @throws Exception
5959 */
60- public static function validateOpen(array $value): bool {
60+ public static function validateTuple(array $value): bool {
6161 if (!is_array($value)) {
62- throw new Exception("Attribute Error:TopLevel::open");
62+ throw new Exception("Attribute Error:TopLevel::tuple");
6363 }
6464 array_walk($value, function($value_v) {
6565 if (is_bool($value_v)) {
6666 if (!is_bool($value_v)) {
67- throw new Exception("Attribute Error:TopLevel::open");
67+ throw new Exception("Attribute Error:TopLevel::tuple");
6868 }
6969 } elseif (is_int($value_v)) {
7070 if (!is_integer($value_v)) {
71- throw new Exception("Attribute Error:TopLevel::open");
71+ throw new Exception("Attribute Error:TopLevel::tuple");
7272 }
7373 } else {
74- throw new Exception("Attribute Error:TopLevel::open");
74+ throw new Exception("Attribute Error:TopLevel::tuple");
7575 }
7676 });
7777 return true;
@@ -81,20 +81,20 @@ class TopLevel {
8181 * @throws Exception
8282 * @return array
8383 */
84- public function getOpen(): array {
85- if (TopLevel::validateOpen($this->open)) {
86- return $this->open;
84+ public function getTuple(): array {
85+ if (TopLevel::validateTuple($this->tuple)) {
86+ return $this->tuple;
8787 }
88- throw new Exception('never get to getOpen TopLevel::open');
88+ throw new Exception('never get to getTuple TopLevel::tuple');
8989 }
9090
9191 /**
9292 * @return array
9393 */
94- public static function sampleOpen(): array {
94+ public static function sampleTuple(): array {
9595 return array(
9696 true /*31:*/
97- ); /* 31:open*/
97+ ); /* 31:tuple*/
9898 }
9999
100100 /**
@@ -102,7 +102,7 @@ class TopLevel {
102102 * @throws Exception
103103 * @return array
104104 */
105- public static function fromTuple(array $value): array {
105+ public static function fromOpen(array $value): array {
106106 return array_map(function ($value) {
107107 if (is_bool($value)) {
108108 return $value; /*bool*/
@@ -118,8 +118,8 @@ class TopLevel {
118118 * @throws Exception
119119 * @return array
120120 */
121- public function toTuple(): array {
122- if (TopLevel::validateTuple($this->tuple)) {
121+ public function toOpen(): array {
122+ if (TopLevel::validateOpen($this->open)) {
123123 return array_map(function ($value) {
124124 if (is_bool($value)) {
125125 return $value; /*bool*/
@@ -128,9 +128,9 @@ class TopLevel {
128128 } else {
129129 throw new Exception('Union value has no matching member in TopLevel');
130130 }
131- }, $this->tuple);
131+ }, $this->open);
132132 }
133- throw new Exception('never get to this TopLevel::tuple');
133+ throw new Exception('never get to this TopLevel::open');
134134 }
135135
136136 /**
@@ -138,21 +138,21 @@ class TopLevel {
138138 * @return bool
139139 * @throws Exception
140140 */
141- public static function validateTuple(array $value): bool {
141+ public static function validateOpen(array $value): bool {
142142 if (!is_array($value)) {
143- throw new Exception("Attribute Error:TopLevel::tuple");
143+ throw new Exception("Attribute Error:TopLevel::open");
144144 }
145145 array_walk($value, function($value_v) {
146146 if (is_bool($value_v)) {
147147 if (!is_bool($value_v)) {
148- throw new Exception("Attribute Error:TopLevel::tuple");
148+ throw new Exception("Attribute Error:TopLevel::open");
149149 }
150150 } elseif (is_int($value_v)) {
151151 if (!is_integer($value_v)) {
152- throw new Exception("Attribute Error:TopLevel::tuple");
152+ throw new Exception("Attribute Error:TopLevel::open");
153153 }
154154 } else {
155- throw new Exception("Attribute Error:TopLevel::tuple");
155+ throw new Exception("Attribute Error:TopLevel::open");
156156 }
157157 });
158158 return true;
@@ -162,20 +162,20 @@ class TopLevel {
162162 * @throws Exception
163163 * @return array
164164 */
165- public function getTuple(): array {
166- if (TopLevel::validateTuple($this->tuple)) {
167- return $this->tuple;
165+ public function getOpen(): array {
166+ if (TopLevel::validateOpen($this->open)) {
167+ return $this->open;
168168 }
169- throw new Exception('never get to getTuple TopLevel::tuple');
169+ throw new Exception('never get to getOpen TopLevel::open');
170170 }
171171
172172 /**
173173 * @return array
174174 */
175- public static function sampleTuple(): array {
175+ public static function sampleOpen(): array {
176176 return array(
177177 true /*32:*/
178- ); /* 32:tuple*/
178+ ); /* 32:open*/
179179 }
180180
181181 /**
@@ -183,8 +183,8 @@ class TopLevel {
183183 * @return bool
184184 */
185185 public function validate(): bool {
186- return TopLevel::validateOpen($this->open)
187- || TopLevel::validateTuple($this->tuple);
186+ return TopLevel::validateTuple($this->tuple)
187+ || TopLevel::validateOpen($this->open);
188188 }
189189
190190 /**
@@ -193,8 +193,8 @@ class TopLevel {
193193 */
194194 public function to(): stdClass {
195195 $out = new stdClass();
196- $out->{'open'} = $this->toOpen();
197196 $out->{'tuple'} = $this->toTuple();
197+ $out->{'open'} = $this->toOpen();
198198 return $out;
199199 }
200200
@@ -205,8 +205,8 @@ class TopLevel {
205205 */
206206 public static function from(stdClass $obj): TopLevel {
207207 return new TopLevel(
208- TopLevel::fromOpen($obj->{'open'})
209- ,TopLevel::fromTuple($obj->{'tuple'})
208+ TopLevel::fromTuple($obj->{'tuple'})
209+ ,TopLevel::fromOpen($obj->{'open'})
210210 );
211211 }
212212
@@ -215,8 +215,8 @@ class TopLevel {
215215 */
216216 public static function sample(): TopLevel {
217217 return new TopLevel(
218- TopLevel::sampleOpen()
219- ,TopLevel::sampleTuple()
218+ TopLevel::sampleTuple()
219+ ,TopLevel::sampleOpen()
220220 );
221221 }
222222 }
Aschema-php/test/inputs/schema/property-order.schema/default/TopLevel.php+577 −0
@@ -0,0 +1,577 @@
1+<?php
2+declare(strict_types=1);
3+
4+// This is an autogenerated file:TopLevel
5+
6+class TopLevel {
7+ private string $zebra; // json:zebra Required
8+ private float $mango; // json:mango Required
9+ private bool $apple; // json:apple Required
10+ private string $delta; // json:delta Required
11+ private int $banana; // json:banana Required
12+ private Ordered $ordered; // json:ordered Required
13+
14+ /**
15+ * @param string $zebra
16+ * @param float $mango
17+ * @param bool $apple
18+ * @param string $delta
19+ * @param int $banana
20+ * @param Ordered $ordered
21+ */
22+ public function __construct(string $zebra, float $mango, bool $apple, string $delta, int $banana, Ordered $ordered) {
23+ $this->zebra = $zebra;
24+ $this->mango = $mango;
25+ $this->apple = $apple;
26+ $this->delta = $delta;
27+ $this->banana = $banana;
28+ $this->ordered = $ordered;
29+ }
30+
31+ /**
32+ * @param string $value
33+ * @throws Exception
34+ * @return string
35+ */
36+ public static function fromZebra(string $value): string {
37+ return $value; /*string*/
38+ }
39+
40+ /**
41+ * @throws Exception
42+ * @return string
43+ */
44+ public function toZebra(): string {
45+ if (TopLevel::validateZebra($this->zebra)) {
46+ return $this->zebra; /*string*/
47+ }
48+ throw new Exception('never get to this TopLevel::zebra');
49+ }
50+
51+ /**
52+ * @param string
53+ * @return bool
54+ * @throws Exception
55+ */
56+ public static function validateZebra(string $value): bool {
57+ return true;
58+ }
59+
60+ /**
61+ * @throws Exception
62+ * @return string
63+ */
64+ public function getZebra(): string {
65+ if (TopLevel::validateZebra($this->zebra)) {
66+ return $this->zebra;
67+ }
68+ throw new Exception('never get to getZebra TopLevel::zebra');
69+ }
70+
71+ /**
72+ * @return string
73+ */
74+ public static function sampleZebra(): string {
75+ return 'TopLevel::zebra::31'; /*31:zebra*/
76+ }
77+
78+ /**
79+ * @param float $value
80+ * @throws Exception
81+ * @return float
82+ */
83+ public static function fromMango(float $value): float {
84+ return $value; /*float*/
85+ }
86+
87+ /**
88+ * @throws Exception
89+ * @return float
90+ */
91+ public function toMango(): float {
92+ if (TopLevel::validateMango($this->mango)) {
93+ return $this->mango; /*float*/
94+ }
95+ throw new Exception('never get to this TopLevel::mango');
96+ }
97+
98+ /**
99+ * @param float
100+ * @return bool
101+ * @throws Exception
102+ */
103+ public static function validateMango(float $value): bool {
104+ return true;
105+ }
106+
107+ /**
108+ * @throws Exception
109+ * @return float
110+ */
111+ public function getMango(): float {
112+ if (TopLevel::validateMango($this->mango)) {
113+ return $this->mango;
114+ }
115+ throw new Exception('never get to getMango TopLevel::mango');
116+ }
117+
118+ /**
119+ * @return float
120+ */
121+ public static function sampleMango(): float {
122+ return 32.032; /*32:mango*/
123+ }
124+
125+ /**
126+ * @param bool $value
127+ * @throws Exception
128+ * @return bool
129+ */
130+ public static function fromApple(bool $value): bool {
131+ return $value; /*bool*/
132+ }
133+
134+ /**
135+ * @throws Exception
136+ * @return bool
137+ */
138+ public function toApple(): bool {
139+ if (TopLevel::validateApple($this->apple)) {
140+ return $this->apple; /*bool*/
141+ }
142+ throw new Exception('never get to this TopLevel::apple');
143+ }
144+
145+ /**
146+ * @param bool
147+ * @return bool
148+ * @throws Exception
149+ */
150+ public static function validateApple(bool $value): bool {
151+ return true;
152+ }
153+
154+ /**
155+ * @throws Exception
156+ * @return bool
157+ */
158+ public function getApple(): bool {
159+ if (TopLevel::validateApple($this->apple)) {
160+ return $this->apple;
161+ }
162+ throw new Exception('never get to getApple TopLevel::apple');
163+ }
164+
165+ /**
166+ * @return bool
167+ */
168+ public static function sampleApple(): bool {
169+ return true; /*33:apple*/
170+ }
171+
172+ /**
173+ * @param string $value
174+ * @throws Exception
175+ * @return string
176+ */
177+ public static function fromDelta(string $value): string {
178+ return $value; /*string*/
179+ }
180+
181+ /**
182+ * @throws Exception
183+ * @return string
184+ */
185+ public function toDelta(): string {
186+ if (TopLevel::validateDelta($this->delta)) {
187+ return $this->delta; /*string*/
188+ }
189+ throw new Exception('never get to this TopLevel::delta');
190+ }
191+
192+ /**
193+ * @param string
194+ * @return bool
195+ * @throws Exception
196+ */
197+ public static function validateDelta(string $value): bool {
198+ return true;
199+ }
200+
201+ /**
202+ * @throws Exception
203+ * @return string
204+ */
205+ public function getDelta(): string {
206+ if (TopLevel::validateDelta($this->delta)) {
207+ return $this->delta;
208+ }
209+ throw new Exception('never get to getDelta TopLevel::delta');
210+ }
211+
212+ /**
213+ * @return string
214+ */
215+ public static function sampleDelta(): string {
216+ return 'TopLevel::delta::34'; /*34:delta*/
217+ }
218+
219+ /**
220+ * @param int $value
221+ * @throws Exception
222+ * @return int
223+ */
224+ public static function fromBanana(int $value): int {
225+ return $value; /*int*/
226+ }
227+
228+ /**
229+ * @throws Exception
230+ * @return int
231+ */
232+ public function toBanana(): int {
233+ if (TopLevel::validateBanana($this->banana)) {
234+ return $this->banana; /*int*/
235+ }
236+ throw new Exception('never get to this TopLevel::banana');
237+ }
238+
239+ /**
240+ * @param int
241+ * @return bool
242+ * @throws Exception
243+ */
244+ public static function validateBanana(int $value): bool {
245+ return true;
246+ }
247+
248+ /**
249+ * @throws Exception
250+ * @return int
251+ */
252+ public function getBanana(): int {
253+ if (TopLevel::validateBanana($this->banana)) {
254+ return $this->banana;
255+ }
256+ throw new Exception('never get to getBanana TopLevel::banana');
257+ }
258+
259+ /**
260+ * @return int
261+ */
262+ public static function sampleBanana(): int {
263+ return 35; /*35:banana*/
264+ }
265+
266+ /**
267+ * @param stdClass $value
268+ * @throws Exception
269+ * @return Ordered
270+ */
271+ public static function fromOrdered(stdClass $value): Ordered {
272+ return Ordered::from($value); /*class*/
273+ }
274+
275+ /**
276+ * @throws Exception
277+ * @return stdClass
278+ */
279+ public function toOrdered(): stdClass {
280+ if (TopLevel::validateOrdered($this->ordered)) {
281+ return $this->ordered->to(); /*class*/
282+ }
283+ throw new Exception('never get to this TopLevel::ordered');
284+ }
285+
286+ /**
287+ * @param Ordered
288+ * @return bool
289+ * @throws Exception
290+ */
291+ public static function validateOrdered(Ordered $value): bool {
292+ $value->validate();
293+ return true;
294+ }
295+
296+ /**
297+ * @throws Exception
298+ * @return Ordered
299+ */
300+ public function getOrdered(): Ordered {
301+ if (TopLevel::validateOrdered($this->ordered)) {
302+ return $this->ordered;
303+ }
304+ throw new Exception('never get to getOrdered TopLevel::ordered');
305+ }
306+
307+ /**
308+ * @return Ordered
309+ */
310+ public static function sampleOrdered(): Ordered {
311+ return Ordered::sample(); /*36:ordered*/
312+ }
313+
314+ /**
315+ * @throws Exception
316+ * @return bool
317+ */
318+ public function validate(): bool {
319+ return TopLevel::validateZebra($this->zebra)
320+ || TopLevel::validateMango($this->mango)
321+ || TopLevel::validateApple($this->apple)
322+ || TopLevel::validateDelta($this->delta)
323+ || TopLevel::validateBanana($this->banana)
324+ || TopLevel::validateOrdered($this->ordered);
325+ }
326+
327+ /**
328+ * @return stdClass
329+ * @throws Exception
330+ */
331+ public function to(): stdClass {
332+ $out = new stdClass();
333+ $out->{'zebra'} = $this->toZebra();
334+ $out->{'mango'} = $this->toMango();
335+ $out->{'apple'} = $this->toApple();
336+ $out->{'delta'} = $this->toDelta();
337+ $out->{'banana'} = $this->toBanana();
338+ $out->{'ordered'} = $this->toOrdered();
339+ return $out;
340+ }
341+
342+ /**
343+ * @param stdClass $obj
344+ * @return TopLevel
345+ * @throws Exception
346+ */
347+ public static function from(stdClass $obj): TopLevel {
348+ return new TopLevel(
349+ TopLevel::fromZebra($obj->{'zebra'})
350+ ,TopLevel::fromMango($obj->{'mango'})
351+ ,TopLevel::fromApple($obj->{'apple'})
352+ ,TopLevel::fromDelta($obj->{'delta'})
353+ ,TopLevel::fromBanana($obj->{'banana'})
354+ ,TopLevel::fromOrdered($obj->{'ordered'})
355+ );
356+ }
357+
358+ /**
359+ * @return TopLevel
360+ */
361+ public static function sample(): TopLevel {
362+ return new TopLevel(
363+ TopLevel::sampleZebra()
364+ ,TopLevel::sampleMango()
365+ ,TopLevel::sampleApple()
366+ ,TopLevel::sampleDelta()
367+ ,TopLevel::sampleBanana()
368+ ,TopLevel::sampleOrdered()
369+ );
370+ }
371+}
372+
373+// This is an autogenerated file:Ordered
374+
375+class Ordered {
376+ private float $mango; // json:mango Required
377+ private string $zebra; // json:zebra Required
378+ private bool $apple; // json:apple Required
379+
380+ /**
381+ * @param float $mango
382+ * @param string $zebra
383+ * @param bool $apple
384+ */
385+ public function __construct(float $mango, string $zebra, bool $apple) {
386+ $this->mango = $mango;
387+ $this->zebra = $zebra;
388+ $this->apple = $apple;
389+ }
390+
391+ /**
392+ * @param float $value
393+ * @throws Exception
394+ * @return float
395+ */
396+ public static function fromMango(float $value): float {
397+ return $value; /*float*/
398+ }
399+
400+ /**
401+ * @throws Exception
402+ * @return float
403+ */
404+ public function toMango(): float {
405+ if (Ordered::validateMango($this->mango)) {
406+ return $this->mango; /*float*/
407+ }
408+ throw new Exception('never get to this Ordered::mango');
409+ }
410+
411+ /**
412+ * @param float
413+ * @return bool
414+ * @throws Exception
415+ */
416+ public static function validateMango(float $value): bool {
417+ return true;
418+ }
419+
420+ /**
421+ * @throws Exception
422+ * @return float
423+ */
424+ public function getMango(): float {
425+ if (Ordered::validateMango($this->mango)) {
426+ return $this->mango;
427+ }
428+ throw new Exception('never get to getMango Ordered::mango');
429+ }
430+
431+ /**
432+ * @return float
433+ */
434+ public static function sampleMango(): float {
435+ return 31.031; /*31:mango*/
436+ }
437+
438+ /**
439+ * @param string $value
440+ * @throws Exception
441+ * @return string
442+ */
443+ public static function fromZebra(string $value): string {
444+ return $value; /*string*/
445+ }
446+
447+ /**
448+ * @throws Exception
449+ * @return string
450+ */
451+ public function toZebra(): string {
452+ if (Ordered::validateZebra($this->zebra)) {
453+ return $this->zebra; /*string*/
454+ }
455+ throw new Exception('never get to this Ordered::zebra');
456+ }
457+
458+ /**
459+ * @param string
460+ * @return bool
461+ * @throws Exception
462+ */
463+ public static function validateZebra(string $value): bool {
464+ return true;
465+ }
466+
467+ /**
468+ * @throws Exception
469+ * @return string
470+ */
471+ public function getZebra(): string {
472+ if (Ordered::validateZebra($this->zebra)) {
473+ return $this->zebra;
474+ }
475+ throw new Exception('never get to getZebra Ordered::zebra');
476+ }
477+
478+ /**
479+ * @return string
480+ */
481+ public static function sampleZebra(): string {
482+ return 'Ordered::zebra::32'; /*32:zebra*/
483+ }
484+
485+ /**
486+ * @param bool $value
487+ * @throws Exception
488+ * @return bool
489+ */
490+ public static function fromApple(bool $value): bool {
491+ return $value; /*bool*/
492+ }
493+
494+ /**
495+ * @throws Exception
496+ * @return bool
497+ */
498+ public function toApple(): bool {
499+ if (Ordered::validateApple($this->apple)) {
500+ return $this->apple; /*bool*/
501+ }
502+ throw new Exception('never get to this Ordered::apple');
503+ }
504+
505+ /**
506+ * @param bool
507+ * @return bool
508+ * @throws Exception
509+ */
510+ public static function validateApple(bool $value): bool {
511+ return true;
512+ }
513+
514+ /**
515+ * @throws Exception
516+ * @return bool
517+ */
518+ public function getApple(): bool {
519+ if (Ordered::validateApple($this->apple)) {
520+ return $this->apple;
521+ }
522+ throw new Exception('never get to getApple Ordered::apple');
523+ }
524+
525+ /**
526+ * @return bool
527+ */
528+ public static function sampleApple(): bool {
529+ return true; /*33:apple*/
530+ }
531+
532+ /**
533+ * @throws Exception
534+ * @return bool
535+ */
536+ public function validate(): bool {
537+ return Ordered::validateMango($this->mango)
538+ || Ordered::validateZebra($this->zebra)
539+ || Ordered::validateApple($this->apple);
540+ }
541+
542+ /**
543+ * @return stdClass
544+ * @throws Exception
545+ */
546+ public function to(): stdClass {
547+ $out = new stdClass();
548+ $out->{'mango'} = $this->toMango();
549+ $out->{'zebra'} = $this->toZebra();
550+ $out->{'apple'} = $this->toApple();
551+ return $out;
552+ }
553+
554+ /**
555+ * @param stdClass $obj
556+ * @return Ordered
557+ * @throws Exception
558+ */
559+ public static function from(stdClass $obj): Ordered {
560+ return new Ordered(
561+ Ordered::fromMango($obj->{'mango'})
562+ ,Ordered::fromZebra($obj->{'zebra'})
563+ ,Ordered::fromApple($obj->{'apple'})
564+ );
565+ }
566+
567+ /**
568+ * @return Ordered
569+ */
570+ public static function sample(): Ordered {
571+ return new Ordered(
572+ Ordered::sampleMango()
573+ ,Ordered::sampleZebra()
574+ ,Ordered::sampleApple()
575+ );
576+ }
577+}
Mschema-php/test/inputs/schema/renaming-bug.schema/default/TopLevel.php+368 −368
@@ -265,18 +265,18 @@ class TopLevel {
265265
266266 class Fruit {
267267 private ?bool $apple; // json:apple Optional
268- private ?array $berries; // json:berries Optional
269268 private ?bool $orange; // json:orange Optional
269+ private ?array $berries; // json:berries Optional
270270
271271 /**
272272 * @param bool|null $apple
273- * @param array|null $berries
274273 * @param bool|null $orange
274+ * @param array|null $berries
275275 */
276- public function __construct(?bool $apple, ?array $berries, ?bool $orange) {
276+ public function __construct(?bool $apple, ?bool $orange, ?array $berries) {
277277 $this->apple = $apple;
278- $this->berries = $berries;
279278 $this->orange = $orange;
279+ $this->berries = $berries;
280280 }
281281
282282 /**
@@ -337,15 +337,13 @@ class Fruit {
337337 }
338338
339339 /**
340- * @param ?array $value
340+ * @param ?bool $value
341341 * @throws Exception
342- * @return ?array
342+ * @return ?bool
343343 */
344- public static function fromBerries(?array $value): ?array {
344+ public static function fromOrange(?bool $value): ?bool {
345345 if (!is_null($value)) {
346- return array_map(function ($value) {
347- return Berry::from($value); /*class*/
348- }, $value);
346+ return $value; /*bool*/
349347 } else {
350348 return null;
351349 }
@@ -353,66 +351,58 @@ class Fruit {
353351
354352 /**
355353 * @throws Exception
356- * @return ?array
354+ * @return ?bool
357355 */
358- public function toBerries(): ?array {
359- if (Fruit::validateBerries($this->berries)) {
360- if (!is_null($this->berries)) {
361- return array_map(function ($value) {
362- return $value->to(); /*class*/
363- }, $this->berries);
356+ public function toOrange(): ?bool {
357+ if (Fruit::validateOrange($this->orange)) {
358+ if (!is_null($this->orange)) {
359+ return $this->orange; /*bool*/
364360 } else {
365361 return null;
366362 }
367363 }
368- throw new Exception('never get to this Fruit::berries');
364+ throw new Exception('never get to this Fruit::orange');
369365 }
370366
371367 /**
372- * @param array|null
368+ * @param bool|null
373369 * @return bool
374370 * @throws Exception
375371 */
376- public static function validateBerries(?array $value): bool {
372+ public static function validateOrange(?bool $value): bool {
377373 if (!is_null($value)) {
378- if (!is_array($value)) {
379- throw new Exception("Attribute Error:Fruit::berries");
380- }
381- array_walk($value, function($value_v) {
382- $value_v->validate();
383- });
384374 }
385375 return true;
386376 }
387377
388378 /**
389379 * @throws Exception
390- * @return ?array
380+ * @return ?bool
391381 */
392- public function getBerries(): ?array {
393- if (Fruit::validateBerries($this->berries)) {
394- return $this->berries;
382+ public function getOrange(): ?bool {
383+ if (Fruit::validateOrange($this->orange)) {
384+ return $this->orange;
395385 }
396- throw new Exception('never get to getBerries Fruit::berries');
386+ throw new Exception('never get to getOrange Fruit::orange');
397387 }
398388
399389 /**
400- * @return ?array
390+ * @return ?bool
401391 */
402- public static function sampleBerries(): ?array {
403- return array(
404- Berry::sample() /*32:*/
405- ); /* 32:berries*/
392+ public static function sampleOrange(): ?bool {
393+ return true; /*32:orange*/
406394 }
407395
408396 /**
409- * @param ?bool $value
397+ * @param ?array $value
410398 * @throws Exception
411- * @return ?bool
399+ * @return ?array
412400 */
413- public static function fromOrange(?bool $value): ?bool {
401+ public static function fromBerries(?array $value): ?array {
414402 if (!is_null($value)) {
415- return $value; /*bool*/
403+ return array_map(function ($value) {
404+ return Berry::from($value); /*class*/
405+ }, $value);
416406 } else {
417407 return null;
418408 }
@@ -420,46 +410,56 @@ class Fruit {
420410
421411 /**
422412 * @throws Exception
423- * @return ?bool
413+ * @return ?array
424414 */
425- public function toOrange(): ?bool {
426- if (Fruit::validateOrange($this->orange)) {
427- if (!is_null($this->orange)) {
428- return $this->orange; /*bool*/
415+ public function toBerries(): ?array {
416+ if (Fruit::validateBerries($this->berries)) {
417+ if (!is_null($this->berries)) {
418+ return array_map(function ($value) {
419+ return $value->to(); /*class*/
420+ }, $this->berries);
429421 } else {
430422 return null;
431423 }
432424 }
433- throw new Exception('never get to this Fruit::orange');
425+ throw new Exception('never get to this Fruit::berries');
434426 }
435427
436428 /**
437- * @param bool|null
429+ * @param array|null
438430 * @return bool
439431 * @throws Exception
440432 */
441- public static function validateOrange(?bool $value): bool {
433+ public static function validateBerries(?array $value): bool {
442434 if (!is_null($value)) {
435+ if (!is_array($value)) {
436+ throw new Exception("Attribute Error:Fruit::berries");
437+ }
438+ array_walk($value, function($value_v) {
439+ $value_v->validate();
440+ });
443441 }
444442 return true;
445443 }
446444
447445 /**
448446 * @throws Exception
449- * @return ?bool
447+ * @return ?array
450448 */
451- public function getOrange(): ?bool {
452- if (Fruit::validateOrange($this->orange)) {
453- return $this->orange;
449+ public function getBerries(): ?array {
450+ if (Fruit::validateBerries($this->berries)) {
451+ return $this->berries;
454452 }
455- throw new Exception('never get to getOrange Fruit::orange');
453+ throw new Exception('never get to getBerries Fruit::berries');
456454 }
457455
458456 /**
459- * @return ?bool
457+ * @return ?array
460458 */
461- public static function sampleOrange(): ?bool {
462- return true; /*33:orange*/
459+ public static function sampleBerries(): ?array {
460+ return array(
461+ Berry::sample() /*33:*/
462+ ); /* 33:berries*/
463463 }
464464
465465 /**
@@ -468,8 +468,8 @@ class Fruit {
468468 */
469469 public function validate(): bool {
470470 return Fruit::validateApple($this->apple)
471- || Fruit::validateBerries($this->berries)
472- || Fruit::validateOrange($this->orange);
471+ || Fruit::validateOrange($this->orange)
472+ || Fruit::validateBerries($this->berries);
473473 }
474474
475475 /**
@@ -479,8 +479,8 @@ class Fruit {
479479 public function to(): stdClass {
480480 $out = new stdClass();
481481 $out->{'apple'} = $this->toApple();
482- $out->{'berries'} = $this->toBerries();
483482 $out->{'orange'} = $this->toOrange();
483+ $out->{'berries'} = $this->toBerries();
484484 return $out;
485485 }
486486
@@ -492,8 +492,8 @@ class Fruit {
492492 public static function from(stdClass $obj): Fruit {
493493 return new Fruit(
494494 Fruit::fromApple($obj->{'apple'})
495- ,Fruit::fromBerries($obj->{'berries'})
496495 ,Fruit::fromOrange($obj->{'orange'})
496+ ,Fruit::fromBerries($obj->{'berries'})
497497 );
498498 }
499499
@@ -503,8 +503,8 @@ class Fruit {
503503 public static function sample(): Fruit {
504504 return new Fruit(
505505 Fruit::sampleApple()
506- ,Fruit::sampleBerries()
507506 ,Fruit::sampleOrange()
507+ ,Fruit::sampleBerries()
508508 );
509509 }
510510 }
@@ -512,29 +512,29 @@ class Fruit {
512512 // This is an autogenerated file:Berry
513513
514514 class Berry {
515- private ?Color $color; // json:color Optional
516515 private ?string $name; // json:name Optional
516+ private ?Color $color; // json:color Optional
517517 private ?array $shapes; // json:shapes Optional
518518
519519 /**
520- * @param Color|null $color
521520 * @param string|null $name
521+ * @param Color|null $color
522522 * @param array|null $shapes
523523 */
524- public function __construct(?Color $color, ?string $name, ?array $shapes) {
525- $this->color = $color;
524+ public function __construct(?string $name, ?Color $color, ?array $shapes) {
526525 $this->name = $name;
526+ $this->color = $color;
527527 $this->shapes = $shapes;
528528 }
529529
530530 /**
531- * @param ?stdClass $value
531+ * @param ?string $value
532532 * @throws Exception
533- * @return ?Color
533+ * @return ?string
534534 */
535- public static function fromColor(?stdClass $value): ?Color {
535+ public static function fromName(?string $value): ?string {
536536 if (!is_null($value)) {
537- return Color::from($value); /*class*/
537+ return $value; /*string*/
538538 } else {
539539 return null;
540540 }
@@ -542,57 +542,56 @@ class Berry {
542542
543543 /**
544544 * @throws Exception
545- * @return ?stdClass
545+ * @return ?string
546546 */
547- public function toColor(): ?stdClass {
548- if (Berry::validateColor($this->color)) {
549- if (!is_null($this->color)) {
550- return $this->color->to(); /*class*/
547+ public function toName(): ?string {
548+ if (Berry::validateName($this->name)) {
549+ if (!is_null($this->name)) {
550+ return $this->name; /*string*/
551551 } else {
552552 return null;
553553 }
554554 }
555- throw new Exception('never get to this Berry::color');
555+ throw new Exception('never get to this Berry::name');
556556 }
557557
558558 /**
559- * @param Color|null
559+ * @param string|null
560560 * @return bool
561561 * @throws Exception
562562 */
563- public static function validateColor(?Color $value): bool {
563+ public static function validateName(?string $value): bool {
564564 if (!is_null($value)) {
565- $value->validate();
566565 }
567566 return true;
568567 }
569568
570569 /**
571570 * @throws Exception
572- * @return ?Color
571+ * @return ?string
573572 */
574- public function getColor(): ?Color {
575- if (Berry::validateColor($this->color)) {
576- return $this->color;
573+ public function getName(): ?string {
574+ if (Berry::validateName($this->name)) {
575+ return $this->name;
577576 }
578- throw new Exception('never get to getColor Berry::color');
577+ throw new Exception('never get to getName Berry::name');
579578 }
580579
581580 /**
582- * @return ?Color
581+ * @return ?string
583582 */
584- public static function sampleColor(): ?Color {
585- return Color::sample(); /*31:color*/
583+ public static function sampleName(): ?string {
584+ return 'Berry::name::31'; /*31:name*/
586585 }
587586
588587 /**
589- * @param ?string $value
588+ * @param ?stdClass $value
590589 * @throws Exception
591- * @return ?string
590+ * @return ?Color
592591 */
593- public static function fromName(?string $value): ?string {
592+ public static function fromColor(?stdClass $value): ?Color {
594593 if (!is_null($value)) {
595- return $value; /*string*/
594+ return Color::from($value); /*class*/
596595 } else {
597596 return null;
598597 }
@@ -600,46 +599,47 @@ class Berry {
600599
601600 /**
602601 * @throws Exception
603- * @return ?string
602+ * @return ?stdClass
604603 */
605- public function toName(): ?string {
606- if (Berry::validateName($this->name)) {
607- if (!is_null($this->name)) {
608- return $this->name; /*string*/
604+ public function toColor(): ?stdClass {
605+ if (Berry::validateColor($this->color)) {
606+ if (!is_null($this->color)) {
607+ return $this->color->to(); /*class*/
609608 } else {
610609 return null;
611610 }
612611 }
613- throw new Exception('never get to this Berry::name');
612+ throw new Exception('never get to this Berry::color');
614613 }
615614
616615 /**
617- * @param string|null
616+ * @param Color|null
618617 * @return bool
619618 * @throws Exception
620619 */
621- public static function validateName(?string $value): bool {
620+ public static function validateColor(?Color $value): bool {
622621 if (!is_null($value)) {
622+ $value->validate();
623623 }
624624 return true;
625625 }
626626
627627 /**
628628 * @throws Exception
629- * @return ?string
629+ * @return ?Color
630630 */
631- public function getName(): ?string {
632- if (Berry::validateName($this->name)) {
633- return $this->name;
631+ public function getColor(): ?Color {
632+ if (Berry::validateColor($this->color)) {
633+ return $this->color;
634634 }
635- throw new Exception('never get to getName Berry::name');
635+ throw new Exception('never get to getColor Berry::color');
636636 }
637637
638638 /**
639- * @return ?string
639+ * @return ?Color
640640 */
641- public static function sampleName(): ?string {
642- return 'Berry::name::32'; /*32:name*/
641+ public static function sampleColor(): ?Color {
642+ return Color::sample(); /*32:color*/
643643 }
644644
645645 /**
@@ -716,8 +716,8 @@ class Berry {
716716 * @return bool
717717 */
718718 public function validate(): bool {
719- return Berry::validateColor($this->color)
720- || Berry::validateName($this->name)
719+ return Berry::validateName($this->name)
720+ || Berry::validateColor($this->color)
721721 || Berry::validateShapes($this->shapes);
722722 }
723723
@@ -727,8 +727,8 @@ class Berry {
727727 */
728728 public function to(): stdClass {
729729 $out = new stdClass();
730- $out->{'color'} = $this->toColor();
731730 $out->{'name'} = $this->toName();
731+ $out->{'color'} = $this->toColor();
732732 $out->{'shapes'} = $this->toShapes();
733733 return $out;
734734 }
@@ -740,8 +740,8 @@ class Berry {
740740 */
741741 public static function from(stdClass $obj): Berry {
742742 return new Berry(
743- Berry::fromColor($obj->{'color'})
744- ,Berry::fromName($obj->{'name'})
743+ Berry::fromName($obj->{'name'})
744+ ,Berry::fromColor($obj->{'color'})
745745 ,Berry::fromShapes($obj->{'shapes'})
746746 );
747747 }
@@ -751,8 +751,8 @@ class Berry {
751751 */
752752 public static function sample(): Berry {
753753 return new Berry(
754- Berry::sampleColor()
755- ,Berry::sampleName()
754+ Berry::sampleName()
755+ ,Berry::sampleColor()
756756 ,Berry::sampleShapes()
757757 );
758758 }
@@ -869,26 +869,26 @@ class Color {
869869 // This is an autogenerated file:Shape
870870
871871 class Shape {
872- private ?Geometry $geometry; // json:geometry Optional
873872 private ?History $history; // json:history Optional
873+ private ?Geometry $geometry; // json:geometry Optional
874874
875875 /**
876- * @param Geometry|null $geometry
877876 * @param History|null $history
877+ * @param Geometry|null $geometry
878878 */
879- public function __construct(?Geometry $geometry, ?History $history) {
880- $this->geometry = $geometry;
879+ public function __construct(?History $history, ?Geometry $geometry) {
881880 $this->history = $history;
881+ $this->geometry = $geometry;
882882 }
883883
884884 /**
885885 * @param ?stdClass $value
886886 * @throws Exception
887- * @return ?Geometry
887+ * @return ?History
888888 */
889- public static function fromGeometry(?stdClass $value): ?Geometry {
889+ public static function fromHistory(?stdClass $value): ?History {
890890 if (!is_null($value)) {
891- return Geometry::from($value); /*class*/
891+ return History::from($value); /*class*/
892892 } else {
893893 return null;
894894 }
@@ -898,23 +898,23 @@ class Shape {
898898 * @throws Exception
899899 * @return ?stdClass
900900 */
901- public function toGeometry(): ?stdClass {
902- if (Shape::validateGeometry($this->geometry)) {
903- if (!is_null($this->geometry)) {
904- return $this->geometry->to(); /*class*/
901+ public function toHistory(): ?stdClass {
902+ if (Shape::validateHistory($this->history)) {
903+ if (!is_null($this->history)) {
904+ return $this->history->to(); /*class*/
905905 } else {
906906 return null;
907907 }
908908 }
909- throw new Exception('never get to this Shape::geometry');
909+ throw new Exception('never get to this Shape::history');
910910 }
911911
912912 /**
913- * @param Geometry|null
913+ * @param History|null
914914 * @return bool
915915 * @throws Exception
916916 */
917- public static function validateGeometry(?Geometry $value): bool {
917+ public static function validateHistory(?History $value): bool {
918918 if (!is_null($value)) {
919919 $value->validate();
920920 }
@@ -923,30 +923,30 @@ class Shape {
923923
924924 /**
925925 * @throws Exception
926- * @return ?Geometry
926+ * @return ?History
927927 */
928- public function getGeometry(): ?Geometry {
929- if (Shape::validateGeometry($this->geometry)) {
930- return $this->geometry;
928+ public function getHistory(): ?History {
929+ if (Shape::validateHistory($this->history)) {
930+ return $this->history;
931931 }
932- throw new Exception('never get to getGeometry Shape::geometry');
932+ throw new Exception('never get to getHistory Shape::history');
933933 }
934934
935935 /**
936- * @return ?Geometry
936+ * @return ?History
937937 */
938- public static function sampleGeometry(): ?Geometry {
939- return Geometry::sample(); /*31:geometry*/
938+ public static function sampleHistory(): ?History {
939+ return History::sample(); /*31:history*/
940940 }
941941
942942 /**
943943 * @param ?stdClass $value
944944 * @throws Exception
945- * @return ?History
945+ * @return ?Geometry
946946 */
947- public static function fromHistory(?stdClass $value): ?History {
947+ public static function fromGeometry(?stdClass $value): ?Geometry {
948948 if (!is_null($value)) {
949- return History::from($value); /*class*/
949+ return Geometry::from($value); /*class*/
950950 } else {
951951 return null;
952952 }
@@ -956,23 +956,23 @@ class Shape {
956956 * @throws Exception
957957 * @return ?stdClass
958958 */
959- public function toHistory(): ?stdClass {
960- if (Shape::validateHistory($this->history)) {
961- if (!is_null($this->history)) {
962- return $this->history->to(); /*class*/
959+ public function toGeometry(): ?stdClass {
960+ if (Shape::validateGeometry($this->geometry)) {
961+ if (!is_null($this->geometry)) {
962+ return $this->geometry->to(); /*class*/
963963 } else {
964964 return null;
965965 }
966966 }
967- throw new Exception('never get to this Shape::history');
967+ throw new Exception('never get to this Shape::geometry');
968968 }
969969
970970 /**
971- * @param History|null
971+ * @param Geometry|null
972972 * @return bool
973973 * @throws Exception
974974 */
975- public static function validateHistory(?History $value): bool {
975+ public static function validateGeometry(?Geometry $value): bool {
976976 if (!is_null($value)) {
977977 $value->validate();
978978 }
@@ -981,20 +981,20 @@ class Shape {
981981
982982 /**
983983 * @throws Exception
984- * @return ?History
984+ * @return ?Geometry
985985 */
986- public function getHistory(): ?History {
987- if (Shape::validateHistory($this->history)) {
988- return $this->history;
986+ public function getGeometry(): ?Geometry {
987+ if (Shape::validateGeometry($this->geometry)) {
988+ return $this->geometry;
989989 }
990- throw new Exception('never get to getHistory Shape::history');
990+ throw new Exception('never get to getGeometry Shape::geometry');
991991 }
992992
993993 /**
994- * @return ?History
994+ * @return ?Geometry
995995 */
996- public static function sampleHistory(): ?History {
997- return History::sample(); /*32:history*/
996+ public static function sampleGeometry(): ?Geometry {
997+ return Geometry::sample(); /*32:geometry*/
998998 }
999999
10001000 /**
@@ -1002,8 +1002,8 @@ class Shape {
10021002 * @return bool
10031003 */
10041004 public function validate(): bool {
1005- return Shape::validateGeometry($this->geometry)
1006- || Shape::validateHistory($this->history);
1005+ return Shape::validateHistory($this->history)
1006+ || Shape::validateGeometry($this->geometry);
10071007 }
10081008
10091009 /**
@@ -1012,8 +1012,8 @@ class Shape {
10121012 */
10131013 public function to(): stdClass {
10141014 $out = new stdClass();
1015- $out->{'geometry'} = $this->toGeometry();
10161015 $out->{'history'} = $this->toHistory();
1016+ $out->{'geometry'} = $this->toGeometry();
10171017 return $out;
10181018 }
10191019
@@ -1024,8 +1024,8 @@ class Shape {
10241024 */
10251025 public static function from(stdClass $obj): Shape {
10261026 return new Shape(
1027- Shape::fromGeometry($obj->{'geometry'})
1028- ,Shape::fromHistory($obj->{'history'})
1027+ Shape::fromHistory($obj->{'history'})
1028+ ,Shape::fromGeometry($obj->{'geometry'})
10291029 );
10301030 }
10311031
@@ -1034,8 +1034,8 @@ class Shape {
10341034 */
10351035 public static function sample(): Shape {
10361036 return new Shape(
1037- Shape::sampleGeometry()
1038- ,Shape::sampleHistory()
1037+ Shape::sampleHistory()
1038+ ,Shape::sampleGeometry()
10391039 );
10401040 }
10411041 }
@@ -1456,19 +1456,19 @@ class RectShape {
14561456 // This is an autogenerated file:Part
14571457
14581458 class Part {
1459- private ?string $depth; // json:depth Optional
14601459 private ?string $length; // json:length Optional
14611460 private ?string $width; // json:width Optional
1461+ private ?string $depth; // json:depth Optional
14621462
14631463 /**
1464- * @param string|null $depth
14651464 * @param string|null $length
14661465 * @param string|null $width
1466+ * @param string|null $depth
14671467 */
1468- public function __construct(?string $depth, ?string $length, ?string $width) {
1469- $this->depth = $depth;
1468+ public function __construct(?string $length, ?string $width, ?string $depth) {
14701469 $this->length = $length;
14711470 $this->width = $width;
1471+ $this->depth = $depth;
14721472 }
14731473
14741474 /**
@@ -1476,7 +1476,7 @@ class Part {
14761476 * @throws Exception
14771477 * @return ?string
14781478 */
1479- public static function fromDepth(?string $value): ?string {
1479+ public static function fromLength(?string $value): ?string {
14801480 if (!is_null($value)) {
14811481 return $value; /*string*/
14821482 } else {
@@ -1488,15 +1488,15 @@ class Part {
14881488 * @throws Exception
14891489 * @return ?string
14901490 */
1491- public function toDepth(): ?string {
1492- if (Part::validateDepth($this->depth)) {
1493- if (!is_null($this->depth)) {
1494- return $this->depth; /*string*/
1491+ public function toLength(): ?string {
1492+ if (Part::validateLength($this->length)) {
1493+ if (!is_null($this->length)) {
1494+ return $this->length; /*string*/
14951495 } else {
14961496 return null;
14971497 }
14981498 }
1499- throw new Exception('never get to this Part::depth');
1499+ throw new Exception('never get to this Part::length');
15001500 }
15011501
15021502 /**
@@ -1504,7 +1504,7 @@ class Part {
15041504 * @return bool
15051505 * @throws Exception
15061506 */
1507- public static function validateDepth(?string $value): bool {
1507+ public static function validateLength(?string $value): bool {
15081508 if (!is_null($value)) {
15091509 }
15101510 return true;
@@ -1514,18 +1514,18 @@ class Part {
15141514 * @throws Exception
15151515 * @return ?string
15161516 */
1517- public function getDepth(): ?string {
1518- if (Part::validateDepth($this->depth)) {
1519- return $this->depth;
1517+ public function getLength(): ?string {
1518+ if (Part::validateLength($this->length)) {
1519+ return $this->length;
15201520 }
1521- throw new Exception('never get to getDepth Part::depth');
1521+ throw new Exception('never get to getLength Part::length');
15221522 }
15231523
15241524 /**
15251525 * @return ?string
15261526 */
1527- public static function sampleDepth(): ?string {
1528- return 'Part::depth::31'; /*31:depth*/
1527+ public static function sampleLength(): ?string {
1528+ return 'Part::length::31'; /*31:length*/
15291529 }
15301530
15311531 /**
@@ -1533,7 +1533,7 @@ class Part {
15331533 * @throws Exception
15341534 * @return ?string
15351535 */
1536- public static function fromLength(?string $value): ?string {
1536+ public static function fromWidth(?string $value): ?string {
15371537 if (!is_null($value)) {
15381538 return $value; /*string*/
15391539 } else {
@@ -1545,15 +1545,15 @@ class Part {
15451545 * @throws Exception
15461546 * @return ?string
15471547 */
1548- public function toLength(): ?string {
1549- if (Part::validateLength($this->length)) {
1550- if (!is_null($this->length)) {
1551- return $this->length; /*string*/
1548+ public function toWidth(): ?string {
1549+ if (Part::validateWidth($this->width)) {
1550+ if (!is_null($this->width)) {
1551+ return $this->width; /*string*/
15521552 } else {
15531553 return null;
15541554 }
15551555 }
1556- throw new Exception('never get to this Part::length');
1556+ throw new Exception('never get to this Part::width');
15571557 }
15581558
15591559 /**
@@ -1561,7 +1561,7 @@ class Part {
15611561 * @return bool
15621562 * @throws Exception
15631563 */
1564- public static function validateLength(?string $value): bool {
1564+ public static function validateWidth(?string $value): bool {
15651565 if (!is_null($value)) {
15661566 }
15671567 return true;
@@ -1571,18 +1571,18 @@ class Part {
15711571 * @throws Exception
15721572 * @return ?string
15731573 */
1574- public function getLength(): ?string {
1575- if (Part::validateLength($this->length)) {
1576- return $this->length;
1574+ public function getWidth(): ?string {
1575+ if (Part::validateWidth($this->width)) {
1576+ return $this->width;
15771577 }
1578- throw new Exception('never get to getLength Part::length');
1578+ throw new Exception('never get to getWidth Part::width');
15791579 }
15801580
15811581 /**
15821582 * @return ?string
15831583 */
1584- public static function sampleLength(): ?string {
1585- return 'Part::length::32'; /*32:length*/
1584+ public static function sampleWidth(): ?string {
1585+ return 'Part::width::32'; /*32:width*/
15861586 }
15871587
15881588 /**
@@ -1590,7 +1590,7 @@ class Part {
15901590 * @throws Exception
15911591 * @return ?string
15921592 */
1593- public static function fromWidth(?string $value): ?string {
1593+ public static function fromDepth(?string $value): ?string {
15941594 if (!is_null($value)) {
15951595 return $value; /*string*/
15961596 } else {
@@ -1602,15 +1602,15 @@ class Part {
16021602 * @throws Exception
16031603 * @return ?string
16041604 */
1605- public function toWidth(): ?string {
1606- if (Part::validateWidth($this->width)) {
1607- if (!is_null($this->width)) {
1608- return $this->width; /*string*/
1605+ public function toDepth(): ?string {
1606+ if (Part::validateDepth($this->depth)) {
1607+ if (!is_null($this->depth)) {
1608+ return $this->depth; /*string*/
16091609 } else {
16101610 return null;
16111611 }
16121612 }
1613- throw new Exception('never get to this Part::width');
1613+ throw new Exception('never get to this Part::depth');
16141614 }
16151615
16161616 /**
@@ -1618,7 +1618,7 @@ class Part {
16181618 * @return bool
16191619 * @throws Exception
16201620 */
1621- public static function validateWidth(?string $value): bool {
1621+ public static function validateDepth(?string $value): bool {
16221622 if (!is_null($value)) {
16231623 }
16241624 return true;
@@ -1628,18 +1628,18 @@ class Part {
16281628 * @throws Exception
16291629 * @return ?string
16301630 */
1631- public function getWidth(): ?string {
1632- if (Part::validateWidth($this->width)) {
1633- return $this->width;
1631+ public function getDepth(): ?string {
1632+ if (Part::validateDepth($this->depth)) {
1633+ return $this->depth;
16341634 }
1635- throw new Exception('never get to getWidth Part::width');
1635+ throw new Exception('never get to getDepth Part::depth');
16361636 }
16371637
16381638 /**
16391639 * @return ?string
16401640 */
1641- public static function sampleWidth(): ?string {
1642- return 'Part::width::33'; /*33:width*/
1641+ public static function sampleDepth(): ?string {
1642+ return 'Part::depth::33'; /*33:depth*/
16431643 }
16441644
16451645 /**
@@ -1647,9 +1647,9 @@ class Part {
16471647 * @return bool
16481648 */
16491649 public function validate(): bool {
1650- return Part::validateDepth($this->depth)
1651- || Part::validateLength($this->length)
1652- || Part::validateWidth($this->width);
1650+ return Part::validateLength($this->length)
1651+ || Part::validateWidth($this->width)
1652+ || Part::validateDepth($this->depth);
16531653 }
16541654
16551655 /**
@@ -1658,9 +1658,9 @@ class Part {
16581658 */
16591659 public function to(): stdClass {
16601660 $out = new stdClass();
1661- $out->{'depth'} = $this->toDepth();
16621661 $out->{'length'} = $this->toLength();
16631662 $out->{'width'} = $this->toWidth();
1663+ $out->{'depth'} = $this->toDepth();
16641664 return $out;
16651665 }
16661666
@@ -1671,9 +1671,9 @@ class Part {
16711671 */
16721672 public static function from(stdClass $obj): Part {
16731673 return new Part(
1674- Part::fromDepth($obj->{'depth'})
1675- ,Part::fromLength($obj->{'length'})
1674+ Part::fromLength($obj->{'length'})
16761675 ,Part::fromWidth($obj->{'width'})
1676+ ,Part::fromDepth($obj->{'depth'})
16771677 );
16781678 }
16791679
@@ -1682,9 +1682,9 @@ class Part {
16821682 */
16831683 public static function sample(): Part {
16841684 return new Part(
1685- Part::sampleDepth()
1686- ,Part::sampleLength()
1685+ Part::sampleLength()
16871686 ,Part::sampleWidth()
1687+ ,Part::sampleDepth()
16881688 );
16891689 }
16901690 }
@@ -1800,28 +1800,28 @@ class History {
18001800 // This is an autogenerated file:Vehicle
18011801
18021802 class Vehicle {
1803- private ?string $brand; // json:brand Optional
18041803 private ?string $id; // json:id Optional
1805- private ?Speed $speed; // json:speed Optional
1806- private ?bool $subModule; // json:subModule Optional
18071804 private ?VehicleType $type; // json:type Optional
1805+ private ?Speed $speed; // json:speed Optional
18081806 private ?string $year; // json:year Optional
1807+ private ?string $brand; // json:brand Optional
1808+ private ?bool $subModule; // json:subModule Optional
18091809
18101810 /**
1811- * @param string|null $brand
18121811 * @param string|null $id
1813- * @param Speed|null $speed
1814- * @param bool|null $subModule
18151812 * @param VehicleType|null $type
1813+ * @param Speed|null $speed
18161814 * @param string|null $year
1815+ * @param string|null $brand
1816+ * @param bool|null $subModule
18171817 */
1818- public function __construct(?string $brand, ?string $id, ?Speed $speed, ?bool $subModule, ?VehicleType $type, ?string $year) {
1819- $this->brand = $brand;
1818+ public function __construct(?string $id, ?VehicleType $type, ?Speed $speed, ?string $year, ?string $brand, ?bool $subModule) {
18201819 $this->id = $id;
1821- $this->speed = $speed;
1822- $this->subModule = $subModule;
18231820 $this->type = $type;
1821+ $this->speed = $speed;
18241822 $this->year = $year;
1823+ $this->brand = $brand;
1824+ $this->subModule = $subModule;
18251825 }
18261826
18271827 /**
@@ -1829,7 +1829,7 @@ class Vehicle {
18291829 * @throws Exception
18301830 * @return ?string
18311831 */
1832- public static function fromBrand(?string $value): ?string {
1832+ public static function fromID(?string $value): ?string {
18331833 if (!is_null($value)) {
18341834 return $value; /*string*/
18351835 } else {
@@ -1841,15 +1841,15 @@ class Vehicle {
18411841 * @throws Exception
18421842 * @return ?string
18431843 */
1844- public function toBrand(): ?string {
1845- if (Vehicle::validateBrand($this->brand)) {
1846- if (!is_null($this->brand)) {
1847- return $this->brand; /*string*/
1844+ public function toID(): ?string {
1845+ if (Vehicle::validateID($this->id)) {
1846+ if (!is_null($this->id)) {
1847+ return $this->id; /*string*/
18481848 } else {
18491849 return null;
18501850 }
18511851 }
1852- throw new Exception('never get to this Vehicle::brand');
1852+ throw new Exception('never get to this Vehicle::id');
18531853 }
18541854
18551855 /**
@@ -1857,7 +1857,7 @@ class Vehicle {
18571857 * @return bool
18581858 * @throws Exception
18591859 */
1860- public static function validateBrand(?string $value): bool {
1860+ public static function validateID(?string $value): bool {
18611861 if (!is_null($value)) {
18621862 }
18631863 return true;
@@ -1867,28 +1867,28 @@ class Vehicle {
18671867 * @throws Exception
18681868 * @return ?string
18691869 */
1870- public function getBrand(): ?string {
1871- if (Vehicle::validateBrand($this->brand)) {
1872- return $this->brand;
1870+ public function getID(): ?string {
1871+ if (Vehicle::validateID($this->id)) {
1872+ return $this->id;
18731873 }
1874- throw new Exception('never get to getBrand Vehicle::brand');
1874+ throw new Exception('never get to getID Vehicle::id');
18751875 }
18761876
18771877 /**
18781878 * @return ?string
18791879 */
1880- public static function sampleBrand(): ?string {
1881- return 'Vehicle::brand::31'; /*31:brand*/
1880+ public static function sampleID(): ?string {
1881+ return 'Vehicle::id::31'; /*31:id*/
18821882 }
18831883
18841884 /**
1885- * @param ?string $value
1885+ * @param ?stdClass $value
18861886 * @throws Exception
1887- * @return ?string
1887+ * @return ?VehicleType
18881888 */
1889- public static function fromID(?string $value): ?string {
1889+ public static function fromType(?stdClass $value): ?VehicleType {
18901890 if (!is_null($value)) {
1891- return $value; /*string*/
1891+ return VehicleType::from($value); /*class*/
18921892 } else {
18931893 return null;
18941894 }
@@ -1896,46 +1896,47 @@ class Vehicle {
18961896
18971897 /**
18981898 * @throws Exception
1899- * @return ?string
1899+ * @return ?stdClass
19001900 */
1901- public function toID(): ?string {
1902- if (Vehicle::validateID($this->id)) {
1903- if (!is_null($this->id)) {
1904- return $this->id; /*string*/
1901+ public function toType(): ?stdClass {
1902+ if (Vehicle::validateType($this->type)) {
1903+ if (!is_null($this->type)) {
1904+ return $this->type->to(); /*class*/
19051905 } else {
19061906 return null;
19071907 }
19081908 }
1909- throw new Exception('never get to this Vehicle::id');
1909+ throw new Exception('never get to this Vehicle::type');
19101910 }
19111911
19121912 /**
1913- * @param string|null
1913+ * @param VehicleType|null
19141914 * @return bool
19151915 * @throws Exception
19161916 */
1917- public static function validateID(?string $value): bool {
1917+ public static function validateType(?VehicleType $value): bool {
19181918 if (!is_null($value)) {
1919+ $value->validate();
19191920 }
19201921 return true;
19211922 }
19221923
19231924 /**
19241925 * @throws Exception
1925- * @return ?string
1926+ * @return ?VehicleType
19261927 */
1927- public function getID(): ?string {
1928- if (Vehicle::validateID($this->id)) {
1929- return $this->id;
1928+ public function getType(): ?VehicleType {
1929+ if (Vehicle::validateType($this->type)) {
1930+ return $this->type;
19301931 }
1931- throw new Exception('never get to getID Vehicle::id');
1932+ throw new Exception('never get to getType Vehicle::type');
19321933 }
19331934
19341935 /**
1935- * @return ?string
1936+ * @return ?VehicleType
19361937 */
1937- public static function sampleID(): ?string {
1938- return 'Vehicle::id::32'; /*32:id*/
1938+ public static function sampleType(): ?VehicleType {
1939+ return VehicleType::sample(); /*32:type*/
19391940 }
19401941
19411942 /**
@@ -1997,13 +1998,13 @@ class Vehicle {
19971998 }
19981999
19992000 /**
2000- * @param ?bool $value
2001+ * @param ?string $value
20012002 * @throws Exception
2002- * @return ?bool
2003+ * @return ?string
20032004 */
2004- public static function fromSubModule(?bool $value): ?bool {
2005+ public static function fromYear(?string $value): ?string {
20052006 if (!is_null($value)) {
2006- return $value; /*bool*/
2007+ return $value; /*string*/
20072008 } else {
20082009 return null;
20092010 }
@@ -2011,25 +2012,25 @@ class Vehicle {
20112012
20122013 /**
20132014 * @throws Exception
2014- * @return ?bool
2015+ * @return ?string
20152016 */
2016- public function toSubModule(): ?bool {
2017- if (Vehicle::validateSubModule($this->subModule)) {
2018- if (!is_null($this->subModule)) {
2019- return $this->subModule; /*bool*/
2017+ public function toYear(): ?string {
2018+ if (Vehicle::validateYear($this->year)) {
2019+ if (!is_null($this->year)) {
2020+ return $this->year; /*string*/
20202021 } else {
20212022 return null;
20222023 }
20232024 }
2024- throw new Exception('never get to this Vehicle::subModule');
2025+ throw new Exception('never get to this Vehicle::year');
20252026 }
20262027
20272028 /**
2028- * @param bool|null
2029+ * @param string|null
20292030 * @return bool
20302031 * @throws Exception
20312032 */
2032- public static function validateSubModule(?bool $value): bool {
2033+ public static function validateYear(?string $value): bool {
20332034 if (!is_null($value)) {
20342035 }
20352036 return true;
@@ -2037,30 +2038,30 @@ class Vehicle {
20372038
20382039 /**
20392040 * @throws Exception
2040- * @return ?bool
2041+ * @return ?string
20412042 */
2042- public function getSubModule(): ?bool {
2043- if (Vehicle::validateSubModule($this->subModule)) {
2044- return $this->subModule;
2043+ public function getYear(): ?string {
2044+ if (Vehicle::validateYear($this->year)) {
2045+ return $this->year;
20452046 }
2046- throw new Exception('never get to getSubModule Vehicle::subModule');
2047+ throw new Exception('never get to getYear Vehicle::year');
20472048 }
20482049
20492050 /**
2050- * @return ?bool
2051+ * @return ?string
20512052 */
2052- public static function sampleSubModule(): ?bool {
2053- return true; /*34:subModule*/
2053+ public static function sampleYear(): ?string {
2054+ return 'Vehicle::year::34'; /*34:year*/
20542055 }
20552056
20562057 /**
2057- * @param ?stdClass $value
2058+ * @param ?string $value
20582059 * @throws Exception
2059- * @return ?VehicleType
2060+ * @return ?string
20602061 */
2061- public static function fromType(?stdClass $value): ?VehicleType {
2062+ public static function fromBrand(?string $value): ?string {
20622063 if (!is_null($value)) {
2063- return VehicleType::from($value); /*class*/
2064+ return $value; /*string*/
20642065 } else {
20652066 return null;
20662067 }
@@ -2068,57 +2069,56 @@ class Vehicle {
20682069
20692070 /**
20702071 * @throws Exception
2071- * @return ?stdClass
2072+ * @return ?string
20722073 */
2073- public function toType(): ?stdClass {
2074- if (Vehicle::validateType($this->type)) {
2075- if (!is_null($this->type)) {
2076- return $this->type->to(); /*class*/
2074+ public function toBrand(): ?string {
2075+ if (Vehicle::validateBrand($this->brand)) {
2076+ if (!is_null($this->brand)) {
2077+ return $this->brand; /*string*/
20772078 } else {
20782079 return null;
20792080 }
20802081 }
2081- throw new Exception('never get to this Vehicle::type');
2082+ throw new Exception('never get to this Vehicle::brand');
20822083 }
20832084
20842085 /**
2085- * @param VehicleType|null
2086+ * @param string|null
20862087 * @return bool
20872088 * @throws Exception
20882089 */
2089- public static function validateType(?VehicleType $value): bool {
2090+ public static function validateBrand(?string $value): bool {
20902091 if (!is_null($value)) {
2091- $value->validate();
20922092 }
20932093 return true;
20942094 }
20952095
20962096 /**
20972097 * @throws Exception
2098- * @return ?VehicleType
2098+ * @return ?string
20992099 */
2100- public function getType(): ?VehicleType {
2101- if (Vehicle::validateType($this->type)) {
2102- return $this->type;
2100+ public function getBrand(): ?string {
2101+ if (Vehicle::validateBrand($this->brand)) {
2102+ return $this->brand;
21032103 }
2104- throw new Exception('never get to getType Vehicle::type');
2104+ throw new Exception('never get to getBrand Vehicle::brand');
21052105 }
21062106
21072107 /**
2108- * @return ?VehicleType
2108+ * @return ?string
21092109 */
2110- public static function sampleType(): ?VehicleType {
2111- return VehicleType::sample(); /*35:type*/
2110+ public static function sampleBrand(): ?string {
2111+ return 'Vehicle::brand::35'; /*35:brand*/
21122112 }
21132113
21142114 /**
2115- * @param ?string $value
2115+ * @param ?bool $value
21162116 * @throws Exception
2117- * @return ?string
2117+ * @return ?bool
21182118 */
2119- public static function fromYear(?string $value): ?string {
2119+ public static function fromSubModule(?bool $value): ?bool {
21202120 if (!is_null($value)) {
2121- return $value; /*string*/
2121+ return $value; /*bool*/
21222122 } else {
21232123 return null;
21242124 }
@@ -2126,25 +2126,25 @@ class Vehicle {
21262126
21272127 /**
21282128 * @throws Exception
2129- * @return ?string
2129+ * @return ?bool
21302130 */
2131- public function toYear(): ?string {
2132- if (Vehicle::validateYear($this->year)) {
2133- if (!is_null($this->year)) {
2134- return $this->year; /*string*/
2131+ public function toSubModule(): ?bool {
2132+ if (Vehicle::validateSubModule($this->subModule)) {
2133+ if (!is_null($this->subModule)) {
2134+ return $this->subModule; /*bool*/
21352135 } else {
21362136 return null;
21372137 }
21382138 }
2139- throw new Exception('never get to this Vehicle::year');
2139+ throw new Exception('never get to this Vehicle::subModule');
21402140 }
21412141
21422142 /**
2143- * @param string|null
2143+ * @param bool|null
21442144 * @return bool
21452145 * @throws Exception
21462146 */
2147- public static function validateYear(?string $value): bool {
2147+ public static function validateSubModule(?bool $value): bool {
21482148 if (!is_null($value)) {
21492149 }
21502150 return true;
@@ -2152,20 +2152,20 @@ class Vehicle {
21522152
21532153 /**
21542154 * @throws Exception
2155- * @return ?string
2155+ * @return ?bool
21562156 */
2157- public function getYear(): ?string {
2158- if (Vehicle::validateYear($this->year)) {
2159- return $this->year;
2157+ public function getSubModule(): ?bool {
2158+ if (Vehicle::validateSubModule($this->subModule)) {
2159+ return $this->subModule;
21602160 }
2161- throw new Exception('never get to getYear Vehicle::year');
2161+ throw new Exception('never get to getSubModule Vehicle::subModule');
21622162 }
21632163
21642164 /**
2165- * @return ?string
2165+ * @return ?bool
21662166 */
2167- public static function sampleYear(): ?string {
2168- return 'Vehicle::year::36'; /*36:year*/
2167+ public static function sampleSubModule(): ?bool {
2168+ return true; /*36:subModule*/
21692169 }
21702170
21712171 /**
@@ -2173,12 +2173,12 @@ class Vehicle {
21732173 * @return bool
21742174 */
21752175 public function validate(): bool {
2176- return Vehicle::validateBrand($this->brand)
2177- || Vehicle::validateID($this->id)
2178- || Vehicle::validateSpeed($this->speed)
2179- || Vehicle::validateSubModule($this->subModule)
2176+ return Vehicle::validateID($this->id)
21802177 || Vehicle::validateType($this->type)
2181- || Vehicle::validateYear($this->year);
2178+ || Vehicle::validateSpeed($this->speed)
2179+ || Vehicle::validateYear($this->year)
2180+ || Vehicle::validateBrand($this->brand)
2181+ || Vehicle::validateSubModule($this->subModule);
21822182 }
21832183
21842184 /**
@@ -2187,12 +2187,12 @@ class Vehicle {
21872187 */
21882188 public function to(): stdClass {
21892189 $out = new stdClass();
2190- $out->{'brand'} = $this->toBrand();
21912190 $out->{'id'} = $this->toID();
2192- $out->{'speed'} = $this->toSpeed();
2193- $out->{'subModule'} = $this->toSubModule();
21942191 $out->{'type'} = $this->toType();
2192+ $out->{'speed'} = $this->toSpeed();
21952193 $out->{'year'} = $this->toYear();
2194+ $out->{'brand'} = $this->toBrand();
2195+ $out->{'subModule'} = $this->toSubModule();
21962196 return $out;
21972197 }
21982198
@@ -2203,12 +2203,12 @@ class Vehicle {
22032203 */
22042204 public static function from(stdClass $obj): Vehicle {
22052205 return new Vehicle(
2206- Vehicle::fromBrand($obj->{'brand'})
2207- ,Vehicle::fromID($obj->{'id'})
2208- ,Vehicle::fromSpeed($obj->{'speed'})
2209- ,Vehicle::fromSubModule($obj->{'subModule'})
2206+ Vehicle::fromID($obj->{'id'})
22102207 ,Vehicle::fromType($obj->{'type'})
2208+ ,Vehicle::fromSpeed($obj->{'speed'})
22112209 ,Vehicle::fromYear($obj->{'year'})
2210+ ,Vehicle::fromBrand($obj->{'brand'})
2211+ ,Vehicle::fromSubModule($obj->{'subModule'})
22122212 );
22132213 }
22142214
@@ -2217,12 +2217,12 @@ class Vehicle {
22172217 */
22182218 public static function sample(): Vehicle {
22192219 return new Vehicle(
2220- Vehicle::sampleBrand()
2221- ,Vehicle::sampleID()
2222- ,Vehicle::sampleSpeed()
2223- ,Vehicle::sampleSubModule()
2220+ Vehicle::sampleID()
22242221 ,Vehicle::sampleType()
2222+ ,Vehicle::sampleSpeed()
22252223 ,Vehicle::sampleYear()
2224+ ,Vehicle::sampleBrand()
2225+ ,Vehicle::sampleSubModule()
22262226 );
22272227 }
22282228 }
@@ -2339,16 +2339,16 @@ class Speed {
23392339 // This is an autogenerated file:Limit
23402340
23412341 class Limit {
2342- private ?float $maximum; // json:maximum Optional
23432342 private ?float $minimum; // json:minimum Optional
2343+ private ?float $maximum; // json:maximum Optional
23442344
23452345 /**
2346- * @param float|null $maximum
23472346 * @param float|null $minimum
2347+ * @param float|null $maximum
23482348 */
2349- public function __construct(?float $maximum, ?float $minimum) {
2350- $this->maximum = $maximum;
2349+ public function __construct(?float $minimum, ?float $maximum) {
23512350 $this->minimum = $minimum;
2351+ $this->maximum = $maximum;
23522352 }
23532353
23542354 /**
@@ -2356,7 +2356,7 @@ class Limit {
23562356 * @throws Exception
23572357 * @return ?float
23582358 */
2359- public static function fromMaximum(?float $value): ?float {
2359+ public static function fromMinimum(?float $value): ?float {
23602360 if (!is_null($value)) {
23612361 return $value; /*float*/
23622362 } else {
@@ -2368,15 +2368,15 @@ class Limit {
23682368 * @throws Exception
23692369 * @return ?float
23702370 */
2371- public function toMaximum(): ?float {
2372- if (Limit::validateMaximum($this->maximum)) {
2373- if (!is_null($this->maximum)) {
2374- return $this->maximum; /*float*/
2371+ public function toMinimum(): ?float {
2372+ if (Limit::validateMinimum($this->minimum)) {
2373+ if (!is_null($this->minimum)) {
2374+ return $this->minimum; /*float*/
23752375 } else {
23762376 return null;
23772377 }
23782378 }
2379- throw new Exception('never get to this Limit::maximum');
2379+ throw new Exception('never get to this Limit::minimum');
23802380 }
23812381
23822382 /**
@@ -2384,7 +2384,7 @@ class Limit {
23842384 * @return bool
23852385 * @throws Exception
23862386 */
2387- public static function validateMaximum(?float $value): bool {
2387+ public static function validateMinimum(?float $value): bool {
23882388 if (!is_null($value)) {
23892389 }
23902390 return true;
@@ -2394,18 +2394,18 @@ class Limit {
23942394 * @throws Exception
23952395 * @return ?float
23962396 */
2397- public function getMaximum(): ?float {
2398- if (Limit::validateMaximum($this->maximum)) {
2399- return $this->maximum;
2397+ public function getMinimum(): ?float {
2398+ if (Limit::validateMinimum($this->minimum)) {
2399+ return $this->minimum;
24002400 }
2401- throw new Exception('never get to getMaximum Limit::maximum');
2401+ throw new Exception('never get to getMinimum Limit::minimum');
24022402 }
24032403
24042404 /**
24052405 * @return ?float
24062406 */
2407- public static function sampleMaximum(): ?float {
2408- return 31.031; /*31:maximum*/
2407+ public static function sampleMinimum(): ?float {
2408+ return 31.031; /*31:minimum*/
24092409 }
24102410
24112411 /**
@@ -2413,7 +2413,7 @@ class Limit {
24132413 * @throws Exception
24142414 * @return ?float
24152415 */
2416- public static function fromMinimum(?float $value): ?float {
2416+ public static function fromMaximum(?float $value): ?float {
24172417 if (!is_null($value)) {
24182418 return $value; /*float*/
24192419 } else {
@@ -2425,15 +2425,15 @@ class Limit {
24252425 * @throws Exception
24262426 * @return ?float
24272427 */
2428- public function toMinimum(): ?float {
2429- if (Limit::validateMinimum($this->minimum)) {
2430- if (!is_null($this->minimum)) {
2431- return $this->minimum; /*float*/
2428+ public function toMaximum(): ?float {
2429+ if (Limit::validateMaximum($this->maximum)) {
2430+ if (!is_null($this->maximum)) {
2431+ return $this->maximum; /*float*/
24322432 } else {
24332433 return null;
24342434 }
24352435 }
2436- throw new Exception('never get to this Limit::minimum');
2436+ throw new Exception('never get to this Limit::maximum');
24372437 }
24382438
24392439 /**
@@ -2441,7 +2441,7 @@ class Limit {
24412441 * @return bool
24422442 * @throws Exception
24432443 */
2444- public static function validateMinimum(?float $value): bool {
2444+ public static function validateMaximum(?float $value): bool {
24452445 if (!is_null($value)) {
24462446 }
24472447 return true;
@@ -2451,18 +2451,18 @@ class Limit {
24512451 * @throws Exception
24522452 * @return ?float
24532453 */
2454- public function getMinimum(): ?float {
2455- if (Limit::validateMinimum($this->minimum)) {
2456- return $this->minimum;
2454+ public function getMaximum(): ?float {
2455+ if (Limit::validateMaximum($this->maximum)) {
2456+ return $this->maximum;
24572457 }
2458- throw new Exception('never get to getMinimum Limit::minimum');
2458+ throw new Exception('never get to getMaximum Limit::maximum');
24592459 }
24602460
24612461 /**
24622462 * @return ?float
24632463 */
2464- public static function sampleMinimum(): ?float {
2465- return 32.032; /*32:minimum*/
2464+ public static function sampleMaximum(): ?float {
2465+ return 32.032; /*32:maximum*/
24662466 }
24672467
24682468 /**
@@ -2470,8 +2470,8 @@ class Limit {
24702470 * @return bool
24712471 */
24722472 public function validate(): bool {
2473- return Limit::validateMaximum($this->maximum)
2474- || Limit::validateMinimum($this->minimum);
2473+ return Limit::validateMinimum($this->minimum)
2474+ || Limit::validateMaximum($this->maximum);
24752475 }
24762476
24772477 /**
@@ -2480,8 +2480,8 @@ class Limit {
24802480 */
24812481 public function to(): stdClass {
24822482 $out = new stdClass();
2483- $out->{'maximum'} = $this->toMaximum();
24842483 $out->{'minimum'} = $this->toMinimum();
2484+ $out->{'maximum'} = $this->toMaximum();
24852485 return $out;
24862486 }
24872487
@@ -2492,8 +2492,8 @@ class Limit {
24922492 */
24932493 public static function from(stdClass $obj): Limit {
24942494 return new Limit(
2495- Limit::fromMaximum($obj->{'maximum'})
2496- ,Limit::fromMinimum($obj->{'minimum'})
2495+ Limit::fromMinimum($obj->{'minimum'})
2496+ ,Limit::fromMaximum($obj->{'maximum'})
24972497 );
24982498 }
24992499
@@ -2502,8 +2502,8 @@ class Limit {
25022502 */
25032503 public static function sample(): Limit {
25042504 return new Limit(
2505- Limit::sampleMaximum()
2506- ,Limit::sampleMinimum()
2505+ Limit::sampleMinimum()
2506+ ,Limit::sampleMaximum()
25072507 );
25082508 }
25092509 }
Mschema-php/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.php+118 −118
@@ -4,16 +4,63 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private Node|string|null $next; // json:next Optional
87 private string $value; // json:value Required
8+ private Node|string|null $next; // json:next Optional
99
1010 /**
11- * @param Node|string|null $next
1211 * @param string $value
12+ * @param Node|string|null $next
1313 */
14- public function __construct(Node|string|null $next, string $value) {
15- $this->next = $next;
14+ public function __construct(string $value, Node|string|null $next) {
1615 $this->value = $value;
16+ $this->next = $next;
17+ }
18+
19+ /**
20+ * @param string $value
21+ * @throws Exception
22+ * @return string
23+ */
24+ public static function fromValue(string $value): string {
25+ return $value; /*string*/
26+ }
27+
28+ /**
29+ * @throws Exception
30+ * @return string
31+ */
32+ public function toValue(): string {
33+ if (TopLevel::validateValue($this->value)) {
34+ return $this->value; /*string*/
35+ }
36+ throw new Exception('never get to this TopLevel::value');
37+ }
38+
39+ /**
40+ * @param string
41+ * @return bool
42+ * @throws Exception
43+ */
44+ public static function validateValue(string $value): bool {
45+ return true;
46+ }
47+
48+ /**
49+ * @throws Exception
50+ * @return string
51+ */
52+ public function getValue(): string {
53+ if (TopLevel::validateValue($this->value)) {
54+ return $this->value;
55+ }
56+ throw new Exception('never get to getValue TopLevel::value');
57+ }
58+
59+ /**
60+ * @return string
61+ */
62+ public static function sampleValue(): string {
63+ return 'TopLevel::value::31'; /*31:value*/
1764 }
1865
1966 /**
@@ -89,54 +136,7 @@ class TopLevel {
89136 * @return Node|string|null
90137 */
91138 public static function sampleNext(): Node|string|null {
92- return Node::sample(); /*31:next*/
93- }
94-
95- /**
96- * @param string $value
97- * @throws Exception
98- * @return string
99- */
100- public static function fromValue(string $value): string {
101- return $value; /*string*/
102- }
103-
104- /**
105- * @throws Exception
106- * @return string
107- */
108- public function toValue(): string {
109- if (TopLevel::validateValue($this->value)) {
110- return $this->value; /*string*/
111- }
112- throw new Exception('never get to this TopLevel::value');
113- }
114-
115- /**
116- * @param string
117- * @return bool
118- * @throws Exception
119- */
120- public static function validateValue(string $value): bool {
121- return true;
122- }
123-
124- /**
125- * @throws Exception
126- * @return string
127- */
128- public function getValue(): string {
129- if (TopLevel::validateValue($this->value)) {
130- return $this->value;
131- }
132- throw new Exception('never get to getValue TopLevel::value');
133- }
134-
135- /**
136- * @return string
137- */
138- public static function sampleValue(): string {
139- return 'TopLevel::value::32'; /*32:value*/
139+ return Node::sample(); /*32:next*/
140140 }
141141
142142 /**
@@ -144,8 +144,8 @@ class TopLevel {
144144 * @return bool
145145 */
146146 public function validate(): bool {
147- return TopLevel::validateNext($this->next)
148- || TopLevel::validateValue($this->value);
147+ return TopLevel::validateValue($this->value)
148+ || TopLevel::validateNext($this->next);
149149 }
150150
151151 /**
@@ -154,8 +154,8 @@ class TopLevel {
154154 */
155155 public function to(): stdClass {
156156 $out = new stdClass();
157- $out->{'next'} = $this->toNext();
158157 $out->{'value'} = $this->toValue();
158+ $out->{'next'} = $this->toNext();
159159 return $out;
160160 }
161161
@@ -166,8 +166,8 @@ class TopLevel {
166166 */
167167 public static function from(stdClass $obj): TopLevel {
168168 return new TopLevel(
169- TopLevel::fromNext($obj->{'next'})
170- ,TopLevel::fromValue($obj->{'value'})
169+ TopLevel::fromValue($obj->{'value'})
170+ ,TopLevel::fromNext($obj->{'next'})
171171 );
172172 }
173173
@@ -176,8 +176,8 @@ class TopLevel {
176176 */
177177 public static function sample(): TopLevel {
178178 return new TopLevel(
179- TopLevel::sampleNext()
180- ,TopLevel::sampleValue()
179+ TopLevel::sampleValue()
180+ ,TopLevel::sampleNext()
181181 );
182182 }
183183 }
@@ -185,16 +185,63 @@ class TopLevel {
185185 // This is an autogenerated file:Node
186186
187187 class Node {
188- private Node|string|null $next; // json:next Optional
189188 private string $value; // json:value Required
189+ private Node|string|null $next; // json:next Optional
190190
191191 /**
192- * @param Node|string|null $next
193192 * @param string $value
193+ * @param Node|string|null $next
194194 */
195- public function __construct(Node|string|null $next, string $value) {
196- $this->next = $next;
195+ public function __construct(string $value, Node|string|null $next) {
197196 $this->value = $value;
197+ $this->next = $next;
198+ }
199+
200+ /**
201+ * @param string $value
202+ * @throws Exception
203+ * @return string
204+ */
205+ public static function fromValue(string $value): string {
206+ return $value; /*string*/
207+ }
208+
209+ /**
210+ * @throws Exception
211+ * @return string
212+ */
213+ public function toValue(): string {
214+ if (Node::validateValue($this->value)) {
215+ return $this->value; /*string*/
216+ }
217+ throw new Exception('never get to this Node::value');
218+ }
219+
220+ /**
221+ * @param string
222+ * @return bool
223+ * @throws Exception
224+ */
225+ public static function validateValue(string $value): bool {
226+ return true;
227+ }
228+
229+ /**
230+ * @throws Exception
231+ * @return string
232+ */
233+ public function getValue(): string {
234+ if (Node::validateValue($this->value)) {
235+ return $this->value;
236+ }
237+ throw new Exception('never get to getValue Node::value');
238+ }
239+
240+ /**
241+ * @return string
242+ */
243+ public static function sampleValue(): string {
244+ return 'Node::value::31'; /*31:value*/
198245 }
199246
200247 /**
@@ -270,54 +317,7 @@ class Node {
270317 * @return Node|string|null
271318 */
272319 public static function sampleNext(): Node|string|null {
273- return Node::sample(); /*31:next*/
274- }
275-
276- /**
277- * @param string $value
278- * @throws Exception
279- * @return string
280- */
281- public static function fromValue(string $value): string {
282- return $value; /*string*/
283- }
284-
285- /**
286- * @throws Exception
287- * @return string
288- */
289- public function toValue(): string {
290- if (Node::validateValue($this->value)) {
291- return $this->value; /*string*/
292- }
293- throw new Exception('never get to this Node::value');
294- }
295-
296- /**
297- * @param string
298- * @return bool
299- * @throws Exception
300- */
301- public static function validateValue(string $value): bool {
302- return true;
303- }
304-
305- /**
306- * @throws Exception
307- * @return string
308- */
309- public function getValue(): string {
310- if (Node::validateValue($this->value)) {
311- return $this->value;
312- }
313- throw new Exception('never get to getValue Node::value');
314- }
315-
316- /**
317- * @return string
318- */
319- public static function sampleValue(): string {
320- return 'Node::value::32'; /*32:value*/
320+ return Node::sample(); /*32:next*/
321321 }
322322
323323 /**
@@ -325,8 +325,8 @@ class Node {
325325 * @return bool
326326 */
327327 public function validate(): bool {
328- return Node::validateNext($this->next)
329- || Node::validateValue($this->value);
328+ return Node::validateValue($this->value)
329+ || Node::validateNext($this->next);
330330 }
331331
332332 /**
@@ -335,8 +335,8 @@ class Node {
335335 */
336336 public function to(): stdClass {
337337 $out = new stdClass();
338- $out->{'next'} = $this->toNext();
339338 $out->{'value'} = $this->toValue();
339+ $out->{'next'} = $this->toNext();
340340 return $out;
341341 }
342342
@@ -347,8 +347,8 @@ class Node {
347347 */
348348 public static function from(stdClass $obj): Node {
349349 return new Node(
350- Node::fromNext($obj->{'next'})
351- ,Node::fromValue($obj->{'value'})
350+ Node::fromValue($obj->{'value'})
351+ ,Node::fromNext($obj->{'next'})
352352 );
353353 }
354354
@@ -357,8 +357,8 @@ class Node {
357357 */
358358 public static function sample(): Node {
359359 return new Node(
360- Node::sampleNext()
361- ,Node::sampleValue()
360+ Node::sampleValue()
361+ ,Node::sampleNext()
362362 );
363363 }
364364 }
Mschema-php/test/inputs/schema/uuid.schema/default/TopLevel.php+159 −159
@@ -4,124 +4,88 @@ declare(strict_types=1);
44 // This is an autogenerated file:TopLevel
55
66 class TopLevel {
7- private ?array $arrNullable; // json:arrNullable Optional
8- private ?array $arrOne; // json:arrOne Optional
9- private ?string $nullable; // json:nullable Optional
107 private string $one; // json:one Required
118 private ?string $optional; // json:optional Optional
9+ private ?string $nullable; // json:nullable Optional
10+ private ?array $arrOne; // json:arrOne Optional
11+ private ?array $arrNullable; // json:arrNullable Optional
1212 private UnionWithEnum|string $unionWithEnum; // json:unionWithEnum Required
1313
1414 /**
15- * @param array|null $arrNullable
16- * @param array|null $arrOne
17- * @param string|null $nullable
1815 * @param string $one
1916 * @param string|null $optional
17+ * @param string|null $nullable
18+ * @param array|null $arrOne
19+ * @param array|null $arrNullable
2020 * @param UnionWithEnum|string $unionWithEnum
2121 */
22- public function __construct(?array $arrNullable, ?array $arrOne, ?string $nullable, string $one, ?string $optional, UnionWithEnum|string $unionWithEnum) {
23- $this->arrNullable = $arrNullable;
24- $this->arrOne = $arrOne;
25- $this->nullable = $nullable;
22+ public function __construct(string $one, ?string $optional, ?string $nullable, ?array $arrOne, ?array $arrNullable, UnionWithEnum|string $unionWithEnum) {
2623 $this->one = $one;
2724 $this->optional = $optional;
25+ $this->nullable = $nullable;
26+ $this->arrOne = $arrOne;
27+ $this->arrNullable = $arrNullable;
2828 $this->unionWithEnum = $unionWithEnum;
2929 }
3030
3131 /**
32- * @param ?array $value
32+ * @param string $value
3333 * @throws Exception
34- * @return ?array
34+ * @return string
3535 */
36- public static function fromArrNullable(?array $value): ?array {
37- if (!is_null($value)) {
38- return array_map(function ($value) {
39- if (!is_null($value)) {
40- return $value; /*uuid*/
41- } else {
42- return null;
43- }
44- }, $value);
45- } else {
46- return null;
47- }
36+ public static function fromOne(string $value): string {
37+ return $value; /*uuid*/
4838 }
4939
5040 /**
5141 * @throws Exception
52- * @return ?array
42+ * @return string
5343 */
54- public function toArrNullable(): ?array {
55- if (TopLevel::validateArrNullable($this->arrNullable)) {
56- if (!is_null($this->arrNullable)) {
57- return array_map(function ($value) {
58- if (!is_null($value)) {
59- return $value; /*uuid*/
60- } else {
61- return null;
62- }
63- }, $this->arrNullable);
64- } else {
65- return null;
66- }
44+ public function toOne(): string {
45+ if (TopLevel::validateOne($this->one)) {
46+ return $this->one; /*uuid*/
6747 }
68- throw new Exception('never get to this TopLevel::arrNullable');
48+ throw new Exception('never get to this TopLevel::one');
6949 }
7050
7151 /**
72- * @param array|null
52+ * @param string
7353 * @return bool
7454 * @throws Exception
7555 */
76- public static function validateArrNullable(?array $value): bool {
77- if (!is_null($value)) {
78- if (!is_array($value)) {
79- throw new Exception("Attribute Error:TopLevel::arrNullable");
80- }
81- array_walk($value, function($value_v) {
82- if (!is_null($value_v)) {
83- if (!is_string($value_v)) {
84- throw new Exception("Attribute Error:TopLevel::arrNullable");
85- }
86- if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value_v)) {
87- throw new Exception("Attribute Error:TopLevel::arrNullable");
88- }
89- }
90- });
56+ public static function validateOne(string $value): bool {
57+ if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) {
58+ throw new Exception("Attribute Error:TopLevel::one");
9159 }
9260 return true;
9361 }
9462
9563 /**
9664 * @throws Exception
97- * @return ?array
65+ * @return string
9866 */
99- public function getArrNullable(): ?array {
100- if (TopLevel::validateArrNullable($this->arrNullable)) {
101- return $this->arrNullable;
67+ public function getOne(): string {
68+ if (TopLevel::validateOne($this->one)) {
69+ return $this->one;
10270 }
103- throw new Exception('never get to getArrNullable TopLevel::arrNullable');
71+ throw new Exception('never get to getOne TopLevel::one');
10472 }
10573
10674 /**
107- * @return ?array
75+ * @return string
10876 */
109- public static function sampleArrNullable(): ?array {
110- return array(
111- '9277b8fb-2a65-4663-a36c-8d417e2d284b' /*31:*/
112- ); /* 31:arrNullable*/
77+ public static function sampleOne(): string {
78+ return '9277b8fb-2a65-4663-a36c-8d417e2d284b'; /*31:one*/
11379 }
11480
11581 /**
116- * @param ?array $value
82+ * @param ?string $value
11783 * @throws Exception
118- * @return ?array
84+ * @return ?string
11985 */
120- public static function fromArrOne(?array $value): ?array {
86+ public static function fromOptional(?string $value): ?string {
12187 if (!is_null($value)) {
122- return array_map(function ($value) {
123- return $value; /*uuid*/
124- }, $value);
88+ return $value; /*uuid*/
12589 } else {
12690 return null;
12791 }
@@ -129,61 +93,49 @@ class TopLevel {
12993
13094 /**
13195 * @throws Exception
132- * @return ?array
96+ * @return ?string
13397 */
134- public function toArrOne(): ?array {
135- if (TopLevel::validateArrOne($this->arrOne)) {
136- if (!is_null($this->arrOne)) {
137- return array_map(function ($value) {
138- return $value; /*uuid*/
139- }, $this->arrOne);
98+ public function toOptional(): ?string {
99+ if (TopLevel::validateOptional($this->optional)) {
100+ if (!is_null($this->optional)) {
101+ return $this->optional; /*uuid*/
140102 } else {
141103 return null;
142104 }
143105 }
144- throw new Exception('never get to this TopLevel::arrOne');
106+ throw new Exception('never get to this TopLevel::optional');
145107 }
146108
147109 /**
148- * @param array|null
110+ * @param string|null
149111 * @return bool
150112 * @throws Exception
151113 */
152- public static function validateArrOne(?array $value): bool {
114+ public static function validateOptional(?string $value): bool {
153115 if (!is_null($value)) {
154- if (!is_array($value)) {
155- throw new Exception("Attribute Error:TopLevel::arrOne");
116+ if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) {
117+ throw new Exception("Attribute Error:TopLevel::optional");
156118 }
157- array_walk($value, function($value_v) {
158- if (!is_string($value_v)) {
159- throw new Exception("Attribute Error:TopLevel::arrOne");
160- }
161- if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value_v)) {
162- throw new Exception("Attribute Error:TopLevel::arrOne");
163- }
164- });
165119 }
166120 return true;
167121 }
168122
169123 /**
170124 * @throws Exception
171- * @return ?array
125+ * @return ?string
172126 */
173- public function getArrOne(): ?array {
174- if (TopLevel::validateArrOne($this->arrOne)) {
175- return $this->arrOne;
127+ public function getOptional(): ?string {
128+ if (TopLevel::validateOptional($this->optional)) {
129+ return $this->optional;
176130 }
177- throw new Exception('never get to getArrOne TopLevel::arrOne');
131+ throw new Exception('never get to getOptional TopLevel::optional');
178132 }
179133
180134 /**
181- * @return ?array
135+ * @return ?string
182136 */
183- public static function sampleArrOne(): ?array {
184- return array(
185- '9277b8fb-2a65-4663-a36c-8d417e2d284b' /*32:*/
186- ); /* 32:arrOne*/
137+ public static function sampleOptional(): ?string {
138+ return '9277b8fb-2a65-4663-a36c-8d417e2d284b'; /*32:optional*/
187139 }
188140
189141 /**
@@ -247,63 +199,93 @@ class TopLevel {
247199 }
248200
249201 /**
250- * @param string $value
202+ * @param ?array $value
251203 * @throws Exception
252- * @return string
204+ * @return ?array
253205 */
254- public static function fromOne(string $value): string {
255- return $value; /*uuid*/
206+ public static function fromArrOne(?array $value): ?array {
207+ if (!is_null($value)) {
208+ return array_map(function ($value) {
209+ return $value; /*uuid*/
210+ }, $value);
211+ } else {
212+ return null;
213+ }
256214 }
257215
258216 /**
259217 * @throws Exception
260- * @return string
218+ * @return ?array
261219 */
262- public function toOne(): string {
263- if (TopLevel::validateOne($this->one)) {
264- return $this->one; /*uuid*/
220+ public function toArrOne(): ?array {
221+ if (TopLevel::validateArrOne($this->arrOne)) {
222+ if (!is_null($this->arrOne)) {
223+ return array_map(function ($value) {
224+ return $value; /*uuid*/
225+ }, $this->arrOne);
226+ } else {
227+ return null;
228+ }
265229 }
266- throw new Exception('never get to this TopLevel::one');
230+ throw new Exception('never get to this TopLevel::arrOne');
267231 }
268232
269233 /**
270- * @param string
234+ * @param array|null
271235 * @return bool
272236 * @throws Exception
273237 */
274- public static function validateOne(string $value): bool {
275- if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) {
276- throw new Exception("Attribute Error:TopLevel::one");
238+ public static function validateArrOne(?array $value): bool {
239+ if (!is_null($value)) {
240+ if (!is_array($value)) {
241+ throw new Exception("Attribute Error:TopLevel::arrOne");
242+ }
243+ array_walk($value, function($value_v) {
244+ if (!is_string($value_v)) {
245+ throw new Exception("Attribute Error:TopLevel::arrOne");
246+ }
247+ if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value_v)) {
248+ throw new Exception("Attribute Error:TopLevel::arrOne");
249+ }
250+ });
277251 }
278252 return true;
279253 }
280254
281255 /**
282256 * @throws Exception
283- * @return string
257+ * @return ?array
284258 */
285- public function getOne(): string {
286- if (TopLevel::validateOne($this->one)) {
287- return $this->one;
259+ public function getArrOne(): ?array {
260+ if (TopLevel::validateArrOne($this->arrOne)) {
261+ return $this->arrOne;
288262 }
289- throw new Exception('never get to getOne TopLevel::one');
263+ throw new Exception('never get to getArrOne TopLevel::arrOne');
290264 }
291265
292266 /**
293- * @return string
267+ * @return ?array
294268 */
295- public static function sampleOne(): string {
296- return '9277b8fb-2a65-4663-a36c-8d417e2d284b'; /*34:one*/
269+ public static function sampleArrOne(): ?array {
270+ return array(
271+ '9277b8fb-2a65-4663-a36c-8d417e2d284b' /*34:*/
272+ ); /* 34:arrOne*/
297273 }
298274
299275 /**
300- * @param ?string $value
276+ * @param ?array $value
301277 * @throws Exception
302- * @return ?string
278+ * @return ?array
303279 */
304- public static function fromOptional(?string $value): ?string {
280+ public static function fromArrNullable(?array $value): ?array {
305281 if (!is_null($value)) {
306- return $value; /*uuid*/
282+ return array_map(function ($value) {
283+ if (!is_null($value)) {
284+ return $value; /*uuid*/
285+ } else {
286+ return null;
287+ }
288+ }, $value);
307289 } else {
308290 return null;
309291 }
@@ -311,49 +293,67 @@ class TopLevel {
311293
312294 /**
313295 * @throws Exception
314- * @return ?string
296+ * @return ?array
315297 */
316- public function toOptional(): ?string {
317- if (TopLevel::validateOptional($this->optional)) {
318- if (!is_null($this->optional)) {
319- return $this->optional; /*uuid*/
298+ public function toArrNullable(): ?array {
299+ if (TopLevel::validateArrNullable($this->arrNullable)) {
300+ if (!is_null($this->arrNullable)) {
301+ return array_map(function ($value) {
302+ if (!is_null($value)) {
303+ return $value; /*uuid*/
304+ } else {
305+ return null;
306+ }
307+ }, $this->arrNullable);
320308 } else {
321309 return null;
322310 }
323311 }
324- throw new Exception('never get to this TopLevel::optional');
312+ throw new Exception('never get to this TopLevel::arrNullable');
325313 }
326314
327315 /**
328- * @param string|null
316+ * @param array|null
329317 * @return bool
330318 * @throws Exception
331319 */
332- public static function validateOptional(?string $value): bool {
320+ public static function validateArrNullable(?array $value): bool {
333321 if (!is_null($value)) {
334- if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) {
335- throw new Exception("Attribute Error:TopLevel::optional");
322+ if (!is_array($value)) {
323+ throw new Exception("Attribute Error:TopLevel::arrNullable");
336324 }
325+ array_walk($value, function($value_v) {
326+ if (!is_null($value_v)) {
327+ if (!is_string($value_v)) {
328+ throw new Exception("Attribute Error:TopLevel::arrNullable");
329+ }
330+ if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value_v)) {
331+ throw new Exception("Attribute Error:TopLevel::arrNullable");
332+ }
333+ }
334+ });
337335 }
338336 return true;
339337 }
340338
341339 /**
342340 * @throws Exception
343- * @return ?string
341+ * @return ?array
344342 */
345- public function getOptional(): ?string {
346- if (TopLevel::validateOptional($this->optional)) {
347- return $this->optional;
343+ public function getArrNullable(): ?array {
344+ if (TopLevel::validateArrNullable($this->arrNullable)) {
345+ return $this->arrNullable;
348346 }
349- throw new Exception('never get to getOptional TopLevel::optional');
347+ throw new Exception('never get to getArrNullable TopLevel::arrNullable');
350348 }
351349
352350 /**
353- * @return ?string
351+ * @return ?array
354352 */
355- public static function sampleOptional(): ?string {
356- return '9277b8fb-2a65-4663-a36c-8d417e2d284b'; /*35:optional*/
353+ public static function sampleArrNullable(): ?array {
354+ return array(
355+ '9277b8fb-2a65-4663-a36c-8d417e2d284b' /*35:*/
356+ ); /* 35:arrNullable*/
357357 }
358358
359359 /**
@@ -432,11 +432,11 @@ class TopLevel {
432432 * @return bool
433433 */
434434 public function validate(): bool {
435- return TopLevel::validateArrNullable($this->arrNullable)
436- || TopLevel::validateArrOne($this->arrOne)
437- || TopLevel::validateNullable($this->nullable)
438- || TopLevel::validateOne($this->one)
435+ return TopLevel::validateOne($this->one)
439436 || TopLevel::validateOptional($this->optional)
437+ || TopLevel::validateNullable($this->nullable)
438+ || TopLevel::validateArrOne($this->arrOne)
439+ || TopLevel::validateArrNullable($this->arrNullable)
440440 || TopLevel::validateUnionWithEnum($this->unionWithEnum);
441441 }
442442
@@ -446,11 +446,11 @@ class TopLevel {
446446 */
447447 public function to(): stdClass {
448448 $out = new stdClass();
449- $out->{'arrNullable'} = $this->toArrNullable();
450- $out->{'arrOne'} = $this->toArrOne();
451- $out->{'nullable'} = $this->toNullable();
452449 $out->{'one'} = $this->toOne();
453450 $out->{'optional'} = $this->toOptional();
451+ $out->{'nullable'} = $this->toNullable();
452+ $out->{'arrOne'} = $this->toArrOne();
453+ $out->{'arrNullable'} = $this->toArrNullable();
454454 $out->{'unionWithEnum'} = $this->toUnionWithEnum();
455455 return $out;
456456 }
@@ -462,11 +462,11 @@ class TopLevel {
462462 */
463463 public static function from(stdClass $obj): TopLevel {
464464 return new TopLevel(
465- TopLevel::fromArrNullable($obj->{'arrNullable'})
466- ,TopLevel::fromArrOne($obj->{'arrOne'})
467- ,TopLevel::fromNullable($obj->{'nullable'})
468- ,TopLevel::fromOne($obj->{'one'})
465+ TopLevel::fromOne($obj->{'one'})
469466 ,TopLevel::fromOptional($obj->{'optional'})
467+ ,TopLevel::fromNullable($obj->{'nullable'})
468+ ,TopLevel::fromArrOne($obj->{'arrOne'})
469+ ,TopLevel::fromArrNullable($obj->{'arrNullable'})
470470 ,TopLevel::fromUnionWithEnum($obj->{'unionWithEnum'})
471471 );
472472 }
@@ -476,11 +476,11 @@ class TopLevel {
476476 */
477477 public static function sample(): TopLevel {
478478 return new TopLevel(
479- TopLevel::sampleArrNullable()
480- ,TopLevel::sampleArrOne()
481- ,TopLevel::sampleNullable()
482- ,TopLevel::sampleOne()
479+ TopLevel::sampleOne()
483480 ,TopLevel::sampleOptional()
481+ ,TopLevel::sampleNullable()
482+ ,TopLevel::sampleArrOne()
483+ ,TopLevel::sampleArrNullable()
484484 ,TopLevel::sampleUnionWithEnum()
485485 );
486486 }
Mschema-php/test/inputs/schema/vega-lite.schema/default/TopLevel.php+640 −640
@@ -5858,8 +5858,8 @@ class MarkConfig {
58585858 private ?float $dx; // json:dx Optional
58595859 private ?float $dy; // json:dy Optional
58605860 private ?string $fill; // json:fill Optional
5861- private ?bool $filled; // json:filled Optional
58625861 private ?float $fillOpacity; // json:fillOpacity Optional
5862+ private ?bool $filled; // json:filled Optional
58635863 private ?string $font; // json:font Optional
58645864 private ?float $fontSize; // json:fontSize Optional
58655865 private ?FontStyle $fontStyle; // json:fontStyle Optional
@@ -5890,8 +5890,8 @@ class MarkConfig {
58905890 * @param float|null $dx
58915891 * @param float|null $dy
58925892 * @param string|null $fill
5893- * @param bool|null $filled
58945893 * @param float|null $fillOpacity
5894+ * @param bool|null $filled
58955895 * @param string|null $font
58965896 * @param float|null $fontSize
58975897 * @param FontStyle|null $fontStyle
@@ -5913,7 +5913,7 @@ class MarkConfig {
59135913 * @param string|null $text
59145914 * @param float|null $theta
59155915 */
5916- public function __construct(?HorizontalAlign $align, ?float $angle, ?VerticalAlign $baseline, ?string $color, ?Cursor $cursor, ?float $dx, ?float $dy, ?string $fill, ?bool $filled, ?float $fillOpacity, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, ?float $tension, ?string $text, ?float $theta) {
5916+ public function __construct(?HorizontalAlign $align, ?float $angle, ?VerticalAlign $baseline, ?string $color, ?Cursor $cursor, ?float $dx, ?float $dy, ?string $fill, ?float $fillOpacity, ?bool $filled, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, ?float $tension, ?string $text, ?float $theta) {
59175917 $this->align = $align;
59185918 $this->angle = $angle;
59195919 $this->baseline = $baseline;
@@ -5922,8 +5922,8 @@ class MarkConfig {
59225922 $this->dx = $dx;
59235923 $this->dy = $dy;
59245924 $this->fill = $fill;
5925- $this->filled = $filled;
59265925 $this->fillOpacity = $fillOpacity;
5926+ $this->filled = $filled;
59275927 $this->font = $font;
59285928 $this->fontSize = $fontSize;
59295929 $this->fontStyle = $fontStyle;
@@ -6545,6 +6545,83 @@ class MarkConfig {
65456545 return 'MarkConfig::fill::38'; /*38:fill*/
65466546 }
65476547
6548+ /**
6549+ * The fill opacity (value between [0,1]).
6550+ *
6551+ * __Default value:__ `1`
6552+ *
6553+ * @param ?float $value
6554+ * @throws Exception
6555+ * @return ?float
6556+ */
6557+ public static function fromFillOpacity(?float $value): ?float {
6558+ if (!is_null($value)) {
6559+ return $value; /*float*/
6560+ } else {
6561+ return null;
6562+ }
6563+ }
6564+
6565+ /**
6566+ * The fill opacity (value between [0,1]).
6567+ *
6568+ * __Default value:__ `1`
6569+ *
6570+ * @throws Exception
6571+ * @return ?float
6572+ */
6573+ public function toFillOpacity(): ?float {
6574+ if (MarkConfig::validateFillOpacity($this->fillOpacity)) {
6575+ if (!is_null($this->fillOpacity)) {
6576+ return $this->fillOpacity; /*float*/
6577+ } else {
6578+ return null;
6579+ }
6580+ }
6581+ throw new Exception('never get to this MarkConfig::fillOpacity');
6582+ }
6583+
6584+ /**
6585+ * The fill opacity (value between [0,1]).
6586+ *
6587+ * __Default value:__ `1`
6588+ *
6589+ * @param float|null
6590+ * @return bool
6591+ * @throws Exception
6592+ */
6593+ public static function validateFillOpacity(?float $value): bool {
6594+ if (!is_null($value)) {
6595+ }
6596+ return true;
6597+ }
6598+
6599+ /**
6600+ * The fill opacity (value between [0,1]).
6601+ *
6602+ * __Default value:__ `1`
6603+ *
6604+ * @throws Exception
6605+ * @return ?float
6606+ */
6607+ public function getFillOpacity(): ?float {
6608+ if (MarkConfig::validateFillOpacity($this->fillOpacity)) {
6609+ return $this->fillOpacity;
6610+ }
6611+ throw new Exception('never get to getFillOpacity MarkConfig::fillOpacity');
6612+ }
6613+
6614+ /**
6615+ * The fill opacity (value between [0,1]).
6616+ *
6617+ * __Default value:__ `1`
6618+ *
6619+ * @return ?float
6620+ */
6621+ public static function sampleFillOpacity(): ?float {
6622+ return 39.039; /*39:fillOpacity*/
6623+ }
6624+
65486625 /**
65496626 * Whether the mark's color should be used as fill color instead of stroke color.
65506627 *
@@ -6639,84 +6716,7 @@ class MarkConfig {
66396716 * @return ?bool
66406717 */
66416718 public static function sampleFilled(): ?bool {
6642- return true; /*39:filled*/
6643- }
6644-
6645- /**
6646- * The fill opacity (value between [0,1]).
6647- *
6648- * __Default value:__ `1`
6649- *
6650- * @param ?float $value
6651- * @throws Exception
6652- * @return ?float
6653- */
6654- public static function fromFillOpacity(?float $value): ?float {
6655- if (!is_null($value)) {
6656- return $value; /*float*/
6657- } else {
6658- return null;
6659- }
6660- }
6661-
6662- /**
6663- * The fill opacity (value between [0,1]).
6664- *
6665- * __Default value:__ `1`
6666- *
6667- * @throws Exception
6668- * @return ?float
6669- */
6670- public function toFillOpacity(): ?float {
6671- if (MarkConfig::validateFillOpacity($this->fillOpacity)) {
6672- if (!is_null($this->fillOpacity)) {
6673- return $this->fillOpacity; /*float*/
6674- } else {
6675- return null;
6676- }
6677- }
6678- throw new Exception('never get to this MarkConfig::fillOpacity');
6679- }
6680-
6681- /**
6682- * The fill opacity (value between [0,1]).
6683- *
6684- * __Default value:__ `1`
6685- *
6686- * @param float|null
6687- * @return bool
6688- * @throws Exception
6689- */
6690- public static function validateFillOpacity(?float $value): bool {
6691- if (!is_null($value)) {
6692- }
6693- return true;
6694- }
6695-
6696- /**
6697- * The fill opacity (value between [0,1]).
6698- *
6699- * __Default value:__ `1`
6700- *
6701- * @throws Exception
6702- * @return ?float
6703- */
6704- public function getFillOpacity(): ?float {
6705- if (MarkConfig::validateFillOpacity($this->fillOpacity)) {
6706- return $this->fillOpacity;
6707- }
6708- throw new Exception('never get to getFillOpacity MarkConfig::fillOpacity');
6709- }
6710-
6711- /**
6712- * The fill opacity (value between [0,1]).
6713- *
6714- * __Default value:__ `1`
6715- *
6716- * @return ?float
6717- */
6718- public static function sampleFillOpacity(): ?float {
6719- return 40.04; /*40:fillOpacity*/
6719+ return true; /*40:filled*/
67206720 }
67216721
67226722 /**
@@ -8328,8 +8328,8 @@ class MarkConfig {
83288328 || MarkConfig::validateDx($this->dx)
83298329 || MarkConfig::validateDy($this->dy)
83308330 || MarkConfig::validateFill($this->fill)
8331- || MarkConfig::validateFilled($this->filled)
83328331 || MarkConfig::validateFillOpacity($this->fillOpacity)
8332+ || MarkConfig::validateFilled($this->filled)
83338333 || MarkConfig::validateFont($this->font)
83348334 || MarkConfig::validateFontSize($this->fontSize)
83358335 || MarkConfig::validateFontStyle($this->fontStyle)
@@ -8366,8 +8366,8 @@ class MarkConfig {
83668366 $out->{'dx'} = $this->toDx();
83678367 $out->{'dy'} = $this->toDy();
83688368 $out->{'fill'} = $this->toFill();
8369- $out->{'filled'} = $this->toFilled();
83708369 $out->{'fillOpacity'} = $this->toFillOpacity();
8370+ $out->{'filled'} = $this->toFilled();
83718371 $out->{'font'} = $this->toFont();
83728372 $out->{'fontSize'} = $this->toFontSize();
83738373 $out->{'fontStyle'} = $this->toFontStyle();
@@ -8406,8 +8406,8 @@ class MarkConfig {
84068406 ,MarkConfig::fromDx($obj->{'dx'})
84078407 ,MarkConfig::fromDy($obj->{'dy'})
84088408 ,MarkConfig::fromFill($obj->{'fill'})
8409- ,MarkConfig::fromFilled($obj->{'filled'})
84108409 ,MarkConfig::fromFillOpacity($obj->{'fillOpacity'})
8410+ ,MarkConfig::fromFilled($obj->{'filled'})
84118411 ,MarkConfig::fromFont($obj->{'font'})
84128412 ,MarkConfig::fromFontSize($obj->{'fontSize'})
84138413 ,MarkConfig::fromFontStyle($obj->{'fontStyle'})
@@ -8444,8 +8444,8 @@ class MarkConfig {
84448444 ,MarkConfig::sampleDx()
84458445 ,MarkConfig::sampleDy()
84468446 ,MarkConfig::sampleFill()
8447- ,MarkConfig::sampleFilled()
84488447 ,MarkConfig::sampleFillOpacity()
8448+ ,MarkConfig::sampleFilled()
84498449 ,MarkConfig::sampleFont()
84508450 ,MarkConfig::sampleFontSize()
84518451 ,MarkConfig::sampleFontStyle()
@@ -9076,9 +9076,9 @@ class AxisConfig {
90769076 private ?bool $shortTimeLabels; // json:shortTimeLabels Optional
90779077 private ?string $tickColor; // json:tickColor Optional
90789078 private ?bool $tickRound; // json:tickRound Optional
9079- private ?bool $ticks; // json:ticks Optional
90809079 private ?float $tickSize; // json:tickSize Optional
90819080 private ?float $tickWidth; // json:tickWidth Optional
9081+ private ?bool $ticks; // json:ticks Optional
90829082 private ?string $titleAlign; // json:titleAlign Optional
90839083 private ?float $titleAngle; // json:titleAngle Optional
90849084 private ?string $titleBaseline; // json:titleBaseline Optional
@@ -9117,9 +9117,9 @@ class AxisConfig {
91179117 * @param bool|null $shortTimeLabels
91189118 * @param string|null $tickColor
91199119 * @param bool|null $tickRound
9120- * @param bool|null $ticks
91219120 * @param float|null $tickSize
91229121 * @param float|null $tickWidth
9122+ * @param bool|null $ticks
91239123 * @param string|null $titleAlign
91249124 * @param float|null $titleAngle
91259125 * @param string|null $titleBaseline
@@ -9133,7 +9133,7 @@ class AxisConfig {
91339133 * @param float|null $titleX
91349134 * @param float|null $titleY
91359135 */
9136- public function __construct(?float $bandPosition, ?bool $domain, ?string $domainColor, ?float $domainWidth, ?bool $grid, ?string $gridColor, ?array $gridDash, ?float $gridOpacity, ?float $gridWidth, ?float $labelAngle, bool|float|null $labelBound, ?string $labelColor, bool|float|null $labelFlush, ?string $labelFont, ?float $labelFontSize, ?float $labelLimit, LabelOverlap|bool|null $labelOverlap, ?float $labelPadding, ?bool $labels, ?float $maxExtent, ?float $minExtent, ?bool $shortTimeLabels, ?string $tickColor, ?bool $tickRound, ?bool $ticks, ?float $tickSize, ?float $tickWidth, ?string $titleAlign, ?float $titleAngle, ?string $titleBaseline, ?string $titleColor, ?string $titleFont, ?float $titleFontSize, float|string|null $titleFontWeight, ?float $titleLimit, ?float $titleMaxLength, ?float $titlePadding, ?float $titleX, ?float $titleY) {
9136+ public function __construct(?float $bandPosition, ?bool $domain, ?string $domainColor, ?float $domainWidth, ?bool $grid, ?string $gridColor, ?array $gridDash, ?float $gridOpacity, ?float $gridWidth, ?float $labelAngle, bool|float|null $labelBound, ?string $labelColor, bool|float|null $labelFlush, ?string $labelFont, ?float $labelFontSize, ?float $labelLimit, LabelOverlap|bool|null $labelOverlap, ?float $labelPadding, ?bool $labels, ?float $maxExtent, ?float $minExtent, ?bool $shortTimeLabels, ?string $tickColor, ?bool $tickRound, ?float $tickSize, ?float $tickWidth, ?bool $ticks, ?string $titleAlign, ?float $titleAngle, ?string $titleBaseline, ?string $titleColor, ?string $titleFont, ?float $titleFontSize, float|string|null $titleFontWeight, ?float $titleLimit, ?float $titleMaxLength, ?float $titlePadding, ?float $titleX, ?float $titleY) {
91379137 $this->bandPosition = $bandPosition;
91389138 $this->domain = $domain;
91399139 $this->domainColor = $domainColor;
@@ -9158,9 +9158,9 @@ class AxisConfig {
91589158 $this->shortTimeLabels = $shortTimeLabels;
91599159 $this->tickColor = $tickColor;
91609160 $this->tickRound = $tickRound;
9161- $this->ticks = $ticks;
91629161 $this->tickSize = $tickSize;
91639162 $this->tickWidth = $tickWidth;
9163+ $this->ticks = $ticks;
91649164 $this->titleAlign = $titleAlign;
91659165 $this->titleAngle = $titleAngle;
91669166 $this->titleBaseline = $titleBaseline;
@@ -11094,80 +11094,80 @@ class AxisConfig {
1109411094 }
1109511095
1109611096 /**
11097- * Boolean value that determines whether the axis should include ticks.
11097+ * The size in pixels of axis ticks.
1109811098 *
11099- * @param ?bool $value
11099+ * @param ?float $value
1110011100 * @throws Exception
11101- * @return ?bool
11101+ * @return ?float
1110211102 */
11103- public static function fromTicks(?bool $value): ?bool {
11103+ public static function fromTickSize(?float $value): ?float {
1110411104 if (!is_null($value)) {
11105- return $value; /*bool*/
11105+ return $value; /*float*/
1110611106 } else {
1110711107 return null;
1110811108 }
1110911109 }
1111011110
1111111111 /**
11112- * Boolean value that determines whether the axis should include ticks.
11112+ * The size in pixels of axis ticks.
1111311113 *
1111411114 * @throws Exception
11115- * @return ?bool
11115+ * @return ?float
1111611116 */
11117- public function toTicks(): ?bool {
11118- if (AxisConfig::validateTicks($this->ticks)) {
11119- if (!is_null($this->ticks)) {
11120- return $this->ticks; /*bool*/
11117+ public function toTickSize(): ?float {
11118+ if (AxisConfig::validateTickSize($this->tickSize)) {
11119+ if (!is_null($this->tickSize)) {
11120+ return $this->tickSize; /*float*/
1112111121 } else {
1112211122 return null;
1112311123 }
1112411124 }
11125- throw new Exception('never get to this AxisConfig::ticks');
11125+ throw new Exception('never get to this AxisConfig::tickSize');
1112611126 }
1112711127
1112811128 /**
11129- * Boolean value that determines whether the axis should include ticks.
11129+ * The size in pixels of axis ticks.
1113011130 *
11131- * @param bool|null
11131+ * @param float|null
1113211132 * @return bool
1113311133 * @throws Exception
1113411134 */
11135- public static function validateTicks(?bool $value): bool {
11135+ public static function validateTickSize(?float $value): bool {
1113611136 if (!is_null($value)) {
1113711137 }
1113811138 return true;
1113911139 }
1114011140
1114111141 /**
11142- * Boolean value that determines whether the axis should include ticks.
11142+ * The size in pixels of axis ticks.
1114311143 *
1114411144 * @throws Exception
11145- * @return ?bool
11145+ * @return ?float
1114611146 */
11147- public function getTicks(): ?bool {
11148- if (AxisConfig::validateTicks($this->ticks)) {
11149- return $this->ticks;
11147+ public function getTickSize(): ?float {
11148+ if (AxisConfig::validateTickSize($this->tickSize)) {
11149+ return $this->tickSize;
1115011150 }
11151- throw new Exception('never get to getTicks AxisConfig::ticks');
11151+ throw new Exception('never get to getTickSize AxisConfig::tickSize');
1115211152 }
1115311153
1115411154 /**
11155- * Boolean value that determines whether the axis should include ticks.
11155+ * The size in pixels of axis ticks.
1115611156 *
11157- * @return ?bool
11157+ * @return ?float
1115811158 */
11159- public static function sampleTicks(): ?bool {
11160- return true; /*55:ticks*/
11159+ public static function sampleTickSize(): ?float {
11160+ return 55.055; /*55:tickSize*/
1116111161 }
1116211162
1116311163 /**
11164- * The size in pixels of axis ticks.
11164+ * The width, in pixels, of ticks.
1116511165 *
1116611166 * @param ?float $value
1116711167 * @throws Exception
1116811168 * @return ?float
1116911169 */
11170- public static function fromTickSize(?float $value): ?float {
11170+ public static function fromTickWidth(?float $value): ?float {
1117111171 if (!is_null($value)) {
1117211172 return $value; /*float*/
1117311173 } else {
@@ -11176,122 +11176,122 @@ class AxisConfig {
1117611176 }
1117711177
1117811178 /**
11179- * The size in pixels of axis ticks.
11179+ * The width, in pixels, of ticks.
1118011180 *
1118111181 * @throws Exception
1118211182 * @return ?float
1118311183 */
11184- public function toTickSize(): ?float {
11185- if (AxisConfig::validateTickSize($this->tickSize)) {
11186- if (!is_null($this->tickSize)) {
11187- return $this->tickSize; /*float*/
11184+ public function toTickWidth(): ?float {
11185+ if (AxisConfig::validateTickWidth($this->tickWidth)) {
11186+ if (!is_null($this->tickWidth)) {
11187+ return $this->tickWidth; /*float*/
1118811188 } else {
1118911189 return null;
1119011190 }
1119111191 }
11192- throw new Exception('never get to this AxisConfig::tickSize');
11192+ throw new Exception('never get to this AxisConfig::tickWidth');
1119311193 }
1119411194
1119511195 /**
11196- * The size in pixels of axis ticks.
11196+ * The width, in pixels, of ticks.
1119711197 *
1119811198 * @param float|null
1119911199 * @return bool
1120011200 * @throws Exception
1120111201 */
11202- public static function validateTickSize(?float $value): bool {
11202+ public static function validateTickWidth(?float $value): bool {
1120311203 if (!is_null($value)) {
1120411204 }
1120511205 return true;
1120611206 }
1120711207
1120811208 /**
11209- * The size in pixels of axis ticks.
11209+ * The width, in pixels, of ticks.
1121011210 *
1121111211 * @throws Exception
1121211212 * @return ?float
1121311213 */
11214- public function getTickSize(): ?float {
11215- if (AxisConfig::validateTickSize($this->tickSize)) {
11216- return $this->tickSize;
11214+ public function getTickWidth(): ?float {
11215+ if (AxisConfig::validateTickWidth($this->tickWidth)) {
11216+ return $this->tickWidth;
1121711217 }
11218- throw new Exception('never get to getTickSize AxisConfig::tickSize');
11218+ throw new Exception('never get to getTickWidth AxisConfig::tickWidth');
1121911219 }
1122011220
1122111221 /**
11222- * The size in pixels of axis ticks.
11222+ * The width, in pixels, of ticks.
1122311223 *
1122411224 * @return ?float
1122511225 */
11226- public static function sampleTickSize(): ?float {
11227- return 56.056; /*56:tickSize*/
11226+ public static function sampleTickWidth(): ?float {
11227+ return 56.056; /*56:tickWidth*/
1122811228 }
1122911229
1123011230 /**
11231- * The width, in pixels, of ticks.
11231+ * Boolean value that determines whether the axis should include ticks.
1123211232 *
11233- * @param ?float $value
11233+ * @param ?bool $value
1123411234 * @throws Exception
11235- * @return ?float
11235+ * @return ?bool
1123611236 */
11237- public static function fromTickWidth(?float $value): ?float {
11237+ public static function fromTicks(?bool $value): ?bool {
1123811238 if (!is_null($value)) {
11239- return $value; /*float*/
11239+ return $value; /*bool*/
1124011240 } else {
1124111241 return null;
1124211242 }
1124311243 }
1124411244
1124511245 /**
11246- * The width, in pixels, of ticks.
11246+ * Boolean value that determines whether the axis should include ticks.
1124711247 *
1124811248 * @throws Exception
11249- * @return ?float
11249+ * @return ?bool
1125011250 */
11251- public function toTickWidth(): ?float {
11252- if (AxisConfig::validateTickWidth($this->tickWidth)) {
11253- if (!is_null($this->tickWidth)) {
11254- return $this->tickWidth; /*float*/
11251+ public function toTicks(): ?bool {
11252+ if (AxisConfig::validateTicks($this->ticks)) {
11253+ if (!is_null($this->ticks)) {
11254+ return $this->ticks; /*bool*/
1125511255 } else {
1125611256 return null;
1125711257 }
1125811258 }
11259- throw new Exception('never get to this AxisConfig::tickWidth');
11259+ throw new Exception('never get to this AxisConfig::ticks');
1126011260 }
1126111261
1126211262 /**
11263- * The width, in pixels, of ticks.
11263+ * Boolean value that determines whether the axis should include ticks.
1126411264 *
11265- * @param float|null
11265+ * @param bool|null
1126611266 * @return bool
1126711267 * @throws Exception
1126811268 */
11269- public static function validateTickWidth(?float $value): bool {
11269+ public static function validateTicks(?bool $value): bool {
1127011270 if (!is_null($value)) {
1127111271 }
1127211272 return true;
1127311273 }
1127411274
1127511275 /**
11276- * The width, in pixels, of ticks.
11276+ * Boolean value that determines whether the axis should include ticks.
1127711277 *
1127811278 * @throws Exception
11279- * @return ?float
11279+ * @return ?bool
1128011280 */
11281- public function getTickWidth(): ?float {
11282- if (AxisConfig::validateTickWidth($this->tickWidth)) {
11283- return $this->tickWidth;
11281+ public function getTicks(): ?bool {
11282+ if (AxisConfig::validateTicks($this->ticks)) {
11283+ return $this->ticks;
1128411284 }
11285- throw new Exception('never get to getTickWidth AxisConfig::tickWidth');
11285+ throw new Exception('never get to getTicks AxisConfig::ticks');
1128611286 }
1128711287
1128811288 /**
11289- * The width, in pixels, of ticks.
11289+ * Boolean value that determines whether the axis should include ticks.
1129011290 *
11291- * @return ?float
11291+ * @return ?bool
1129211292 */
11293- public static function sampleTickWidth(): ?float {
11294- return 57.057; /*57:tickWidth*/
11293+ public static function sampleTicks(): ?bool {
11294+ return true; /*57:ticks*/
1129511295 }
1129611296
1129711297 /**
@@ -12153,9 +12153,9 @@ class AxisConfig {
1215312153 || AxisConfig::validateShortTimeLabels($this->shortTimeLabels)
1215412154 || AxisConfig::validateTickColor($this->tickColor)
1215512155 || AxisConfig::validateTickRound($this->tickRound)
12156- || AxisConfig::validateTicks($this->ticks)
1215712156 || AxisConfig::validateTickSize($this->tickSize)
1215812157 || AxisConfig::validateTickWidth($this->tickWidth)
12158+ || AxisConfig::validateTicks($this->ticks)
1215912159 || AxisConfig::validateTitleAlign($this->titleAlign)
1216012160 || AxisConfig::validateTitleAngle($this->titleAngle)
1216112161 || AxisConfig::validateTitleBaseline($this->titleBaseline)
@@ -12200,9 +12200,9 @@ class AxisConfig {
1220012200 $out->{'shortTimeLabels'} = $this->toShortTimeLabels();
1220112201 $out->{'tickColor'} = $this->toTickColor();
1220212202 $out->{'tickRound'} = $this->toTickRound();
12203- $out->{'ticks'} = $this->toTicks();
1220412203 $out->{'tickSize'} = $this->toTickSize();
1220512204 $out->{'tickWidth'} = $this->toTickWidth();
12205+ $out->{'ticks'} = $this->toTicks();
1220612206 $out->{'titleAlign'} = $this->toTitleAlign();
1220712207 $out->{'titleAngle'} = $this->toTitleAngle();
1220812208 $out->{'titleBaseline'} = $this->toTitleBaseline();
@@ -12249,9 +12249,9 @@ class AxisConfig {
1224912249 ,AxisConfig::fromShortTimeLabels($obj->{'shortTimeLabels'})
1225012250 ,AxisConfig::fromTickColor($obj->{'tickColor'})
1225112251 ,AxisConfig::fromTickRound($obj->{'tickRound'})
12252- ,AxisConfig::fromTicks($obj->{'ticks'})
1225312252 ,AxisConfig::fromTickSize($obj->{'tickSize'})
1225412253 ,AxisConfig::fromTickWidth($obj->{'tickWidth'})
12254+ ,AxisConfig::fromTicks($obj->{'ticks'})
1225512255 ,AxisConfig::fromTitleAlign($obj->{'titleAlign'})
1225612256 ,AxisConfig::fromTitleAngle($obj->{'titleAngle'})
1225712257 ,AxisConfig::fromTitleBaseline($obj->{'titleBaseline'})
@@ -12296,9 +12296,9 @@ class AxisConfig {
1229612296 ,AxisConfig::sampleShortTimeLabels()
1229712297 ,AxisConfig::sampleTickColor()
1229812298 ,AxisConfig::sampleTickRound()
12299- ,AxisConfig::sampleTicks()
1230012299 ,AxisConfig::sampleTickSize()
1230112300 ,AxisConfig::sampleTickWidth()
12301+ ,AxisConfig::sampleTicks()
1230212302 ,AxisConfig::sampleTitleAlign()
1230312303 ,AxisConfig::sampleTitleAngle()
1230412304 ,AxisConfig::sampleTitleBaseline()
@@ -12390,9 +12390,9 @@ class VGAxisConfig {
1239012390 private ?float $minExtent; // json:minExtent Optional
1239112391 private ?string $tickColor; // json:tickColor Optional
1239212392 private ?bool $tickRound; // json:tickRound Optional
12393- private ?bool $ticks; // json:ticks Optional
1239412393 private ?float $tickSize; // json:tickSize Optional
1239512394 private ?float $tickWidth; // json:tickWidth Optional
12395+ private ?bool $ticks; // json:ticks Optional
1239612396 private ?string $titleAlign; // json:titleAlign Optional
1239712397 private ?float $titleAngle; // json:titleAngle Optional
1239812398 private ?string $titleBaseline; // json:titleBaseline Optional
@@ -12430,9 +12430,9 @@ class VGAxisConfig {
1243012430 * @param float|null $minExtent
1243112431 * @param string|null $tickColor
1243212432 * @param bool|null $tickRound
12433- * @param bool|null $ticks
1243412433 * @param float|null $tickSize
1243512434 * @param float|null $tickWidth
12435+ * @param bool|null $ticks
1243612436 * @param string|null $titleAlign
1243712437 * @param float|null $titleAngle
1243812438 * @param string|null $titleBaseline
@@ -12446,7 +12446,7 @@ class VGAxisConfig {
1244612446 * @param float|null $titleX
1244712447 * @param float|null $titleY
1244812448 */
12449- public function __construct(?float $bandPosition, ?bool $domain, ?string $domainColor, ?float $domainWidth, ?bool $grid, ?string $gridColor, ?array $gridDash, ?float $gridOpacity, ?float $gridWidth, ?float $labelAngle, bool|float|null $labelBound, ?string $labelColor, bool|float|null $labelFlush, ?string $labelFont, ?float $labelFontSize, ?float $labelLimit, LabelOverlap|bool|null $labelOverlap, ?float $labelPadding, ?bool $labels, ?float $maxExtent, ?float $minExtent, ?string $tickColor, ?bool $tickRound, ?bool $ticks, ?float $tickSize, ?float $tickWidth, ?string $titleAlign, ?float $titleAngle, ?string $titleBaseline, ?string $titleColor, ?string $titleFont, ?float $titleFontSize, float|string|null $titleFontWeight, ?float $titleLimit, ?float $titleMaxLength, ?float $titlePadding, ?float $titleX, ?float $titleY) {
12449+ public function __construct(?float $bandPosition, ?bool $domain, ?string $domainColor, ?float $domainWidth, ?bool $grid, ?string $gridColor, ?array $gridDash, ?float $gridOpacity, ?float $gridWidth, ?float $labelAngle, bool|float|null $labelBound, ?string $labelColor, bool|float|null $labelFlush, ?string $labelFont, ?float $labelFontSize, ?float $labelLimit, LabelOverlap|bool|null $labelOverlap, ?float $labelPadding, ?bool $labels, ?float $maxExtent, ?float $minExtent, ?string $tickColor, ?bool $tickRound, ?float $tickSize, ?float $tickWidth, ?bool $ticks, ?string $titleAlign, ?float $titleAngle, ?string $titleBaseline, ?string $titleColor, ?string $titleFont, ?float $titleFontSize, float|string|null $titleFontWeight, ?float $titleLimit, ?float $titleMaxLength, ?float $titlePadding, ?float $titleX, ?float $titleY) {
1245012450 $this->bandPosition = $bandPosition;
1245112451 $this->domain = $domain;
1245212452 $this->domainColor = $domainColor;
@@ -12470,9 +12470,9 @@ class VGAxisConfig {
1247012470 $this->minExtent = $minExtent;
1247112471 $this->tickColor = $tickColor;
1247212472 $this->tickRound = $tickRound;
12473- $this->ticks = $ticks;
1247412473 $this->tickSize = $tickSize;
1247512474 $this->tickWidth = $tickWidth;
12475+ $this->ticks = $ticks;
1247612476 $this->titleAlign = $titleAlign;
1247712477 $this->titleAngle = $titleAngle;
1247812478 $this->titleBaseline = $titleBaseline;
@@ -14329,80 +14329,80 @@ class VGAxisConfig {
1432914329 }
1433014330
1433114331 /**
14332- * Boolean value that determines whether the axis should include ticks.
14332+ * The size in pixels of axis ticks.
1433314333 *
14334- * @param ?bool $value
14334+ * @param ?float $value
1433514335 * @throws Exception
14336- * @return ?bool
14336+ * @return ?float
1433714337 */
14338- public static function fromTicks(?bool $value): ?bool {
14338+ public static function fromTickSize(?float $value): ?float {
1433914339 if (!is_null($value)) {
14340- return $value; /*bool*/
14340+ return $value; /*float*/
1434114341 } else {
1434214342 return null;
1434314343 }
1434414344 }
1434514345
1434614346 /**
14347- * Boolean value that determines whether the axis should include ticks.
14347+ * The size in pixels of axis ticks.
1434814348 *
1434914349 * @throws Exception
14350- * @return ?bool
14350+ * @return ?float
1435114351 */
14352- public function toTicks(): ?bool {
14353- if (VGAxisConfig::validateTicks($this->ticks)) {
14354- if (!is_null($this->ticks)) {
14355- return $this->ticks; /*bool*/
14352+ public function toTickSize(): ?float {
14353+ if (VGAxisConfig::validateTickSize($this->tickSize)) {
14354+ if (!is_null($this->tickSize)) {
14355+ return $this->tickSize; /*float*/
1435614356 } else {
1435714357 return null;
1435814358 }
1435914359 }
14360- throw new Exception('never get to this VGAxisConfig::ticks');
14360+ throw new Exception('never get to this VGAxisConfig::tickSize');
1436114361 }
1436214362
1436314363 /**
14364- * Boolean value that determines whether the axis should include ticks.
14364+ * The size in pixels of axis ticks.
1436514365 *
14366- * @param bool|null
14366+ * @param float|null
1436714367 * @return bool
1436814368 * @throws Exception
1436914369 */
14370- public static function validateTicks(?bool $value): bool {
14370+ public static function validateTickSize(?float $value): bool {
1437114371 if (!is_null($value)) {
1437214372 }
1437314373 return true;
1437414374 }
1437514375
1437614376 /**
14377- * Boolean value that determines whether the axis should include ticks.
14377+ * The size in pixels of axis ticks.
1437814378 *
1437914379 * @throws Exception
14380- * @return ?bool
14380+ * @return ?float
1438114381 */
14382- public function getTicks(): ?bool {
14383- if (VGAxisConfig::validateTicks($this->ticks)) {
14384- return $this->ticks;
14382+ public function getTickSize(): ?float {
14383+ if (VGAxisConfig::validateTickSize($this->tickSize)) {
14384+ return $this->tickSize;
1438514385 }
14386- throw new Exception('never get to getTicks VGAxisConfig::ticks');
14386+ throw new Exception('never get to getTickSize VGAxisConfig::tickSize');
1438714387 }
1438814388
1438914389 /**
14390- * Boolean value that determines whether the axis should include ticks.
14390+ * The size in pixels of axis ticks.
1439114391 *
14392- * @return ?bool
14392+ * @return ?float
1439314393 */
14394- public static function sampleTicks(): ?bool {
14395- return true; /*54:ticks*/
14394+ public static function sampleTickSize(): ?float {
14395+ return 54.054; /*54:tickSize*/
1439614396 }
1439714397
1439814398 /**
14399- * The size in pixels of axis ticks.
14399+ * The width, in pixels, of ticks.
1440014400 *
1440114401 * @param ?float $value
1440214402 * @throws Exception
1440314403 * @return ?float
1440414404 */
14405- public static function fromTickSize(?float $value): ?float {
14405+ public static function fromTickWidth(?float $value): ?float {
1440614406 if (!is_null($value)) {
1440714407 return $value; /*float*/
1440814408 } else {
@@ -14411,122 +14411,122 @@ class VGAxisConfig {
1441114411 }
1441214412
1441314413 /**
14414- * The size in pixels of axis ticks.
14414+ * The width, in pixels, of ticks.
1441514415 *
1441614416 * @throws Exception
1441714417 * @return ?float
1441814418 */
14419- public function toTickSize(): ?float {
14420- if (VGAxisConfig::validateTickSize($this->tickSize)) {
14421- if (!is_null($this->tickSize)) {
14422- return $this->tickSize; /*float*/
14419+ public function toTickWidth(): ?float {
14420+ if (VGAxisConfig::validateTickWidth($this->tickWidth)) {
14421+ if (!is_null($this->tickWidth)) {
14422+ return $this->tickWidth; /*float*/
1442314423 } else {
1442414424 return null;
1442514425 }
1442614426 }
14427- throw new Exception('never get to this VGAxisConfig::tickSize');
14427+ throw new Exception('never get to this VGAxisConfig::tickWidth');
1442814428 }
1442914429
1443014430 /**
14431- * The size in pixels of axis ticks.
14431+ * The width, in pixels, of ticks.
1443214432 *
1443314433 * @param float|null
1443414434 * @return bool
1443514435 * @throws Exception
1443614436 */
14437- public static function validateTickSize(?float $value): bool {
14437+ public static function validateTickWidth(?float $value): bool {
1443814438 if (!is_null($value)) {
1443914439 }
1444014440 return true;
1444114441 }
1444214442
1444314443 /**
14444- * The size in pixels of axis ticks.
14444+ * The width, in pixels, of ticks.
1444514445 *
1444614446 * @throws Exception
1444714447 * @return ?float
1444814448 */
14449- public function getTickSize(): ?float {
14450- if (VGAxisConfig::validateTickSize($this->tickSize)) {
14451- return $this->tickSize;
14449+ public function getTickWidth(): ?float {
14450+ if (VGAxisConfig::validateTickWidth($this->tickWidth)) {
14451+ return $this->tickWidth;
1445214452 }
14453- throw new Exception('never get to getTickSize VGAxisConfig::tickSize');
14453+ throw new Exception('never get to getTickWidth VGAxisConfig::tickWidth');
1445414454 }
1445514455
1445614456 /**
14457- * The size in pixels of axis ticks.
14457+ * The width, in pixels, of ticks.
1445814458 *
1445914459 * @return ?float
1446014460 */
14461- public static function sampleTickSize(): ?float {
14462- return 55.055; /*55:tickSize*/
14461+ public static function sampleTickWidth(): ?float {
14462+ return 55.055; /*55:tickWidth*/
1446314463 }
1446414464
1446514465 /**
14466- * The width, in pixels, of ticks.
14466+ * Boolean value that determines whether the axis should include ticks.
1446714467 *
14468- * @param ?float $value
14468+ * @param ?bool $value
1446914469 * @throws Exception
14470- * @return ?float
14470+ * @return ?bool
1447114471 */
14472- public static function fromTickWidth(?float $value): ?float {
14472+ public static function fromTicks(?bool $value): ?bool {
1447314473 if (!is_null($value)) {
14474- return $value; /*float*/
14474+ return $value; /*bool*/
1447514475 } else {
1447614476 return null;
1447714477 }
1447814478 }
1447914479
1448014480 /**
14481- * The width, in pixels, of ticks.
14481+ * Boolean value that determines whether the axis should include ticks.
1448214482 *
1448314483 * @throws Exception
14484- * @return ?float
14484+ * @return ?bool
1448514485 */
14486- public function toTickWidth(): ?float {
14487- if (VGAxisConfig::validateTickWidth($this->tickWidth)) {
14488- if (!is_null($this->tickWidth)) {
14489- return $this->tickWidth; /*float*/
14486+ public function toTicks(): ?bool {
14487+ if (VGAxisConfig::validateTicks($this->ticks)) {
14488+ if (!is_null($this->ticks)) {
14489+ return $this->ticks; /*bool*/
1449014490 } else {
1449114491 return null;
1449214492 }
1449314493 }
14494- throw new Exception('never get to this VGAxisConfig::tickWidth');
14494+ throw new Exception('never get to this VGAxisConfig::ticks');
1449514495 }
1449614496
1449714497 /**
14498- * The width, in pixels, of ticks.
14498+ * Boolean value that determines whether the axis should include ticks.
1449914499 *
14500- * @param float|null
14500+ * @param bool|null
1450114501 * @return bool
1450214502 * @throws Exception
1450314503 */
14504- public static function validateTickWidth(?float $value): bool {
14504+ public static function validateTicks(?bool $value): bool {
1450514505 if (!is_null($value)) {
1450614506 }
1450714507 return true;
1450814508 }
1450914509
1451014510 /**
14511- * The width, in pixels, of ticks.
14511+ * Boolean value that determines whether the axis should include ticks.
1451214512 *
1451314513 * @throws Exception
14514- * @return ?float
14514+ * @return ?bool
1451514515 */
14516- public function getTickWidth(): ?float {
14517- if (VGAxisConfig::validateTickWidth($this->tickWidth)) {
14518- return $this->tickWidth;
14516+ public function getTicks(): ?bool {
14517+ if (VGAxisConfig::validateTicks($this->ticks)) {
14518+ return $this->ticks;
1451914519 }
14520- throw new Exception('never get to getTickWidth VGAxisConfig::tickWidth');
14520+ throw new Exception('never get to getTicks VGAxisConfig::ticks');
1452114521 }
1452214522
1452314523 /**
14524- * The width, in pixels, of ticks.
14524+ * Boolean value that determines whether the axis should include ticks.
1452514525 *
14526- * @return ?float
14526+ * @return ?bool
1452714527 */
14528- public static function sampleTickWidth(): ?float {
14529- return 56.056; /*56:tickWidth*/
14528+ public static function sampleTicks(): ?bool {
14529+ return true; /*56:ticks*/
1453014530 }
1453114531
1453214532 /**
@@ -15387,9 +15387,9 @@ class VGAxisConfig {
1538715387 || VGAxisConfig::validateMinExtent($this->minExtent)
1538815388 || VGAxisConfig::validateTickColor($this->tickColor)
1538915389 || VGAxisConfig::validateTickRound($this->tickRound)
15390- || VGAxisConfig::validateTicks($this->ticks)
1539115390 || VGAxisConfig::validateTickSize($this->tickSize)
1539215391 || VGAxisConfig::validateTickWidth($this->tickWidth)
15392+ || VGAxisConfig::validateTicks($this->ticks)
1539315393 || VGAxisConfig::validateTitleAlign($this->titleAlign)
1539415394 || VGAxisConfig::validateTitleAngle($this->titleAngle)
1539515395 || VGAxisConfig::validateTitleBaseline($this->titleBaseline)
@@ -15433,9 +15433,9 @@ class VGAxisConfig {
1543315433 $out->{'minExtent'} = $this->toMinExtent();
1543415434 $out->{'tickColor'} = $this->toTickColor();
1543515435 $out->{'tickRound'} = $this->toTickRound();
15436- $out->{'ticks'} = $this->toTicks();
1543715436 $out->{'tickSize'} = $this->toTickSize();
1543815437 $out->{'tickWidth'} = $this->toTickWidth();
15438+ $out->{'ticks'} = $this->toTicks();
1543915439 $out->{'titleAlign'} = $this->toTitleAlign();
1544015440 $out->{'titleAngle'} = $this->toTitleAngle();
1544115441 $out->{'titleBaseline'} = $this->toTitleBaseline();
@@ -15481,9 +15481,9 @@ class VGAxisConfig {
1548115481 ,VGAxisConfig::fromMinExtent($obj->{'minExtent'})
1548215482 ,VGAxisConfig::fromTickColor($obj->{'tickColor'})
1548315483 ,VGAxisConfig::fromTickRound($obj->{'tickRound'})
15484- ,VGAxisConfig::fromTicks($obj->{'ticks'})
1548515484 ,VGAxisConfig::fromTickSize($obj->{'tickSize'})
1548615485 ,VGAxisConfig::fromTickWidth($obj->{'tickWidth'})
15486+ ,VGAxisConfig::fromTicks($obj->{'ticks'})
1548715487 ,VGAxisConfig::fromTitleAlign($obj->{'titleAlign'})
1548815488 ,VGAxisConfig::fromTitleAngle($obj->{'titleAngle'})
1548915489 ,VGAxisConfig::fromTitleBaseline($obj->{'titleBaseline'})
@@ -15527,9 +15527,9 @@ class VGAxisConfig {
1552715527 ,VGAxisConfig::sampleMinExtent()
1552815528 ,VGAxisConfig::sampleTickColor()
1552915529 ,VGAxisConfig::sampleTickRound()
15530- ,VGAxisConfig::sampleTicks()
1553115530 ,VGAxisConfig::sampleTickSize()
1553215531 ,VGAxisConfig::sampleTickWidth()
15532+ ,VGAxisConfig::sampleTicks()
1553315533 ,VGAxisConfig::sampleTitleAlign()
1553415534 ,VGAxisConfig::sampleTitleAngle()
1553515535 ,VGAxisConfig::sampleTitleBaseline()
@@ -15560,8 +15560,8 @@ class BarConfig {
1556015560 private ?float $dx; // json:dx Optional
1556115561 private ?float $dy; // json:dy Optional
1556215562 private ?string $fill; // json:fill Optional
15563- private ?bool $filled; // json:filled Optional
1556415563 private ?float $fillOpacity; // json:fillOpacity Optional
15564+ private ?bool $filled; // json:filled Optional
1556515565 private ?string $font; // json:font Optional
1556615566 private ?float $fontSize; // json:fontSize Optional
1556715567 private ?FontStyle $fontStyle; // json:fontStyle Optional
@@ -15595,8 +15595,8 @@ class BarConfig {
1559515595 * @param float|null $dx
1559615596 * @param float|null $dy
1559715597 * @param string|null $fill
15598- * @param bool|null $filled
1559915598 * @param float|null $fillOpacity
15599+ * @param bool|null $filled
1560015600 * @param string|null $font
1560115601 * @param float|null $fontSize
1560215602 * @param FontStyle|null $fontStyle
@@ -15618,7 +15618,7 @@ class BarConfig {
1561815618 * @param string|null $text
1561915619 * @param float|null $theta
1562015620 */
15621- public function __construct(?HorizontalAlign $align, ?float $angle, ?VerticalAlign $baseline, ?float $binSpacing, ?string $color, ?float $continuousBandSize, ?Cursor $cursor, ?float $discreteBandSize, ?float $dx, ?float $dy, ?string $fill, ?bool $filled, ?float $fillOpacity, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, ?float $tension, ?string $text, ?float $theta) {
15621+ public function __construct(?HorizontalAlign $align, ?float $angle, ?VerticalAlign $baseline, ?float $binSpacing, ?string $color, ?float $continuousBandSize, ?Cursor $cursor, ?float $discreteBandSize, ?float $dx, ?float $dy, ?string $fill, ?float $fillOpacity, ?bool $filled, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, ?float $tension, ?string $text, ?float $theta) {
1562215622 $this->align = $align;
1562315623 $this->angle = $angle;
1562415624 $this->baseline = $baseline;
@@ -15630,8 +15630,8 @@ class BarConfig {
1563015630 $this->dx = $dx;
1563115631 $this->dy = $dy;
1563215632 $this->fill = $fill;
15633- $this->filled = $filled;
1563415633 $this->fillOpacity = $fillOpacity;
15634+ $this->filled = $filled;
1563515635 $this->font = $font;
1563615636 $this->fontSize = $fontSize;
1563715637 $this->fontStyle = $fontStyle;
@@ -16484,6 +16484,83 @@ class BarConfig {
1648416484 return 'BarConfig::fill::41'; /*41:fill*/
1648516485 }
1648616486
16487+ /**
16488+ * The fill opacity (value between [0,1]).
16489+ *
16490+ * __Default value:__ `1`
16491+ *
16492+ * @param ?float $value
16493+ * @throws Exception
16494+ * @return ?float
16495+ */
16496+ public static function fromFillOpacity(?float $value): ?float {
16497+ if (!is_null($value)) {
16498+ return $value; /*float*/
16499+ } else {
16500+ return null;
16501+ }
16502+ }
16503+
16504+ /**
16505+ * The fill opacity (value between [0,1]).
16506+ *
16507+ * __Default value:__ `1`
16508+ *
16509+ * @throws Exception
16510+ * @return ?float
16511+ */
16512+ public function toFillOpacity(): ?float {
16513+ if (BarConfig::validateFillOpacity($this->fillOpacity)) {
16514+ if (!is_null($this->fillOpacity)) {
16515+ return $this->fillOpacity; /*float*/
16516+ } else {
16517+ return null;
16518+ }
16519+ }
16520+ throw new Exception('never get to this BarConfig::fillOpacity');
16521+ }
16522+
16523+ /**
16524+ * The fill opacity (value between [0,1]).
16525+ *
16526+ * __Default value:__ `1`
16527+ *
16528+ * @param float|null
16529+ * @return bool
16530+ * @throws Exception
16531+ */
16532+ public static function validateFillOpacity(?float $value): bool {
16533+ if (!is_null($value)) {
16534+ }
16535+ return true;
16536+ }
16537+
16538+ /**
16539+ * The fill opacity (value between [0,1]).
16540+ *
16541+ * __Default value:__ `1`
16542+ *
16543+ * @throws Exception
16544+ * @return ?float
16545+ */
16546+ public function getFillOpacity(): ?float {
16547+ if (BarConfig::validateFillOpacity($this->fillOpacity)) {
16548+ return $this->fillOpacity;
16549+ }
16550+ throw new Exception('never get to getFillOpacity BarConfig::fillOpacity');
16551+ }
16552+
16553+ /**
16554+ * The fill opacity (value between [0,1]).
16555+ *
16556+ * __Default value:__ `1`
16557+ *
16558+ * @return ?float
16559+ */
16560+ public static function sampleFillOpacity(): ?float {
16561+ return 42.042; /*42:fillOpacity*/
16562+ }
16563+
1648716564 /**
1648816565 * Whether the mark's color should be used as fill color instead of stroke color.
1648916566 *
@@ -16578,84 +16655,7 @@ class BarConfig {
1657816655 * @return ?bool
1657916656 */
1658016657 public static function sampleFilled(): ?bool {
16581- return true; /*42:filled*/
16582- }
16583-
16584- /**
16585- * The fill opacity (value between [0,1]).
16586- *
16587- * __Default value:__ `1`
16588- *
16589- * @param ?float $value
16590- * @throws Exception
16591- * @return ?float
16592- */
16593- public static function fromFillOpacity(?float $value): ?float {
16594- if (!is_null($value)) {
16595- return $value; /*float*/
16596- } else {
16597- return null;
16598- }
16599- }
16600-
16601- /**
16602- * The fill opacity (value between [0,1]).
16603- *
16604- * __Default value:__ `1`
16605- *
16606- * @throws Exception
16607- * @return ?float
16608- */
16609- public function toFillOpacity(): ?float {
16610- if (BarConfig::validateFillOpacity($this->fillOpacity)) {
16611- if (!is_null($this->fillOpacity)) {
16612- return $this->fillOpacity; /*float*/
16613- } else {
16614- return null;
16615- }
16616- }
16617- throw new Exception('never get to this BarConfig::fillOpacity');
16618- }
16619-
16620- /**
16621- * The fill opacity (value between [0,1]).
16622- *
16623- * __Default value:__ `1`
16624- *
16625- * @param float|null
16626- * @return bool
16627- * @throws Exception
16628- */
16629- public static function validateFillOpacity(?float $value): bool {
16630- if (!is_null($value)) {
16631- }
16632- return true;
16633- }
16634-
16635- /**
16636- * The fill opacity (value between [0,1]).
16637- *
16638- * __Default value:__ `1`
16639- *
16640- * @throws Exception
16641- * @return ?float
16642- */
16643- public function getFillOpacity(): ?float {
16644- if (BarConfig::validateFillOpacity($this->fillOpacity)) {
16645- return $this->fillOpacity;
16646- }
16647- throw new Exception('never get to getFillOpacity BarConfig::fillOpacity');
16648- }
16649-
16650- /**
16651- * The fill opacity (value between [0,1]).
16652- *
16653- * __Default value:__ `1`
16654- *
16655- * @return ?float
16656- */
16657- public static function sampleFillOpacity(): ?float {
16658- return 43.043; /*43:fillOpacity*/
16658+ return true; /*43:filled*/
1665916659 }
1666016660
1666116661 /**
@@ -18270,8 +18270,8 @@ class BarConfig {
1827018270 || BarConfig::validateDx($this->dx)
1827118271 || BarConfig::validateDy($this->dy)
1827218272 || BarConfig::validateFill($this->fill)
18273- || BarConfig::validateFilled($this->filled)
1827418273 || BarConfig::validateFillOpacity($this->fillOpacity)
18274+ || BarConfig::validateFilled($this->filled)
1827518275 || BarConfig::validateFont($this->font)
1827618276 || BarConfig::validateFontSize($this->fontSize)
1827718277 || BarConfig::validateFontStyle($this->fontStyle)
@@ -18311,8 +18311,8 @@ class BarConfig {
1831118311 $out->{'dx'} = $this->toDx();
1831218312 $out->{'dy'} = $this->toDy();
1831318313 $out->{'fill'} = $this->toFill();
18314- $out->{'filled'} = $this->toFilled();
1831518314 $out->{'fillOpacity'} = $this->toFillOpacity();
18315+ $out->{'filled'} = $this->toFilled();
1831618316 $out->{'font'} = $this->toFont();
1831718317 $out->{'fontSize'} = $this->toFontSize();
1831818318 $out->{'fontStyle'} = $this->toFontStyle();
@@ -18354,8 +18354,8 @@ class BarConfig {
1835418354 ,BarConfig::fromDx($obj->{'dx'})
1835518355 ,BarConfig::fromDy($obj->{'dy'})
1835618356 ,BarConfig::fromFill($obj->{'fill'})
18357- ,BarConfig::fromFilled($obj->{'filled'})
1835818357 ,BarConfig::fromFillOpacity($obj->{'fillOpacity'})
18358+ ,BarConfig::fromFilled($obj->{'filled'})
1835918359 ,BarConfig::fromFont($obj->{'font'})
1836018360 ,BarConfig::fromFontSize($obj->{'fontSize'})
1836118361 ,BarConfig::fromFontStyle($obj->{'fontStyle'})
@@ -18395,8 +18395,8 @@ class BarConfig {
1839518395 ,BarConfig::sampleDx()
1839618396 ,BarConfig::sampleDy()
1839718397 ,BarConfig::sampleFill()
18398- ,BarConfig::sampleFilled()
1839918398 ,BarConfig::sampleFillOpacity()
18399+ ,BarConfig::sampleFilled()
1840018400 ,BarConfig::sampleFont()
1840118401 ,BarConfig::sampleFontSize()
1840218402 ,BarConfig::sampleFontStyle()
@@ -31466,8 +31466,8 @@ class TextConfig {
3146631466 private ?float $dx; // json:dx Optional
3146731467 private ?float $dy; // json:dy Optional
3146831468 private ?string $fill; // json:fill Optional
31469- private ?bool $filled; // json:filled Optional
3147031469 private ?float $fillOpacity; // json:fillOpacity Optional
31470+ private ?bool $filled; // json:filled Optional
3147131471 private ?string $font; // json:font Optional
3147231472 private ?float $fontSize; // json:fontSize Optional
3147331473 private ?FontStyle $fontStyle; // json:fontStyle Optional
@@ -31499,8 +31499,8 @@ class TextConfig {
3149931499 * @param float|null $dx
3150031500 * @param float|null $dy
3150131501 * @param string|null $fill
31502- * @param bool|null $filled
3150331502 * @param float|null $fillOpacity
31503+ * @param bool|null $filled
3150431504 * @param string|null $font
3150531505 * @param float|null $fontSize
3150631506 * @param FontStyle|null $fontStyle
@@ -31523,7 +31523,7 @@ class TextConfig {
3152331523 * @param string|null $text
3152431524 * @param float|null $theta
3152531525 */
31526- public function __construct(?HorizontalAlign $align, ?float $angle, ?VerticalAlign $baseline, ?string $color, ?Cursor $cursor, ?float $dx, ?float $dy, ?string $fill, ?bool $filled, ?float $fillOpacity, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?bool $shortTimeLabels, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, ?float $tension, ?string $text, ?float $theta) {
31526+ public function __construct(?HorizontalAlign $align, ?float $angle, ?VerticalAlign $baseline, ?string $color, ?Cursor $cursor, ?float $dx, ?float $dy, ?string $fill, ?float $fillOpacity, ?bool $filled, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?bool $shortTimeLabels, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, ?float $tension, ?string $text, ?float $theta) {
3152731527 $this->align = $align;
3152831528 $this->angle = $angle;
3152931529 $this->baseline = $baseline;
@@ -31532,8 +31532,8 @@ class TextConfig {
3153231532 $this->dx = $dx;
3153331533 $this->dy = $dy;
3153431534 $this->fill = $fill;
31535- $this->filled = $filled;
3153631535 $this->fillOpacity = $fillOpacity;
31536+ $this->filled = $filled;
3153731537 $this->font = $font;
3153831538 $this->fontSize = $fontSize;
3153931539 $this->fontStyle = $fontStyle;
@@ -32156,6 +32156,83 @@ class TextConfig {
3215632156 return 'TextConfig::fill::38'; /*38:fill*/
3215732157 }
3215832158
32159+ /**
32160+ * The fill opacity (value between [0,1]).
32161+ *
32162+ * __Default value:__ `1`
32163+ *
32164+ * @param ?float $value
32165+ * @throws Exception
32166+ * @return ?float
32167+ */
32168+ public static function fromFillOpacity(?float $value): ?float {
32169+ if (!is_null($value)) {
32170+ return $value; /*float*/
32171+ } else {
32172+ return null;
32173+ }
32174+ }
32175+
32176+ /**
32177+ * The fill opacity (value between [0,1]).
32178+ *
32179+ * __Default value:__ `1`
32180+ *
32181+ * @throws Exception
32182+ * @return ?float
32183+ */
32184+ public function toFillOpacity(): ?float {
32185+ if (TextConfig::validateFillOpacity($this->fillOpacity)) {
32186+ if (!is_null($this->fillOpacity)) {
32187+ return $this->fillOpacity; /*float*/
32188+ } else {
32189+ return null;
32190+ }
32191+ }
32192+ throw new Exception('never get to this TextConfig::fillOpacity');
32193+ }
32194+
32195+ /**
32196+ * The fill opacity (value between [0,1]).
32197+ *
32198+ * __Default value:__ `1`
32199+ *
32200+ * @param float|null
32201+ * @return bool
32202+ * @throws Exception
32203+ */
32204+ public static function validateFillOpacity(?float $value): bool {
32205+ if (!is_null($value)) {
32206+ }
32207+ return true;
32208+ }
32209+
32210+ /**
32211+ * The fill opacity (value between [0,1]).
32212+ *
32213+ * __Default value:__ `1`
32214+ *
32215+ * @throws Exception
32216+ * @return ?float
32217+ */
32218+ public function getFillOpacity(): ?float {
32219+ if (TextConfig::validateFillOpacity($this->fillOpacity)) {
32220+ return $this->fillOpacity;
32221+ }
32222+ throw new Exception('never get to getFillOpacity TextConfig::fillOpacity');
32223+ }
32224+
32225+ /**
32226+ * The fill opacity (value between [0,1]).
32227+ *
32228+ * __Default value:__ `1`
32229+ *
32230+ * @return ?float
32231+ */
32232+ public static function sampleFillOpacity(): ?float {
32233+ return 39.039; /*39:fillOpacity*/
32234+ }
32235+
3215932236 /**
3216032237 * Whether the mark's color should be used as fill color instead of stroke color.
3216132238 *
@@ -32250,84 +32327,7 @@ class TextConfig {
3225032327 * @return ?bool
3225132328 */
3225232329 public static function sampleFilled(): ?bool {
32253- return true; /*39:filled*/
32254- }
32255-
32256- /**
32257- * The fill opacity (value between [0,1]).
32258- *
32259- * __Default value:__ `1`
32260- *
32261- * @param ?float $value
32262- * @throws Exception
32263- * @return ?float
32264- */
32265- public static function fromFillOpacity(?float $value): ?float {
32266- if (!is_null($value)) {
32267- return $value; /*float*/
32268- } else {
32269- return null;
32270- }
32271- }
32272-
32273- /**
32274- * The fill opacity (value between [0,1]).
32275- *
32276- * __Default value:__ `1`
32277- *
32278- * @throws Exception
32279- * @return ?float
32280- */
32281- public function toFillOpacity(): ?float {
32282- if (TextConfig::validateFillOpacity($this->fillOpacity)) {
32283- if (!is_null($this->fillOpacity)) {
32284- return $this->fillOpacity; /*float*/
32285- } else {
32286- return null;
32287- }
32288- }
32289- throw new Exception('never get to this TextConfig::fillOpacity');
32290- }
32291-
32292- /**
32293- * The fill opacity (value between [0,1]).
32294- *
32295- * __Default value:__ `1`
32296- *
32297- * @param float|null
32298- * @return bool
32299- * @throws Exception
32300- */
32301- public static function validateFillOpacity(?float $value): bool {
32302- if (!is_null($value)) {
32303- }
32304- return true;
32305- }
32306-
32307- /**
32308- * The fill opacity (value between [0,1]).
32309- *
32310- * __Default value:__ `1`
32311- *
32312- * @throws Exception
32313- * @return ?float
32314- */
32315- public function getFillOpacity(): ?float {
32316- if (TextConfig::validateFillOpacity($this->fillOpacity)) {
32317- return $this->fillOpacity;
32318- }
32319- throw new Exception('never get to getFillOpacity TextConfig::fillOpacity');
32320- }
32321-
32322- /**
32323- * The fill opacity (value between [0,1]).
32324- *
32325- * __Default value:__ `1`
32326- *
32327- * @return ?float
32328- */
32329- public static function sampleFillOpacity(): ?float {
32330- return 40.04; /*40:fillOpacity*/
32330+ return true; /*40:filled*/
3233132331 }
3233232332
3233332333 /**
@@ -34006,8 +34006,8 @@ class TextConfig {
3400634006 || TextConfig::validateDx($this->dx)
3400734007 || TextConfig::validateDy($this->dy)
3400834008 || TextConfig::validateFill($this->fill)
34009- || TextConfig::validateFilled($this->filled)
3401034009 || TextConfig::validateFillOpacity($this->fillOpacity)
34010+ || TextConfig::validateFilled($this->filled)
3401134011 || TextConfig::validateFont($this->font)
3401234012 || TextConfig::validateFontSize($this->fontSize)
3401334013 || TextConfig::validateFontStyle($this->fontStyle)
@@ -34045,8 +34045,8 @@ class TextConfig {
3404534045 $out->{'dx'} = $this->toDx();
3404634046 $out->{'dy'} = $this->toDy();
3404734047 $out->{'fill'} = $this->toFill();
34048- $out->{'filled'} = $this->toFilled();
3404934048 $out->{'fillOpacity'} = $this->toFillOpacity();
34049+ $out->{'filled'} = $this->toFilled();
3405034050 $out->{'font'} = $this->toFont();
3405134051 $out->{'fontSize'} = $this->toFontSize();
3405234052 $out->{'fontStyle'} = $this->toFontStyle();
@@ -34086,8 +34086,8 @@ class TextConfig {
3408634086 ,TextConfig::fromDx($obj->{'dx'})
3408734087 ,TextConfig::fromDy($obj->{'dy'})
3408834088 ,TextConfig::fromFill($obj->{'fill'})
34089- ,TextConfig::fromFilled($obj->{'filled'})
3409034089 ,TextConfig::fromFillOpacity($obj->{'fillOpacity'})
34090+ ,TextConfig::fromFilled($obj->{'filled'})
3409134091 ,TextConfig::fromFont($obj->{'font'})
3409234092 ,TextConfig::fromFontSize($obj->{'fontSize'})
3409334093 ,TextConfig::fromFontStyle($obj->{'fontStyle'})
@@ -34125,8 +34125,8 @@ class TextConfig {
3412534125 ,TextConfig::sampleDx()
3412634126 ,TextConfig::sampleDy()
3412734127 ,TextConfig::sampleFill()
34128- ,TextConfig::sampleFilled()
3412934128 ,TextConfig::sampleFillOpacity()
34129+ ,TextConfig::sampleFilled()
3413034130 ,TextConfig::sampleFont()
3413134131 ,TextConfig::sampleFontSize()
3413234132 ,TextConfig::sampleFontStyle()
@@ -34164,8 +34164,8 @@ class TickConfig {
3416434164 private ?float $dx; // json:dx Optional
3416534165 private ?float $dy; // json:dy Optional
3416634166 private ?string $fill; // json:fill Optional
34167- private ?bool $filled; // json:filled Optional
3416834167 private ?float $fillOpacity; // json:fillOpacity Optional
34168+ private ?bool $filled; // json:filled Optional
3416934169 private ?string $font; // json:font Optional
3417034170 private ?float $fontSize; // json:fontSize Optional
3417134171 private ?FontStyle $fontStyle; // json:fontStyle Optional
@@ -34198,8 +34198,8 @@ class TickConfig {
3419834198 * @param float|null $dx
3419934199 * @param float|null $dy
3420034200 * @param string|null $fill
34201- * @param bool|null $filled
3420234201 * @param float|null $fillOpacity
34202+ * @param bool|null $filled
3420334203 * @param string|null $font
3420434204 * @param float|null $fontSize
3420534205 * @param FontStyle|null $fontStyle
@@ -34222,7 +34222,7 @@ class TickConfig {
3422234222 * @param float|null $theta
3422334223 * @param float|null $thickness
3422434224 */
34225- public function __construct(?HorizontalAlign $align, ?float $angle, ?float $bandSize, ?VerticalAlign $baseline, ?string $color, ?Cursor $cursor, ?float $dx, ?float $dy, ?string $fill, ?bool $filled, ?float $fillOpacity, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, ?float $tension, ?string $text, ?float $theta, ?float $thickness) {
34225+ public function __construct(?HorizontalAlign $align, ?float $angle, ?float $bandSize, ?VerticalAlign $baseline, ?string $color, ?Cursor $cursor, ?float $dx, ?float $dy, ?string $fill, ?float $fillOpacity, ?bool $filled, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, ?float $tension, ?string $text, ?float $theta, ?float $thickness) {
3422634226 $this->align = $align;
3422734227 $this->angle = $angle;
3422834228 $this->bandSize = $bandSize;
@@ -34232,8 +34232,8 @@ class TickConfig {
3423234232 $this->dx = $dx;
3423334233 $this->dy = $dy;
3423434234 $this->fill = $fill;
34235- $this->filled = $filled;
3423634235 $this->fillOpacity = $fillOpacity;
34236+ $this->filled = $filled;
3423734237 $this->font = $font;
3423834238 $this->fontSize = $fontSize;
3423934239 $this->fontStyle = $fontStyle;
@@ -34933,6 +34933,83 @@ class TickConfig {
3493334933 return 'TickConfig::fill::39'; /*39:fill*/
3493434934 }
3493534935
34936+ /**
34937+ * The fill opacity (value between [0,1]).
34938+ *
34939+ * __Default value:__ `1`
34940+ *
34941+ * @param ?float $value
34942+ * @throws Exception
34943+ * @return ?float
34944+ */
34945+ public static function fromFillOpacity(?float $value): ?float {
34946+ if (!is_null($value)) {
34947+ return $value; /*float*/
34948+ } else {
34949+ return null;
34950+ }
34951+ }
34952+
34953+ /**
34954+ * The fill opacity (value between [0,1]).
34955+ *
34956+ * __Default value:__ `1`
34957+ *
34958+ * @throws Exception
34959+ * @return ?float
34960+ */
34961+ public function toFillOpacity(): ?float {
34962+ if (TickConfig::validateFillOpacity($this->fillOpacity)) {
34963+ if (!is_null($this->fillOpacity)) {
34964+ return $this->fillOpacity; /*float*/
34965+ } else {
34966+ return null;
34967+ }
34968+ }
34969+ throw new Exception('never get to this TickConfig::fillOpacity');
34970+ }
34971+
34972+ /**
34973+ * The fill opacity (value between [0,1]).
34974+ *
34975+ * __Default value:__ `1`
34976+ *
34977+ * @param float|null
34978+ * @return bool
34979+ * @throws Exception
34980+ */
34981+ public static function validateFillOpacity(?float $value): bool {
34982+ if (!is_null($value)) {
34983+ }
34984+ return true;
34985+ }
34986+
34987+ /**
34988+ * The fill opacity (value between [0,1]).
34989+ *
34990+ * __Default value:__ `1`
34991+ *
34992+ * @throws Exception
34993+ * @return ?float
34994+ */
34995+ public function getFillOpacity(): ?float {
34996+ if (TickConfig::validateFillOpacity($this->fillOpacity)) {
34997+ return $this->fillOpacity;
34998+ }
34999+ throw new Exception('never get to getFillOpacity TickConfig::fillOpacity');
35000+ }
35001+
35002+ /**
35003+ * The fill opacity (value between [0,1]).
35004+ *
35005+ * __Default value:__ `1`
35006+ *
35007+ * @return ?float
35008+ */
35009+ public static function sampleFillOpacity(): ?float {
35010+ return 40.04; /*40:fillOpacity*/
35011+ }
35012+
3493635013 /**
3493735014 * Whether the mark's color should be used as fill color instead of stroke color.
3493835015 *
@@ -35027,84 +35104,7 @@ class TickConfig {
3502735104 * @return ?bool
3502835105 */
3502935106 public static function sampleFilled(): ?bool {
35030- return true; /*40:filled*/
35031- }
35032-
35033- /**
35034- * The fill opacity (value between [0,1]).
35035- *
35036- * __Default value:__ `1`
35037- *
35038- * @param ?float $value
35039- * @throws Exception
35040- * @return ?float
35041- */
35042- public static function fromFillOpacity(?float $value): ?float {
35043- if (!is_null($value)) {
35044- return $value; /*float*/
35045- } else {
35046- return null;
35047- }
35048- }
35049-
35050- /**
35051- * The fill opacity (value between [0,1]).
35052- *
35053- * __Default value:__ `1`
35054- *
35055- * @throws Exception
35056- * @return ?float
35057- */
35058- public function toFillOpacity(): ?float {
35059- if (TickConfig::validateFillOpacity($this->fillOpacity)) {
35060- if (!is_null($this->fillOpacity)) {
35061- return $this->fillOpacity; /*float*/
35062- } else {
35063- return null;
35064- }
35065- }
35066- throw new Exception('never get to this TickConfig::fillOpacity');
35067- }
35068-
35069- /**
35070- * The fill opacity (value between [0,1]).
35071- *
35072- * __Default value:__ `1`
35073- *
35074- * @param float|null
35075- * @return bool
35076- * @throws Exception
35077- */
35078- public static function validateFillOpacity(?float $value): bool {
35079- if (!is_null($value)) {
35080- }
35081- return true;
35082- }
35083-
35084- /**
35085- * The fill opacity (value between [0,1]).
35086- *
35087- * __Default value:__ `1`
35088- *
35089- * @throws Exception
35090- * @return ?float
35091- */
35092- public function getFillOpacity(): ?float {
35093- if (TickConfig::validateFillOpacity($this->fillOpacity)) {
35094- return $this->fillOpacity;
35095- }
35096- throw new Exception('never get to getFillOpacity TickConfig::fillOpacity');
35097- }
35098-
35099- /**
35100- * The fill opacity (value between [0,1]).
35101- *
35102- * __Default value:__ `1`
35103- *
35104- * @return ?float
35105- */
35106- public static function sampleFillOpacity(): ?float {
35107- return 41.041; /*41:fillOpacity*/
35107+ return true; /*41:filled*/
3510835108 }
3510935109
3511035110 /**
@@ -36794,8 +36794,8 @@ class TickConfig {
3679436794 || TickConfig::validateDx($this->dx)
3679536795 || TickConfig::validateDy($this->dy)
3679636796 || TickConfig::validateFill($this->fill)
36797- || TickConfig::validateFilled($this->filled)
3679836797 || TickConfig::validateFillOpacity($this->fillOpacity)
36798+ || TickConfig::validateFilled($this->filled)
3679936799 || TickConfig::validateFont($this->font)
3680036800 || TickConfig::validateFontSize($this->fontSize)
3680136801 || TickConfig::validateFontStyle($this->fontStyle)
@@ -36834,8 +36834,8 @@ class TickConfig {
3683436834 $out->{'dx'} = $this->toDx();
3683536835 $out->{'dy'} = $this->toDy();
3683636836 $out->{'fill'} = $this->toFill();
36837- $out->{'filled'} = $this->toFilled();
3683836837 $out->{'fillOpacity'} = $this->toFillOpacity();
36838+ $out->{'filled'} = $this->toFilled();
3683936839 $out->{'font'} = $this->toFont();
3684036840 $out->{'fontSize'} = $this->toFontSize();
3684136841 $out->{'fontStyle'} = $this->toFontStyle();
@@ -36876,8 +36876,8 @@ class TickConfig {
3687636876 ,TickConfig::fromDx($obj->{'dx'})
3687736877 ,TickConfig::fromDy($obj->{'dy'})
3687836878 ,TickConfig::fromFill($obj->{'fill'})
36879- ,TickConfig::fromFilled($obj->{'filled'})
3688036879 ,TickConfig::fromFillOpacity($obj->{'fillOpacity'})
36880+ ,TickConfig::fromFilled($obj->{'filled'})
3688136881 ,TickConfig::fromFont($obj->{'font'})
3688236882 ,TickConfig::fromFontSize($obj->{'fontSize'})
3688336883 ,TickConfig::fromFontStyle($obj->{'fontStyle'})
@@ -36916,8 +36916,8 @@ class TickConfig {
3691636916 ,TickConfig::sampleDx()
3691736917 ,TickConfig::sampleDy()
3691836918 ,TickConfig::sampleFill()
36919- ,TickConfig::sampleFilled()
3692036919 ,TickConfig::sampleFillOpacity()
36920+ ,TickConfig::sampleFilled()
3692136921 ,TickConfig::sampleFont()
3692236922 ,TickConfig::sampleFontSize()
3692336923 ,TickConfig::sampleFontStyle()
@@ -58822,8 +58822,8 @@ class Axis {
5882258822 private ?TitleOrient $orient; // json:orient Optional
5882358823 private ?float $position; // json:position Optional
5882458824 private ?float $tickCount; // json:tickCount Optional
58825- private ?bool $ticks; // json:ticks Optional
5882658825 private ?float $tickSize; // json:tickSize Optional
58826+ private ?bool $ticks; // json:ticks Optional
5882758827 private ?string $title; // json:title Optional
5882858828 private ?float $titleMaxLength; // json:titleMaxLength Optional
5882958829 private ?float $titlePadding; // json:titlePadding Optional
@@ -58846,15 +58846,15 @@ class Axis {
5884658846 * @param TitleOrient|null $orient
5884758847 * @param float|null $position
5884858848 * @param float|null $tickCount
58849- * @param bool|null $ticks
5885058849 * @param float|null $tickSize
58850+ * @param bool|null $ticks
5885158851 * @param string|null $title
5885258852 * @param float|null $titleMaxLength
5885358853 * @param float|null $titlePadding
5885458854 * @param array|null $values
5885558855 * @param float|null $zindex
5885658856 */
58857- public function __construct(?bool $domain, ?string $format, ?bool $grid, ?float $labelAngle, bool|float|null $labelBound, bool|float|null $labelFlush, LabelOverlap|bool|null $labelOverlap, ?float $labelPadding, ?bool $labels, ?float $maxExtent, ?float $minExtent, ?float $offset, ?TitleOrient $orient, ?float $position, ?float $tickCount, ?bool $ticks, ?float $tickSize, ?string $title, ?float $titleMaxLength, ?float $titlePadding, ?array $values, ?float $zindex) {
58857+ public function __construct(?bool $domain, ?string $format, ?bool $grid, ?float $labelAngle, bool|float|null $labelBound, bool|float|null $labelFlush, LabelOverlap|bool|null $labelOverlap, ?float $labelPadding, ?bool $labels, ?float $maxExtent, ?float $minExtent, ?float $offset, ?TitleOrient $orient, ?float $position, ?float $tickCount, ?float $tickSize, ?bool $ticks, ?string $title, ?float $titleMaxLength, ?float $titlePadding, ?array $values, ?float $zindex) {
5885858858 $this->domain = $domain;
5885958859 $this->format = $format;
5886058860 $this->grid = $grid;
@@ -58870,8 +58870,8 @@ class Axis {
5887058870 $this->orient = $orient;
5887158871 $this->position = $position;
5887258872 $this->tickCount = $tickCount;
58873- $this->ticks = $ticks;
5887458873 $this->tickSize = $tickSize;
58874+ $this->ticks = $ticks;
5887558875 $this->title = $title;
5887658876 $this->titleMaxLength = $titleMaxLength;
5887758877 $this->titlePadding = $titlePadding;
@@ -60242,137 +60242,137 @@ class Axis {
6024260242 }
6024360243
6024460244 /**
60245- * Boolean value that determines whether the axis should include ticks.
60245+ * The size in pixels of axis ticks.
6024660246 *
60247- * @param ?bool $value
60247+ * @param ?float $value
6024860248 * @throws Exception
60249- * @return ?bool
60249+ * @return ?float
6025060250 */
60251- public static function fromTicks(?bool $value): ?bool {
60251+ public static function fromTickSize(?float $value): ?float {
6025260252 if (!is_null($value)) {
60253- return $value; /*bool*/
60253+ return $value; /*float*/
6025460254 } else {
6025560255 return null;
6025660256 }
6025760257 }
6025860258
6025960259 /**
60260- * Boolean value that determines whether the axis should include ticks.
60260+ * The size in pixels of axis ticks.
6026160261 *
6026260262 * @throws Exception
60263- * @return ?bool
60263+ * @return ?float
6026460264 */
60265- public function toTicks(): ?bool {
60266- if (Axis::validateTicks($this->ticks)) {
60267- if (!is_null($this->ticks)) {
60268- return $this->ticks; /*bool*/
60265+ public function toTickSize(): ?float {
60266+ if (Axis::validateTickSize($this->tickSize)) {
60267+ if (!is_null($this->tickSize)) {
60268+ return $this->tickSize; /*float*/
6026960269 } else {
6027060270 return null;
6027160271 }
6027260272 }
60273- throw new Exception('never get to this Axis::ticks');
60273+ throw new Exception('never get to this Axis::tickSize');
6027460274 }
6027560275
6027660276 /**
60277- * Boolean value that determines whether the axis should include ticks.
60277+ * The size in pixels of axis ticks.
6027860278 *
60279- * @param bool|null
60279+ * @param float|null
6028060280 * @return bool
6028160281 * @throws Exception
6028260282 */
60283- public static function validateTicks(?bool $value): bool {
60283+ public static function validateTickSize(?float $value): bool {
6028460284 if (!is_null($value)) {
6028560285 }
6028660286 return true;
6028760287 }
6028860288
6028960289 /**
60290- * Boolean value that determines whether the axis should include ticks.
60290+ * The size in pixels of axis ticks.
6029160291 *
6029260292 * @throws Exception
60293- * @return ?bool
60293+ * @return ?float
6029460294 */
60295- public function getTicks(): ?bool {
60296- if (Axis::validateTicks($this->ticks)) {
60297- return $this->ticks;
60295+ public function getTickSize(): ?float {
60296+ if (Axis::validateTickSize($this->tickSize)) {
60297+ return $this->tickSize;
6029860298 }
60299- throw new Exception('never get to getTicks Axis::ticks');
60299+ throw new Exception('never get to getTickSize Axis::tickSize');
6030060300 }
6030160301
6030260302 /**
60303- * Boolean value that determines whether the axis should include ticks.
60303+ * The size in pixels of axis ticks.
6030460304 *
60305- * @return ?bool
60305+ * @return ?float
6030660306 */
60307- public static function sampleTicks(): ?bool {
60308- return true; /*46:ticks*/
60307+ public static function sampleTickSize(): ?float {
60308+ return 46.046; /*46:tickSize*/
6030960309 }
6031060310
6031160311 /**
60312- * The size in pixels of axis ticks.
60312+ * Boolean value that determines whether the axis should include ticks.
6031360313 *
60314- * @param ?float $value
60314+ * @param ?bool $value
6031560315 * @throws Exception
60316- * @return ?float
60316+ * @return ?bool
6031760317 */
60318- public static function fromTickSize(?float $value): ?float {
60318+ public static function fromTicks(?bool $value): ?bool {
6031960319 if (!is_null($value)) {
60320- return $value; /*float*/
60320+ return $value; /*bool*/
6032160321 } else {
6032260322 return null;
6032360323 }
6032460324 }
6032560325
6032660326 /**
60327- * The size in pixels of axis ticks.
60327+ * Boolean value that determines whether the axis should include ticks.
6032860328 *
6032960329 * @throws Exception
60330- * @return ?float
60330+ * @return ?bool
6033160331 */
60332- public function toTickSize(): ?float {
60333- if (Axis::validateTickSize($this->tickSize)) {
60334- if (!is_null($this->tickSize)) {
60335- return $this->tickSize; /*float*/
60332+ public function toTicks(): ?bool {
60333+ if (Axis::validateTicks($this->ticks)) {
60334+ if (!is_null($this->ticks)) {
60335+ return $this->ticks; /*bool*/
6033660336 } else {
6033760337 return null;
6033860338 }
6033960339 }
60340- throw new Exception('never get to this Axis::tickSize');
60340+ throw new Exception('never get to this Axis::ticks');
6034160341 }
6034260342
6034360343 /**
60344- * The size in pixels of axis ticks.
60344+ * Boolean value that determines whether the axis should include ticks.
6034560345 *
60346- * @param float|null
60346+ * @param bool|null
6034760347 * @return bool
6034860348 * @throws Exception
6034960349 */
60350- public static function validateTickSize(?float $value): bool {
60350+ public static function validateTicks(?bool $value): bool {
6035160351 if (!is_null($value)) {
6035260352 }
6035360353 return true;
6035460354 }
6035560355
6035660356 /**
60357- * The size in pixels of axis ticks.
60357+ * Boolean value that determines whether the axis should include ticks.
6035860358 *
6035960359 * @throws Exception
60360- * @return ?float
60360+ * @return ?bool
6036160361 */
60362- public function getTickSize(): ?float {
60363- if (Axis::validateTickSize($this->tickSize)) {
60364- return $this->tickSize;
60362+ public function getTicks(): ?bool {
60363+ if (Axis::validateTicks($this->ticks)) {
60364+ return $this->ticks;
6036560365 }
60366- throw new Exception('never get to getTickSize Axis::tickSize');
60366+ throw new Exception('never get to getTicks Axis::ticks');
6036760367 }
6036860368
6036960369 /**
60370- * The size in pixels of axis ticks.
60370+ * Boolean value that determines whether the axis should include ticks.
6037160371 *
60372- * @return ?float
60372+ * @return ?bool
6037360373 */
60374- public static function sampleTickSize(): ?float {
60375- return 47.047; /*47:tickSize*/
60374+ public static function sampleTicks(): ?bool {
60375+ return true; /*47:ticks*/
6037660376 }
6037760377
6037860378 /**
@@ -60847,8 +60847,8 @@ class Axis {
6084760847 || Axis::validateOrient($this->orient)
6084860848 || Axis::validatePosition($this->position)
6084960849 || Axis::validateTickCount($this->tickCount)
60850- || Axis::validateTicks($this->ticks)
6085160850 || Axis::validateTickSize($this->tickSize)
60851+ || Axis::validateTicks($this->ticks)
6085260852 || Axis::validateTitle($this->title)
6085360853 || Axis::validateTitleMaxLength($this->titleMaxLength)
6085460854 || Axis::validateTitlePadding($this->titlePadding)
@@ -60877,8 +60877,8 @@ class Axis {
6087760877 $out->{'orient'} = $this->toOrient();
6087860878 $out->{'position'} = $this->toPosition();
6087960879 $out->{'tickCount'} = $this->toTickCount();
60880- $out->{'ticks'} = $this->toTicks();
6088160880 $out->{'tickSize'} = $this->toTickSize();
60881+ $out->{'ticks'} = $this->toTicks();
6088260882 $out->{'title'} = $this->toTitle();
6088360883 $out->{'titleMaxLength'} = $this->toTitleMaxLength();
6088460884 $out->{'titlePadding'} = $this->toTitlePadding();
@@ -60909,8 +60909,8 @@ class Axis {
6090960909 ,Axis::fromOrient($obj->{'orient'})
6091060910 ,Axis::fromPosition($obj->{'position'})
6091160911 ,Axis::fromTickCount($obj->{'tickCount'})
60912- ,Axis::fromTicks($obj->{'ticks'})
6091360912 ,Axis::fromTickSize($obj->{'tickSize'})
60913+ ,Axis::fromTicks($obj->{'ticks'})
6091460914 ,Axis::fromTitle($obj->{'title'})
6091560915 ,Axis::fromTitleMaxLength($obj->{'titleMaxLength'})
6091660916 ,Axis::fromTitlePadding($obj->{'titlePadding'})
@@ -60939,8 +60939,8 @@ class Axis {
6093960939 ,Axis::sampleOrient()
6094060940 ,Axis::samplePosition()
6094160941 ,Axis::sampleTickCount()
60942- ,Axis::sampleTicks()
6094360942 ,Axis::sampleTickSize()
60943+ ,Axis::sampleTicks()
6094460944 ,Axis::sampleTitle()
6094560945 ,Axis::sampleTitleMaxLength()
6094660946 ,Axis::sampleTitlePadding()
@@ -66085,8 +66085,8 @@ class MarkDef {
6608566085 private ?float $dx; // json:dx Optional
6608666086 private ?float $dy; // json:dy Optional
6608766087 private ?string $fill; // json:fill Optional
66088- private ?bool $filled; // json:filled Optional
6608966088 private ?float $fillOpacity; // json:fillOpacity Optional
66089+ private ?bool $filled; // json:filled Optional
6609066090 private ?string $font; // json:font Optional
6609166091 private ?float $fontSize; // json:fontSize Optional
6609266092 private ?FontStyle $fontStyle; // json:fontStyle Optional
@@ -66120,8 +66120,8 @@ class MarkDef {
6612066120 * @param float|null $dx
6612166121 * @param float|null $dy
6612266122 * @param string|null $fill
66123- * @param bool|null $filled
6612466123 * @param float|null $fillOpacity
66124+ * @param bool|null $filled
6612566125 * @param string|null $font
6612666126 * @param float|null $fontSize
6612766127 * @param FontStyle|null $fontStyle
@@ -66145,7 +66145,7 @@ class MarkDef {
6614566145 * @param float|null $theta
6614666146 * @param Mark $type
6614766147 */
66148- public function __construct(?HorizontalAlign $align, ?float $angle, ?VerticalAlign $baseline, ?bool $clip, ?string $color, ?Cursor $cursor, ?float $dx, ?float $dy, ?string $fill, ?bool $filled, ?float $fillOpacity, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, array|string|null $style, ?float $tension, ?string $text, ?float $theta, Mark $type) {
66148+ public function __construct(?HorizontalAlign $align, ?float $angle, ?VerticalAlign $baseline, ?bool $clip, ?string $color, ?Cursor $cursor, ?float $dx, ?float $dy, ?string $fill, ?float $fillOpacity, ?bool $filled, ?string $font, ?float $fontSize, ?FontStyle $fontStyle, FontWeight|float|null $fontWeight, ?string $href, ?Interpolate $interpolate, ?float $limit, ?float $opacity, ?Orient $orient, ?float $radius, ?string $shape, ?float $size, ?string $stroke, ?array $strokeDash, ?float $strokeDashOffset, ?float $strokeOpacity, ?float $strokeWidth, array|string|null $style, ?float $tension, ?string $text, ?float $theta, Mark $type) {
6614966149 $this->align = $align;
6615066150 $this->angle = $angle;
6615166151 $this->baseline = $baseline;
@@ -66155,8 +66155,8 @@ class MarkDef {
6615566155 $this->dx = $dx;
6615666156 $this->dy = $dy;
6615766157 $this->fill = $fill;
66158- $this->filled = $filled;
6615966158 $this->fillOpacity = $fillOpacity;
66159+ $this->filled = $filled;
6616066160 $this->font = $font;
6616166161 $this->fontSize = $fontSize;
6616266162 $this->fontStyle = $fontStyle;
@@ -66847,6 +66847,83 @@ class MarkDef {
6684766847 return 'MarkDef::fill::39'; /*39:fill*/
6684866848 }
6684966849
66850+ /**
66851+ * The fill opacity (value between [0,1]).
66852+ *
66853+ * __Default value:__ `1`
66854+ *
66855+ * @param ?float $value
66856+ * @throws Exception
66857+ * @return ?float
66858+ */
66859+ public static function fromFillOpacity(?float $value): ?float {
66860+ if (!is_null($value)) {
66861+ return $value; /*float*/
66862+ } else {
66863+ return null;
66864+ }
66865+ }
66866+
66867+ /**
66868+ * The fill opacity (value between [0,1]).
66869+ *
66870+ * __Default value:__ `1`
66871+ *
66872+ * @throws Exception
66873+ * @return ?float
66874+ */
66875+ public function toFillOpacity(): ?float {
66876+ if (MarkDef::validateFillOpacity($this->fillOpacity)) {
66877+ if (!is_null($this->fillOpacity)) {
66878+ return $this->fillOpacity; /*float*/
66879+ } else {
66880+ return null;
66881+ }
66882+ }
66883+ throw new Exception('never get to this MarkDef::fillOpacity');
66884+ }
66885+
66886+ /**
66887+ * The fill opacity (value between [0,1]).
66888+ *
66889+ * __Default value:__ `1`
66890+ *
66891+ * @param float|null
66892+ * @return bool
66893+ * @throws Exception
66894+ */
66895+ public static function validateFillOpacity(?float $value): bool {
66896+ if (!is_null($value)) {
66897+ }
66898+ return true;
66899+ }
66900+
66901+ /**
66902+ * The fill opacity (value between [0,1]).
66903+ *
66904+ * __Default value:__ `1`
66905+ *
66906+ * @throws Exception
66907+ * @return ?float
66908+ */
66909+ public function getFillOpacity(): ?float {
66910+ if (MarkDef::validateFillOpacity($this->fillOpacity)) {
66911+ return $this->fillOpacity;
66912+ }
66913+ throw new Exception('never get to getFillOpacity MarkDef::fillOpacity');
66914+ }
66915+
66916+ /**
66917+ * The fill opacity (value between [0,1]).
66918+ *
66919+ * __Default value:__ `1`
66920+ *
66921+ * @return ?float
66922+ */
66923+ public static function sampleFillOpacity(): ?float {
66924+ return 40.04; /*40:fillOpacity*/
66925+ }
66926+
6685066927 /**
6685166928 * Whether the mark's color should be used as fill color instead of stroke color.
6685266929 *
@@ -66941,84 +67018,7 @@ class MarkDef {
6694167018 * @return ?bool
6694267019 */
6694367020 public static function sampleFilled(): ?bool {
66944- return true; /*40:filled*/
66945- }
66946-
66947- /**
66948- * The fill opacity (value between [0,1]).
66949- *
66950- * __Default value:__ `1`
66951- *
66952- * @param ?float $value
66953- * @throws Exception
66954- * @return ?float
66955- */
66956- public static function fromFillOpacity(?float $value): ?float {
66957- if (!is_null($value)) {
66958- return $value; /*float*/
66959- } else {
66960- return null;
66961- }
66962- }
66963-
66964- /**
66965- * The fill opacity (value between [0,1]).
66966- *
66967- * __Default value:__ `1`
66968- *
66969- * @throws Exception
66970- * @return ?float
66971- */
66972- public function toFillOpacity(): ?float {
66973- if (MarkDef::validateFillOpacity($this->fillOpacity)) {
66974- if (!is_null($this->fillOpacity)) {
66975- return $this->fillOpacity; /*float*/
66976- } else {
66977- return null;
66978- }
66979- }
66980- throw new Exception('never get to this MarkDef::fillOpacity');
66981- }
66982-
66983- /**
66984- * The fill opacity (value between [0,1]).
66985- *
66986- * __Default value:__ `1`
66987- *
66988- * @param float|null
66989- * @return bool
66990- * @throws Exception
66991- */
66992- public static function validateFillOpacity(?float $value): bool {
66993- if (!is_null($value)) {
66994- }
66995- return true;
66996- }
66997-
66998- /**
66999- * The fill opacity (value between [0,1]).
67000- *
67001- * __Default value:__ `1`
67002- *
67003- * @throws Exception
67004- * @return ?float
67005- */
67006- public function getFillOpacity(): ?float {
67007- if (MarkDef::validateFillOpacity($this->fillOpacity)) {
67008- return $this->fillOpacity;
67009- }
67010- throw new Exception('never get to getFillOpacity MarkDef::fillOpacity');
67011- }
67012-
67013- /**
67014- * The fill opacity (value between [0,1]).
67015- *
67016- * __Default value:__ `1`
67017- *
67018- * @return ?float
67019- */
67020- public static function sampleFillOpacity(): ?float {
67021- return 41.041; /*41:fillOpacity*/
67021+ return true; /*41:filled*/
6702267022 }
6702367023
6702467024 /**
@@ -68848,8 +68848,8 @@ class MarkDef {
6884868848 || MarkDef::validateDx($this->dx)
6884968849 || MarkDef::validateDy($this->dy)
6885068850 || MarkDef::validateFill($this->fill)
68851- || MarkDef::validateFilled($this->filled)
6885268851 || MarkDef::validateFillOpacity($this->fillOpacity)
68852+ || MarkDef::validateFilled($this->filled)
6885368853 || MarkDef::validateFont($this->font)
6885468854 || MarkDef::validateFontSize($this->fontSize)
6885568855 || MarkDef::validateFontStyle($this->fontStyle)
@@ -68889,8 +68889,8 @@ class MarkDef {
6888968889 $out->{'dx'} = $this->toDx();
6889068890 $out->{'dy'} = $this->toDy();
6889168891 $out->{'fill'} = $this->toFill();
68892- $out->{'filled'} = $this->toFilled();
6889368892 $out->{'fillOpacity'} = $this->toFillOpacity();
68893+ $out->{'filled'} = $this->toFilled();
6889468894 $out->{'font'} = $this->toFont();
6889568895 $out->{'fontSize'} = $this->toFontSize();
6889668896 $out->{'fontStyle'} = $this->toFontStyle();
@@ -68932,8 +68932,8 @@ class MarkDef {
6893268932 ,MarkDef::fromDx($obj->{'dx'})
6893368933 ,MarkDef::fromDy($obj->{'dy'})
6893468934 ,MarkDef::fromFill($obj->{'fill'})
68935- ,MarkDef::fromFilled($obj->{'filled'})
6893668935 ,MarkDef::fromFillOpacity($obj->{'fillOpacity'})
68936+ ,MarkDef::fromFilled($obj->{'filled'})
6893768937 ,MarkDef::fromFont($obj->{'font'})
6893868938 ,MarkDef::fromFontSize($obj->{'fontSize'})
6893968939 ,MarkDef::fromFontStyle($obj->{'fontStyle'})
@@ -68973,8 +68973,8 @@ class MarkDef {
6897368973 ,MarkDef::sampleDx()
6897468974 ,MarkDef::sampleDy()
6897568975 ,MarkDef::sampleFill()
68976- ,MarkDef::sampleFilled()
6897768976 ,MarkDef::sampleFillOpacity()
68977+ ,MarkDef::sampleFilled()
6897868978 ,MarkDef::sampleFont()
6897968979 ,MarkDef::sampleFontSize()
6898068980 ,MarkDef::sampleFontStyle()
Mschema-pike/test/inputs/schema/accessors.schema/default/TopLevel.pmod+6 −6
@@ -13,17 +13,17 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- string barre; // json: "bar"
16+ Union unionization; // json: "union"
1717 Enum enumerification; // json: "enum"
1818 string foo; // json: "foo"
19- Union unionization; // json: "union"
19+ string barre; // json: "bar"
2020
2121 string encode_json() {
2222 mapping(string:mixed) json = ([
23- "bar" : barre,
23+ "union" : unionization,
2424 "enum" : enumerification,
2525 "foo" : foo,
26- "union" : unionization,
26+ "bar" : barre,
2727 ]);
2828
2929 return Standards.JSON.encode(json);
@@ -33,10 +33,10 @@ class TopLevel {
3333 TopLevel TopLevel_from_JSON(mixed json) {
3434 TopLevel retval = TopLevel();
3535
36- retval.barre = json["bar"];
36+ retval.unionization = json["union"];
3737 retval.enumerification = json["enum"];
3838 retval.foo = json["foo"];
39- retval.unionization = json["union"];
39+ retval.barre = json["bar"];
4040
4141 return retval;
4242 }
Mschema-pike/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.pmod+3 −3
@@ -15,15 +15,15 @@
1515 class TopLevel {
1616 float amount; // json: "amount"
1717 Frequency frequency; // json: "frequency"
18- mixed|string description; // json: "description"
1918 Type type; // json: "type"
19+ mixed|string description; // json: "description"
2020
2121 string encode_json() {
2222 mapping(string:mixed) json = ([
2323 "amount" : amount,
2424 "frequency" : frequency,
25- "description" : description,
2625 "type" : type,
26+ "description" : description,
2727 ]);
2828
2929 return Standards.JSON.encode(json);
@@ -35,8 +35,8 @@ TopLevel TopLevel_from_JSON(mixed json) {
3535
3636 retval.amount = json["amount"];
3737 retval.frequency = json["frequency"];
38- retval.description = json["description"];
3938 retval.type = json["type"];
39+ retval.description = json["description"];
4040
4141 return retval;
4242 }
Mschema-pike/test/inputs/schema/bool-string.schema/default/TopLevel.pmod+9 −9
@@ -13,21 +13,21 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- array(mixed|string)|mixed arr_nullable; // json: "arrNullable"
17- array(string)|mixed arr_one; // json: "arrOne"
18- mixed|string nullable; // json: "nullable"
1916 string one; // json: "one"
2017 mixed|string top_level_optional; // json: "optional"
18+ mixed|string nullable; // json: "nullable"
19+ array(string)|mixed arr_one; // json: "arrOne"
20+ array(mixed|string)|mixed arr_nullable; // json: "arrNullable"
2121 UnionWithBool union_with_bool; // json: "unionWithBool"
2222 UnionWithBool union_with_bool_and_enum; // json: "unionWithBoolAndEnum"
2323
2424 string encode_json() {
2525 mapping(string:mixed) json = ([
26- "arrNullable" : arr_nullable,
27- "arrOne" : arr_one,
28- "nullable" : nullable,
2926 "one" : one,
3027 "optional" : top_level_optional,
28+ "nullable" : nullable,
29+ "arrOne" : arr_one,
30+ "arrNullable" : arr_nullable,
3131 "unionWithBool" : union_with_bool,
3232 "unionWithBoolAndEnum" : union_with_bool_and_enum,
3333 ]);
@@ -39,11 +39,11 @@ class TopLevel {
3939 TopLevel TopLevel_from_JSON(mixed json) {
4040 TopLevel retval = TopLevel();
4141
42- retval.arr_nullable = json["arrNullable"];
43- retval.arr_one = json["arrOne"];
44- retval.nullable = json["nullable"];
4542 retval.one = json["one"];
4643 retval.top_level_optional = json["optional"];
44+ retval.nullable = json["nullable"];
45+ retval.arr_one = json["arrOne"];
46+ retval.arr_nullable = json["arrNullable"];
4747 retval.union_with_bool = json["unionWithBool"];
4848 retval.union_with_bool_and_enum = json["unionWithBoolAndEnum"];
Mschema-pike/test/inputs/schema/boolean-subschema.schema/default/TopLevel.pmod+3 −3
@@ -13,16 +13,16 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16+ string foo; // json: "foo"
1617 mixed disallowed; // json: "disallowed"
1718 array(mixed) empty; // json: "empty"
18- string foo; // json: "foo"
1919 mixed impossible; // json: "impossible"
2020
2121 string encode_json() {
2222 mapping(string:mixed) json = ([
23+ "foo" : foo,
2324 "disallowed" : disallowed,
2425 "empty" : empty,
25- "foo" : foo,
2626 "impossible" : impossible,
2727 ]);
2828
@@ -33,9 +33,9 @@ class TopLevel {
3333 TopLevel TopLevel_from_JSON(mixed json) {
3434 TopLevel retval = TopLevel();
3535
36+ retval.foo = json["foo"];
3637 retval.disallowed = json["disallowed"];
3738 retval.empty = json["empty"];
38- retval.foo = json["foo"];
3939 retval.impossible = json["impossible"];
4040
4141 return retval;
Mschema-pike/test/inputs/schema/comment-injection.schema/default/TopLevel.pmod+3 −3
@@ -25,17 +25,17 @@
2525 // }
2626 // }
2727 class TopLevel {
28+ string value; // json: "value"
2829 mixed|string trailing_backslash; // json: "trailingBackslash"
2930 mixed|string trailing_quote; // json: "trailingQuote"
3031 mixed|string trailing_triple_quote; // json: "trailingTripleQuote"
31- string value; // json: "value"
3232
3333 string encode_json() {
3434 mapping(string:mixed) json = ([
35+ "value" : value,
3536 "trailingBackslash" : trailing_backslash,
3637 "trailingQuote" : trailing_quote,
3738 "trailingTripleQuote" : trailing_triple_quote,
38- "value" : value,
3939 ]);
4040
4141 return Standards.JSON.encode(json);
@@ -45,10 +45,10 @@ class TopLevel {
4545 TopLevel TopLevel_from_JSON(mixed json) {
4646 TopLevel retval = TopLevel();
4747
48+ retval.value = json["value"];
4849 retval.trailing_backslash = json["trailingBackslash"];
4950 retval.trailing_quote = json["trailingQuote"];
5051 retval.trailing_triple_quote = json["trailingTripleQuote"];
51- retval.value = json["value"];
5252
5353 return retval;
5454 }
Mschema-pike/test/inputs/schema/const-non-string.schema/default/TopLevel.pmod+6 −6
@@ -13,19 +13,19 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16+ float version; // json: "version"
1617 int amount; // json: "amount"
18+ float ratio; // json: "ratio"
1719 bool enabled; // json: "enabled"
1820 Kind kind; // json: "kind"
19- float ratio; // json: "ratio"
20- float version; // json: "version"
2121
2222 string encode_json() {
2323 mapping(string:mixed) json = ([
24+ "version" : version,
2425 "amount" : amount,
26+ "ratio" : ratio,
2527 "enabled" : enabled,
2628 "kind" : kind,
27- "ratio" : ratio,
28- "version" : version,
2929 ]);
3030
3131 return Standards.JSON.encode(json);
@@ -35,11 +35,11 @@ class TopLevel {
3535 TopLevel TopLevel_from_JSON(mixed json) {
3636 TopLevel retval = TopLevel();
3737
38+ retval.version = json["version"];
3839 retval.amount = json["amount"];
40+ retval.ratio = json["ratio"];
3941 retval.enabled = json["enabled"];
4042 retval.kind = json["kind"];
41- retval.ratio = json["ratio"];
42- retval.version = json["version"];
4343
4444 return retval;
4545 }
Mschema-pike/test/inputs/schema/date-time-or-string.schema/default/TopLevel.pmod+3 −3
@@ -13,13 +13,13 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- string bar; // json: "bar"
1716 string foo; // json: "foo"
17+ string bar; // json: "bar"
1818
1919 string encode_json() {
2020 mapping(string:mixed) json = ([
21- "bar" : bar,
2221 "foo" : foo,
22+ "bar" : bar,
2323 ]);
2424
2525 return Standards.JSON.encode(json);
@@ -29,8 +29,8 @@ class TopLevel {
2929 TopLevel TopLevel_from_JSON(mixed json) {
3030 TopLevel retval = TopLevel();
3131
32- retval.bar = json["bar"];
3332 retval.foo = json["foo"];
33+ retval.bar = json["bar"];
3434
3535 return retval;
3636 }
Mschema-pike/test/inputs/schema/date-time.schema/default/TopLevel.pmod+6 −6
@@ -13,19 +13,19 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- array(ComplexUnionArray) complex_union_array; // json: "complex-union-array"
1716 string date; // json: "date"
18- string date_time; // json: "date-time"
1917 string time; // json: "time"
18+ string date_time; // json: "date-time"
2019 array(string) union_array; // json: "union-array"
20+ array(ComplexUnionArray) complex_union_array; // json: "complex-union-array"
2121
2222 string encode_json() {
2323 mapping(string:mixed) json = ([
24- "complex-union-array" : complex_union_array,
2524 "date" : date,
26- "date-time" : date_time,
2725 "time" : time,
26+ "date-time" : date_time,
2827 "union-array" : union_array,
28+ "complex-union-array" : complex_union_array,
2929 ]);
3030
3131 return Standards.JSON.encode(json);
@@ -35,11 +35,11 @@ class TopLevel {
3535 TopLevel TopLevel_from_JSON(mixed json) {
3636 TopLevel retval = TopLevel();
3737
38- retval.complex_union_array = json["complex-union-array"];
3938 retval.date = json["date"];
40- retval.date_time = json["date-time"];
4139 retval.time = json["time"];
40+ retval.date_time = json["date-time"];
4241 retval.union_array = json["union-array"];
42+ retval.complex_union_array = json["complex-union-array"];
4343
4444 return retval;
4545 }
Mschema-pike/test/inputs/schema/description.schema/default/TopLevel.pmod+6 −6
@@ -15,19 +15,19 @@
1515 // The top-level class.
1616 // Its description has two lines.
1717 class TopLevel {
18- bool|mixed bar; // json: "bar"
18+ Union union; // json: "union"
1919 Enum top_level_enum; // json: "enum"
2020 float|mixed foo; // json: "foo"
21+ bool|mixed bar; // json: "bar"
2122 ObjectOrStringUnion object_or_string; // json: "object-or-string"
22- Union union; // json: "union"
2323
2424 string encode_json() {
2525 mapping(string:mixed) json = ([
26- "bar" : bar,
26+ "union" : union,
2727 "enum" : top_level_enum,
2828 "foo" : foo,
29+ "bar" : bar,
2930 "object-or-string" : object_or_string,
30- "union" : union,
3131 ]);
3232
3333 return Standards.JSON.encode(json);
@@ -37,11 +37,11 @@ class TopLevel {
3737 TopLevel TopLevel_from_JSON(mixed json) {
3838 TopLevel retval = TopLevel();
3939
40- retval.bar = json["bar"];
40+ retval.union = json["union"];
4141 retval.top_level_enum = json["enum"];
4242 retval.foo = json["foo"];
43+ retval.bar = json["bar"];
4344 retval.object_or_string = json["object-or-string"];
44- retval.union = json["union"];
4545
4646 return retval;
4747 }
Mschema-pike/test/inputs/schema/direct-union.schema/default/TopLevel.pmod+3 −3
@@ -33,13 +33,13 @@ TopLevel TopLevel_from_JSON(mixed json) {
3333 }
3434
3535 class Thing {
36- Anything thing_optional; // json: "optional"
3736 Anything required; // json: "required"
37+ Anything thing_optional; // json: "optional"
3838
3939 string encode_json() {
4040 mapping(string:mixed) json = ([
41- "optional" : thing_optional,
4241 "required" : required,
42+ "optional" : thing_optional,
4343 ]);
4444
4545 return Standards.JSON.encode(json);
@@ -49,8 +49,8 @@ class Thing {
4949 Thing Thing_from_JSON(mixed json) {
5050 Thing retval = Thing();
5151
52- retval.thing_optional = json["optional"];
5352 retval.required = json["required"];
53+ retval.thing_optional = json["optional"];
5454
5555 return retval;
5656 }
Mschema-pike/test/inputs/schema/enum.schema/default/TopLevel.pmod+9 −9
@@ -13,19 +13,19 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- array(Arr)|mixed arr; // json: "arr"
17- mixed|string top_level_for; // json: "for"
18- Gve gve; // json: "gve"
1916 Lvc|mixed lvc; // json: "lvc"
17+ Gve gve; // json: "gve"
18+ array(Arr)|mixed arr; // json: "arr"
2019 array(OtherArr)|mixed other_arr; // json: "otherArr"
20+ mixed|string top_level_for; // json: "for"
2121
2222 string encode_json() {
2323 mapping(string:mixed) json = ([
24- "arr" : arr,
25- "for" : top_level_for,
26- "gve" : gve,
2724 "lvc" : lvc,
25+ "gve" : gve,
26+ "arr" : arr,
2827 "otherArr" : other_arr,
28+ "for" : top_level_for,
2929 ]);
3030
3131 return Standards.JSON.encode(json);
@@ -35,11 +35,11 @@ class TopLevel {
3535 TopLevel TopLevel_from_JSON(mixed json) {
3636 TopLevel retval = TopLevel();
3737
38- retval.arr = json["arr"];
39- retval.top_level_for = json["for"];
40- retval.gve = json["gve"];
4138 retval.lvc = json["lvc"];
39+ retval.gve = json["gve"];
40+ retval.arr = json["arr"];
4241 retval.other_arr = json["otherArr"];
42+ retval.top_level_for = json["for"];
4343
4444 return retval;
4545 }
Mschema-pike/test/inputs/schema/integer-string.schema/default/TopLevel.pmod+9 −9
@@ -13,21 +13,21 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- array(mixed|string)|mixed arr_nullable; // json: "arrNullable"
17- array(string)|mixed arr_one; // json: "arrOne"
18- mixed|string nullable; // json: "nullable"
1916 string one; // json: "one"
2017 mixed|string top_level_optional; // json: "optional"
18+ mixed|string nullable; // json: "nullable"
19+ array(string)|mixed arr_one; // json: "arrOne"
20+ array(mixed|string)|mixed arr_nullable; // json: "arrNullable"
2121 UnionWithInt union_with_int; // json: "unionWithInt"
2222 UnionWithInt union_with_int_and_enum; // json: "unionWithIntAndEnum"
2323
2424 string encode_json() {
2525 mapping(string:mixed) json = ([
26- "arrNullable" : arr_nullable,
27- "arrOne" : arr_one,
28- "nullable" : nullable,
2926 "one" : one,
3027 "optional" : top_level_optional,
28+ "nullable" : nullable,
29+ "arrOne" : arr_one,
30+ "arrNullable" : arr_nullable,
3131 "unionWithInt" : union_with_int,
3232 "unionWithIntAndEnum" : union_with_int_and_enum,
3333 ]);
@@ -39,11 +39,11 @@ class TopLevel {
3939 TopLevel TopLevel_from_JSON(mixed json) {
4040 TopLevel retval = TopLevel();
4141
42- retval.arr_nullable = json["arrNullable"];
43- retval.arr_one = json["arrOne"];
44- retval.nullable = json["nullable"];
4542 retval.one = json["one"];
4643 retval.top_level_optional = json["optional"];
44+ retval.nullable = json["nullable"];
45+ retval.arr_one = json["arrOne"];
46+ retval.arr_nullable = json["arrNullable"];
4747 retval.union_with_int = json["unionWithInt"];
4848 retval.union_with_int_and_enum = json["unionWithIntAndEnum"];
Mschema-pike/test/inputs/schema/integer-type.schema/default/TopLevel.pmod+15 −15
@@ -13,27 +13,27 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16+ int small_positive; // json: "small_positive"
17+ int small_negative; // json: "small_negative"
18+ int i32_range; // json: "i32_range"
1619 int above_i32_max; // json: "above_i32_max"
1720 int below_i32_min; // json: "below_i32_min"
18- int i32_range; // json: "i32_range"
19- int large_bounds; // json: "large_bounds"
20- int only_maximum; // json: "only_maximum"
2121 int only_minimum; // json: "only_minimum"
22- int small_negative; // json: "small_negative"
23- int small_positive; // json: "small_positive"
22+ int only_maximum; // json: "only_maximum"
2423 int unbounded; // json: "unbounded"
24+ int large_bounds; // json: "large_bounds"
2525
2626 string encode_json() {
2727 mapping(string:mixed) json = ([
28+ "small_positive" : small_positive,
29+ "small_negative" : small_negative,
30+ "i32_range" : i32_range,
2831 "above_i32_max" : above_i32_max,
2932 "below_i32_min" : below_i32_min,
30- "i32_range" : i32_range,
31- "large_bounds" : large_bounds,
32- "only_maximum" : only_maximum,
3333 "only_minimum" : only_minimum,
34- "small_negative" : small_negative,
35- "small_positive" : small_positive,
34+ "only_maximum" : only_maximum,
3635 "unbounded" : unbounded,
36+ "large_bounds" : large_bounds,
3737 ]);
3838
3939 return Standards.JSON.encode(json);
@@ -43,15 +43,15 @@ class TopLevel {
4343 TopLevel TopLevel_from_JSON(mixed json) {
4444 TopLevel retval = TopLevel();
4545
46+ retval.small_positive = json["small_positive"];
47+ retval.small_negative = json["small_negative"];
48+ retval.i32_range = json["i32_range"];
4649 retval.above_i32_max = json["above_i32_max"];
4750 retval.below_i32_min = json["below_i32_min"];
48- retval.i32_range = json["i32_range"];
49- retval.large_bounds = json["large_bounds"];
50- retval.only_maximum = json["only_maximum"];
5151 retval.only_minimum = json["only_minimum"];
52- retval.small_negative = json["small_negative"];
53- retval.small_positive = json["small_positive"];
52+ retval.only_maximum = json["only_maximum"];
5453 retval.unbounded = json["unbounded"];
54+ retval.large_bounds = json["large_bounds"];
5555
5656 return retval;
5757 }
Mschema-pike/test/inputs/schema/light.schema/default/TopLevel.pmod+3 −3
@@ -33,14 +33,14 @@ TopLevel TopLevel_from_JSON(mixed json) {
3333 }
3434
3535 class LightParams {
36- string app_id; // json: "app_id"
3736 string outlet_id; // json: "outlet_id"
37+ string app_id; // json: "app_id"
3838 string rgba; // json: "rgba"
3939
4040 string encode_json() {
4141 mapping(string:mixed) json = ([
42- "app_id" : app_id,
4342 "outlet_id" : outlet_id,
43+ "app_id" : app_id,
4444 "rgba" : rgba,
4545 ]);
4646
@@ -51,8 +51,8 @@ class LightParams {
5151 LightParams LightParams_from_JSON(mixed json) {
5252 LightParams retval = LightParams();
5353
54- retval.app_id = json["app_id"];
5554 retval.outlet_id = json["outlet_id"];
55+ retval.app_id = json["app_id"];
5656 retval.rgba = json["rgba"];
5757
5858 return retval;
Mschema-pike/test/inputs/schema/min-max-items.schema/default/TopLevel.pmod+3 −3
@@ -13,17 +13,17 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16+ array(string) min_only; // json: "minOnly"
1617 array(int) max_only; // json: "maxOnly"
1718 array(float) min_and_max; // json: "minAndMax"
18- array(string) min_only; // json: "minOnly"
1919 array(string) plain; // json: "plain"
2020 array(UnionItem) union_items; // json: "unionItems"
2121
2222 string encode_json() {
2323 mapping(string:mixed) json = ([
24+ "minOnly" : min_only,
2425 "maxOnly" : max_only,
2526 "minAndMax" : min_and_max,
26- "minOnly" : min_only,
2727 "plain" : plain,
2828 "unionItems" : union_items,
2929 ]);
@@ -35,9 +35,9 @@ class TopLevel {
3535 TopLevel TopLevel_from_JSON(mixed json) {
3636 TopLevel retval = TopLevel();
3737
38+ retval.min_only = json["minOnly"];
3839 retval.max_only = json["maxOnly"];
3940 retval.min_and_max = json["minAndMax"];
40- retval.min_only = json["minOnly"];
4141 retval.plain = json["plain"];
4242 retval.union_items = json["unionItems"];
Mschema-pike/test/inputs/schema/minmax-integer.schema/default/TopLevel.pmod+12 −12
@@ -14,24 +14,24 @@
1414
1515 class TopLevel {
1616 int free; // json: "free"
17- int intersection; // json: "intersection"
18- int max; // json: "max"
1917 int min; // json: "min"
18+ int max; // json: "max"
2019 int minmax; // json: "minmax"
21- int min_max_intersection; // json: "minMaxIntersection"
22- int min_max_union; // json: "minMaxUnion"
2320 int union; // json: "union"
21+ int min_max_union; // json: "minMaxUnion"
22+ int intersection; // json: "intersection"
23+ int min_max_intersection; // json: "minMaxIntersection"
2424
2525 string encode_json() {
2626 mapping(string:mixed) json = ([
2727 "free" : free,
28- "intersection" : intersection,
29- "max" : max,
3028 "min" : min,
29+ "max" : max,
3130 "minmax" : minmax,
32- "minMaxIntersection" : min_max_intersection,
33- "minMaxUnion" : min_max_union,
3431 "union" : union,
32+ "minMaxUnion" : min_max_union,
33+ "intersection" : intersection,
34+ "minMaxIntersection" : min_max_intersection,
3535 ]);
3636
3737 return Standards.JSON.encode(json);
@@ -42,13 +42,13 @@ TopLevel TopLevel_from_JSON(mixed json) {
4242 TopLevel retval = TopLevel();
4343
4444 retval.free = json["free"];
45- retval.intersection = json["intersection"];
46- retval.max = json["max"];
4745 retval.min = json["min"];
46+ retval.max = json["max"];
4847 retval.minmax = json["minmax"];
49- retval.min_max_intersection = json["minMaxIntersection"];
50- retval.min_max_union = json["minMaxUnion"];
5148 retval.union = json["union"];
49+ retval.min_max_union = json["minMaxUnion"];
50+ retval.intersection = json["intersection"];
51+ retval.min_max_intersection = json["minMaxIntersection"];
5252
5353 return retval;
5454 }
Mschema-pike/test/inputs/schema/minmaxlength.schema/default/TopLevel.pmod+15 −15
@@ -13,25 +13,25 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- string intersection; // json: "intersection"
17- InUnion in_union; // json: "inUnion"
18- string maxlength; // json: "maxlength"
1916 string minlength; // json: "minlength"
20- string min_max_intersection; // json: "minMaxIntersection"
17+ string maxlength; // json: "maxlength"
2118 string minmaxlength; // json: "minmaxlength"
22- string min_max_union; // json: "minMaxUnion"
2319 string union; // json: "union"
20+ InUnion in_union; // json: "inUnion"
21+ string min_max_union; // json: "minMaxUnion"
22+ string intersection; // json: "intersection"
23+ string min_max_intersection; // json: "minMaxIntersection"
2424
2525 string encode_json() {
2626 mapping(string:mixed) json = ([
27- "intersection" : intersection,
28- "inUnion" : in_union,
29- "maxlength" : maxlength,
3027 "minlength" : minlength,
31- "minMaxIntersection" : min_max_intersection,
28+ "maxlength" : maxlength,
3229 "minmaxlength" : minmaxlength,
33- "minMaxUnion" : min_max_union,
3430 "union" : union,
31+ "inUnion" : in_union,
32+ "minMaxUnion" : min_max_union,
33+ "intersection" : intersection,
34+ "minMaxIntersection" : min_max_intersection,
3535 ]);
3636
3737 return Standards.JSON.encode(json);
@@ -41,14 +41,14 @@ class TopLevel {
4141 TopLevel TopLevel_from_JSON(mixed json) {
4242 TopLevel retval = TopLevel();
4343
44- retval.intersection = json["intersection"];
45- retval.in_union = json["inUnion"];
46- retval.maxlength = json["maxlength"];
4744 retval.minlength = json["minlength"];
48- retval.min_max_intersection = json["minMaxIntersection"];
45+ retval.maxlength = json["maxlength"];
4946 retval.minmaxlength = json["minmaxlength"];
50- retval.min_max_union = json["minMaxUnion"];
5147 retval.union = json["union"];
48+ retval.in_union = json["inUnion"];
49+ retval.min_max_union = json["minMaxUnion"];
50+ retval.intersection = json["intersection"];
51+ retval.min_max_intersection = json["minMaxIntersection"];
5252
5353 return retval;
5454 }
Mschema-pike/test/inputs/schema/non-standard-ref.schema/default/TopLevel.pmod+3 −3
@@ -13,14 +13,14 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- int bar; // json: "bar"
1716 int foo; // json: "foo"
17+ int bar; // json: "bar"
1818 bool quux; // json: "quux"
1919
2020 string encode_json() {
2121 mapping(string:mixed) json = ([
22- "bar" : bar,
2322 "foo" : foo,
23+ "bar" : bar,
2424 "quux" : quux,
2525 ]);
2626
@@ -31,8 +31,8 @@ class TopLevel {
3131 TopLevel TopLevel_from_JSON(mixed json) {
3232 TopLevel retval = TopLevel();
3333
34- retval.bar = json["bar"];
3534 retval.foo = json["foo"];
35+ retval.bar = json["bar"];
3636 retval.quux = json["quux"];
3737
3838 return retval;
Mschema-pike/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.pmod+3 −3
@@ -13,13 +13,13 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- mixed|string b; // json: "b"
1716 Kind kind; // json: "kind"
17+ mixed|string b; // json: "b"
1818
1919 string encode_json() {
2020 mapping(string:mixed) json = ([
21- "b" : b,
2221 "kind" : kind,
22+ "b" : b,
2323 ]);
2424
2525 return Standards.JSON.encode(json);
@@ -29,8 +29,8 @@ class TopLevel {
2929 TopLevel TopLevel_from_JSON(mixed json) {
3030 TopLevel retval = TopLevel();
3131
32- retval.b = json["b"];
3332 retval.kind = json["kind"];
33+ retval.b = json["b"];
3434
3535 return retval;
3636 }
Mschema-pike/test/inputs/schema/optional-any.schema/default/TopLevel.pmod+3 −3
@@ -13,13 +13,13 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- bool bar; // json: "bar"
1716 mixed foo; // json: "foo"
17+ bool bar; // json: "bar"
1818
1919 string encode_json() {
2020 mapping(string:mixed) json = ([
21- "bar" : bar,
2221 "foo" : foo,
22+ "bar" : bar,
2323 ]);
2424
2525 return Standards.JSON.encode(json);
@@ -29,8 +29,8 @@ class TopLevel {
2929 TopLevel TopLevel_from_JSON(mixed json) {
3030 TopLevel retval = TopLevel();
3131
32- retval.bar = json["bar"];
3332 retval.foo = json["foo"];
33+ retval.bar = json["bar"];
3434
3535 return retval;
3636 }
Mschema-pike/test/inputs/schema/optional-const-ref.schema/default/TopLevel.pmod+9 −9
@@ -14,22 +14,22 @@
1414
1515 class TopLevel {
1616 array(Coordinate)|mixed coordinates; // json: "coordinates"
17- int|mixed count; // json: "count"
18- mixed|string label; // json: "label"
1917 array(Coordinate) required_coordinates; // json: "requiredCoordinates"
18+ int|mixed count; // json: "count"
2019 int required_count; // json: "requiredCount"
21- string required_label; // json: "requiredLabel"
2220 float|mixed weight; // json: "weight"
21+ mixed|string label; // json: "label"
22+ string required_label; // json: "requiredLabel"
2323
2424 string encode_json() {
2525 mapping(string:mixed) json = ([
2626 "coordinates" : coordinates,
27- "count" : count,
28- "label" : label,
2927 "requiredCoordinates" : required_coordinates,
28+ "count" : count,
3029 "requiredCount" : required_count,
31- "requiredLabel" : required_label,
3230 "weight" : weight,
31+ "label" : label,
32+ "requiredLabel" : required_label,
3333 ]);
3434
3535 return Standards.JSON.encode(json);
@@ -40,12 +40,12 @@ TopLevel TopLevel_from_JSON(mixed json) {
4040 TopLevel retval = TopLevel();
4141
4242 retval.coordinates = json["coordinates"];
43- retval.count = json["count"];
44- retval.label = json["label"];
4543 retval.required_coordinates = json["requiredCoordinates"];
44+ retval.count = json["count"];
4645 retval.required_count = json["requiredCount"];
47- retval.required_label = json["requiredLabel"];
4846 retval.weight = json["weight"];
47+ retval.label = json["label"];
48+ retval.required_label = json["requiredLabel"];
4949
5050 return retval;
5151 }
Mschema-pike/test/inputs/schema/optional-constraints.schema/default/TopLevel.pmod+9 −9
@@ -13,19 +13,19 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- float|mixed opt_double; // json: "optDouble"
16+ int req_zero_min; // json: "reqZeroMin"
1717 int|mixed opt_int; // json: "optInt"
18- mixed|string opt_pattern; // json: "optPattern"
18+ float|mixed opt_double; // json: "optDouble"
1919 mixed|string opt_string; // json: "optString"
20- int req_zero_min; // json: "reqZeroMin"
20+ mixed|string opt_pattern; // json: "optPattern"
2121
2222 string encode_json() {
2323 mapping(string:mixed) json = ([
24- "optDouble" : opt_double,
24+ "reqZeroMin" : req_zero_min,
2525 "optInt" : opt_int,
26- "optPattern" : opt_pattern,
26+ "optDouble" : opt_double,
2727 "optString" : opt_string,
28- "reqZeroMin" : req_zero_min,
28+ "optPattern" : opt_pattern,
2929 ]);
3030
3131 return Standards.JSON.encode(json);
@@ -35,11 +35,11 @@ class TopLevel {
3535 TopLevel TopLevel_from_JSON(mixed json) {
3636 TopLevel retval = TopLevel();
3737
38- retval.opt_double = json["optDouble"];
38+ retval.req_zero_min = json["reqZeroMin"];
3939 retval.opt_int = json["optInt"];
40- retval.opt_pattern = json["optPattern"];
40+ retval.opt_double = json["optDouble"];
4141 retval.opt_string = json["optString"];
42- retval.req_zero_min = json["reqZeroMin"];
42+ retval.opt_pattern = json["optPattern"];
4343
4444 return retval;
4545 }
Mschema-pike/test/inputs/schema/optional-date-time.schema/default/TopLevel.pmod+12 −12
@@ -13,21 +13,21 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- mixed|string optional_date; // json: "optional-date"
17- mixed|string optional_date_time; // json: "optional-date-time"
18- mixed|string optional_time; // json: "optional-time"
1916 string required_date; // json: "required-date"
20- string required_date_time; // json: "required-date-time"
2117 string required_time; // json: "required-time"
18+ string required_date_time; // json: "required-date-time"
19+ mixed|string optional_date; // json: "optional-date"
20+ mixed|string optional_time; // json: "optional-time"
21+ mixed|string optional_date_time; // json: "optional-date-time"
2222
2323 string encode_json() {
2424 mapping(string:mixed) json = ([
25- "optional-date" : optional_date,
26- "optional-date-time" : optional_date_time,
27- "optional-time" : optional_time,
2825 "required-date" : required_date,
29- "required-date-time" : required_date_time,
3026 "required-time" : required_time,
27+ "required-date-time" : required_date_time,
28+ "optional-date" : optional_date,
29+ "optional-time" : optional_time,
30+ "optional-date-time" : optional_date_time,
3131 ]);
3232
3333 return Standards.JSON.encode(json);
@@ -37,12 +37,12 @@ class TopLevel {
3737 TopLevel TopLevel_from_JSON(mixed json) {
3838 TopLevel retval = TopLevel();
3939
40- retval.optional_date = json["optional-date"];
41- retval.optional_date_time = json["optional-date-time"];
42- retval.optional_time = json["optional-time"];
4340 retval.required_date = json["required-date"];
44- retval.required_date_time = json["required-date-time"];
4541 retval.required_time = json["required-time"];
42+ retval.required_date_time = json["required-date-time"];
43+ retval.optional_date = json["optional-date"];
44+ retval.optional_time = json["optional-time"];
45+ retval.optional_date_time = json["optional-date-time"];
4646
4747 return retval;
4848 }
Mschema-pike/test/inputs/schema/prefix-items.schema/default/TopLevel.pmod+3 −3
@@ -13,13 +13,13 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- array(Open) open; // json: "open"
1716 array(Open) tuple; // json: "tuple"
17+ array(Open) open; // json: "open"
1818
1919 string encode_json() {
2020 mapping(string:mixed) json = ([
21- "open" : open,
2221 "tuple" : tuple,
22+ "open" : open,
2323 ]);
2424
2525 return Standards.JSON.encode(json);
@@ -29,8 +29,8 @@ class TopLevel {
2929 TopLevel TopLevel_from_JSON(mixed json) {
3030 TopLevel retval = TopLevel();
3131
32- retval.open = json["open"];
3332 retval.tuple = json["tuple"];
33+ retval.open = json["open"];
3434
3535 return retval;
3636 }
Aschema-pike/test/inputs/schema/property-order.schema/default/TopLevel.pmod+74 −0
@@ -0,0 +1,74 @@
1+// This source has been automatically generated by quicktype.
2+// ( https://github.com/quicktype/quicktype )
3+//
4+// To use this code, simply import it into your project as a Pike module.
5+// To JSON-encode your object, you can pass it to `Standards.JSON.encode`
6+// or call `encode_json` on it.
7+//
8+// To decode a JSON string, first pass it to `Standards.JSON.decode`,
9+// and then pass the result to `<YourClass>_from_JSON`.
10+// It will return an instance of <YourClass>.
11+// Bear in mind that these functions have unexpected behavior,
12+// and will likely throw an error, if the JSON string does not
13+// match the expected interface, even if the JSON itself is valid.
14+
15+class TopLevel {
16+ string zebra; // json: "zebra"
17+ float mango; // json: "mango"
18+ bool apple; // json: "apple"
19+ string delta; // json: "delta"
20+ int banana; // json: "banana"
21+ Ordered ordered; // json: "ordered"
22+
23+ string encode_json() {
24+ mapping(string:mixed) json = ([
25+ "zebra" : zebra,
26+ "mango" : mango,
27+ "apple" : apple,
28+ "delta" : delta,
29+ "banana" : banana,
30+ "ordered" : ordered,
31+ ]);
32+
33+ return Standards.JSON.encode(json);
34+ }
35+}
36+
37+TopLevel TopLevel_from_JSON(mixed json) {
38+ TopLevel retval = TopLevel();
39+
40+ retval.zebra = json["zebra"];
41+ retval.mango = json["mango"];
42+ retval.apple = json["apple"];
43+ retval.delta = json["delta"];
44+ retval.banana = json["banana"];
45+ retval.ordered = json["ordered"];
46+
47+ return retval;
48+}
49+
50+class Ordered {
51+ float mango; // json: "mango"
52+ string zebra; // json: "zebra"
53+ bool apple; // json: "apple"
54+
55+ string encode_json() {
56+ mapping(string:mixed) json = ([
57+ "mango" : mango,
58+ "zebra" : zebra,
59+ "apple" : apple,
60+ ]);
61+
62+ return Standards.JSON.encode(json);
63+ }
64+}
65+
66+Ordered Ordered_from_JSON(mixed json) {
67+ Ordered retval = Ordered();
68+
69+ retval.mango = json["mango"];
70+ retval.zebra = json["zebra"];
71+ retval.apple = json["apple"];
72+
73+ return retval;
74+}
Mschema-pike/test/inputs/schema/renaming-bug.schema/default/TopLevel.pmod+24 −24
@@ -40,14 +40,14 @@ TopLevel TopLevel_from_JSON(mixed json) {
4040
4141 class Fruit {
4242 bool|mixed apple; // json: "apple"
43- array(Berry)|mixed berries; // json: "berries"
4443 bool|mixed orange; // json: "orange"
44+ array(Berry)|mixed berries; // json: "berries"
4545
4646 string encode_json() {
4747 mapping(string:mixed) json = ([
4848 "apple" : apple,
49- "berries" : berries,
5049 "orange" : orange,
50+ "berries" : berries,
5151 ]);
5252
5353 return Standards.JSON.encode(json);
@@ -58,21 +58,21 @@ Fruit Fruit_from_JSON(mixed json) {
5858 Fruit retval = Fruit();
5959
6060 retval.apple = json["apple"];
61- retval.berries = json["berries"];
6261 retval.orange = json["orange"];
62+ retval.berries = json["berries"];
6363
6464 return retval;
6565 }
6666
6767 class Berry {
68- Color|mixed color; // json: "color"
6968 mixed|string name; // json: "name"
69+ Color|mixed color; // json: "color"
7070 array(Shape)|mixed shapes; // json: "shapes"
7171
7272 string encode_json() {
7373 mapping(string:mixed) json = ([
74- "color" : color,
7574 "name" : name,
75+ "color" : color,
7676 "shapes" : shapes,
7777 ]);
7878
@@ -83,8 +83,8 @@ class Berry {
8383 Berry Berry_from_JSON(mixed json) {
8484 Berry retval = Berry();
8585
86- retval.color = json["color"];
8786 retval.name = json["name"];
87+ retval.color = json["color"];
8888 retval.shapes = json["shapes"];
8989
9090 return retval;
@@ -111,13 +111,13 @@ Color Color_from_JSON(mixed json) {
111111 }
112112
113113 class Shape {
114- Geometry|mixed geometry; // json: "geometry"
115114 History|mixed history; // json: "history"
115+ Geometry|mixed geometry; // json: "geometry"
116116
117117 string encode_json() {
118118 mapping(string:mixed) json = ([
119- "geometry" : geometry,
120119 "history" : history,
120+ "geometry" : geometry,
121121 ]);
122122
123123 return Standards.JSON.encode(json);
@@ -127,8 +127,8 @@ class Shape {
127127 Shape Shape_from_JSON(mixed json) {
128128 Shape retval = Shape();
129129
130- retval.geometry = json["geometry"];
131130 retval.history = json["history"];
131+ retval.geometry = json["geometry"];
132132
133133 return retval;
134134 }
@@ -197,15 +197,15 @@ RectShape RectShape_from_JSON(mixed json) {
197197 }
198198
199199 class Part {
200- mixed|string depth; // json: "depth"
201200 mixed|string length; // json: "length"
202201 mixed|string width; // json: "width"
202+ mixed|string depth; // json: "depth"
203203
204204 string encode_json() {
205205 mapping(string:mixed) json = ([
206- "depth" : depth,
207206 "length" : length,
208207 "width" : width,
208+ "depth" : depth,
209209 ]);
210210
211211 return Standards.JSON.encode(json);
@@ -215,9 +215,9 @@ class Part {
215215 Part Part_from_JSON(mixed json) {
216216 Part retval = Part();
217217
218- retval.depth = json["depth"];
219218 retval.length = json["length"];
220219 retval.width = json["width"];
220+ retval.depth = json["depth"];
221221
222222 return retval;
223223 }
@@ -243,21 +243,21 @@ History History_from_JSON(mixed json) {
243243 }
244244
245245 class Vehicle {
246- mixed|string brand; // json: "brand"
247246 mixed|string id; // json: "id"
248- Speed|mixed speed; // json: "speed"
249- bool|mixed sub_module; // json: "subModule"
250247 VehicleType|mixed type; // json: "type"
248+ Speed|mixed speed; // json: "speed"
251249 mixed|string year; // json: "year"
250+ mixed|string brand; // json: "brand"
251+ bool|mixed sub_module; // json: "subModule"
252252
253253 string encode_json() {
254254 mapping(string:mixed) json = ([
255- "brand" : brand,
256255 "id" : id,
257- "speed" : speed,
258- "subModule" : sub_module,
259256 "type" : type,
257+ "speed" : speed,
260258 "year" : year,
259+ "brand" : brand,
260+ "subModule" : sub_module,
261261 ]);
262262
263263 return Standards.JSON.encode(json);
@@ -267,12 +267,12 @@ class Vehicle {
267267 Vehicle Vehicle_from_JSON(mixed json) {
268268 Vehicle retval = Vehicle();
269269
270- retval.brand = json["brand"];
271270 retval.id = json["id"];
272- retval.speed = json["speed"];
273- retval.sub_module = json["subModule"];
274271 retval.type = json["type"];
272+ retval.speed = json["speed"];
275273 retval.year = json["year"];
274+ retval.brand = json["brand"];
275+ retval.sub_module = json["subModule"];
276276
277277 return retval;
278278 }
@@ -298,13 +298,13 @@ Speed Speed_from_JSON(mixed json) {
298298 }
299299
300300 class Limit {
301- float|mixed maximum; // json: "maximum"
302301 float|mixed minimum; // json: "minimum"
302+ float|mixed maximum; // json: "maximum"
303303
304304 string encode_json() {
305305 mapping(string:mixed) json = ([
306- "maximum" : maximum,
307306 "minimum" : minimum,
307+ "maximum" : maximum,
308308 ]);
309309
310310 return Standards.JSON.encode(json);
@@ -314,8 +314,8 @@ class Limit {
314314 Limit Limit_from_JSON(mixed json) {
315315 Limit retval = Limit();
316316
317- retval.maximum = json["maximum"];
318317 retval.minimum = json["minimum"];
318+ retval.maximum = json["maximum"];
319319
320320 return retval;
321321 }
Mschema-pike/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.pmod+6 −6
@@ -13,13 +13,13 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- Next next; // json: "next"
1716 string value; // json: "value"
17+ Next next; // json: "next"
1818
1919 string encode_json() {
2020 mapping(string:mixed) json = ([
21- "next" : next,
2221 "value" : value,
22+ "next" : next,
2323 ]);
2424
2525 return Standards.JSON.encode(json);
@@ -29,20 +29,20 @@ class TopLevel {
2929 TopLevel TopLevel_from_JSON(mixed json) {
3030 TopLevel retval = TopLevel();
3131
32- retval.next = json["next"];
3332 retval.value = json["value"];
33+ retval.next = json["next"];
3434
3535 return retval;
3636 }
3737
3838 class Node {
39- Next next; // json: "next"
4039 string value; // json: "value"
40+ Next next; // json: "next"
4141
4242 string encode_json() {
4343 mapping(string:mixed) json = ([
44- "next" : next,
4544 "value" : value,
45+ "next" : next,
4646 ]);
4747
4848 return Standards.JSON.encode(json);
@@ -52,8 +52,8 @@ class Node {
5252 Node Node_from_JSON(mixed json) {
5353 Node retval = Node();
5454
55- retval.next = json["next"];
5655 retval.value = json["value"];
56+ retval.next = json["next"];
5757
5858 return retval;
5959 }
Mschema-pike/test/inputs/schema/uuid.schema/default/TopLevel.pmod+9 −9
@@ -13,20 +13,20 @@
1313 // match the expected interface, even if the JSON itself is valid.
1414
1515 class TopLevel {
16- array(mixed|string)|mixed arr_nullable; // json: "arrNullable"
17- array(string)|mixed arr_one; // json: "arrOne"
18- mixed|string nullable; // json: "nullable"
1916 string one; // json: "one"
2017 mixed|string top_level_optional; // json: "optional"
18+ mixed|string nullable; // json: "nullable"
19+ array(string)|mixed arr_one; // json: "arrOne"
20+ array(mixed|string)|mixed arr_nullable; // json: "arrNullable"
2121 string union_with_enum; // json: "unionWithEnum"
2222
2323 string encode_json() {
2424 mapping(string:mixed) json = ([
25- "arrNullable" : arr_nullable,
26- "arrOne" : arr_one,
27- "nullable" : nullable,
2825 "one" : one,
2926 "optional" : top_level_optional,
27+ "nullable" : nullable,
28+ "arrOne" : arr_one,
29+ "arrNullable" : arr_nullable,
3030 "unionWithEnum" : union_with_enum,
3131 ]);
3232
@@ -37,11 +37,11 @@ class TopLevel {
3737 TopLevel TopLevel_from_JSON(mixed json) {
3838 TopLevel retval = TopLevel();
3939
40- retval.arr_nullable = json["arrNullable"];
41- retval.arr_one = json["arrOne"];
42- retval.nullable = json["nullable"];
4340 retval.one = json["one"];
4441 retval.top_level_optional = json["optional"];
42+ retval.nullable = json["nullable"];
43+ retval.arr_one = json["arrOne"];
44+ retval.arr_nullable = json["arrNullable"];
4545 retval.union_with_enum = json["unionWithEnum"];
4646
4747 return retval;
Mschema-pike/test/inputs/schema/vega-lite.schema/default/TopLevel.pmod+24 −24
@@ -304,8 +304,8 @@ class MarkConfig {
304304 float|mixed dx; // json: "dx"
305305 float|mixed dy; // json: "dy"
306306 mixed|string fill; // json: "fill"
307- bool|mixed filled; // json: "filled"
308307 float|mixed fill_opacity; // json: "fillOpacity"
308+ bool|mixed filled; // json: "filled"
309309 mixed|string font; // json: "font"
310310 float|mixed font_size; // json: "fontSize"
311311 FontStyle|mixed font_style; // json: "fontStyle"
@@ -337,8 +337,8 @@ class MarkConfig {
337337 "dx" : dx,
338338 "dy" : dy,
339339 "fill" : fill,
340- "filled" : filled,
341340 "fillOpacity" : fill_opacity,
341+ "filled" : filled,
342342 "font" : font,
343343 "fontSize" : font_size,
344344 "fontStyle" : font_style,
@@ -376,8 +376,8 @@ MarkConfig MarkConfig_from_JSON(mixed json) {
376376 retval.dx = json["dx"];
377377 retval.dy = json["dy"];
378378 retval.fill = json["fill"];
379- retval.filled = json["filled"];
380379 retval.fill_opacity = json["fillOpacity"];
380+ retval.filled = json["filled"];
381381 retval.font = json["font"];
382382 retval.font_size = json["fontSize"];
383383 retval.font_style = json["fontStyle"];
@@ -521,9 +521,9 @@ class AxisConfig {
521521 bool|mixed short_time_labels; // json: "shortTimeLabels"
522522 mixed|string tick_color; // json: "tickColor"
523523 bool|mixed tick_round; // json: "tickRound"
524- bool|mixed ticks; // json: "ticks"
525524 float|mixed tick_size; // json: "tickSize"
526525 float|mixed tick_width; // json: "tickWidth"
526+ bool|mixed ticks; // json: "ticks"
527527 mixed|string title_align; // json: "titleAlign"
528528 float|mixed title_angle; // json: "titleAngle"
529529 mixed|string title_baseline; // json: "titleBaseline"
@@ -563,9 +563,9 @@ class AxisConfig {
563563 "shortTimeLabels" : short_time_labels,
564564 "tickColor" : tick_color,
565565 "tickRound" : tick_round,
566- "ticks" : ticks,
567566 "tickSize" : tick_size,
568567 "tickWidth" : tick_width,
568+ "ticks" : ticks,
569569 "titleAlign" : title_align,
570570 "titleAngle" : title_angle,
571571 "titleBaseline" : title_baseline,
@@ -611,9 +611,9 @@ AxisConfig AxisConfig_from_JSON(mixed json) {
611611 retval.short_time_labels = json["shortTimeLabels"];
612612 retval.tick_color = json["tickColor"];
613613 retval.tick_round = json["tickRound"];
614- retval.ticks = json["ticks"];
615614 retval.tick_size = json["tickSize"];
616615 retval.tick_width = json["tickWidth"];
616+ retval.ticks = json["ticks"];
617617 retval.title_align = json["titleAlign"];
618618 retval.title_angle = json["titleAngle"];
619619 retval.title_baseline = json["titleBaseline"];
@@ -710,9 +710,9 @@ class VgAxisConfig {
710710 float|mixed min_extent; // json: "minExtent"
711711 mixed|string tick_color; // json: "tickColor"
712712 bool|mixed tick_round; // json: "tickRound"
713- bool|mixed ticks; // json: "ticks"
714713 float|mixed tick_size; // json: "tickSize"
715714 float|mixed tick_width; // json: "tickWidth"
715+ bool|mixed ticks; // json: "ticks"
716716 mixed|string title_align; // json: "titleAlign"
717717 float|mixed title_angle; // json: "titleAngle"
718718 mixed|string title_baseline; // json: "titleBaseline"
@@ -751,9 +751,9 @@ class VgAxisConfig {
751751 "minExtent" : min_extent,
752752 "tickColor" : tick_color,
753753 "tickRound" : tick_round,
754- "ticks" : ticks,
755754 "tickSize" : tick_size,
756755 "tickWidth" : tick_width,
756+ "ticks" : ticks,
757757 "titleAlign" : title_align,
758758 "titleAngle" : title_angle,
759759 "titleBaseline" : title_baseline,
@@ -798,9 +798,9 @@ VgAxisConfig VgAxisConfig_from_JSON(mixed json) {
798798 retval.min_extent = json["minExtent"];
799799 retval.tick_color = json["tickColor"];
800800 retval.tick_round = json["tickRound"];
801- retval.ticks = json["ticks"];
802801 retval.tick_size = json["tickSize"];
803802 retval.tick_width = json["tickWidth"];
803+ retval.ticks = json["ticks"];
804804 retval.title_align = json["titleAlign"];
805805 retval.title_angle = json["titleAngle"];
806806 retval.title_baseline = json["titleBaseline"];
@@ -830,8 +830,8 @@ class BarConfig {
830830 float|mixed dx; // json: "dx"
831831 float|mixed dy; // json: "dy"
832832 mixed|string fill; // json: "fill"
833- bool|mixed filled; // json: "filled"
834833 float|mixed fill_opacity; // json: "fillOpacity"
834+ bool|mixed filled; // json: "filled"
835835 mixed|string font; // json: "font"
836836 float|mixed font_size; // json: "fontSize"
837837 FontStyle|mixed font_style; // json: "fontStyle"
@@ -866,8 +866,8 @@ class BarConfig {
866866 "dx" : dx,
867867 "dy" : dy,
868868 "fill" : fill,
869- "filled" : filled,
870869 "fillOpacity" : fill_opacity,
870+ "filled" : filled,
871871 "font" : font,
872872 "fontSize" : font_size,
873873 "fontStyle" : font_style,
@@ -908,8 +908,8 @@ BarConfig BarConfig_from_JSON(mixed json) {
908908 retval.dx = json["dx"];
909909 retval.dy = json["dy"];
910910 retval.fill = json["fill"];
911- retval.filled = json["filled"];
912911 retval.fill_opacity = json["fillOpacity"];
912+ retval.filled = json["filled"];
913913 retval.font = json["font"];
914914 retval.font_size = json["fontSize"];
915915 retval.font_style = json["fontStyle"];
@@ -1748,8 +1748,8 @@ class TextConfig {
17481748 float|mixed dx; // json: "dx"
17491749 float|mixed dy; // json: "dy"
17501750 mixed|string fill; // json: "fill"
1751- bool|mixed filled; // json: "filled"
17521751 float|mixed fill_opacity; // json: "fillOpacity"
1752+ bool|mixed filled; // json: "filled"
17531753 mixed|string font; // json: "font"
17541754 float|mixed font_size; // json: "fontSize"
17551755 FontStyle|mixed font_style; // json: "fontStyle"
@@ -1782,8 +1782,8 @@ class TextConfig {
17821782 "dx" : dx,
17831783 "dy" : dy,
17841784 "fill" : fill,
1785- "filled" : filled,
17861785 "fillOpacity" : fill_opacity,
1786+ "filled" : filled,
17871787 "font" : font,
17881788 "fontSize" : font_size,
17891789 "fontStyle" : font_style,
@@ -1822,8 +1822,8 @@ TextConfig TextConfig_from_JSON(mixed json) {
18221822 retval.dx = json["dx"];
18231823 retval.dy = json["dy"];
18241824 retval.fill = json["fill"];
1825- retval.filled = json["filled"];
18261825 retval.fill_opacity = json["fillOpacity"];
1826+ retval.filled = json["filled"];
18271827 retval.font = json["font"];
18281828 retval.font_size = json["fontSize"];
18291829 retval.font_style = json["fontStyle"];
@@ -1860,8 +1860,8 @@ class TickConfig {
18601860 float|mixed dx; // json: "dx"
18611861 float|mixed dy; // json: "dy"
18621862 mixed|string fill; // json: "fill"
1863- bool|mixed filled; // json: "filled"
18641863 float|mixed fill_opacity; // json: "fillOpacity"
1864+ bool|mixed filled; // json: "filled"
18651865 mixed|string font; // json: "font"
18661866 float|mixed font_size; // json: "fontSize"
18671867 FontStyle|mixed font_style; // json: "fontStyle"
@@ -1895,8 +1895,8 @@ class TickConfig {
18951895 "dx" : dx,
18961896 "dy" : dy,
18971897 "fill" : fill,
1898- "filled" : filled,
18991898 "fillOpacity" : fill_opacity,
1899+ "filled" : filled,
19001900 "font" : font,
19011901 "fontSize" : font_size,
19021902 "fontStyle" : font_style,
@@ -1936,8 +1936,8 @@ TickConfig TickConfig_from_JSON(mixed json) {
19361936 retval.dx = json["dx"];
19371937 retval.dy = json["dy"];
19381938 retval.fill = json["fill"];
1939- retval.filled = json["filled"];
19401939 retval.fill_opacity = json["fillOpacity"];
1940+ retval.filled = json["filled"];
19411941 retval.font = json["font"];
19421942 retval.font_size = json["fontSize"];
19431943 retval.font_style = json["fontStyle"];
@@ -3625,8 +3625,8 @@ class Axis {
36253625 TitleOrient|mixed orient; // json: "orient"
36263626 float|mixed position; // json: "position"
36273627 float|mixed tick_count; // json: "tickCount"
3628- bool|mixed ticks; // json: "ticks"
36293628 float|mixed tick_size; // json: "tickSize"
3629+ bool|mixed ticks; // json: "ticks"
36303630 mixed|string title; // json: "title"
36313631 float|mixed title_max_length; // json: "titleMaxLength"
36323632 float|mixed title_padding; // json: "titlePadding"
@@ -3650,8 +3650,8 @@ class Axis {
36503650 "orient" : orient,
36513651 "position" : position,
36523652 "tickCount" : tick_count,
3653- "ticks" : ticks,
36543653 "tickSize" : tick_size,
3654+ "ticks" : ticks,
36553655 "title" : title,
36563656 "titleMaxLength" : title_max_length,
36573657 "titlePadding" : title_padding,
@@ -3681,8 +3681,8 @@ Axis Axis_from_JSON(mixed json) {
36813681 retval.orient = json["orient"];
36823682 retval.position = json["position"];
36833683 retval.tick_count = json["tickCount"];
3684- retval.ticks = json["ticks"];
36853684 retval.tick_size = json["tickSize"];
3685+ retval.ticks = json["ticks"];
36863686 retval.title = json["title"];
36873687 retval.title_max_length = json["titleMaxLength"];
36883688 retval.title_padding = json["titlePadding"];
@@ -3971,8 +3971,8 @@ class MarkDef {
39713971 float|mixed dx; // json: "dx"
39723972 float|mixed dy; // json: "dy"
39733973 mixed|string fill; // json: "fill"
3974- bool|mixed filled; // json: "filled"
39753974 float|mixed fill_opacity; // json: "fillOpacity"
3975+ bool|mixed filled; // json: "filled"
39763976 mixed|string font; // json: "font"
39773977 float|mixed font_size; // json: "fontSize"
39783978 FontStyle|mixed font_style; // json: "fontStyle"
@@ -4007,8 +4007,8 @@ class MarkDef {
40074007 "dx" : dx,
40084008 "dy" : dy,
40094009 "fill" : fill,
4010- "filled" : filled,
40114010 "fillOpacity" : fill_opacity,
4011+ "filled" : filled,
40124012 "font" : font,
40134013 "fontSize" : font_size,
40144014 "fontStyle" : font_style,
@@ -4049,8 +4049,8 @@ MarkDef MarkDef_from_JSON(mixed json) {
40494049 retval.dx = json["dx"];
40504050 retval.dy = json["dy"];
40514051 retval.fill = json["fill"];
4052- retval.filled = json["filled"];
40534052 retval.fill_opacity = json["fillOpacity"];
4053+ retval.filled = json["filled"];
40544054 retval.font = json["font"];
40554055 retval.font_size = json["fontSize"];
40564056 retval.font_style = json["fontStyle"];
Mschema-python/test/inputs/schema/accessors.schema/default/quicktype.py+15 −15
@@ -7,11 +7,6 @@ T = TypeVar("T")
77 EnumT = TypeVar("EnumT", bound=Enum)
88
99
10-def from_str(x: Any) -> str:
11- assert isinstance(x, str)
12- return x
13-
14-
1510 def from_bool(x: Any) -> bool:
1611 assert isinstance(x, bool)
1712 return x
@@ -31,9 +26,9 @@ def from_union(fs, x):
3126 assert False
3227
3328
34-def to_enum(c: Type[EnumT], x: Any) -> EnumT:
35- assert isinstance(x, c)
36- return x.value
29+def from_str(x: Any) -> str:
30+ assert isinstance(x, str)
31+ return x
3732
3833
3934 def to_float(x: Any) -> float:
@@ -41,6 +36,11 @@ def to_float(x: Any) -> float:
4136 return x
4237
4338
39+def to_enum(c: Type[EnumT], x: Any) -> EnumT:
40+ assert isinstance(x, c)
41+ return x.value
42+
43+
4444 def to_class(c: Type[T], x: Any) -> dict:
4545 assert isinstance(x, c)
4646 return cast(Any, x).to_dict()
@@ -54,26 +54,26 @@ class EnumEnum(Enum):
5454
5555 @dataclass
5656 class TopLevel:
57- barre: str
57+ unionization: bool | float
5858 enumerification: EnumEnum
5959 foo: str
60- unionization: bool | float
60+ barre: str
6161
6262 @staticmethod
6363 def from_dict(obj: Any) -> 'TopLevel':
6464 assert isinstance(obj, dict)
65- barre = from_str(obj.get("bar"))
65+ unionization = from_union([from_bool, from_float], obj.get("union"))
6666 enumerification = EnumEnum(obj.get("enum"))
6767 foo = from_str(obj.get("foo"))
68- unionization = from_union([from_bool, from_float], obj.get("union"))
69- return TopLevel(barre, enumerification, foo, unionization)
68+ barre = from_str(obj.get("bar"))
69+ return TopLevel(unionization, enumerification, foo, barre)
7070
7171 def to_dict(self) -> dict:
7272 result: dict = {}
73- result["bar"] = from_str(self.barre)
73+ result["union"] = from_union([from_bool, to_float], self.unionization)
7474 result["enum"] = to_enum(EnumEnum, self.enumerification)
7575 result["foo"] = from_str(self.foo)
76- result["union"] = from_union([from_bool, to_float], self.unionization)
76+ result["bar"] = from_str(self.barre)
7777 return result
Mschema-python/test/inputs/schema/bool-string.schema/default/quicktype.py+17 −17
@@ -34,16 +34,16 @@ def from_union(fs, x):
3434 assert False
3535
3636
37-def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
38- assert isinstance(x, list)
39- return [f(y) for y in x]
40-
41-
4237 def from_none(x: Any) -> Any:
4338 assert x is None
4439 return x
4540
4641
42+def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
43+ assert isinstance(x, list)
44+ return [f(y) for y in x]
45+
46+
4747 def is_type(t: Type[T], x: Any) -> T:
4848 assert isinstance(x, t)
4949 return x
@@ -68,10 +68,10 @@ class TopLevel:
6868 one: bool
6969 union_with_bool: bool
7070 union_with_bool_and_enum: bool | UnionWithBoolAndEnumEnum
71- arr_nullable: list[bool | None] | None = None
72- arr_one: list[bool] | None = None
73- nullable: bool | None = None
7471 optional: bool | None = None
72+ nullable: bool | None = None
73+ arr_one: list[bool] | None = None
74+ arr_nullable: list[bool | None] | None = None
7575
7676 @staticmethod
7777 def from_dict(obj: Any) -> 'TopLevel':
@@ -79,24 +79,24 @@ class TopLevel:
7979 one = from_stringified_bool(from_str(obj.get("one")))
8080 union_with_bool = from_union([from_bool, lambda x: from_stringified_bool(from_str(x))], obj.get("unionWithBool"))
8181 union_with_bool_and_enum = from_union([from_bool, lambda x: from_union([from_stringified_bool, UnionWithBoolAndEnumEnum], from_str(x))], obj.get("unionWithBoolAndEnum"))
82- arr_nullable = from_union([lambda x: from_list(lambda x: from_union([from_none, lambda x: from_stringified_bool(from_str(x))], x), x), from_none], obj.get("arrNullable"))
83- arr_one = from_union([lambda x: from_list(lambda x: from_stringified_bool(from_str(x)), x), from_none], obj.get("arrOne"))
84- nullable = from_union([from_none, lambda x: from_stringified_bool(from_str(x))], obj.get("nullable"))
8582 optional = from_union([from_none, lambda x: from_stringified_bool(from_str(x))], obj.get("optional"))
86- return TopLevel(one, union_with_bool, union_with_bool_and_enum, arr_nullable, arr_one, nullable, optional)
83+ nullable = from_union([from_none, lambda x: from_stringified_bool(from_str(x))], obj.get("nullable"))
84+ arr_one = from_union([lambda x: from_list(lambda x: from_stringified_bool(from_str(x)), x), from_none], obj.get("arrOne"))
85+ arr_nullable = from_union([lambda x: from_list(lambda x: from_union([from_none, lambda x: from_stringified_bool(from_str(x))], x), x), from_none], obj.get("arrNullable"))
86+ return TopLevel(one, union_with_bool, union_with_bool_and_enum, optional, nullable, arr_one, arr_nullable)
8787
8888 def to_dict(self) -> dict:
8989 result: dict = {}
9090 result["one"] = from_str(str(self.one).lower())
9191 result["unionWithBool"] = from_bool(self.union_with_bool)
9292 result["unionWithBoolAndEnum"] = from_union([lambda x: from_bool((lambda x: is_type(bool, x))(x)), lambda x: from_str((lambda x: to_enum(UnionWithBoolAndEnumEnum, (lambda x: is_type(UnionWithBoolAndEnumEnum, x))(x)))(x))], self.union_with_bool_and_enum)
93- if self.arr_nullable is not None:
94- result["arrNullable"] = from_union([lambda x: from_list(lambda x: from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(bool, x))(x)).lower())(x))], x), x), from_none], self.arr_nullable)
95- if self.arr_one is not None:
96- result["arrOne"] = from_union([lambda x: from_list(lambda x: from_str((lambda x: str(x).lower())(x)), x), from_none], self.arr_one)
97- result["nullable"] = from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(bool, x))(x)).lower())(x))], self.nullable)
9893 if self.optional is not None:
9994 result["optional"] = from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(bool, x))(x)).lower())(x))], self.optional)
95+ result["nullable"] = from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(bool, x))(x)).lower())(x))], self.nullable)
96+ if self.arr_one is not None:
97+ result["arrOne"] = from_union([lambda x: from_list(lambda x: from_str((lambda x: str(x).lower())(x)), x), from_none], self.arr_one)
98+ if self.arr_nullable is not None:
99+ result["arrNullable"] = from_union([lambda x: from_list(lambda x: from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(bool, x))(x)).lower())(x))], x), x), from_none], self.arr_nullable)
100100 return result
Mschema-python/test/inputs/schema/boolean-subschema.schema/default/quicktype.py+9 −9
@@ -5,16 +5,16 @@ from typing import Any, TypeVar, Callable, Type, cast
55 T = TypeVar("T")
66
77
8-def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
9- assert isinstance(x, list)
10- return [f(y) for y in x]
11-
12-
138 def from_str(x: Any) -> str:
149 assert isinstance(x, str)
1510 return x
1611
1712
13+def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
14+ assert isinstance(x, list)
15+ return [f(y) for y in x]
16+
17+
1818 def to_class(c: Type[T], x: Any) -> dict:
1919 assert isinstance(x, c)
2020 return cast(Any, x).to_dict()
@@ -22,24 +22,24 @@ def to_class(c: Type[T], x: Any) -> dict:
2222
2323 @dataclass
2424 class TopLevel:
25- empty: list[Any]
2625 foo: str
26+ empty: list[Any]
2727 disallowed: Any = None
2828 impossible: Any = None
2929
3030 @staticmethod
3131 def from_dict(obj: Any) -> 'TopLevel':
3232 assert isinstance(obj, dict)
33- empty = from_list(lambda x: x, obj.get("empty"))
3433 foo = from_str(obj.get("foo"))
34+ empty = from_list(lambda x: x, obj.get("empty"))
3535 disallowed = obj.get("disallowed")
3636 impossible = obj.get("impossible")
37- return TopLevel(empty, foo, disallowed, impossible)
37+ return TopLevel(foo, empty, disallowed, impossible)
3838
3939 def to_dict(self) -> dict:
4040 result: dict = {}
41- result["empty"] = from_list(lambda x: x, self.empty)
4241 result["foo"] = from_str(self.foo)
42+ result["empty"] = from_list(lambda x: x, self.empty)
4343 if self.disallowed is not None:
4444 result["disallowed"] = self.disallowed
4545 if self.impossible is not None:
Mschema-python/test/inputs/schema/const-non-string.schema/default/quicktype.py+15 −15
@@ -7,6 +7,11 @@ T = TypeVar("T")
77 EnumT = TypeVar("EnumT", bound=Enum)
88
99
10+def from_float(x: Any) -> float:
11+ assert isinstance(x, (float, int)) and not isinstance(x, bool)
12+ return float(x)
13+
14+
1015 def from_int(x: Any) -> int:
1116 assert isinstance(x, int) and not isinstance(x, bool)
1217 return x
@@ -17,9 +22,9 @@ def from_bool(x: Any) -> bool:
1722 return x
1823
1924
20-def from_float(x: Any) -> float:
21- assert isinstance(x, (float, int)) and not isinstance(x, bool)
22- return float(x)
25+def to_float(x: Any) -> float:
26+ assert isinstance(x, (int, float))
27+ return x
2328
2429
2530 def to_enum(c: Type[EnumT], x: Any) -> EnumT:
@@ -27,11 +32,6 @@ def to_enum(c: Type[EnumT], x: Any) -> EnumT:
2732 return x.value
2833
2934
30-def to_float(x: Any) -> float:
31- assert isinstance(x, (int, float))
32- return x
33-
34-
3535 def to_class(c: Type[T], x: Any) -> dict:
3636 assert isinstance(x, c)
3737 return cast(Any, x).to_dict()
@@ -43,29 +43,29 @@ class Kind(Enum):
4343
4444 @dataclass
4545 class TopLevel:
46+ version: float
4647 amount: int
48+ ratio: float
4749 enabled: bool
4850 kind: Kind
49- ratio: float
50- version: float
5151
5252 @staticmethod
5353 def from_dict(obj: Any) -> 'TopLevel':
5454 assert isinstance(obj, dict)
55+ version = from_float(obj.get("version"))
5556 amount = from_int(obj.get("amount"))
57+ ratio = from_float(obj.get("ratio"))
5658 enabled = from_bool(obj.get("enabled"))
5759 kind = Kind(obj.get("kind"))
58- ratio = from_float(obj.get("ratio"))
59- version = from_float(obj.get("version"))
60- return TopLevel(amount, enabled, kind, ratio, version)
60+ return TopLevel(version, amount, ratio, enabled, kind)
6161
6262 def to_dict(self) -> dict:
6363 result: dict = {}
64+ result["version"] = to_float(self.version)
6465 result["amount"] = from_int(self.amount)
66+ result["ratio"] = to_float(self.ratio)
6567 result["enabled"] = from_bool(self.enabled)
6668 result["kind"] = to_enum(Kind, self.kind)
67- result["ratio"] = to_float(self.ratio)
68- result["version"] = to_float(self.version)
6969 return result
Mschema-python/test/inputs/schema/date-time-or-string.schema/default/quicktype.py+9 −9
@@ -9,6 +9,11 @@ T = TypeVar("T")
99 EnumT = TypeVar("EnumT", bound=Enum)
1010
1111
12+def from_str(x: Any) -> str:
13+ assert isinstance(x, str)
14+ return x
15+
16+
1217 def from_datetime(x: Any) -> datetime.datetime:
1318 return dateutil.parser.parse(x)
1419
@@ -22,11 +27,6 @@ def from_union(fs, x):
2227 assert False
2328
2429
25-def from_str(x: Any) -> str:
26- assert isinstance(x, str)
27- return x
28-
29-
3030 def to_enum(c: Type[EnumT], x: Any) -> EnumT:
3131 assert isinstance(x, c)
3232 return x.value
@@ -43,20 +43,20 @@ class BarEnum(Enum):
4343
4444 @dataclass
4545 class TopLevel:
46- bar: BarEnum | datetime.datetime
4746 foo: str
47+ bar: BarEnum | datetime.datetime
4848
4949 @staticmethod
5050 def from_dict(obj: Any) -> 'TopLevel':
5151 assert isinstance(obj, dict)
52- bar = from_union([BarEnum, from_datetime], obj.get("bar"))
5352 foo = from_str(obj.get("foo"))
54- return TopLevel(bar, foo)
53+ bar = from_union([BarEnum, from_datetime], obj.get("bar"))
54+ return TopLevel(foo, bar)
5555
5656 def to_dict(self) -> dict:
5757 result: dict = {}
58- result["bar"] = from_union([lambda x: to_enum(BarEnum, x), lambda x: x.isoformat()], self.bar)
5958 result["foo"] = from_str(self.foo)
59+ result["bar"] = from_union([lambda x: to_enum(BarEnum, x), lambda x: x.isoformat()], self.bar)
6060 return result
Mschema-python/test/inputs/schema/date-time.schema/default/quicktype.py+21 −21
@@ -10,20 +10,25 @@ T = TypeVar("T")
1010 EnumT = TypeVar("EnumT", bound=Enum)
1111
1212
13-def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
14- assert isinstance(x, list)
15- return [f(y) for y in x]
13+def from_date(x: Any) -> datetime.date:
14+ assert isinstance(x, str) and re.match(r"^\d{4}-\d{2}-\d{2}$", x)
15+ return dateutil.parser.parse(x).date()
1616
1717
18-def from_int(x: Any) -> int:
19- assert isinstance(x, int) and not isinstance(x, bool)
20- return x
18+def from_time(x: Any) -> datetime.time:
19+ assert isinstance(x, str) and re.match(r"^\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$", x)
20+ return dateutil.parser.parse(x).time()
2121
2222
2323 def from_datetime(x: Any) -> datetime.datetime:
2424 return dateutil.parser.parse(x)
2525
2626
27+def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
28+ assert isinstance(x, list)
29+ return [f(y) for y in x]
30+
31+
2732 def from_union(fs, x):
2833 for f in fs:
2934 try:
@@ -33,14 +38,9 @@ def from_union(fs, x):
3338 assert False
3439
3540
36-def from_date(x: Any) -> datetime.date:
37- assert isinstance(x, str) and re.match(r"^\d{4}-\d{2}-\d{2}$", x)
38- return dateutil.parser.parse(x).date()
39-
40-
41-def from_time(x: Any) -> datetime.time:
42- assert isinstance(x, str) and re.match(r"^\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$", x)
43- return dateutil.parser.parse(x).time()
41+def from_int(x: Any) -> int:
42+ assert isinstance(x, int) and not isinstance(x, bool)
43+ return x
4444
4545
4646 def to_enum(c: Type[EnumT], x: Any) -> EnumT:
@@ -60,29 +60,29 @@ class ComplexUnionArrayEnum(Enum):
6060
6161 @dataclass
6262 class TopLevel:
63- complex_union_array: list[int | ComplexUnionArrayEnum | datetime.datetime]
6463 date: datetime.date
65- date_time: datetime.datetime
6664 time: datetime.time
65+ date_time: datetime.datetime
6766 union_array: list[datetime.date | datetime.time | datetime.datetime]
67+ complex_union_array: list[int | ComplexUnionArrayEnum | datetime.datetime]
6868
6969 @staticmethod
7070 def from_dict(obj: Any) -> 'TopLevel':
7171 assert isinstance(obj, dict)
72- complex_union_array = from_list(lambda x: from_union([from_int, ComplexUnionArrayEnum, from_datetime], x), obj.get("complex-union-array"))
7372 date = from_date(obj.get("date"))
74- date_time = from_datetime(obj.get("date-time"))
7573 time = from_time(obj.get("time"))
74+ date_time = from_datetime(obj.get("date-time"))
7675 union_array = from_list(lambda x: from_union([from_date, from_time, from_datetime], x), obj.get("union-array"))
77- return TopLevel(complex_union_array, date, date_time, time, union_array)
76+ complex_union_array = from_list(lambda x: from_union([from_int, ComplexUnionArrayEnum, from_datetime], x), obj.get("complex-union-array"))
77+ return TopLevel(date, time, date_time, union_array, complex_union_array)
7878
7979 def to_dict(self) -> dict:
8080 result: dict = {}
81- result["complex-union-array"] = from_list(lambda x: from_union([from_int, lambda x: to_enum(ComplexUnionArrayEnum, x), lambda x: x.isoformat()], x), self.complex_union_array)
8281 result["date"] = self.date.isoformat()
83- result["date-time"] = self.date_time.isoformat()
8482 result["time"] = self.time.isoformat()
83+ result["date-time"] = self.date_time.isoformat()
8584 result["union-array"] = from_list(lambda x: from_union([lambda x: x.isoformat(), lambda x: x.isoformat(), lambda x: x.isoformat()], x), self.union_array)
85+ result["complex-union-array"] = from_list(lambda x: from_union([from_int, lambda x: to_enum(ComplexUnionArrayEnum, x), lambda x: x.isoformat()], x), self.complex_union_array)
8686 return result
Mschema-python/test/inputs/schema/description.schema/default/quicktype.py+14 −15
@@ -31,13 +31,13 @@ def from_union(fs, x):
3131 assert False
3232
3333
34-def from_bool(x: Any) -> bool:
35- assert isinstance(x, bool)
34+def from_none(x: Any) -> Any:
35+ assert x is None
3636 return x
3737
3838
39-def from_none(x: Any) -> Any:
40- assert x is None
39+def from_bool(x: Any) -> bool:
40+ assert isinstance(x, bool)
4141 return x
4242
4343
@@ -80,37 +80,36 @@ class TopLevel:
8080 """The top-level class.
8181 Its description has two lines.
8282 """
83+ union: float | str
84+ """Either a number or a string"""
85+
8386 enum: EnumEnum
8487 """An enumeration"""
8588
8689 object_or_string: str | ObjectOrStringClass
87- union: float | str
88- """Either a number or a string"""
89-
90+ foo: float | None = None
9091 bar: bool | None = None
9192 """A pretty boolean"""
9293
93- foo: float | None = None
94-
9594 @staticmethod
9695 def from_dict(obj: Any) -> 'TopLevel':
9796 assert isinstance(obj, dict)
97+ union = from_union([from_float, from_str], obj.get("union"))
9898 enum = EnumEnum(obj.get("enum"))
9999 object_or_string = from_union([from_str, ObjectOrStringClass.from_dict], obj.get("object-or-string"))
100- union = from_union([from_float, from_str], obj.get("union"))
101- bar = from_union([from_bool, from_none], obj.get("bar"))
102100 foo = from_union([from_float, from_none], obj.get("foo"))
103- return TopLevel(enum, object_or_string, union, bar, foo)
101+ bar = from_union([from_bool, from_none], obj.get("bar"))
102+ return TopLevel(union, enum, object_or_string, foo, bar)
104103
105104 def to_dict(self) -> dict:
106105 result: dict = {}
106+ result["union"] = from_union([to_float, from_str], self.union)
107107 result["enum"] = to_enum(EnumEnum, self.enum)
108108 result["object-or-string"] = from_union([from_str, lambda x: to_class(ObjectOrStringClass, x)], self.object_or_string)
109- result["union"] = from_union([to_float, from_str], self.union)
110- if self.bar is not None:
111- result["bar"] = from_union([from_bool, from_none], self.bar)
112109 if self.foo is not None:
113110 result["foo"] = from_union([to_float, from_none], self.foo)
111+ if self.bar is not None:
112+ result["bar"] = from_union([from_bool, from_none], self.bar)
114113 return result
Mschema-python/test/inputs/schema/direct-union.schema/default/quicktype.py+4 −4
@@ -61,21 +61,21 @@ def to_class(c: Type[T], x: Any) -> dict:
6161
6262 @dataclass
6363 class Thing:
64- optional: float | int | bool | str | list[Any] | dict[str, Any] | None = None
6564 required: float | int | bool | str | list[Any] | dict[str, Any] | None = None
65+ optional: float | int | bool | str | list[Any] | dict[str, Any] | None = None
6666
6767 @staticmethod
6868 def from_dict(obj: Any) -> 'Thing':
6969 assert isinstance(obj, dict)
70- optional = from_union([from_none, from_int, from_float, from_bool, from_str, lambda x: from_list(lambda x: x, x), lambda x: from_dict(lambda x: x, x)], obj.get("optional"))
7170 required = from_union([from_none, from_int, from_float, from_bool, from_str, lambda x: from_list(lambda x: x, x), lambda x: from_dict(lambda x: x, x)], obj.get("required"))
72- return Thing(optional, required)
71+ optional = from_union([from_none, from_int, from_float, from_bool, from_str, lambda x: from_list(lambda x: x, x), lambda x: from_dict(lambda x: x, x)], obj.get("optional"))
72+ return Thing(required, optional)
7373
7474 def to_dict(self) -> dict:
7575 result: dict = {}
76+ result["required"] = from_union([from_none, from_int, to_float, from_bool, from_str, lambda x: from_list(lambda x: x, x), lambda x: from_dict(lambda x: x, x)], self.required)
7677 if self.optional is not None:
7778 result["optional"] = from_union([from_none, from_int, to_float, from_bool, from_str, lambda x: from_list(lambda x: x, x), lambda x: from_dict(lambda x: x, x)], self.optional)
78- result["required"] = from_union([from_none, from_int, to_float, from_bool, from_str, lambda x: from_list(lambda x: x, x), lambda x: from_dict(lambda x: x, x)], self.required)
7979 return result
Mschema-python/test/inputs/schema/enum.schema/default/quicktype.py+18 −18
@@ -7,13 +7,8 @@ T = TypeVar("T")
77 EnumT = TypeVar("EnumT", bound=Enum)
88
99
10-def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
11- assert isinstance(x, list)
12- return [f(y) for y in x]
13-
14-
15-def from_int(x: Any) -> int:
16- assert isinstance(x, int) and not isinstance(x, bool)
10+def from_none(x: Any) -> Any:
11+ assert x is None
1712 return x
1813
1914
@@ -26,8 +21,13 @@ def from_union(fs, x):
2621 assert False
2722
2823
29-def from_none(x: Any) -> Any:
30- assert x is None
24+def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
25+ assert isinstance(x, list)
26+ return [f(y) for y in x]
27+
28+
29+def from_int(x: Any) -> int:
30+ assert isinstance(x, int) and not isinstance(x, bool)
3131 return x
3232
3333
@@ -67,32 +67,32 @@ class Lvc(Enum):
6767 @dataclass
6868 class TopLevel:
6969 gve: Gve
70- arr: list[int | OtherArr] | None = None
71- top_level_for: str | None = None
7270 lvc: Lvc | None = None
71+ arr: list[int | OtherArr] | None = None
7372 other_arr: list[OtherArr] | None = None
73+ top_level_for: str | None = None
7474
7575 @staticmethod
7676 def from_dict(obj: Any) -> 'TopLevel':
7777 assert isinstance(obj, dict)
7878 gve = Gve(obj.get("gve"))
79- arr = from_union([lambda x: from_list(lambda x: from_union([from_int, OtherArr], x), x), from_none], obj.get("arr"))
80- top_level_for = from_union([from_str, from_none], obj.get("for"))
8179 lvc = from_union([Lvc, from_none], obj.get("lvc"))
80+ arr = from_union([lambda x: from_list(lambda x: from_union([from_int, OtherArr], x), x), from_none], obj.get("arr"))
8281 other_arr = from_union([lambda x: from_list(OtherArr, x), from_none], obj.get("otherArr"))
83- return TopLevel(gve, arr, top_level_for, lvc, other_arr)
82+ top_level_for = from_union([from_str, from_none], obj.get("for"))
83+ return TopLevel(gve, lvc, arr, other_arr, top_level_for)
8484
8585 def to_dict(self) -> dict:
8686 result: dict = {}
8787 result["gve"] = to_enum(Gve, self.gve)
88- if self.arr is not None:
89- result["arr"] = from_union([lambda x: from_list(lambda x: from_union([from_int, lambda x: to_enum(OtherArr, x)], x), x), from_none], self.arr)
90- if self.top_level_for is not None:
91- result["for"] = from_union([from_str, from_none], self.top_level_for)
9288 if self.lvc is not None:
9389 result["lvc"] = from_union([lambda x: to_enum(Lvc, x), from_none], self.lvc)
90+ if self.arr is not None:
91+ result["arr"] = from_union([lambda x: from_list(lambda x: from_union([from_int, lambda x: to_enum(OtherArr, x)], x), x), from_none], self.arr)
9492 if self.other_arr is not None:
9593 result["otherArr"] = from_union([lambda x: from_list(lambda x: to_enum(OtherArr, x), x), from_none], self.other_arr)
94+ if self.top_level_for is not None:
95+ result["for"] = from_union([from_str, from_none], self.top_level_for)
9696 return result
Mschema-python/test/inputs/schema/integer-string.schema/default/quicktype.py+17 −17
@@ -26,16 +26,16 @@ def from_union(fs, x):
2626 assert False
2727
2828
29-def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
30- assert isinstance(x, list)
31- return [f(y) for y in x]
32-
33-
3429 def from_none(x: Any) -> Any:
3530 assert x is None
3631 return x
3732
3833
34+def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
35+ assert isinstance(x, list)
36+ return [f(y) for y in x]
37+
38+
3939 def is_type(t: Type[T], x: Any) -> T:
4040 assert isinstance(x, t)
4141 return x
@@ -60,10 +60,10 @@ class TopLevel:
6060 one: int
6161 union_with_int: int
6262 union_with_int_and_enum: int | UnionWithIntAndEnumEnum
63- arr_nullable: list[int | None] | None = None
64- arr_one: list[int] | None = None
65- nullable: int | None = None
6663 optional: int | None = None
64+ nullable: int | None = None
65+ arr_one: list[int] | None = None
66+ arr_nullable: list[int | None] | None = None
6767
6868 @staticmethod
6969 def from_dict(obj: Any) -> 'TopLevel':
@@ -71,24 +71,24 @@ class TopLevel:
7171 one = int(from_str(obj.get("one")))
7272 union_with_int = from_union([from_int, lambda x: int(from_str(x))], obj.get("unionWithInt"))
7373 union_with_int_and_enum = from_union([from_int, lambda x: from_union([UnionWithIntAndEnumEnum, lambda x: int(x)], from_str(x))], obj.get("unionWithIntAndEnum"))
74- arr_nullable = from_union([lambda x: from_list(lambda x: from_union([from_none, lambda x: int(from_str(x))], x), x), from_none], obj.get("arrNullable"))
75- arr_one = from_union([lambda x: from_list(lambda x: int(from_str(x)), x), from_none], obj.get("arrOne"))
76- nullable = from_union([from_none, lambda x: int(from_str(x))], obj.get("nullable"))
7774 optional = from_union([from_none, lambda x: int(from_str(x))], obj.get("optional"))
78- return TopLevel(one, union_with_int, union_with_int_and_enum, arr_nullable, arr_one, nullable, optional)
75+ nullable = from_union([from_none, lambda x: int(from_str(x))], obj.get("nullable"))
76+ arr_one = from_union([lambda x: from_list(lambda x: int(from_str(x)), x), from_none], obj.get("arrOne"))
77+ arr_nullable = from_union([lambda x: from_list(lambda x: from_union([from_none, lambda x: int(from_str(x))], x), x), from_none], obj.get("arrNullable"))
78+ return TopLevel(one, union_with_int, union_with_int_and_enum, optional, nullable, arr_one, arr_nullable)
7979
8080 def to_dict(self) -> dict:
8181 result: dict = {}
8282 result["one"] = from_str(str(self.one))
8383 result["unionWithInt"] = from_int(self.union_with_int)
8484 result["unionWithIntAndEnum"] = from_union([lambda x: from_int((lambda x: is_type(int, x))(x)), lambda x: from_str((lambda x: to_enum(UnionWithIntAndEnumEnum, (lambda x: is_type(UnionWithIntAndEnumEnum, x))(x)))(x))], self.union_with_int_and_enum)
85- if self.arr_nullable is not None:
86- result["arrNullable"] = from_union([lambda x: from_list(lambda x: from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(int, x))(x)))(x))], x), x), from_none], self.arr_nullable)
87- if self.arr_one is not None:
88- result["arrOne"] = from_union([lambda x: from_list(lambda x: from_str((lambda x: str(x))(x)), x), from_none], self.arr_one)
89- result["nullable"] = from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(int, x))(x)))(x))], self.nullable)
9085 if self.optional is not None:
9186 result["optional"] = from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(int, x))(x)))(x))], self.optional)
87+ result["nullable"] = from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(int, x))(x)))(x))], self.nullable)
88+ if self.arr_one is not None:
89+ result["arrOne"] = from_union([lambda x: from_list(lambda x: from_str((lambda x: str(x))(x)), x), from_none], self.arr_one)
90+ if self.arr_nullable is not None:
91+ result["arrNullable"] = from_union([lambda x: from_list(lambda x: from_union([lambda x: from_none((lambda x: is_type(type(None), x))(x)), lambda x: from_str((lambda x: str((lambda x: is_type(int, x))(x)))(x))], x), x), from_none], self.arr_nullable)
9292 return result
Mschema-python/test/inputs/schema/integer-type.schema/default/quicktype.py+16 −16
@@ -17,41 +17,41 @@ def to_class(c: Type[T], x: Any) -> dict:
1717
1818 @dataclass
1919 class TopLevel:
20+ small_positive: int
21+ small_negative: int
22+ i32_range: int
2023 above_i32_max: int
2124 below_i32_min: int
22- i32_range: int
23- large_bounds: int
24- only_maximum: int
2525 only_minimum: int
26- small_negative: int
27- small_positive: int
26+ only_maximum: int
2827 unbounded: int
28+ large_bounds: int
2929
3030 @staticmethod
3131 def from_dict(obj: Any) -> 'TopLevel':
3232 assert isinstance(obj, dict)
33+ small_positive = from_int(obj.get("small_positive"))
34+ small_negative = from_int(obj.get("small_negative"))
35+ i32_range = from_int(obj.get("i32_range"))
3336 above_i32_max = from_int(obj.get("above_i32_max"))
3437 below_i32_min = from_int(obj.get("below_i32_min"))
35- i32_range = from_int(obj.get("i32_range"))
36- large_bounds = from_int(obj.get("large_bounds"))
37- only_maximum = from_int(obj.get("only_maximum"))
3838 only_minimum = from_int(obj.get("only_minimum"))
39- small_negative = from_int(obj.get("small_negative"))
40- small_positive = from_int(obj.get("small_positive"))
39+ only_maximum = from_int(obj.get("only_maximum"))
4140 unbounded = from_int(obj.get("unbounded"))
42- return TopLevel(above_i32_max, below_i32_min, i32_range, large_bounds, only_maximum, only_minimum, small_negative, small_positive, unbounded)
41+ large_bounds = from_int(obj.get("large_bounds"))
42+ return TopLevel(small_positive, small_negative, i32_range, above_i32_max, below_i32_min, only_minimum, only_maximum, unbounded, large_bounds)
4343
4444 def to_dict(self) -> dict:
4545 result: dict = {}
46+ result["small_positive"] = from_int(self.small_positive)
47+ result["small_negative"] = from_int(self.small_negative)
48+ result["i32_range"] = from_int(self.i32_range)
4649 result["above_i32_max"] = from_int(self.above_i32_max)
4750 result["below_i32_min"] = from_int(self.below_i32_min)
48- result["i32_range"] = from_int(self.i32_range)
49- result["large_bounds"] = from_int(self.large_bounds)
50- result["only_maximum"] = from_int(self.only_maximum)
5151 result["only_minimum"] = from_int(self.only_minimum)
52- result["small_negative"] = from_int(self.small_negative)
53- result["small_positive"] = from_int(self.small_positive)
52+ result["only_maximum"] = from_int(self.only_maximum)
5453 result["unbounded"] = from_int(self.unbounded)
54+ result["large_bounds"] = from_int(self.large_bounds)
5555 return result
Mschema-python/test/inputs/schema/light.schema/default/quicktype.py+4 −4
@@ -17,22 +17,22 @@ def to_class(c: Type[T], x: Any) -> dict:
1717
1818 @dataclass
1919 class LightParams:
20- app_id: str
2120 outlet_id: str
21+ app_id: str
2222 rgba: str
2323
2424 @staticmethod
2525 def from_dict(obj: Any) -> 'LightParams':
2626 assert isinstance(obj, dict)
27- app_id = from_str(obj.get("app_id"))
2827 outlet_id = from_str(obj.get("outlet_id"))
28+ app_id = from_str(obj.get("app_id"))
2929 rgba = from_str(obj.get("rgba"))
30- return LightParams(app_id, outlet_id, rgba)
30+ return LightParams(outlet_id, app_id, rgba)
3131
3232 def to_dict(self) -> dict:
3333 result: dict = {}
34- result["app_id"] = from_str(self.app_id)
3534 result["outlet_id"] = from_str(self.outlet_id)
35+ result["app_id"] = from_str(self.app_id)
3636 result["rgba"] = from_str(self.rgba)
3737 return result
Mschema-python/test/inputs/schema/min-max-items.schema/default/quicktype.py+9 −9
@@ -10,6 +10,11 @@ def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
1010 return [f(y) for y in x]
1111
1212
13+def from_str(x: Any) -> str:
14+ assert isinstance(x, str)
15+ return x
16+
17+
1318 def from_int(x: Any) -> int:
1419 assert isinstance(x, int) and not isinstance(x, bool)
1520 return x
@@ -20,11 +25,6 @@ def from_float(x: Any) -> float:
2025 return float(x)
2126
2227
23-def from_str(x: Any) -> str:
24- assert isinstance(x, str)
25- return x
26-
27-
2828 def from_union(fs, x):
2929 for f in fs:
3030 try:
@@ -46,27 +46,27 @@ def to_class(c: Type[T], x: Any) -> dict:
4646
4747 @dataclass
4848 class TopLevel:
49+ min_only: list[str]
4950 max_only: list[int]
5051 min_and_max: list[float]
51- min_only: list[str]
5252 plain: list[str]
5353 union_items: list[int | str]
5454
5555 @staticmethod
5656 def from_dict(obj: Any) -> 'TopLevel':
5757 assert isinstance(obj, dict)
58+ min_only = from_list(from_str, obj.get("minOnly"))
5859 max_only = from_list(from_int, obj.get("maxOnly"))
5960 min_and_max = from_list(from_float, obj.get("minAndMax"))
60- min_only = from_list(from_str, obj.get("minOnly"))
6161 plain = from_list(from_str, obj.get("plain"))
6262 union_items = from_list(lambda x: from_union([from_int, from_str], x), obj.get("unionItems"))
63- return TopLevel(max_only, min_and_max, min_only, plain, union_items)
63+ return TopLevel(min_only, max_only, min_and_max, plain, union_items)
6464
6565 def to_dict(self) -> dict:
6666 result: dict = {}
67+ result["minOnly"] = from_list(from_str, self.min_only)
6768 result["maxOnly"] = from_list(from_int, self.max_only)
6869 result["minAndMax"] = from_list(to_float, self.min_and_max)
69- result["minOnly"] = from_list(from_str, self.min_only)
7070 result["plain"] = from_list(from_str, self.plain)
7171 result["unionItems"] = from_list(lambda x: from_union([from_int, from_str], x), self.union_items)
7272 return result
Mschema-python/test/inputs/schema/minmax-integer.schema/default/quicktype.py+13 −13
@@ -18,37 +18,37 @@ def to_class(c: Type[T], x: Any) -> dict:
1818 @dataclass
1919 class TopLevel:
2020 free: int
21- intersection: int
22- max: int
2321 min: int
22+ max: int
2423 minmax: int
25- min_max_intersection: int
26- min_max_union: int
2724 union: int
25+ min_max_union: int
26+ intersection: int
27+ min_max_intersection: int
2828
2929 @staticmethod
3030 def from_dict(obj: Any) -> 'TopLevel':
3131 assert isinstance(obj, dict)
3232 free = from_int(obj.get("free"))
33- intersection = from_int(obj.get("intersection"))
34- max = from_int(obj.get("max"))
3533 min = from_int(obj.get("min"))
34+ max = from_int(obj.get("max"))
3635 minmax = from_int(obj.get("minmax"))
37- min_max_intersection = from_int(obj.get("minMaxIntersection"))
38- min_max_union = from_int(obj.get("minMaxUnion"))
3936 union = from_int(obj.get("union"))
40- return TopLevel(free, intersection, max, min, minmax, min_max_intersection, min_max_union, union)
37+ min_max_union = from_int(obj.get("minMaxUnion"))
38+ intersection = from_int(obj.get("intersection"))
39+ min_max_intersection = from_int(obj.get("minMaxIntersection"))
40+ return TopLevel(free, min, max, minmax, union, min_max_union, intersection, min_max_intersection)
4141
4242 def to_dict(self) -> dict:
4343 result: dict = {}
4444 result["free"] = from_int(self.free)
45- result["intersection"] = from_int(self.intersection)
46- result["max"] = from_int(self.max)
4745 result["min"] = from_int(self.min)
46+ result["max"] = from_int(self.max)
4847 result["minmax"] = from_int(self.minmax)
49- result["minMaxIntersection"] = from_int(self.min_max_intersection)
50- result["minMaxUnion"] = from_int(self.min_max_union)
5148 result["union"] = from_int(self.union)
49+ result["minMaxUnion"] = from_int(self.min_max_union)
50+ result["intersection"] = from_int(self.intersection)
51+ result["minMaxIntersection"] = from_int(self.min_max_intersection)
5252 return result
Mschema-python/test/inputs/schema/minmax.schema/default/quicktype.py+13 −13
@@ -23,37 +23,37 @@ def to_class(c: Type[T], x: Any) -> dict:
2323 @dataclass
2424 class TopLevel:
2525 free: float
26- intersection: float
27- max: float
2826 min: float
27+ max: float
2928 minmax: float
30- min_max_intersection: float
31- min_max_union: float
3229 union: float
30+ min_max_union: float
31+ intersection: float
32+ min_max_intersection: float
3333
3434 @staticmethod
3535 def from_dict(obj: Any) -> 'TopLevel':
3636 assert isinstance(obj, dict)
3737 free = from_float(obj.get("free"))
38- intersection = from_float(obj.get("intersection"))
39- max = from_float(obj.get("max"))
4038 min = from_float(obj.get("min"))
39+ max = from_float(obj.get("max"))
4140 minmax = from_float(obj.get("minmax"))
42- min_max_intersection = from_float(obj.get("minMaxIntersection"))
43- min_max_union = from_float(obj.get("minMaxUnion"))
4441 union = from_float(obj.get("union"))
45- return TopLevel(free, intersection, max, min, minmax, min_max_intersection, min_max_union, union)
42+ min_max_union = from_float(obj.get("minMaxUnion"))
43+ intersection = from_float(obj.get("intersection"))
44+ min_max_intersection = from_float(obj.get("minMaxIntersection"))
45+ return TopLevel(free, min, max, minmax, union, min_max_union, intersection, min_max_intersection)
4646
4747 def to_dict(self) -> dict:
4848 result: dict = {}
4949 result["free"] = to_float(self.free)
50- result["intersection"] = to_float(self.intersection)
51- result["max"] = to_float(self.max)
5250 result["min"] = to_float(self.min)
51+ result["max"] = to_float(self.max)
5352 result["minmax"] = to_float(self.minmax)
54- result["minMaxIntersection"] = to_float(self.min_max_intersection)
55- result["minMaxUnion"] = to_float(self.min_max_union)
5653 result["union"] = to_float(self.union)
54+ result["minMaxUnion"] = to_float(self.min_max_union)
55+ result["intersection"] = to_float(self.intersection)
56+ result["minMaxIntersection"] = to_float(self.min_max_intersection)
5757 return result
Mschema-python/test/inputs/schema/minmaxlength.schema/default/quicktype.py+16 −16
@@ -36,38 +36,38 @@ def to_class(c: Type[T], x: Any) -> dict:
3636
3737 @dataclass
3838 class TopLevel:
39- intersection: str
40- in_union: float | str
41- maxlength: str
4239 minlength: str
43- min_max_intersection: str
40+ maxlength: str
4441 minmaxlength: str
45- min_max_union: str
4642 union: str
43+ in_union: float | str
44+ min_max_union: str
45+ intersection: str
46+ min_max_intersection: str
4747
4848 @staticmethod
4949 def from_dict(obj: Any) -> 'TopLevel':
5050 assert isinstance(obj, dict)
51- intersection = from_str(obj.get("intersection"))
52- in_union = from_union([from_float, from_str], obj.get("inUnion"))
53- maxlength = from_str(obj.get("maxlength"))
5451 minlength = from_str(obj.get("minlength"))
55- min_max_intersection = from_str(obj.get("minMaxIntersection"))
52+ maxlength = from_str(obj.get("maxlength"))
5653 minmaxlength = from_str(obj.get("minmaxlength"))
57- min_max_union = from_str(obj.get("minMaxUnion"))
5854 union = from_str(obj.get("union"))
59- return TopLevel(intersection, in_union, maxlength, minlength, min_max_intersection, minmaxlength, min_max_union, union)
55+ in_union = from_union([from_float, from_str], obj.get("inUnion"))
56+ min_max_union = from_str(obj.get("minMaxUnion"))
57+ intersection = from_str(obj.get("intersection"))
58+ min_max_intersection = from_str(obj.get("minMaxIntersection"))
59+ return TopLevel(minlength, maxlength, minmaxlength, union, in_union, min_max_union, intersection, min_max_intersection)
6060
6161 def to_dict(self) -> dict:
6262 result: dict = {}
63- result["intersection"] = from_str(self.intersection)
64- result["inUnion"] = from_union([to_float, from_str], self.in_union)
65- result["maxlength"] = from_str(self.maxlength)
6663 result["minlength"] = from_str(self.minlength)
67- result["minMaxIntersection"] = from_str(self.min_max_intersection)
64+ result["maxlength"] = from_str(self.maxlength)
6865 result["minmaxlength"] = from_str(self.minmaxlength)
69- result["minMaxUnion"] = from_str(self.min_max_union)
7066 result["union"] = from_str(self.union)
67+ result["inUnion"] = from_union([to_float, from_str], self.in_union)
68+ result["minMaxUnion"] = from_str(self.min_max_union)
69+ result["intersection"] = from_str(self.intersection)
70+ result["minMaxIntersection"] = from_str(self.min_max_intersection)
7171 return result
Mschema-python/test/inputs/schema/non-standard-ref.schema/default/quicktype.py+4 −4
@@ -22,22 +22,22 @@ def to_class(c: Type[T], x: Any) -> dict:
2222
2323 @dataclass
2424 class TopLevel:
25- bar: int
2625 foo: int
26+ bar: int
2727 quux: bool
2828
2929 @staticmethod
3030 def from_dict(obj: Any) -> 'TopLevel':
3131 assert isinstance(obj, dict)
32- bar = from_int(obj.get("bar"))
3332 foo = from_int(obj.get("foo"))
33+ bar = from_int(obj.get("bar"))
3434 quux = from_bool(obj.get("quux"))
35- return TopLevel(bar, foo, quux)
35+ return TopLevel(foo, bar, quux)
3636
3737 def to_dict(self) -> dict:
3838 result: dict = {}
39- result["bar"] = from_int(self.bar)
4039 result["foo"] = from_int(self.foo)
40+ result["bar"] = from_int(self.bar)
4141 result["quux"] = from_bool(self.quux)
4242 return result
Mschema-python/test/inputs/schema/optional-const-ref.schema/default/quicktype.py+5 −5
@@ -75,8 +75,8 @@ class TopLevel:
7575 required_label: str
7676 coordinates: list[Coordinate] | None = None
7777 count: int | None = None
78- label: str | None = None
7978 weight: float | None = None
79+ label: str | None = None
8080
8181 @staticmethod
8282 def from_dict(obj: Any) -> 'TopLevel':
@@ -86,9 +86,9 @@ class TopLevel:
8686 required_label = from_str(obj.get("requiredLabel"))
8787 coordinates = from_union([lambda x: from_list(Coordinate.from_dict, x), from_none], obj.get("coordinates"))
8888 count = from_union([from_int, from_none], obj.get("count"))
89- label = from_union([from_str, from_none], obj.get("label"))
9089 weight = from_union([from_float, from_none], obj.get("weight"))
91- return TopLevel(required_coordinates, required_count, required_label, coordinates, count, label, weight)
90+ label = from_union([from_str, from_none], obj.get("label"))
91+ return TopLevel(required_coordinates, required_count, required_label, coordinates, count, weight, label)
9292
9393 def to_dict(self) -> dict:
9494 result: dict = {}
@@ -99,10 +99,10 @@ class TopLevel:
9999 result["coordinates"] = from_union([lambda x: from_list(lambda x: to_class(Coordinate, x), x), from_none], self.coordinates)
100100 if self.count is not None:
101101 result["count"] = from_union([from_int, from_none], self.count)
102- if self.label is not None:
103- result["label"] = from_union([from_str, from_none], self.label)
104102 if self.weight is not None:
105103 result["weight"] = from_union([to_float, from_none], self.weight)
104+ if self.label is not None:
105+ result["label"] = from_union([from_str, from_none], self.label)
106106 return result
Mschema-python/test/inputs/schema/optional-constraints.schema/default/quicktype.py+14 −14
@@ -10,11 +10,6 @@ def from_int(x: Any) -> int:
1010 return x
1111
1212
13-def from_float(x: Any) -> float:
14- assert isinstance(x, (float, int)) and not isinstance(x, bool)
15- return float(x)
16-
17-
1813 def from_none(x: Any) -> Any:
1914 assert x is None
2015 return x
@@ -29,6 +24,11 @@ def from_union(fs, x):
2924 assert False
3025
3126
27+def from_float(x: Any) -> float:
28+ assert isinstance(x, (float, int)) and not isinstance(x, bool)
29+ return float(x)
30+
31+
3232 def from_str(x: Any) -> str:
3333 assert isinstance(x, str)
3434 return x
@@ -47,32 +47,32 @@ def to_class(c: Type[T], x: Any) -> dict:
4747 @dataclass
4848 class TopLevel:
4949 req_zero_min: int
50- opt_double: float | None = None
5150 opt_int: int | None = None
52- opt_pattern: str | None = None
51+ opt_double: float | None = None
5352 opt_string: str | None = None
53+ opt_pattern: str | None = None
5454
5555 @staticmethod
5656 def from_dict(obj: Any) -> 'TopLevel':
5757 assert isinstance(obj, dict)
5858 req_zero_min = from_int(obj.get("reqZeroMin"))
59- opt_double = from_union([from_float, from_none], obj.get("optDouble"))
6059 opt_int = from_union([from_int, from_none], obj.get("optInt"))
61- opt_pattern = from_union([from_str, from_none], obj.get("optPattern"))
60+ opt_double = from_union([from_float, from_none], obj.get("optDouble"))
6261 opt_string = from_union([from_str, from_none], obj.get("optString"))
63- return TopLevel(req_zero_min, opt_double, opt_int, opt_pattern, opt_string)
62+ opt_pattern = from_union([from_str, from_none], obj.get("optPattern"))
63+ return TopLevel(req_zero_min, opt_int, opt_double, opt_string, opt_pattern)
6464
6565 def to_dict(self) -> dict:
6666 result: dict = {}
6767 result["reqZeroMin"] = from_int(self.req_zero_min)
68- if self.opt_double is not None:
69- result["optDouble"] = from_union([to_float, from_none], self.opt_double)
7068 if self.opt_int is not None:
7169 result["optInt"] = from_union([from_int, from_none], self.opt_int)
72- if self.opt_pattern is not None:
73- result["optPattern"] = from_union([from_str, from_none], self.opt_pattern)
70+ if self.opt_double is not None:
71+ result["optDouble"] = from_union([to_float, from_none], self.opt_double)
7472 if self.opt_string is not None:
7573 result["optString"] = from_union([from_str, from_none], self.opt_string)
74+ if self.opt_pattern is not None:
75+ result["optPattern"] = from_union([from_str, from_none], self.opt_pattern)
7676 return result
Mschema-python/test/inputs/schema/optional-date-time.schema/default/quicktype.py+12 −12
@@ -13,15 +13,15 @@ def from_date(x: Any) -> datetime.date:
1313 return dateutil.parser.parse(x).date()
1414
1515
16-def from_datetime(x: Any) -> datetime.datetime:
17- return dateutil.parser.parse(x)
18-
19-
2016 def from_time(x: Any) -> datetime.time:
2117 assert isinstance(x, str) and re.match(r"^\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$", x)
2218 return dateutil.parser.parse(x).time()
2319
2420
21+def from_datetime(x: Any) -> datetime.datetime:
22+ return dateutil.parser.parse(x)
23+
24+
2525 def from_none(x: Any) -> Any:
2626 assert x is None
2727 return x
@@ -44,34 +44,34 @@ def to_class(c: Type[T], x: Any) -> dict:
4444 @dataclass
4545 class TopLevel:
4646 required_date: datetime.date
47- required_date_time: datetime.datetime
4847 required_time: datetime.time
48+ required_date_time: datetime.datetime
4949 optional_date: datetime.date | None = None
50- optional_date_time: datetime.datetime | None = None
5150 optional_time: datetime.time | None = None
51+ optional_date_time: datetime.datetime | None = None
5252
5353 @staticmethod
5454 def from_dict(obj: Any) -> 'TopLevel':
5555 assert isinstance(obj, dict)
5656 required_date = from_date(obj.get("required-date"))
57- required_date_time = from_datetime(obj.get("required-date-time"))
5857 required_time = from_time(obj.get("required-time"))
58+ required_date_time = from_datetime(obj.get("required-date-time"))
5959 optional_date = from_union([from_date, from_none], obj.get("optional-date"))
60- optional_date_time = from_union([from_datetime, from_none], obj.get("optional-date-time"))
6160 optional_time = from_union([from_time, from_none], obj.get("optional-time"))
62- return TopLevel(required_date, required_date_time, required_time, optional_date, optional_date_time, optional_time)
61+ optional_date_time = from_union([from_datetime, from_none], obj.get("optional-date-time"))
62+ return TopLevel(required_date, required_time, required_date_time, optional_date, optional_time, optional_date_time)
6363
6464 def to_dict(self) -> dict:
6565 result: dict = {}
6666 result["required-date"] = self.required_date.isoformat()
67- result["required-date-time"] = self.required_date_time.isoformat()
6867 result["required-time"] = self.required_time.isoformat()
68+ result["required-date-time"] = self.required_date_time.isoformat()
6969 if self.optional_date is not None:
7070 result["optional-date"] = from_union([lambda x: x.isoformat(), from_none], self.optional_date)
71- if self.optional_date_time is not None:
72- result["optional-date-time"] = from_union([lambda x: x.isoformat(), from_none], self.optional_date_time)
7371 if self.optional_time is not None:
7472 result["optional-time"] = from_union([lambda x: x.isoformat(), from_none], self.optional_time)
73+ if self.optional_date_time is not None:
74+ result["optional-date-time"] = from_union([lambda x: x.isoformat(), from_none], self.optional_date_time)
7575 return result
Mschema-python/test/inputs/schema/prefix-items.schema/default/quicktype.py+4 −4
@@ -36,20 +36,20 @@ def to_class(c: Type[T], x: Any) -> dict:
3636
3737 @dataclass
3838 class TopLevel:
39- open: list[bool | int]
4039 tuple: list[bool | int]
40+ open: list[bool | int]
4141
4242 @staticmethod
4343 def from_dict(obj: Any) -> 'TopLevel':
4444 assert isinstance(obj, dict)
45- open = from_list(lambda x: from_union([from_bool, from_int], x), obj.get("open"))
4645 tuple = from_list(lambda x: from_union([from_bool, from_int], x), obj.get("tuple"))
47- return TopLevel(open, tuple)
46+ open = from_list(lambda x: from_union([from_bool, from_int], x), obj.get("open"))
47+ return TopLevel(tuple, open)
4848
4949 def to_dict(self) -> dict:
5050 result: dict = {}
51- result["open"] = from_list(lambda x: from_union([from_bool, from_int], x), self.open)
5251 result["tuple"] = from_list(lambda x: from_union([from_bool, from_int], x), self.tuple)
52+ result["open"] = from_list(lambda x: from_union([from_bool, from_int], x), self.open)
5353 return result
Aschema-python/test/inputs/schema/property-order.schema/default/quicktype.py+96 −0
@@ -0,0 +1,96 @@
1+from dataclasses import dataclass
2+from typing import Any, TypeVar, Type, cast
3+
4+
5+T = TypeVar("T")
6+
7+
8+def from_float(x: Any) -> float:
9+ assert isinstance(x, (float, int)) and not isinstance(x, bool)
10+ return float(x)
11+
12+
13+def from_str(x: Any) -> str:
14+ assert isinstance(x, str)
15+ return x
16+
17+
18+def from_bool(x: Any) -> bool:
19+ assert isinstance(x, bool)
20+ return x
21+
22+
23+def to_float(x: Any) -> float:
24+ assert isinstance(x, (int, float))
25+ return x
26+
27+
28+def from_int(x: Any) -> int:
29+ assert isinstance(x, int) and not isinstance(x, bool)
30+ return x
31+
32+
33+def to_class(c: Type[T], x: Any) -> dict:
34+ assert isinstance(x, c)
35+ return cast(Any, x).to_dict()
36+
37+
38+@dataclass
39+class Ordered:
40+ mango: float
41+ zebra: str
42+ apple: bool
43+
44+ @staticmethod
45+ def from_dict(obj: Any) -> 'Ordered':
46+ assert isinstance(obj, dict)
47+ mango = from_float(obj.get("mango"))
48+ zebra = from_str(obj.get("zebra"))
49+ apple = from_bool(obj.get("apple"))
50+ return Ordered(mango, zebra, apple)
51+
52+ def to_dict(self) -> dict:
53+ result: dict = {}
54+ result["mango"] = to_float(self.mango)
55+ result["zebra"] = from_str(self.zebra)
56+ result["apple"] = from_bool(self.apple)
57+ return result
58+
59+
60+@dataclass
61+class TopLevel:
62+ zebra: str
63+ mango: float
64+ apple: bool
65+ delta: str
66+ banana: int
67+ ordered: Ordered
68+
69+ @staticmethod
70+ def from_dict(obj: Any) -> 'TopLevel':
71+ assert isinstance(obj, dict)
72+ zebra = from_str(obj.get("zebra"))
73+ mango = from_float(obj.get("mango"))
74+ apple = from_bool(obj.get("apple"))
75+ delta = from_str(obj.get("delta"))
76+ banana = from_int(obj.get("banana"))
77+ ordered = Ordered.from_dict(obj.get("ordered"))
78+ return TopLevel(zebra, mango, apple, delta, banana, ordered)
79+
80+ def to_dict(self) -> dict:
81+ result: dict = {}
82+ result["zebra"] = from_str(self.zebra)
83+ result["mango"] = to_float(self.mango)
84+ result["apple"] = from_bool(self.apple)
85+ result["delta"] = from_str(self.delta)
86+ result["banana"] = from_int(self.banana)
87+ result["ordered"] = to_class(Ordered, self.ordered)
88+ return result
89+
90+
91+def top_level_from_dict(s: Any) -> TopLevel:
92+ return TopLevel.from_dict(s)
93+
94+
95+def top_level_to_dict(x: TopLevel) -> Any:
96+ return to_class(TopLevel, x)
Mschema-python/test/inputs/schema/renaming-bug.schema/default/quicktype.py+38 −38
@@ -92,26 +92,26 @@ class CircularShape:
9292
9393 @dataclass
9494 class Part:
95- depth: str | None = None
9695 length: str | None = None
9796 width: str | None = None
97+ depth: str | None = None
9898
9999 @staticmethod
100100 def from_dict(obj: Any) -> 'Part':
101101 assert isinstance(obj, dict)
102- depth = from_union([from_str, from_none], obj.get("depth"))
103102 length = from_union([from_str, from_none], obj.get("length"))
104103 width = from_union([from_str, from_none], obj.get("width"))
105- return Part(depth, length, width)
104+ depth = from_union([from_str, from_none], obj.get("depth"))
105+ return Part(length, width, depth)
106106
107107 def to_dict(self) -> dict:
108108 result: dict = {}
109- if self.depth is not None:
110- result["depth"] = from_union([from_str, from_none], self.depth)
111109 if self.length is not None:
112110 result["length"] = from_union([from_str, from_none], self.length)
113111 if self.width is not None:
114112 result["width"] = from_union([from_str, from_none], self.width)
113+ if self.depth is not None:
114+ result["depth"] = from_union([from_str, from_none], self.depth)
115115 return result
116116
117117
@@ -172,45 +172,45 @@ class History:
172172
173173 @dataclass
174174 class Shape:
175- geometry: Geometry | None = None
176175 history: History | None = None
176+ geometry: Geometry | None = None
177177
178178 @staticmethod
179179 def from_dict(obj: Any) -> 'Shape':
180180 assert isinstance(obj, dict)
181- geometry = from_union([Geometry.from_dict, from_none], obj.get("geometry"))
182181 history = from_union([History.from_dict, from_none], obj.get("history"))
183- return Shape(geometry, history)
182+ geometry = from_union([Geometry.from_dict, from_none], obj.get("geometry"))
183+ return Shape(history, geometry)
184184
185185 def to_dict(self) -> dict:
186186 result: dict = {}
187- if self.geometry is not None:
188- result["geometry"] = from_union([lambda x: to_class(Geometry, x), from_none], self.geometry)
189187 if self.history is not None:
190188 result["history"] = from_union([lambda x: to_class(History, x), from_none], self.history)
189+ if self.geometry is not None:
190+ result["geometry"] = from_union([lambda x: to_class(Geometry, x), from_none], self.geometry)
191191 return result
192192
193193
194194 @dataclass
195195 class Berry:
196- color: Color | None = None
197196 name: str | None = None
197+ color: Color | None = None
198198 shapes: list[Shape] | None = None
199199
200200 @staticmethod
201201 def from_dict(obj: Any) -> 'Berry':
202202 assert isinstance(obj, dict)
203- color = from_union([Color.from_dict, from_none], obj.get("color"))
204203 name = from_union([from_str, from_none], obj.get("name"))
204+ color = from_union([Color.from_dict, from_none], obj.get("color"))
205205 shapes = from_union([lambda x: from_list(Shape.from_dict, x), from_none], obj.get("shapes"))
206- return Berry(color, name, shapes)
206+ return Berry(name, color, shapes)
207207
208208 def to_dict(self) -> dict:
209209 result: dict = {}
210- if self.color is not None:
211- result["color"] = from_union([lambda x: to_class(Color, x), from_none], self.color)
212210 if self.name is not None:
213211 result["name"] = from_union([from_str, from_none], self.name)
212+ if self.color is not None:
213+ result["color"] = from_union([lambda x: to_class(Color, x), from_none], self.color)
214214 if self.shapes is not None:
215215 result["shapes"] = from_union([lambda x: from_list(lambda x: to_class(Shape, x), x), from_none], self.shapes)
216216 return result
@@ -219,46 +219,46 @@ class Berry:
219219 @dataclass
220220 class Fruit:
221221 apple: bool | None = None
222- berries: list[Berry] | None = None
223222 orange: bool | None = None
223+ berries: list[Berry] | None = None
224224
225225 @staticmethod
226226 def from_dict(obj: Any) -> 'Fruit':
227227 assert isinstance(obj, dict)
228228 apple = from_union([from_bool, from_none], obj.get("apple"))
229- berries = from_union([lambda x: from_list(Berry.from_dict, x), from_none], obj.get("berries"))
230229 orange = from_union([from_bool, from_none], obj.get("orange"))
231- return Fruit(apple, berries, orange)
230+ berries = from_union([lambda x: from_list(Berry.from_dict, x), from_none], obj.get("berries"))
231+ return Fruit(apple, orange, berries)
232232
233233 def to_dict(self) -> dict:
234234 result: dict = {}
235235 if self.apple is not None:
236236 result["apple"] = from_union([from_bool, from_none], self.apple)
237- if self.berries is not None:
238- result["berries"] = from_union([lambda x: from_list(lambda x: to_class(Berry, x), x), from_none], self.berries)
239237 if self.orange is not None:
240238 result["orange"] = from_union([from_bool, from_none], self.orange)
239+ if self.berries is not None:
240+ result["berries"] = from_union([lambda x: from_list(lambda x: to_class(Berry, x), x), from_none], self.berries)
241241 return result
242242
243243
244244 @dataclass
245245 class Limit:
246- maximum: float | None = None
247246 minimum: float | None = None
247+ maximum: float | None = None
248248
249249 @staticmethod
250250 def from_dict(obj: Any) -> 'Limit':
251251 assert isinstance(obj, dict)
252- maximum = from_union([from_float, from_none], obj.get("maximum"))
253252 minimum = from_union([from_float, from_none], obj.get("minimum"))
254- return Limit(maximum, minimum)
253+ maximum = from_union([from_float, from_none], obj.get("maximum"))
254+ return Limit(minimum, maximum)
255255
256256 def to_dict(self) -> dict:
257257 result: dict = {}
258- if self.maximum is not None:
259- result["maximum"] = from_union([to_float, from_none], self.maximum)
260258 if self.minimum is not None:
261259 result["minimum"] = from_union([to_float, from_none], self.minimum)
260+ if self.maximum is not None:
261+ result["maximum"] = from_union([to_float, from_none], self.maximum)
262262 return result
263263
264264
@@ -327,38 +327,38 @@ class VehicleType:
327327
328328 @dataclass
329329 class Vehicle:
330- brand: str | None = None
331330 id: str | None = None
332- speed: Speed | None = None
333- sub_module: bool | None = None
334331 type: VehicleType | None = None
332+ speed: Speed | None = None
335333 year: str | None = None
334+ brand: str | None = None
335+ sub_module: bool | None = None
336336
337337 @staticmethod
338338 def from_dict(obj: Any) -> 'Vehicle':
339339 assert isinstance(obj, dict)
340- brand = from_union([from_str, from_none], obj.get("brand"))
341340 id = from_union([from_str, from_none], obj.get("id"))
342- speed = from_union([Speed.from_dict, from_none], obj.get("speed"))
343- sub_module = from_union([from_bool, from_none], obj.get("subModule"))
344341 type = from_union([VehicleType.from_dict, from_none], obj.get("type"))
342+ speed = from_union([Speed.from_dict, from_none], obj.get("speed"))
345343 year = from_union([from_str, from_none], obj.get("year"))
346- return Vehicle(brand, id, speed, sub_module, type, year)
344+ brand = from_union([from_str, from_none], obj.get("brand"))
345+ sub_module = from_union([from_bool, from_none], obj.get("subModule"))
346+ return Vehicle(id, type, speed, year, brand, sub_module)
347347
348348 def to_dict(self) -> dict:
349349 result: dict = {}
350- if self.brand is not None:
351- result["brand"] = from_union([from_str, from_none], self.brand)
352350 if self.id is not None:
353351 result["id"] = from_union([from_str, from_none], self.id)
354- if self.speed is not None:
355- result["speed"] = from_union([lambda x: to_class(Speed, x), from_none], self.speed)
356- if self.sub_module is not None:
357- result["subModule"] = from_union([from_bool, from_none], self.sub_module)
358352 if self.type is not None:
359353 result["type"] = from_union([lambda x: to_class(VehicleType, x), from_none], self.type)
354+ if self.speed is not None:
355+ result["speed"] = from_union([lambda x: to_class(Speed, x), from_none], self.speed)
360356 if self.year is not None:
361357 result["year"] = from_union([from_str, from_none], self.year)
358+ if self.brand is not None:
359+ result["brand"] = from_union([from_str, from_none], self.brand)
360+ if self.sub_module is not None:
361+ result["subModule"] = from_union([from_bool, from_none], self.sub_module)
362362 return result
Mschema-python/test/inputs/schema/uuid.schema/default/quicktype.py+17 −17
@@ -17,16 +17,16 @@ def from_union(fs, x):
1717 assert False
1818
1919
20-def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
21- assert isinstance(x, list)
22- return [f(y) for y in x]
23-
24-
2520 def from_none(x: Any) -> Any:
2621 assert x is None
2722 return x
2823
2924
25+def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
26+ assert isinstance(x, list)
27+ return [f(y) for y in x]
28+
29+
3030 def to_enum(c: Type[EnumT], x: Any) -> EnumT:
3131 assert isinstance(x, c)
3232 return x.value
@@ -45,33 +45,33 @@ class UnionWithEnumEnum(Enum):
4545 class TopLevel:
4646 one: UUID
4747 union_with_enum: UnionWithEnumEnum | UUID
48- arr_nullable: list[UUID | None] | None = None
49- arr_one: list[UUID] | None = None
50- nullable: UUID | None = None
5148 optional: UUID | None = None
49+ nullable: UUID | None = None
50+ arr_one: list[UUID] | None = None
51+ arr_nullable: list[UUID | None] | None = None
5252
5353 @staticmethod
5454 def from_dict(obj: Any) -> 'TopLevel':
5555 assert isinstance(obj, dict)
5656 one = UUID(obj.get("one"))
5757 union_with_enum = from_union([UnionWithEnumEnum, lambda x: UUID(x)], obj.get("unionWithEnum"))
58- arr_nullable = from_union([lambda x: from_list(lambda x: from_union([from_none, lambda x: UUID(x)], x), x), from_none], obj.get("arrNullable"))
59- arr_one = from_union([lambda x: from_list(lambda x: UUID(x), x), from_none], obj.get("arrOne"))
60- nullable = from_union([from_none, lambda x: UUID(x)], obj.get("nullable"))
6158 optional = from_union([from_none, lambda x: UUID(x)], obj.get("optional"))
62- return TopLevel(one, union_with_enum, arr_nullable, arr_one, nullable, optional)
59+ nullable = from_union([from_none, lambda x: UUID(x)], obj.get("nullable"))
60+ arr_one = from_union([lambda x: from_list(lambda x: UUID(x), x), from_none], obj.get("arrOne"))
61+ arr_nullable = from_union([lambda x: from_list(lambda x: from_union([from_none, lambda x: UUID(x)], x), x), from_none], obj.get("arrNullable"))
62+ return TopLevel(one, union_with_enum, optional, nullable, arr_one, arr_nullable)
6363
6464 def to_dict(self) -> dict:
6565 result: dict = {}
6666 result["one"] = str(self.one)
6767 result["unionWithEnum"] = from_union([lambda x: to_enum(UnionWithEnumEnum, x), lambda x: str(x)], self.union_with_enum)
68- if self.arr_nullable is not None:
69- result["arrNullable"] = from_union([lambda x: from_list(lambda x: from_union([from_none, lambda x: str(x)], x), x), from_none], self.arr_nullable)
70- if self.arr_one is not None:
71- result["arrOne"] = from_union([lambda x: from_list(lambda x: str(x), x), from_none], self.arr_one)
72- result["nullable"] = from_union([from_none, lambda x: str(x)], self.nullable)
7368 if self.optional is not None:
7469 result["optional"] = from_union([from_none, lambda x: str(x)], self.optional)
70+ result["nullable"] = from_union([from_none, lambda x: str(x)], self.nullable)
71+ if self.arr_one is not None:
72+ result["arrOne"] = from_union([lambda x: from_list(lambda x: str(x), x), from_none], self.arr_one)
73+ if self.arr_nullable is not None:
74+ result["arrNullable"] = from_union([lambda x: from_list(lambda x: from_union([from_none, lambda x: str(x)], x), x), from_none], self.arr_nullable)
7575 return result
Mschema-python/test/inputs/schema/vega-lite.schema/default/quicktype.py+66 −66
@@ -310,6 +310,11 @@ class MarkConfig:
310310
311311 __Default value:__ (None)
312312 """
313+ fill_opacity: float | None = None
314+ """The fill opacity (value between [0,1]).
315+
316+ __Default value:__ `1`
317+ """
313318 filled: bool | None = None
314319 """Whether the mark's color should be used as fill color instead of stroke color.
315320
@@ -319,11 +324,6 @@ class MarkConfig:
319324
320325 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
321326 """
322- fill_opacity: float | None = None
323- """The fill opacity (value between [0,1]).
324-
325- __Default value:__ `1`
326- """
327327 font: str | None = None
328328 """The typeface to set the text in (e.g., `"Helvetica Neue"`)."""
329329
@@ -440,8 +440,8 @@ class MarkConfig:
440440 dx = from_union([from_float, from_none], obj.get("dx"))
441441 dy = from_union([from_float, from_none], obj.get("dy"))
442442 fill = from_union([from_str, from_none], obj.get("fill"))
443- filled = from_union([from_bool, from_none], obj.get("filled"))
444443 fill_opacity = from_union([from_float, from_none], obj.get("fillOpacity"))
444+ filled = from_union([from_bool, from_none], obj.get("filled"))
445445 font = from_union([from_str, from_none], obj.get("font"))
446446 font_size = from_union([from_float, from_none], obj.get("fontSize"))
447447 font_style = from_union([FontStyle, from_none], obj.get("fontStyle"))
@@ -462,7 +462,7 @@ class MarkConfig:
462462 tension = from_union([from_float, from_none], obj.get("tension"))
463463 text = from_union([from_str, from_none], obj.get("text"))
464464 theta = from_union([from_float, from_none], obj.get("theta"))
465- return MarkConfig(align, angle, baseline, color, cursor, dx, dy, fill, filled, fill_opacity, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, tension, text, theta)
465+ return MarkConfig(align, angle, baseline, color, cursor, dx, dy, fill, fill_opacity, filled, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, tension, text, theta)
466466
467467 def to_dict(self) -> dict:
468468 result: dict = {}
@@ -482,10 +482,10 @@ class MarkConfig:
482482 result["dy"] = from_union([to_float, from_none], self.dy)
483483 if self.fill is not None:
484484 result["fill"] = from_union([from_str, from_none], self.fill)
485- if self.filled is not None:
486- result["filled"] = from_union([from_bool, from_none], self.filled)
487485 if self.fill_opacity is not None:
488486 result["fillOpacity"] = from_union([to_float, from_none], self.fill_opacity)
487+ if self.filled is not None:
488+ result["filled"] = from_union([from_bool, from_none], self.filled)
489489 if self.font is not None:
490490 result["font"] = from_union([from_str, from_none], self.font)
491491 if self.font_size is not None:
@@ -659,15 +659,15 @@ class AxisConfig:
659659 tick_round: bool | None = None
660660 """Boolean flag indicating if pixel position values should be rounded to the nearest integer."""
661661
662- ticks: bool | None = None
663- """Boolean value that determines whether the axis should include ticks."""
664-
665662 tick_size: float | None = None
666663 """The size in pixels of axis ticks."""
667664
668665 tick_width: float | None = None
669666 """The width, in pixels, of ticks."""
670667
668+ ticks: bool | None = None
669+ """Boolean value that determines whether the axis should include ticks."""
670+
671671 title_align: str | None = None
672672 """Horizontal text alignment of axis titles."""
673673
@@ -732,9 +732,9 @@ class AxisConfig:
732732 short_time_labels = from_union([from_bool, from_none], obj.get("shortTimeLabels"))
733733 tick_color = from_union([from_str, from_none], obj.get("tickColor"))
734734 tick_round = from_union([from_bool, from_none], obj.get("tickRound"))
735- ticks = from_union([from_bool, from_none], obj.get("ticks"))
736735 tick_size = from_union([from_float, from_none], obj.get("tickSize"))
737736 tick_width = from_union([from_float, from_none], obj.get("tickWidth"))
737+ ticks = from_union([from_bool, from_none], obj.get("ticks"))
738738 title_align = from_union([from_str, from_none], obj.get("titleAlign"))
739739 title_angle = from_union([from_float, from_none], obj.get("titleAngle"))
740740 title_baseline = from_union([from_str, from_none], obj.get("titleBaseline"))
@@ -747,7 +747,7 @@ class AxisConfig:
747747 title_padding = from_union([from_float, from_none], obj.get("titlePadding"))
748748 title_x = from_union([from_float, from_none], obj.get("titleX"))
749749 title_y = from_union([from_float, from_none], obj.get("titleY"))
750- return AxisConfig(band_position, domain, domain_color, domain_width, grid, grid_color, grid_dash, grid_opacity, grid_width, label_angle, label_bound, label_color, label_flush, label_font, label_font_size, label_limit, label_overlap, label_padding, labels, max_extent, min_extent, short_time_labels, tick_color, tick_round, ticks, tick_size, tick_width, title_align, title_angle, title_baseline, title_color, title_font, title_font_size, title_font_weight, title_limit, title_max_length, title_padding, title_x, title_y)
750+ return AxisConfig(band_position, domain, domain_color, domain_width, grid, grid_color, grid_dash, grid_opacity, grid_width, label_angle, label_bound, label_color, label_flush, label_font, label_font_size, label_limit, label_overlap, label_padding, labels, max_extent, min_extent, short_time_labels, tick_color, tick_round, tick_size, tick_width, ticks, title_align, title_angle, title_baseline, title_color, title_font, title_font_size, title_font_weight, title_limit, title_max_length, title_padding, title_x, title_y)
751751
752752 def to_dict(self) -> dict:
753753 result: dict = {}
@@ -799,12 +799,12 @@ class AxisConfig:
799799 result["tickColor"] = from_union([from_str, from_none], self.tick_color)
800800 if self.tick_round is not None:
801801 result["tickRound"] = from_union([from_bool, from_none], self.tick_round)
802- if self.ticks is not None:
803- result["ticks"] = from_union([from_bool, from_none], self.ticks)
804802 if self.tick_size is not None:
805803 result["tickSize"] = from_union([to_float, from_none], self.tick_size)
806804 if self.tick_width is not None:
807805 result["tickWidth"] = from_union([to_float, from_none], self.tick_width)
806+ if self.ticks is not None:
807+ result["ticks"] = from_union([from_bool, from_none], self.ticks)
808808 if self.title_align is not None:
809809 result["titleAlign"] = from_union([from_str, from_none], self.title_align)
810810 if self.title_angle is not None:
@@ -962,15 +962,15 @@ class VGAxisConfig:
962962 tick_round: bool | None = None
963963 """Boolean flag indicating if pixel position values should be rounded to the nearest integer."""
964964
965- ticks: bool | None = None
966- """Boolean value that determines whether the axis should include ticks."""
967-
968965 tick_size: float | None = None
969966 """The size in pixels of axis ticks."""
970967
971968 tick_width: float | None = None
972969 """The width, in pixels, of ticks."""
973970
971+ ticks: bool | None = None
972+ """Boolean value that determines whether the axis should include ticks."""
973+
974974 title_align: str | None = None
975975 """Horizontal text alignment of axis titles."""
976976
@@ -1034,9 +1034,9 @@ class VGAxisConfig:
10341034 min_extent = from_union([from_float, from_none], obj.get("minExtent"))
10351035 tick_color = from_union([from_str, from_none], obj.get("tickColor"))
10361036 tick_round = from_union([from_bool, from_none], obj.get("tickRound"))
1037- ticks = from_union([from_bool, from_none], obj.get("ticks"))
10381037 tick_size = from_union([from_float, from_none], obj.get("tickSize"))
10391038 tick_width = from_union([from_float, from_none], obj.get("tickWidth"))
1039+ ticks = from_union([from_bool, from_none], obj.get("ticks"))
10401040 title_align = from_union([from_str, from_none], obj.get("titleAlign"))
10411041 title_angle = from_union([from_float, from_none], obj.get("titleAngle"))
10421042 title_baseline = from_union([from_str, from_none], obj.get("titleBaseline"))
@@ -1049,7 +1049,7 @@ class VGAxisConfig:
10491049 title_padding = from_union([from_float, from_none], obj.get("titlePadding"))
10501050 title_x = from_union([from_float, from_none], obj.get("titleX"))
10511051 title_y = from_union([from_float, from_none], obj.get("titleY"))
1052- return VGAxisConfig(band_position, domain, domain_color, domain_width, grid, grid_color, grid_dash, grid_opacity, grid_width, label_angle, label_bound, label_color, label_flush, label_font, label_font_size, label_limit, label_overlap, label_padding, labels, max_extent, min_extent, tick_color, tick_round, ticks, tick_size, tick_width, title_align, title_angle, title_baseline, title_color, title_font, title_font_size, title_font_weight, title_limit, title_max_length, title_padding, title_x, title_y)
1052+ return VGAxisConfig(band_position, domain, domain_color, domain_width, grid, grid_color, grid_dash, grid_opacity, grid_width, label_angle, label_bound, label_color, label_flush, label_font, label_font_size, label_limit, label_overlap, label_padding, labels, max_extent, min_extent, tick_color, tick_round, tick_size, tick_width, ticks, title_align, title_angle, title_baseline, title_color, title_font, title_font_size, title_font_weight, title_limit, title_max_length, title_padding, title_x, title_y)
10531053
10541054 def to_dict(self) -> dict:
10551055 result: dict = {}
@@ -1099,12 +1099,12 @@ class VGAxisConfig:
10991099 result["tickColor"] = from_union([from_str, from_none], self.tick_color)
11001100 if self.tick_round is not None:
11011101 result["tickRound"] = from_union([from_bool, from_none], self.tick_round)
1102- if self.ticks is not None:
1103- result["ticks"] = from_union([from_bool, from_none], self.ticks)
11041102 if self.tick_size is not None:
11051103 result["tickSize"] = from_union([to_float, from_none], self.tick_size)
11061104 if self.tick_width is not None:
11071105 result["tickWidth"] = from_union([to_float, from_none], self.tick_width)
1106+ if self.ticks is not None:
1107+ result["ticks"] = from_union([from_bool, from_none], self.ticks)
11081108 if self.title_align is not None:
11091109 result["titleAlign"] = from_union([from_str, from_none], self.title_align)
11101110 if self.title_angle is not None:
@@ -1187,6 +1187,11 @@ class BarConfig:
11871187
11881188 __Default value:__ (None)
11891189 """
1190+ fill_opacity: float | None = None
1191+ """The fill opacity (value between [0,1]).
1192+
1193+ __Default value:__ `1`
1194+ """
11901195 filled: bool | None = None
11911196 """Whether the mark's color should be used as fill color instead of stroke color.
11921197
@@ -1196,11 +1201,6 @@ class BarConfig:
11961201
11971202 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
11981203 """
1199- fill_opacity: float | None = None
1200- """The fill opacity (value between [0,1]).
1201-
1202- __Default value:__ `1`
1203- """
12041204 font: str | None = None
12051205 """The typeface to set the text in (e.g., `"Helvetica Neue"`)."""
12061206
@@ -1320,8 +1320,8 @@ class BarConfig:
13201320 dx = from_union([from_float, from_none], obj.get("dx"))
13211321 dy = from_union([from_float, from_none], obj.get("dy"))
13221322 fill = from_union([from_str, from_none], obj.get("fill"))
1323- filled = from_union([from_bool, from_none], obj.get("filled"))
13241323 fill_opacity = from_union([from_float, from_none], obj.get("fillOpacity"))
1324+ filled = from_union([from_bool, from_none], obj.get("filled"))
13251325 font = from_union([from_str, from_none], obj.get("font"))
13261326 font_size = from_union([from_float, from_none], obj.get("fontSize"))
13271327 font_style = from_union([FontStyle, from_none], obj.get("fontStyle"))
@@ -1342,7 +1342,7 @@ class BarConfig:
13421342 tension = from_union([from_float, from_none], obj.get("tension"))
13431343 text = from_union([from_str, from_none], obj.get("text"))
13441344 theta = from_union([from_float, from_none], obj.get("theta"))
1345- return BarConfig(align, angle, baseline, bin_spacing, color, continuous_band_size, cursor, discrete_band_size, dx, dy, fill, filled, fill_opacity, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, tension, text, theta)
1345+ return BarConfig(align, angle, baseline, bin_spacing, color, continuous_band_size, cursor, discrete_band_size, dx, dy, fill, fill_opacity, filled, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, tension, text, theta)
13461346
13471347 def to_dict(self) -> dict:
13481348 result: dict = {}
@@ -1368,10 +1368,10 @@ class BarConfig:
13681368 result["dy"] = from_union([to_float, from_none], self.dy)
13691369 if self.fill is not None:
13701370 result["fill"] = from_union([from_str, from_none], self.fill)
1371- if self.filled is not None:
1372- result["filled"] = from_union([from_bool, from_none], self.filled)
13731371 if self.fill_opacity is not None:
13741372 result["fillOpacity"] = from_union([to_float, from_none], self.fill_opacity)
1373+ if self.filled is not None:
1374+ result["filled"] = from_union([from_bool, from_none], self.filled)
13751375 if self.font is not None:
13761376 result["font"] = from_union([from_str, from_none], self.font)
13771377 if self.font_size is not None:
@@ -2801,6 +2801,11 @@ class TextConfig:
28012801
28022802 __Default value:__ (None)
28032803 """
2804+ fill_opacity: float | None = None
2805+ """The fill opacity (value between [0,1]).
2806+
2807+ __Default value:__ `1`
2808+ """
28042809 filled: bool | None = None
28052810 """Whether the mark's color should be used as fill color instead of stroke color.
28062811
@@ -2810,11 +2815,6 @@ class TextConfig:
28102815
28112816 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
28122817 """
2813- fill_opacity: float | None = None
2814- """The fill opacity (value between [0,1]).
2815-
2816- __Default value:__ `1`
2817- """
28182818 font: str | None = None
28192819 """The typeface to set the text in (e.g., `"Helvetica Neue"`)."""
28202820
@@ -2934,8 +2934,8 @@ class TextConfig:
29342934 dx = from_union([from_float, from_none], obj.get("dx"))
29352935 dy = from_union([from_float, from_none], obj.get("dy"))
29362936 fill = from_union([from_str, from_none], obj.get("fill"))
2937- filled = from_union([from_bool, from_none], obj.get("filled"))
29382937 fill_opacity = from_union([from_float, from_none], obj.get("fillOpacity"))
2938+ filled = from_union([from_bool, from_none], obj.get("filled"))
29392939 font = from_union([from_str, from_none], obj.get("font"))
29402940 font_size = from_union([from_float, from_none], obj.get("fontSize"))
29412941 font_style = from_union([FontStyle, from_none], obj.get("fontStyle"))
@@ -2957,7 +2957,7 @@ class TextConfig:
29572957 tension = from_union([from_float, from_none], obj.get("tension"))
29582958 text = from_union([from_str, from_none], obj.get("text"))
29592959 theta = from_union([from_float, from_none], obj.get("theta"))
2960- return TextConfig(align, angle, baseline, color, cursor, dx, dy, fill, filled, fill_opacity, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, short_time_labels, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, tension, text, theta)
2960+ return TextConfig(align, angle, baseline, color, cursor, dx, dy, fill, fill_opacity, filled, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, short_time_labels, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, tension, text, theta)
29612961
29622962 def to_dict(self) -> dict:
29632963 result: dict = {}
@@ -2977,10 +2977,10 @@ class TextConfig:
29772977 result["dy"] = from_union([to_float, from_none], self.dy)
29782978 if self.fill is not None:
29792979 result["fill"] = from_union([from_str, from_none], self.fill)
2980- if self.filled is not None:
2981- result["filled"] = from_union([from_bool, from_none], self.filled)
29822980 if self.fill_opacity is not None:
29832981 result["fillOpacity"] = from_union([to_float, from_none], self.fill_opacity)
2982+ if self.filled is not None:
2983+ result["filled"] = from_union([from_bool, from_none], self.filled)
29842984 if self.font is not None:
29852985 result["font"] = from_union([from_str, from_none], self.font)
29862986 if self.font_size is not None:
@@ -3071,6 +3071,11 @@ class TickConfig:
30713071
30723072 __Default value:__ (None)
30733073 """
3074+ fill_opacity: float | None = None
3075+ """The fill opacity (value between [0,1]).
3076+
3077+ __Default value:__ `1`
3078+ """
30743079 filled: bool | None = None
30753080 """Whether the mark's color should be used as fill color instead of stroke color.
30763081
@@ -3080,11 +3085,6 @@ class TickConfig:
30803085
30813086 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
30823087 """
3083- fill_opacity: float | None = None
3084- """The fill opacity (value between [0,1]).
3085-
3086- __Default value:__ `1`
3087- """
30883088 font: str | None = None
30893089 """The typeface to set the text in (e.g., `"Helvetica Neue"`)."""
30903090
@@ -3207,8 +3207,8 @@ class TickConfig:
32073207 dx = from_union([from_float, from_none], obj.get("dx"))
32083208 dy = from_union([from_float, from_none], obj.get("dy"))
32093209 fill = from_union([from_str, from_none], obj.get("fill"))
3210- filled = from_union([from_bool, from_none], obj.get("filled"))
32113210 fill_opacity = from_union([from_float, from_none], obj.get("fillOpacity"))
3211+ filled = from_union([from_bool, from_none], obj.get("filled"))
32123212 font = from_union([from_str, from_none], obj.get("font"))
32133213 font_size = from_union([from_float, from_none], obj.get("fontSize"))
32143214 font_style = from_union([FontStyle, from_none], obj.get("fontStyle"))
@@ -3230,7 +3230,7 @@ class TickConfig:
32303230 text = from_union([from_str, from_none], obj.get("text"))
32313231 theta = from_union([from_float, from_none], obj.get("theta"))
32323232 thickness = from_union([from_float, from_none], obj.get("thickness"))
3233- return TickConfig(align, angle, band_size, baseline, color, cursor, dx, dy, fill, filled, fill_opacity, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, tension, text, theta, thickness)
3233+ return TickConfig(align, angle, band_size, baseline, color, cursor, dx, dy, fill, fill_opacity, filled, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, tension, text, theta, thickness)
32343234
32353235 def to_dict(self) -> dict:
32363236 result: dict = {}
@@ -3252,10 +3252,10 @@ class TickConfig:
32523252 result["dy"] = from_union([to_float, from_none], self.dy)
32533253 if self.fill is not None:
32543254 result["fill"] = from_union([from_str, from_none], self.fill)
3255- if self.filled is not None:
3256- result["filled"] = from_union([from_bool, from_none], self.filled)
32573255 if self.fill_opacity is not None:
32583256 result["fillOpacity"] = from_union([to_float, from_none], self.fill_opacity)
3257+ if self.filled is not None:
3258+ result["filled"] = from_union([from_bool, from_none], self.filled)
32593259 if self.font is not None:
32603260 result["font"] = from_union([from_str, from_none], self.font)
32613261 if self.font_size is not None:
@@ -5949,12 +5949,12 @@ class Axis:
59495949 may be different so that values are "nice" (multiples of 2, 5, 10) and lie within the
59505950 underlying scale's range.
59515951 """
5952- ticks: bool | None = None
5953- """Boolean value that determines whether the axis should include ticks."""
5954-
59555952 tick_size: float | None = None
59565953 """The size in pixels of axis ticks."""
59575954
5955+ ticks: bool | None = None
5956+ """Boolean value that determines whether the axis should include ticks."""
5957+
59585958 title: str | None = None
59595959 """A title for the field. If `null`, the title will be removed.
59605960
@@ -6006,14 +6006,14 @@ class Axis:
60066006 orient = from_union([TitleOrient, from_none], obj.get("orient"))
60076007 position = from_union([from_float, from_none], obj.get("position"))
60086008 tick_count = from_union([from_float, from_none], obj.get("tickCount"))
6009- ticks = from_union([from_bool, from_none], obj.get("ticks"))
60106009 tick_size = from_union([from_float, from_none], obj.get("tickSize"))
6010+ ticks = from_union([from_bool, from_none], obj.get("ticks"))
60116011 title = from_union([from_none, from_str], obj.get("title"))
60126012 title_max_length = from_union([from_float, from_none], obj.get("titleMaxLength"))
60136013 title_padding = from_union([from_float, from_none], obj.get("titlePadding"))
60146014 values = from_union([lambda x: from_list(lambda x: from_union([from_float, DateTime.from_dict], x), x), from_none], obj.get("values"))
60156015 zindex = from_union([from_float, from_none], obj.get("zindex"))
6016- return Axis(domain, format, grid, label_angle, label_bound, label_flush, label_overlap, label_padding, labels, max_extent, min_extent, offset, orient, position, tick_count, ticks, tick_size, title, title_max_length, title_padding, values, zindex)
6016+ return Axis(domain, format, grid, label_angle, label_bound, label_flush, label_overlap, label_padding, labels, max_extent, min_extent, offset, orient, position, tick_count, tick_size, ticks, title, title_max_length, title_padding, values, zindex)
60176017
60186018 def to_dict(self) -> dict:
60196019 result: dict = {}
@@ -6047,10 +6047,10 @@ class Axis:
60476047 result["position"] = from_union([to_float, from_none], self.position)
60486048 if self.tick_count is not None:
60496049 result["tickCount"] = from_union([to_float, from_none], self.tick_count)
6050- if self.ticks is not None:
6051- result["ticks"] = from_union([from_bool, from_none], self.ticks)
60526050 if self.tick_size is not None:
60536051 result["tickSize"] = from_union([to_float, from_none], self.tick_size)
6052+ if self.ticks is not None:
6053+ result["ticks"] = from_union([from_bool, from_none], self.ticks)
60546054 if self.title is not None:
60556055 result["title"] = from_union([from_none, from_str], self.title)
60566056 if self.title_max_length is not None:
@@ -6618,6 +6618,11 @@ class MarkDef:
66186618
66196619 __Default value:__ (None)
66206620 """
6621+ fill_opacity: float | None = None
6622+ """The fill opacity (value between [0,1]).
6623+
6624+ __Default value:__ `1`
6625+ """
66216626 filled: bool | None = None
66226627 """Whether the mark's color should be used as fill color instead of stroke color.
66236628
@@ -6627,11 +6632,6 @@ class MarkDef:
66276632
66286633 __Note:__ This property cannot be used in a [style config](mark.html#style-config).
66296634 """
6630- fill_opacity: float | None = None
6631- """The fill opacity (value between [0,1]).
6632-
6633- __Default value:__ `1`
6634- """
66356635 font: str | None = None
66366636 """The typeface to set the text in (e.g., `"Helvetica Neue"`)."""
66376637
@@ -6763,8 +6763,8 @@ class MarkDef:
67636763 dx = from_union([from_float, from_none], obj.get("dx"))
67646764 dy = from_union([from_float, from_none], obj.get("dy"))
67656765 fill = from_union([from_str, from_none], obj.get("fill"))
6766- filled = from_union([from_bool, from_none], obj.get("filled"))
67676766 fill_opacity = from_union([from_float, from_none], obj.get("fillOpacity"))
6767+ filled = from_union([from_bool, from_none], obj.get("filled"))
67686768 font = from_union([from_str, from_none], obj.get("font"))
67696769 font_size = from_union([from_float, from_none], obj.get("fontSize"))
67706770 font_style = from_union([FontStyle, from_none], obj.get("fontStyle"))
@@ -6786,7 +6786,7 @@ class MarkDef:
67866786 tension = from_union([from_float, from_none], obj.get("tension"))
67876787 text = from_union([from_str, from_none], obj.get("text"))
67886788 theta = from_union([from_float, from_none], obj.get("theta"))
6789- return MarkDef(type, align, angle, baseline, clip, color, cursor, dx, dy, fill, filled, fill_opacity, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, style, tension, text, theta)
6789+ return MarkDef(type, align, angle, baseline, clip, color, cursor, dx, dy, fill, fill_opacity, filled, font, font_size, font_style, font_weight, href, interpolate, limit, opacity, orient, radius, shape, size, stroke, stroke_dash, stroke_dash_offset, stroke_opacity, stroke_width, style, tension, text, theta)
67906790
67916791 def to_dict(self) -> dict:
67926792 result: dict = {}
@@ -6809,10 +6809,10 @@ class MarkDef:
68096809 result["dy"] = from_union([to_float, from_none], self.dy)
68106810 if self.fill is not None:
68116811 result["fill"] = from_union([from_str, from_none], self.fill)
6812- if self.filled is not None:
6813- result["filled"] = from_union([from_bool, from_none], self.filled)
68146812 if self.fill_opacity is not None:
68156813 result["fillOpacity"] = from_union([to_float, from_none], self.fill_opacity)
6814+ if self.filled is not None:
6815+ result["filled"] = from_union([from_bool, from_none], self.filled)
68166816 if self.font is not None:
68176817 result["font"] = from_union([from_str, from_none], self.font)
68186818 if self.font_size is not None:
Mschema-ruby/test/inputs/schema/accessors.schema/default/TopLevel.rb+7 −7
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.barre
7+# puts top_level.unionization
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -60,18 +60,18 @@ class Union < Dry::Struct
6060 end
6161
6262 class TopLevel < Dry::Struct
63- attribute :barre, Types::String
63+ attribute :unionization, Types.Instance(Union)
6464 attribute :enumerification, Types::Enum
6565 attribute :foo, Types::String
66- attribute :unionization, Types.Instance(Union)
66+ attribute :barre, Types::String
6767
6868 def self.from_dynamic!(d)
6969 d = Types::Hash[d]
7070 new(
71- barre: d.fetch("bar"),
71+ unionization: Union.from_dynamic!(d.fetch("union")),
7272 enumerification: d.fetch("enum"),
7373 foo: d.fetch("foo"),
74- unionization: Union.from_dynamic!(d.fetch("union")),
74+ barre: d.fetch("bar"),
7575 )
7676 end
7777
@@ -81,10 +81,10 @@ class TopLevel < Dry::Struct
8181
8282 def to_dynamic
8383 {
84- "bar" => barre,
84+ "union" => unionization.to_dynamic,
8585 "enum" => enumerification,
8686 "foo" => foo,
87- "union" => unionization.to_dynamic,
87+ "bar" => barre,
8888 }
8989 end
Mschema-ruby/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.rb+3 −3
@@ -36,16 +36,16 @@ end
3636 class TopLevel < Dry::Struct
3737 attribute :amount, Types::Double
3838 attribute :frequency, Types::Frequency
39- attribute :description, Types::String.optional
4039 attribute :top_level_type, Types::Type
40+ attribute :description, Types::String.optional
4141
4242 def self.from_dynamic!(d)
4343 d = Types::Hash[d]
4444 new(
4545 amount: d.fetch("amount"),
4646 frequency: d.fetch("frequency"),
47- description: d["description"],
4847 top_level_type: d.fetch("type"),
48+ description: d["description"],
4949 )
5050 end
5151
@@ -57,8 +57,8 @@ class TopLevel < Dry::Struct
5757 {
5858 "amount" => amount,
5959 "frequency" => frequency,
60- "description" => description,
6160 "type" => top_level_type,
61+ "description" => description,
6262 }
6363 end
Mschema-ruby/test/inputs/schema/bool-string.schema/default/TopLevel.rb+10 −10
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.arr_one&.first
7+# puts top_level.arr_nullable&.first.nil?
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -53,22 +53,22 @@ class UnionWithBool < Dry::Struct
5353 end
5454
5555 class TopLevel < Dry::Struct
56- attribute :arr_nullable, Types.Array(Types::String.optional).optional
57- attribute :arr_one, Types.Array(Types::String).optional
58- attribute :nullable, Types::String.optional
5956 attribute :one, Types::String
6057 attribute :top_level_optional, Types::String.optional
58+ attribute :nullable, Types::String.optional
59+ attribute :arr_one, Types.Array(Types::String).optional
60+ attribute :arr_nullable, Types.Array(Types::String.optional).optional
6161 attribute :union_with_bool, Types.Instance(UnionWithBool)
6262 attribute :union_with_bool_and_enum, Types.Instance(UnionWithBool)
6363
6464 def self.from_dynamic!(d)
6565 d = Types::Hash[d]
6666 new(
67- arr_nullable: d["arrNullable"],
68- arr_one: d["arrOne"],
69- nullable: d.fetch("nullable"),
7067 one: d.fetch("one"),
7168 top_level_optional: d["optional"],
69+ nullable: d.fetch("nullable"),
70+ arr_one: d["arrOne"],
71+ arr_nullable: d["arrNullable"],
7272 union_with_bool: UnionWithBool.from_dynamic!(d.fetch("unionWithBool")),
7373 union_with_bool_and_enum: UnionWithBool.from_dynamic!(d.fetch("unionWithBoolAndEnum")),
7474 )
@@ -80,11 +80,11 @@ class TopLevel < Dry::Struct
8080
8181 def to_dynamic
8282 {
83- "arrNullable" => arr_nullable,
84- "arrOne" => arr_one,
85- "nullable" => nullable,
8683 "one" => one,
8784 "optional" => top_level_optional,
85+ "nullable" => nullable,
86+ "arrOne" => arr_one,
87+ "arrNullable" => arr_nullable,
8888 "unionWithBool" => union_with_bool.to_dynamic,
8989 "unionWithBoolAndEnum" => union_with_bool_and_enum.to_dynamic,
9090 }
Mschema-ruby/test/inputs/schema/boolean-subschema.schema/default/TopLevel.rb+3 −3
@@ -20,17 +20,17 @@ module Types
2020 end
2121
2222 class TopLevel < Dry::Struct
23+ attribute :foo, Types::String
2324 attribute :disallowed, Types::Any.optional
2425 attribute :empty, Types.Array(Types::Any)
25- attribute :foo, Types::String
2626 attribute :impossible, Types::Any.optional
2727
2828 def self.from_dynamic!(d)
2929 d = Types::Hash[d]
3030 new(
31+ foo: d.fetch("foo"),
3132 disallowed: d["disallowed"],
3233 empty: d.fetch("empty"),
33- foo: d.fetch("foo"),
3434 impossible: d["impossible"],
3535 )
3636 end
@@ -41,9 +41,9 @@ class TopLevel < Dry::Struct
4141
4242 def to_dynamic
4343 {
44+ "foo" => foo,
4445 "disallowed" => disallowed,
4546 "empty" => empty,
46- "foo" => foo,
4747 "impossible" => impossible,
4848 }
4949 end
Mschema-ruby/test/inputs/schema/comment-injection.schema/default/TopLevel.rb+12 −12
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.trailing_backslash
7+# puts top_level.value
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -33,15 +33,6 @@ end
3333 # }
3434 class TopLevel < Dry::Struct
3535
36- # Ends with a backslash \
37- attribute :trailing_backslash, Types::String.optional
38-
39- # Ends with a quote "
40- attribute :trailing_quote, Types::String.optional
41-
42- # Ends with a triple quote """
43- attribute :trailing_triple_quote, Types::String.optional
44-
4536 # Property delimiters:
4637 # */
4738 # /*
@@ -56,13 +47,22 @@ class TopLevel < Dry::Struct
5647 # }
5748 attribute :value, Types::String
5849
50+ # Ends with a backslash \
51+ attribute :trailing_backslash, Types::String.optional
52+
53+ # Ends with a quote "
54+ attribute :trailing_quote, Types::String.optional
55+
56+ # Ends with a triple quote """
57+ attribute :trailing_triple_quote, Types::String.optional
58+
5959 def self.from_dynamic!(d)
6060 d = Types::Hash[d]
6161 new(
62+ value: d.fetch("value"),
6263 trailing_backslash: d["trailingBackslash"],
6364 trailing_quote: d["trailingQuote"],
6465 trailing_triple_quote: d["trailingTripleQuote"],
65- value: d.fetch("value"),
6666 )
6767 end
6868
@@ -72,10 +72,10 @@ class TopLevel < Dry::Struct
7272
7373 def to_dynamic
7474 {
75+ "value" => value,
7576 "trailingBackslash" => trailing_backslash,
7677 "trailingQuote" => trailing_quote,
7778 "trailingTripleQuote" => trailing_triple_quote,
78- "value" => value,
7979 }
8080 end
Mschema-ruby/test/inputs/schema/const-non-string.schema/default/TopLevel.rb+7 −7
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.amount.even?
7+# puts top_level.version
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -28,20 +28,20 @@ module Kind
2828 end
2929
3030 class TopLevel < Dry::Struct
31+ attribute :version, Types::Double
3132 attribute :amount, Types::Integer
33+ attribute :ratio, Types::Double
3234 attribute :enabled, Types::Bool
3335 attribute :kind, Types::Kind
34- attribute :ratio, Types::Double
35- attribute :version, Types::Double
3636
3737 def self.from_dynamic!(d)
3838 d = Types::Hash[d]
3939 new(
40+ version: d.fetch("version"),
4041 amount: d.fetch("amount"),
42+ ratio: d.fetch("ratio"),
4143 enabled: d.fetch("enabled"),
4244 kind: d.fetch("kind"),
43- ratio: d.fetch("ratio"),
44- version: d.fetch("version"),
4545 )
4646 end
4747
@@ -51,11 +51,11 @@ class TopLevel < Dry::Struct
5151
5252 def to_dynamic
5353 {
54+ "version" => version,
5455 "amount" => amount,
56+ "ratio" => ratio,
5557 "enabled" => enabled,
5658 "kind" => kind,
57- "ratio" => ratio,
58- "version" => version,
5959 }
6060 end
Mschema-ruby/test/inputs/schema/date-time-or-string.schema/default/TopLevel.rb+4 −4
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.bar
7+# puts top_level.foo
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -20,14 +20,14 @@ module Types
2020 end
2121
2222 class TopLevel < Dry::Struct
23- attribute :bar, Types::String
2423 attribute :foo, Types::String
24+ attribute :bar, Types::String
2525
2626 def self.from_dynamic!(d)
2727 d = Types::Hash[d]
2828 new(
29- bar: d.fetch("bar"),
3029 foo: d.fetch("foo"),
30+ bar: d.fetch("bar"),
3131 )
3232 end
3333
@@ -37,8 +37,8 @@ class TopLevel < Dry::Struct
3737
3838 def to_dynamic
3939 {
40- "bar" => bar,
4140 "foo" => foo,
41+ "bar" => bar,
4242 }
4343 end
Mschema-ruby/test/inputs/schema/date-time.schema/default/TopLevel.rb+7 −7
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.union_array.first
7+# puts top_level.complex_union_array.first
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -52,20 +52,20 @@ class ComplexUnionArray < Dry::Struct
5252 end
5353
5454 class TopLevel < Dry::Struct
55- attribute :complex_union_array, Types.Array(Types.Instance(ComplexUnionArray))
5655 attribute :date, Types::String
57- attribute :date_time, Types::String
5856 attribute :time, Types::String
57+ attribute :date_time, Types::String
5958 attribute :union_array, Types.Array(Types::String)
59+ attribute :complex_union_array, Types.Array(Types.Instance(ComplexUnionArray))
6060
6161 def self.from_dynamic!(d)
6262 d = Types::Hash[d]
6363 new(
64- complex_union_array: d.fetch("complex-union-array").map { |x| ComplexUnionArray.from_dynamic!(x) },
6564 date: d.fetch("date"),
66- date_time: d.fetch("date-time"),
6765 time: d.fetch("time"),
66+ date_time: d.fetch("date-time"),
6867 union_array: d.fetch("union-array"),
68+ complex_union_array: d.fetch("complex-union-array").map { |x| ComplexUnionArray.from_dynamic!(x) },
6969 )
7070 end
7171
@@ -75,11 +75,11 @@ class TopLevel < Dry::Struct
7575
7676 def to_dynamic
7777 {
78- "complex-union-array" => complex_union_array.map { |x| x.to_dynamic },
7978 "date" => date,
80- "date-time" => date_time,
8179 "time" => time,
80+ "date-time" => date_time,
8281 "union-array" => union_array,
82+ "complex-union-array" => complex_union_array.map { |x| x.to_dynamic },
8383 }
8484 end
Mschema-ruby/test/inputs/schema/description.schema/default/TopLevel.rb+12 −11
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.bar
7+# puts top_level.union
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -126,26 +126,27 @@ end
126126 # Its description has two lines.
127127 class TopLevel < Dry::Struct
128128
129- # A pretty boolean
130- attribute :bar, Types::Bool.optional
129+ # Either a number or a string
130+ attribute :union, Types.Instance(Union)
131131
132132 # An enumeration
133133 attribute :top_level_enum, Types::Enum
134134
135- attribute :foo, Types::Double.optional
136- attribute :object_or_string, Types.Instance(ObjectOrStringUnion)
135+ attribute :foo, Types::Double.optional
137136
138- # Either a number or a string
139- attribute :union, Types.Instance(Union)
137+ # A pretty boolean
138+ attribute :bar, Types::Bool.optional
139+
140+ attribute :object_or_string, Types.Instance(ObjectOrStringUnion)
140141
141142 def self.from_dynamic!(d)
142143 d = Types::Hash[d]
143144 new(
144- bar: d["bar"],
145+ union: Union.from_dynamic!(d.fetch("union")),
145146 top_level_enum: d.fetch("enum"),
146147 foo: d["foo"],
148+ bar: d["bar"],
147149 object_or_string: ObjectOrStringUnion.from_dynamic!(d.fetch("object-or-string")),
148- union: Union.from_dynamic!(d.fetch("union")),
149150 )
150151 end
151152
@@ -155,11 +156,11 @@ class TopLevel < Dry::Struct
155156
156157 def to_dynamic
157158 {
158- "bar" => bar,
159+ "union" => union.to_dynamic,
159160 "enum" => top_level_enum,
160161 "foo" => foo,
162+ "bar" => bar,
161163 "object-or-string" => object_or_string.to_dynamic,
162- "union" => union.to_dynamic,
163164 }
164165 end
Mschema-ruby/test/inputs/schema/direct-union.schema/default/TopLevel.rb+4 −4
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.stuff["…"].thing_optional
7+# puts top_level.stuff["…"].required
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -89,14 +89,14 @@ class Anything < Dry::Struct
8989 end
9090
9191 class Thing < Dry::Struct
92- attribute :thing_optional, Types.Instance(Anything).optional
9392 attribute :required, Types.Instance(Anything)
93+ attribute :thing_optional, Types.Instance(Anything).optional
9494
9595 def self.from_dynamic!(d)
9696 d = Types::Hash[d]
9797 new(
98- thing_optional: d["optional"] ? Anything.from_dynamic!(d["optional"]) : nil,
9998 required: Anything.from_dynamic!(d.fetch("required")),
99+ thing_optional: d["optional"] ? Anything.from_dynamic!(d["optional"]) : nil,
100100 )
101101 end
102102
@@ -106,8 +106,8 @@ class Thing < Dry::Struct
106106
107107 def to_dynamic
108108 {
109- "optional" => thing_optional&.to_dynamic,
110109 "required" => required.to_dynamic,
110+ "optional" => thing_optional&.to_dynamic,
111111 }
112112 end
Mschema-ruby/test/inputs/schema/enum.schema/default/TopLevel.rb+9 −9
@@ -73,20 +73,20 @@ module Lvc
7373 end
7474
7575 class TopLevel < Dry::Struct
76- attribute :arr, Types.Array(Types.Instance(Arr)).optional
77- attribute :top_level_for, Types::String.optional
78- attribute :gve, Types::Gve
7976 attribute :lvc, Types::Lvc.optional
77+ attribute :gve, Types::Gve
78+ attribute :arr, Types.Array(Types.Instance(Arr)).optional
8079 attribute :other_arr, Types.Array(Types::OtherArr).optional
80+ attribute :top_level_for, Types::String.optional
8181
8282 def self.from_dynamic!(d)
8383 d = Types::Hash[d]
8484 new(
85- arr: d["arr"]&.map { |x| Arr.from_dynamic!(x) },
86- top_level_for: d["for"],
87- gve: d.fetch("gve"),
8885 lvc: d["lvc"],
86+ gve: d.fetch("gve"),
87+ arr: d["arr"]&.map { |x| Arr.from_dynamic!(x) },
8988 other_arr: d["otherArr"],
89+ top_level_for: d["for"],
9090 )
9191 end
9292
@@ -96,11 +96,11 @@ class TopLevel < Dry::Struct
9696
9797 def to_dynamic
9898 {
99- "arr" => arr&.map { |x| x.to_dynamic },
100- "for" => top_level_for,
101- "gve" => gve,
10299 "lvc" => lvc,
100+ "gve" => gve,
101+ "arr" => arr&.map { |x| x.to_dynamic },
103102 "otherArr" => other_arr,
103+ "for" => top_level_for,
104104 }
105105 end
Mschema-ruby/test/inputs/schema/integer-string.schema/default/TopLevel.rb+10 −10
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.arr_one&.first
7+# puts top_level.arr_nullable&.first.nil?
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -53,22 +53,22 @@ class UnionWithInt < Dry::Struct
5353 end
5454
5555 class TopLevel < Dry::Struct
56- attribute :arr_nullable, Types.Array(Types::String.optional).optional
57- attribute :arr_one, Types.Array(Types::String).optional
58- attribute :nullable, Types::String.optional
5956 attribute :one, Types::String
6057 attribute :top_level_optional, Types::String.optional
58+ attribute :nullable, Types::String.optional
59+ attribute :arr_one, Types.Array(Types::String).optional
60+ attribute :arr_nullable, Types.Array(Types::String.optional).optional
6161 attribute :union_with_int, Types.Instance(UnionWithInt)
6262 attribute :union_with_int_and_enum, Types.Instance(UnionWithInt)
6363
6464 def self.from_dynamic!(d)
6565 d = Types::Hash[d]
6666 new(
67- arr_nullable: d["arrNullable"],
68- arr_one: d["arrOne"],
69- nullable: d.fetch("nullable"),
7067 one: d.fetch("one"),
7168 top_level_optional: d["optional"],
69+ nullable: d.fetch("nullable"),
70+ arr_one: d["arrOne"],
71+ arr_nullable: d["arrNullable"],
7272 union_with_int: UnionWithInt.from_dynamic!(d.fetch("unionWithInt")),
7373 union_with_int_and_enum: UnionWithInt.from_dynamic!(d.fetch("unionWithIntAndEnum")),
7474 )
@@ -80,11 +80,11 @@ class TopLevel < Dry::Struct
8080
8181 def to_dynamic
8282 {
83- "arrNullable" => arr_nullable,
84- "arrOne" => arr_one,
85- "nullable" => nullable,
8683 "one" => one,
8784 "optional" => top_level_optional,
85+ "nullable" => nullable,
86+ "arrOne" => arr_one,
87+ "arrNullable" => arr_nullable,
8888 "unionWithInt" => union_with_int.to_dynamic,
8989 "unionWithIntAndEnum" => union_with_int_and_enum.to_dynamic,
9090 }
Mschema-ruby/test/inputs/schema/integer-type.schema/default/TopLevel.rb+16 −16
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.above_i32_max.even?
7+# puts top_level.small_positive.even?
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -20,28 +20,28 @@ module Types
2020 end
2121
2222 class TopLevel < Dry::Struct
23+ attribute :small_positive, Types::Integer
24+ attribute :small_negative, Types::Integer
25+ attribute :i32_range, Types::Integer
2326 attribute :above_i32_max, Types::Integer
2427 attribute :below_i32_min, Types::Integer
25- attribute :i32_range, Types::Integer
26- attribute :large_bounds, Types::Integer
27- attribute :only_maximum, Types::Integer
2828 attribute :only_minimum, Types::Integer
29- attribute :small_negative, Types::Integer
30- attribute :small_positive, Types::Integer
29+ attribute :only_maximum, Types::Integer
3130 attribute :unbounded, Types::Integer
31+ attribute :large_bounds, Types::Integer
3232
3333 def self.from_dynamic!(d)
3434 d = Types::Hash[d]
3535 new(
36+ small_positive: d.fetch("small_positive"),
37+ small_negative: d.fetch("small_negative"),
38+ i32_range: d.fetch("i32_range"),
3639 above_i32_max: d.fetch("above_i32_max"),
3740 below_i32_min: d.fetch("below_i32_min"),
38- i32_range: d.fetch("i32_range"),
39- large_bounds: d.fetch("large_bounds"),
40- only_maximum: d.fetch("only_maximum"),
4141 only_minimum: d.fetch("only_minimum"),
42- small_negative: d.fetch("small_negative"),
43- small_positive: d.fetch("small_positive"),
42+ only_maximum: d.fetch("only_maximum"),
4443 unbounded: d.fetch("unbounded"),
44+ large_bounds: d.fetch("large_bounds"),
4545 )
4646 end
4747
@@ -51,15 +51,15 @@ class TopLevel < Dry::Struct
5151
5252 def to_dynamic
5353 {
54+ "small_positive" => small_positive,
55+ "small_negative" => small_negative,
56+ "i32_range" => i32_range,
5457 "above_i32_max" => above_i32_max,
5558 "below_i32_min" => below_i32_min,
56- "i32_range" => i32_range,
57- "large_bounds" => large_bounds,
58- "only_maximum" => only_maximum,
5959 "only_minimum" => only_minimum,
60- "small_negative" => small_negative,
61- "small_positive" => small_positive,
60+ "only_maximum" => only_maximum,
6261 "unbounded" => unbounded,
62+ "large_bounds" => large_bounds,
6363 }
6464 end
Mschema-ruby/test/inputs/schema/keyword-unions.schema/default/TopLevel.rb+6 −6
@@ -15828,7 +15828,6 @@ class TopLevel < Dry::Struct
1582815828 attribute :did_set, Types.Instance(UnionDidSet).optional
1582915829 attribute :top_level_do, Types.Instance(UnionDo).optional
1583015830 attribute :double, Types.Instance(UnionDouble).optional
15831- attribute :dummy, Types::Double.optional
1583215831 attribute :dynamic, Types.Instance(UnionDynamic).optional
1583315832 attribute :dynamic_cast, Types.Instance(UnionDynamicCast).optional
1583415833 attribute :elif, Types.Instance(UnionElif).optional
@@ -15881,8 +15880,8 @@ class TopLevel < Dry::Struct
1588115880 attribute :int, Types.Instance(UnionInt).optional
1588215881 attribute :interface, Types.Instance(UnionInterface).optional
1588315882 attribute :internal, Types.Instance(UnionInternal).optional
15884- attribute :is, Types.Instance(UnionIs).optional
1588515883 attribute :iterable, Types.Instance(UnionIterable).optional
15884+ attribute :is, Types.Instance(UnionIs).optional
1588615885 attribute :jdec, Types.Instance(UnionJdec).optional
1588715886 attribute :jenc, Types.Instance(UnionJenc).optional
1588815887 attribute :jpipe, Types.Instance(UnionJpipe).optional
@@ -16029,6 +16028,7 @@ class TopLevel < Dry::Struct
1602916028 attribute :xor_eq, Types.Instance(UnionXorEq).optional
1603016029 attribute :yes, Types.Instance(UnionYES).optional
1603116030 attribute :top_level_yield, Types.Instance(UnionYield).optional
16031+ attribute :dummy, Types::Double.optional
1603216032
1603316033 def self.from_dynamic!(d)
1603416034 d = Types::Hash[d]
@@ -16109,7 +16109,6 @@ class TopLevel < Dry::Struct
1610916109 did_set: d["didSet"] ? UnionDidSet.from_dynamic!(d["didSet"]) : nil,
1611016110 top_level_do: d["do"] ? UnionDo.from_dynamic!(d["do"]) : nil,
1611116111 double: d["double"] ? UnionDouble.from_dynamic!(d["double"]) : nil,
16112- dummy: d["dummy"],
1611316112 dynamic: d["dynamic"] ? UnionDynamic.from_dynamic!(d["dynamic"]) : nil,
1611416113 dynamic_cast: d["dynamic_cast"] ? UnionDynamicCast.from_dynamic!(d["dynamic_cast"]) : nil,
1611516114 elif: d["elif"] ? UnionElif.from_dynamic!(d["elif"]) : nil,
@@ -16162,8 +16161,8 @@ class TopLevel < Dry::Struct
1616216161 int: d["int"] ? UnionInt.from_dynamic!(d["int"]) : nil,
1616316162 interface: d["interface"] ? UnionInterface.from_dynamic!(d["interface"]) : nil,
1616416163 internal: d["internal"] ? UnionInternal.from_dynamic!(d["internal"]) : nil,
16165- is: d["is"] ? UnionIs.from_dynamic!(d["is"]) : nil,
1616616164 iterable: d["iterable"] ? UnionIterable.from_dynamic!(d["iterable"]) : nil,
16165+ is: d["is"] ? UnionIs.from_dynamic!(d["is"]) : nil,
1616716166 jdec: d["jdec"] ? UnionJdec.from_dynamic!(d["jdec"]) : nil,
1616816167 jenc: d["jenc"] ? UnionJenc.from_dynamic!(d["jenc"]) : nil,
1616916168 jpipe: d["jpipe"] ? UnionJpipe.from_dynamic!(d["jpipe"]) : nil,
@@ -16310,6 +16309,7 @@ class TopLevel < Dry::Struct
1631016309 xor_eq: d["xor_eq"] ? UnionXorEq.from_dynamic!(d["xor_eq"]) : nil,
1631116310 yes: d["YES"] ? UnionYES.from_dynamic!(d["YES"]) : nil,
1631216311 top_level_yield: d["yield"] ? UnionYield.from_dynamic!(d["yield"]) : nil,
16312+ dummy: d["dummy"],
1631316313 )
1631416314 end
1631516315
@@ -16395,7 +16395,6 @@ class TopLevel < Dry::Struct
1639516395 "didSet" => did_set&.to_dynamic,
1639616396 "do" => top_level_do&.to_dynamic,
1639716397 "double" => double&.to_dynamic,
16398- "dummy" => dummy,
1639916398 "dynamic" => dynamic&.to_dynamic,
1640016399 "dynamic_cast" => dynamic_cast&.to_dynamic,
1640116400 "elif" => elif&.to_dynamic,
@@ -16448,8 +16447,8 @@ class TopLevel < Dry::Struct
1644816447 "int" => int&.to_dynamic,
1644916448 "interface" => interface&.to_dynamic,
1645016449 "internal" => internal&.to_dynamic,
16451- "is" => is&.to_dynamic,
1645216450 "iterable" => iterable&.to_dynamic,
16451+ "is" => is&.to_dynamic,
1645316452 "jdec" => jdec&.to_dynamic,
1645416453 "jenc" => jenc&.to_dynamic,
1645516454 "jpipe" => jpipe&.to_dynamic,
@@ -16596,6 +16595,7 @@ class TopLevel < Dry::Struct
1659616595 "xor_eq" => xor_eq&.to_dynamic,
1659716596 "YES" => yes&.to_dynamic,
1659816597 "yield" => top_level_yield&.to_dynamic,
16598+ "dummy" => dummy,
1659916599 }
1660016600 end
Mschema-ruby/test/inputs/schema/light.schema/default/TopLevel.rb+4 −4
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.light_params.app_id
7+# puts top_level.light_params.outlet_id
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -20,15 +20,15 @@ module Types
2020 end
2121
2222 class LightParams < Dry::Struct
23- attribute :app_id, Types::String
2423 attribute :outlet_id, Types::String
24+ attribute :app_id, Types::String
2525 attribute :rgba, Types::String
2626
2727 def self.from_dynamic!(d)
2828 d = Types::Hash[d]
2929 new(
30- app_id: d.fetch("app_id"),
3130 outlet_id: d.fetch("outlet_id"),
31+ app_id: d.fetch("app_id"),
3232 rgba: d.fetch("rgba"),
3333 )
3434 end
@@ -39,8 +39,8 @@ class LightParams < Dry::Struct
3939
4040 def to_dynamic
4141 {
42- "app_id" => app_id,
4342 "outlet_id" => outlet_id,
43+ "app_id" => app_id,
4444 "rgba" => rgba,
4545 }
4646 end
Mschema-ruby/test/inputs/schema/min-max-items.schema/default/TopLevel.rb+3 −3
@@ -53,18 +53,18 @@ class UnionItem < Dry::Struct
5353 end
5454
5555 class TopLevel < Dry::Struct
56+ attribute :min_only, Types.Array(Types::String)
5657 attribute :max_only, Types.Array(Types::Integer)
5758 attribute :min_and_max, Types.Array(Types::Double)
58- attribute :min_only, Types.Array(Types::String)
5959 attribute :plain, Types.Array(Types::String)
6060 attribute :union_items, Types.Array(Types.Instance(UnionItem))
6161
6262 def self.from_dynamic!(d)
6363 d = Types::Hash[d]
6464 new(
65+ min_only: d.fetch("minOnly"),
6566 max_only: d.fetch("maxOnly"),
6667 min_and_max: d.fetch("minAndMax"),
67- min_only: d.fetch("minOnly"),
6868 plain: d.fetch("plain"),
6969 union_items: d.fetch("unionItems").map { |x| UnionItem.from_dynamic!(x) },
7070 )
@@ -76,9 +76,9 @@ class TopLevel < Dry::Struct
7676
7777 def to_dynamic
7878 {
79+ "minOnly" => min_only,
7980 "maxOnly" => max_only,
8081 "minAndMax" => min_and_max,
81- "minOnly" => min_only,
8282 "plain" => plain,
8383 "unionItems" => union_items.map { |x| x.to_dynamic },
8484 }
Mschema-ruby/test/inputs/schema/minmax-integer.schema/default/TopLevel.rb+12 −12
@@ -21,25 +21,25 @@ end
2121
2222 class TopLevel < Dry::Struct
2323 attribute :free, Types::Integer
24- attribute :intersection, Types::Integer
25- attribute :max, Types::Integer
2624 attribute :min, Types::Integer
25+ attribute :max, Types::Integer
2726 attribute :minmax, Types::Integer
28- attribute :min_max_intersection, Types::Integer
29- attribute :min_max_union, Types::Integer
3027 attribute :union, Types::Integer
28+ attribute :min_max_union, Types::Integer
29+ attribute :intersection, Types::Integer
30+ attribute :min_max_intersection, Types::Integer
3131
3232 def self.from_dynamic!(d)
3333 d = Types::Hash[d]
3434 new(
3535 free: d.fetch("free"),
36- intersection: d.fetch("intersection"),
37- max: d.fetch("max"),
3836 min: d.fetch("min"),
37+ max: d.fetch("max"),
3938 minmax: d.fetch("minmax"),
40- min_max_intersection: d.fetch("minMaxIntersection"),
41- min_max_union: d.fetch("minMaxUnion"),
4239 union: d.fetch("union"),
40+ min_max_union: d.fetch("minMaxUnion"),
41+ intersection: d.fetch("intersection"),
42+ min_max_intersection: d.fetch("minMaxIntersection"),
4343 )
4444 end
4545
@@ -50,13 +50,13 @@ class TopLevel < Dry::Struct
5050 def to_dynamic
5151 {
5252 "free" => free,
53- "intersection" => intersection,
54- "max" => max,
5553 "min" => min,
54+ "max" => max,
5655 "minmax" => minmax,
57- "minMaxIntersection" => min_max_intersection,
58- "minMaxUnion" => min_max_union,
5956 "union" => union,
57+ "minMaxUnion" => min_max_union,
58+ "intersection" => intersection,
59+ "minMaxIntersection" => min_max_intersection,
6060 }
6161 end
Mschema-ruby/test/inputs/schema/minmax.schema/default/TopLevel.rb+12 −12
@@ -21,25 +21,25 @@ end
2121
2222 class TopLevel < Dry::Struct
2323 attribute :free, Types::Double
24- attribute :intersection, Types::Double
25- attribute :max, Types::Double
2624 attribute :min, Types::Double
25+ attribute :max, Types::Double
2726 attribute :minmax, Types::Double
28- attribute :min_max_intersection, Types::Double
29- attribute :min_max_union, Types::Double
3027 attribute :union, Types::Double
28+ attribute :min_max_union, Types::Double
29+ attribute :intersection, Types::Double
30+ attribute :min_max_intersection, Types::Double
3131
3232 def self.from_dynamic!(d)
3333 d = Types::Hash[d]
3434 new(
3535 free: d.fetch("free"),
36- intersection: d.fetch("intersection"),
37- max: d.fetch("max"),
3836 min: d.fetch("min"),
37+ max: d.fetch("max"),
3938 minmax: d.fetch("minmax"),
40- min_max_intersection: d.fetch("minMaxIntersection"),
41- min_max_union: d.fetch("minMaxUnion"),
4239 union: d.fetch("union"),
40+ min_max_union: d.fetch("minMaxUnion"),
41+ intersection: d.fetch("intersection"),
42+ min_max_intersection: d.fetch("minMaxIntersection"),
4343 )
4444 end
4545
@@ -50,13 +50,13 @@ class TopLevel < Dry::Struct
5050 def to_dynamic
5151 {
5252 "free" => free,
53- "intersection" => intersection,
54- "max" => max,
5553 "min" => min,
54+ "max" => max,
5655 "minmax" => minmax,
57- "minMaxIntersection" => min_max_intersection,
58- "minMaxUnion" => min_max_union,
5956 "union" => union,
57+ "minMaxUnion" => min_max_union,
58+ "intersection" => intersection,
59+ "minMaxIntersection" => min_max_intersection,
6060 }
6161 end
Mschema-ruby/test/inputs/schema/minmaxlength.schema/default/TopLevel.rb+16 −16
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.intersection
7+# puts top_level.minlength
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -52,26 +52,26 @@ class InUnion < Dry::Struct
5252 end
5353
5454 class TopLevel < Dry::Struct
55- attribute :intersection, Types::String
56- attribute :in_union, Types.Instance(InUnion)
57- attribute :maxlength, Types::String
5855 attribute :minlength, Types::String
59- attribute :min_max_intersection, Types::String
56+ attribute :maxlength, Types::String
6057 attribute :minmaxlength, Types::String
61- attribute :min_max_union, Types::String
6258 attribute :union, Types::String
59+ attribute :in_union, Types.Instance(InUnion)
60+ attribute :min_max_union, Types::String
61+ attribute :intersection, Types::String
62+ attribute :min_max_intersection, Types::String
6363
6464 def self.from_dynamic!(d)
6565 d = Types::Hash[d]
6666 new(
67- intersection: d.fetch("intersection"),
68- in_union: InUnion.from_dynamic!(d.fetch("inUnion")),
69- maxlength: d.fetch("maxlength"),
7067 minlength: d.fetch("minlength"),
71- min_max_intersection: d.fetch("minMaxIntersection"),
68+ maxlength: d.fetch("maxlength"),
7269 minmaxlength: d.fetch("minmaxlength"),
73- min_max_union: d.fetch("minMaxUnion"),
7470 union: d.fetch("union"),
71+ in_union: InUnion.from_dynamic!(d.fetch("inUnion")),
72+ min_max_union: d.fetch("minMaxUnion"),
73+ intersection: d.fetch("intersection"),
74+ min_max_intersection: d.fetch("minMaxIntersection"),
7575 )
7676 end
7777
@@ -81,14 +81,14 @@ class TopLevel < Dry::Struct
8181
8282 def to_dynamic
8383 {
84- "intersection" => intersection,
85- "inUnion" => in_union.to_dynamic,
86- "maxlength" => maxlength,
8784 "minlength" => minlength,
88- "minMaxIntersection" => min_max_intersection,
85+ "maxlength" => maxlength,
8986 "minmaxlength" => minmaxlength,
90- "minMaxUnion" => min_max_union,
9187 "union" => union,
88+ "inUnion" => in_union.to_dynamic,
89+ "minMaxUnion" => min_max_union,
90+ "intersection" => intersection,
91+ "minMaxIntersection" => min_max_intersection,
9292 }
9393 end
Mschema-ruby/test/inputs/schema/non-standard-ref.schema/default/TopLevel.rb+4 −4
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.bar.even?
7+# puts top_level.foo.even?
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -21,15 +21,15 @@ module Types
2121 end
2222
2323 class TopLevel < Dry::Struct
24- attribute :bar, Types::Integer
2524 attribute :foo, Types::Integer
25+ attribute :bar, Types::Integer
2626 attribute :quux, Types::Bool
2727
2828 def self.from_dynamic!(d)
2929 d = Types::Hash[d]
3030 new(
31- bar: d.fetch("bar"),
3231 foo: d.fetch("foo"),
32+ bar: d.fetch("bar"),
3333 quux: d.fetch("quux"),
3434 )
3535 end
@@ -40,8 +40,8 @@ class TopLevel < Dry::Struct
4040
4141 def to_dynamic
4242 {
43- "bar" => bar,
4443 "foo" => foo,
44+ "bar" => bar,
4545 "quux" => quux,
4646 }
4747 end
Mschema-ruby/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.rb+4 −4
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.b.nil?
7+# puts top_level.kind == Kind::One
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -27,14 +27,14 @@ module Kind
2727 end
2828
2929 class TopLevel < Dry::Struct
30- attribute :b, Types::String.optional.optional
3130 attribute :kind, Types::Kind
31+ attribute :b, Types::String.optional.optional
3232
3333 def self.from_dynamic!(d)
3434 d = Types::Hash[d]
3535 new(
36- b: d["b"],
3736 kind: d.fetch("kind"),
37+ b: d["b"],
3838 )
3939 end
4040
@@ -44,8 +44,8 @@ class TopLevel < Dry::Struct
4444
4545 def to_dynamic
4646 {
47- "b" => b,
4847 "kind" => kind,
48+ "b" => b,
4949 }
5050 end
Mschema-ruby/test/inputs/schema/optional-any.schema/default/TopLevel.rb+4 −4
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.bar
7+# puts top_level.foo
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -20,14 +20,14 @@ module Types
2020 end
2121
2222 class TopLevel < Dry::Struct
23- attribute :bar, Types::Bool
2423 attribute :foo, Types::Any.optional
24+ attribute :bar, Types::Bool
2525
2626 def self.from_dynamic!(d)
2727 d = Types::Hash[d]
2828 new(
29- bar: d.fetch("bar"),
3029 foo: d["foo"],
30+ bar: d.fetch("bar"),
3131 )
3232 end
3333
@@ -37,8 +37,8 @@ class TopLevel < Dry::Struct
3737
3838 def to_dynamic
3939 {
40- "bar" => bar,
4140 "foo" => foo,
41+ "bar" => bar,
4242 }
4343 end
Mschema-ruby/test/inputs/schema/optional-const-ref.schema/default/TopLevel.rb+9 −9
@@ -51,23 +51,23 @@ end
5151
5252 class TopLevel < Dry::Struct
5353 attribute :coordinates, Types.Array(Coordinate).optional
54- attribute :count, Types::Integer.optional
55- attribute :label, Types::String.optional
5654 attribute :required_coordinates, Types.Array(Coordinate)
55+ attribute :count, Types::Integer.optional
5756 attribute :required_count, Types::Integer
58- attribute :required_label, Types::String
5957 attribute :weight, Types::Double.optional
58+ attribute :label, Types::String.optional
59+ attribute :required_label, Types::String
6060
6161 def self.from_dynamic!(d)
6262 d = Types::Hash[d]
6363 new(
6464 coordinates: d["coordinates"]&.map { |x| Coordinate.from_dynamic!(x) },
65- count: d["count"],
66- label: d["label"],
6765 required_coordinates: d.fetch("requiredCoordinates").map { |x| Coordinate.from_dynamic!(x) },
66+ count: d["count"],
6867 required_count: d.fetch("requiredCount"),
69- required_label: d.fetch("requiredLabel"),
7068 weight: d["weight"],
69+ label: d["label"],
70+ required_label: d.fetch("requiredLabel"),
7171 )
7272 end
7373
@@ -78,12 +78,12 @@ class TopLevel < Dry::Struct
7878 def to_dynamic
7979 {
8080 "coordinates" => coordinates&.map { |x| x.to_dynamic },
81- "count" => count,
82- "label" => label,
8381 "requiredCoordinates" => required_coordinates.map { |x| x.to_dynamic },
82+ "count" => count,
8483 "requiredCount" => required_count,
85- "requiredLabel" => required_label,
8684 "weight" => weight,
85+ "label" => label,
86+ "requiredLabel" => required_label,
8787 }
8888 end
Mschema-ruby/test/inputs/schema/optional-constraints.schema/default/TopLevel.rb+10 −10
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.opt_double
7+# puts top_level.req_zero_min.even?
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -22,20 +22,20 @@ module Types
2222 end
2323
2424 class TopLevel < Dry::Struct
25- attribute :opt_double, Types::Double.optional
25+ attribute :req_zero_min, Types::Integer
2626 attribute :opt_int, Types::Integer.optional
27- attribute :opt_pattern, Types::String.optional
27+ attribute :opt_double, Types::Double.optional
2828 attribute :opt_string, Types::String.optional
29- attribute :req_zero_min, Types::Integer
29+ attribute :opt_pattern, Types::String.optional
3030
3131 def self.from_dynamic!(d)
3232 d = Types::Hash[d]
3333 new(
34- opt_double: d["optDouble"],
34+ req_zero_min: d.fetch("reqZeroMin"),
3535 opt_int: d["optInt"],
36- opt_pattern: d["optPattern"],
36+ opt_double: d["optDouble"],
3737 opt_string: d["optString"],
38- req_zero_min: d.fetch("reqZeroMin"),
38+ opt_pattern: d["optPattern"],
3939 )
4040 end
4141
@@ -45,11 +45,11 @@ class TopLevel < Dry::Struct
4545
4646 def to_dynamic
4747 {
48- "optDouble" => opt_double,
48+ "reqZeroMin" => req_zero_min,
4949 "optInt" => opt_int,
50- "optPattern" => opt_pattern,
50+ "optDouble" => opt_double,
5151 "optString" => opt_string,
52- "reqZeroMin" => req_zero_min,
52+ "optPattern" => opt_pattern,
5353 }
5454 end
Mschema-ruby/test/inputs/schema/optional-date-time.schema/default/TopLevel.rb+13 −13
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.optional_date
7+# puts top_level.required_date
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -20,22 +20,22 @@ module Types
2020 end
2121
2222 class TopLevel < Dry::Struct
23- attribute :optional_date, Types::String.optional
24- attribute :optional_date_time, Types::String.optional
25- attribute :optional_time, Types::String.optional
2623 attribute :required_date, Types::String
27- attribute :required_date_time, Types::String
2824 attribute :required_time, Types::String
25+ attribute :required_date_time, Types::String
26+ attribute :optional_date, Types::String.optional
27+ attribute :optional_time, Types::String.optional
28+ attribute :optional_date_time, Types::String.optional
2929
3030 def self.from_dynamic!(d)
3131 d = Types::Hash[d]
3232 new(
33- optional_date: d["optional-date"],
34- optional_date_time: d["optional-date-time"],
35- optional_time: d["optional-time"],
3633 required_date: d.fetch("required-date"),
37- required_date_time: d.fetch("required-date-time"),
3834 required_time: d.fetch("required-time"),
35+ required_date_time: d.fetch("required-date-time"),
36+ optional_date: d["optional-date"],
37+ optional_time: d["optional-time"],
38+ optional_date_time: d["optional-date-time"],
3939 )
4040 end
4141
@@ -45,12 +45,12 @@ class TopLevel < Dry::Struct
4545
4646 def to_dynamic
4747 {
48- "optional-date" => optional_date,
49- "optional-date-time" => optional_date_time,
50- "optional-time" => optional_time,
5148 "required-date" => required_date,
52- "required-date-time" => required_date_time,
5349 "required-time" => required_time,
50+ "required-date-time" => required_date_time,
51+ "optional-date" => optional_date,
52+ "optional-time" => optional_time,
53+ "optional-date-time" => optional_date_time,
5454 }
5555 end
Mschema-ruby/test/inputs/schema/prefix-items.schema/default/TopLevel.rb+4 −4
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.tuple.first
7+# puts top_level.top_level_open.first
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -52,14 +52,14 @@ class Open < Dry::Struct
5252 end
5353
5454 class TopLevel < Dry::Struct
55- attribute :top_level_open, Types.Array(Types.Instance(Open))
5655 attribute :tuple, Types.Array(Types.Instance(Open))
56+ attribute :top_level_open, Types.Array(Types.Instance(Open))
5757
5858 def self.from_dynamic!(d)
5959 d = Types::Hash[d]
6060 new(
61- top_level_open: d.fetch("open").map { |x| Open.from_dynamic!(x) },
6261 tuple: d.fetch("tuple").map { |x| Open.from_dynamic!(x) },
62+ top_level_open: d.fetch("open").map { |x| Open.from_dynamic!(x) },
6363 )
6464 end
6565
@@ -69,8 +69,8 @@ class TopLevel < Dry::Struct
6969
7070 def to_dynamic
7171 {
72- "open" => top_level_open.map { |x| x.to_dynamic },
7372 "tuple" => tuple.map { |x| x.to_dynamic },
73+ "open" => top_level_open.map { |x| x.to_dynamic },
7474 }
7575 end
Aschema-ruby/test/inputs/schema/property-order.schema/default/TopLevel.rb+94 −0
@@ -0,0 +1,94 @@
1+# This code may look unusually verbose for Ruby (and it is), but
2+# it performs some subtle and complex validation of JSON data.
3+#
4+# To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
5+#
6+# top_level = TopLevel.from_json! "{…}"
7+# puts top_level.ordered.mango
8+#
9+# If from_json! succeeds, the value returned matches the schema.
10+
11+require 'json'
12+require 'dry-types'
13+require 'dry-struct'
14+
15+module Types
16+ include Dry.Types(default: :nominal)
17+
18+ Integer = Strict::Integer
19+ Bool = Strict::Bool
20+ Hash = Strict::Hash
21+ String = Strict::String
22+ Double = Strict::Float | Strict::Integer
23+end
24+
25+class Ordered < Dry::Struct
26+ attribute :mango, Types::Double
27+ attribute :zebra, Types::String
28+ attribute :apple, Types::Bool
29+
30+ def self.from_dynamic!(d)
31+ d = Types::Hash[d]
32+ new(
33+ mango: d.fetch("mango"),
34+ zebra: d.fetch("zebra"),
35+ apple: d.fetch("apple"),
36+ )
37+ end
38+
39+ def self.from_json!(json)
40+ from_dynamic!(JSON.parse(json))
41+ end
42+
43+ def to_dynamic
44+ {
45+ "mango" => mango,
46+ "zebra" => zebra,
47+ "apple" => apple,
48+ }
49+ end
50+
51+ def to_json(options = nil)
52+ JSON.generate(to_dynamic, options)
53+ end
54+end
55+
56+class TopLevel < Dry::Struct
57+ attribute :zebra, Types::String
58+ attribute :mango, Types::Double
59+ attribute :apple, Types::Bool
60+ attribute :delta, Types::String
61+ attribute :banana, Types::Integer
62+ attribute :ordered, Ordered
63+
64+ def self.from_dynamic!(d)
65+ d = Types::Hash[d]
66+ new(
67+ zebra: d.fetch("zebra"),
68+ mango: d.fetch("mango"),
69+ apple: d.fetch("apple"),
70+ delta: d.fetch("delta"),
71+ banana: d.fetch("banana"),
72+ ordered: Ordered.from_dynamic!(d.fetch("ordered")),
73+ )
74+ end
75+
76+ def self.from_json!(json)
77+ from_dynamic!(JSON.parse(json))
78+ end
79+
80+ def to_dynamic
81+ {
82+ "zebra" => zebra,
83+ "mango" => mango,
84+ "apple" => apple,
85+ "delta" => delta,
86+ "banana" => banana,
87+ "ordered" => ordered.to_dynamic,
88+ }
89+ end
90+
91+ def to_json(options = nil)
92+ JSON.generate(to_dynamic, options)
93+ end
94+end
Mschema-ruby/test/inputs/schema/renaming-bug.schema/default/TopLevel.rb+25 −25
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.vehicles&.first.vehicle_type&.vehicle_type_name == Name::Truck
7+# puts top_level.vehicles&.first.speed&.velocity&.minimum
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -74,16 +74,16 @@ class CircularShape < Dry::Struct
7474 end
7575
7676 class Part < Dry::Struct
77- attribute :depth, Types::String.optional
7877 attribute :length, Types::String.optional
7978 attribute :width, Types::String.optional
79+ attribute :depth, Types::String.optional
8080
8181 def self.from_dynamic!(d)
8282 d = Types::Hash[d]
8383 new(
84- depth: d["depth"],
8584 length: d["length"],
8685 width: d["width"],
86+ depth: d["depth"],
8787 )
8888 end
8989
@@ -93,9 +93,9 @@ class Part < Dry::Struct
9393
9494 def to_dynamic
9595 {
96- "depth" => depth,
9796 "length" => length,
9897 "width" => width,
98+ "depth" => depth,
9999 }
100100 end
101101
@@ -183,14 +183,14 @@ class History < Dry::Struct
183183 end
184184
185185 class Shape < Dry::Struct
186- attribute :geometry, Geometry.optional
187186 attribute :history, History.optional
187+ attribute :geometry, Geometry.optional
188188
189189 def self.from_dynamic!(d)
190190 d = Types::Hash[d]
191191 new(
192- geometry: d["geometry"] ? Geometry.from_dynamic!(d["geometry"]) : nil,
193192 history: d["history"] ? History.from_dynamic!(d["history"]) : nil,
193+ geometry: d["geometry"] ? Geometry.from_dynamic!(d["geometry"]) : nil,
194194 )
195195 end
196196
@@ -200,8 +200,8 @@ class Shape < Dry::Struct
200200
201201 def to_dynamic
202202 {
203- "geometry" => geometry&.to_dynamic,
204203 "history" => history&.to_dynamic,
204+ "geometry" => geometry&.to_dynamic,
205205 }
206206 end
207207
@@ -211,15 +211,15 @@ class Shape < Dry::Struct
211211 end
212212
213213 class Berry < Dry::Struct
214- attribute :color, Color.optional
215214 attribute :berry_name, Types::String.optional
215+ attribute :color, Color.optional
216216 attribute :shapes, Types.Array(Shape).optional
217217
218218 def self.from_dynamic!(d)
219219 d = Types::Hash[d]
220220 new(
221- color: d["color"] ? Color.from_dynamic!(d["color"]) : nil,
222221 berry_name: d["name"],
222+ color: d["color"] ? Color.from_dynamic!(d["color"]) : nil,
223223 shapes: d["shapes"]&.map { |x| Shape.from_dynamic!(x) },
224224 )
225225 end
@@ -230,8 +230,8 @@ class Berry < Dry::Struct
230230
231231 def to_dynamic
232232 {
233- "color" => color&.to_dynamic,
234233 "name" => berry_name,
234+ "color" => color&.to_dynamic,
235235 "shapes" => shapes&.map { |x| x.to_dynamic },
236236 }
237237 end
@@ -243,15 +243,15 @@ end
243243
244244 class Fruit < Dry::Struct
245245 attribute :apple, Types::Bool.optional
246- attribute :berries, Types.Array(Berry).optional
247246 attribute :orange, Types::Bool.optional
247+ attribute :berries, Types.Array(Berry).optional
248248
249249 def self.from_dynamic!(d)
250250 d = Types::Hash[d]
251251 new(
252252 apple: d["apple"],
253- berries: d["berries"]&.map { |x| Berry.from_dynamic!(x) },
254253 orange: d["orange"],
254+ berries: d["berries"]&.map { |x| Berry.from_dynamic!(x) },
255255 )
256256 end
257257
@@ -262,8 +262,8 @@ class Fruit < Dry::Struct
262262 def to_dynamic
263263 {
264264 "apple" => apple,
265- "berries" => berries&.map { |x| x.to_dynamic },
266265 "orange" => orange,
266+ "berries" => berries&.map { |x| x.to_dynamic },
267267 }
268268 end
269269
@@ -273,14 +273,14 @@ class Fruit < Dry::Struct
273273 end
274274
275275 class Limit < Dry::Struct
276- attribute :maximum, Types::Double.optional
277276 attribute :minimum, Types::Double.optional
277+ attribute :maximum, Types::Double.optional
278278
279279 def self.from_dynamic!(d)
280280 d = Types::Hash[d]
281281 new(
282- maximum: d["maximum"],
283282 minimum: d["minimum"],
283+ maximum: d["maximum"],
284284 )
285285 end
286286
@@ -290,8 +290,8 @@ class Limit < Dry::Struct
290290
291291 def to_dynamic
292292 {
293- "maximum" => maximum,
294293 "minimum" => minimum,
294+ "maximum" => maximum,
295295 }
296296 end
297297
@@ -378,22 +378,22 @@ class VehicleType < Dry::Struct
378378 end
379379
380380 class Vehicle < Dry::Struct
381- attribute :brand, Types::String.optional
382381 attribute :id, Types::String.optional
383- attribute :speed, Speed.optional
384- attribute :sub_module, Types::Bool.optional
385382 attribute :vehicle_type, VehicleType.optional
383+ attribute :speed, Speed.optional
386384 attribute :year, Types::String.optional
385+ attribute :brand, Types::String.optional
386+ attribute :sub_module, Types::Bool.optional
387387
388388 def self.from_dynamic!(d)
389389 d = Types::Hash[d]
390390 new(
391- brand: d["brand"],
392391 id: d["id"],
393- speed: d["speed"] ? Speed.from_dynamic!(d["speed"]) : nil,
394- sub_module: d["subModule"],
395392 vehicle_type: d["type"] ? VehicleType.from_dynamic!(d["type"]) : nil,
393+ speed: d["speed"] ? Speed.from_dynamic!(d["speed"]) : nil,
396394 year: d["year"],
395+ brand: d["brand"],
396+ sub_module: d["subModule"],
397397 )
398398 end
399399
@@ -403,12 +403,12 @@ class Vehicle < Dry::Struct
403403
404404 def to_dynamic
405405 {
406- "brand" => brand,
407406 "id" => id,
408- "speed" => speed&.to_dynamic,
409- "subModule" => sub_module,
410407 "type" => vehicle_type&.to_dynamic,
408+ "speed" => speed&.to_dynamic,
411409 "year" => year,
410+ "brand" => brand,
411+ "subModule" => sub_module,
412412 }
413413 end
Mschema-ruby/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.rb+7 −7
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.top_level_next
7+# puts top_level.value
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -65,14 +65,14 @@ class Next < Dry::Struct
6565 end
6666
6767 class Node < Dry::Struct
68- attribute :node_next, Types.Instance(Next).optional
6968 attribute :value, Types::String
69+ attribute :node_next, Types.Instance(Next).optional
7070
7171 def self.from_dynamic!(d)
7272 d = Types::Hash[d]
7373 new(
74- node_next: d["next"] ? Next.from_dynamic!(d["next"]) : nil,
7574 value: d.fetch("value"),
75+ node_next: d["next"] ? Next.from_dynamic!(d["next"]) : nil,
7676 )
7777 end
7878
@@ -82,8 +82,8 @@ class Node < Dry::Struct
8282
8383 def to_dynamic
8484 {
85- "next" => node_next&.to_dynamic,
8685 "value" => value,
86+ "next" => node_next&.to_dynamic,
8787 }
8888 end
8989
@@ -93,14 +93,14 @@ class Node < Dry::Struct
9393 end
9494
9595 class TopLevel < Dry::Struct
96- attribute :top_level_next, Types.Instance(Next).optional
9796 attribute :value, Types::String
97+ attribute :top_level_next, Types.Instance(Next).optional
9898
9999 def self.from_dynamic!(d)
100100 d = Types::Hash[d]
101101 new(
102- top_level_next: d["next"] ? Next.from_dynamic!(d["next"]) : nil,
103102 value: d.fetch("value"),
103+ top_level_next: d["next"] ? Next.from_dynamic!(d["next"]) : nil,
104104 )
105105 end
106106
@@ -110,8 +110,8 @@ class TopLevel < Dry::Struct
110110
111111 def to_dynamic
112112 {
113- "next" => top_level_next&.to_dynamic,
114113 "value" => value,
114+ "next" => top_level_next&.to_dynamic,
115115 }
116116 end
Mschema-ruby/test/inputs/schema/uuid.schema/default/TopLevel.rb+10 −10
@@ -4,7 +4,7 @@
44 # To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
55 #
66 # top_level = TopLevel.from_json! "{…}"
7-# puts top_level.arr_one&.first
7+# puts top_level.arr_nullable&.first.nil?
88 #
99 # If from_json! succeeds, the value returned matches the schema.
1010
@@ -21,21 +21,21 @@ module Types
2121 end
2222
2323 class TopLevel < Dry::Struct
24- attribute :arr_nullable, Types.Array(Types::String.optional).optional
25- attribute :arr_one, Types.Array(Types::String).optional
26- attribute :nullable, Types::String.optional
2724 attribute :one, Types::String
2825 attribute :top_level_optional, Types::String.optional
26+ attribute :nullable, Types::String.optional
27+ attribute :arr_one, Types.Array(Types::String).optional
28+ attribute :arr_nullable, Types.Array(Types::String.optional).optional
2929 attribute :union_with_enum, Types::String
3030
3131 def self.from_dynamic!(d)
3232 d = Types::Hash[d]
3333 new(
34- arr_nullable: d["arrNullable"],
35- arr_one: d["arrOne"],
36- nullable: d.fetch("nullable"),
3734 one: d.fetch("one"),
3835 top_level_optional: d["optional"],
36+ nullable: d.fetch("nullable"),
37+ arr_one: d["arrOne"],
38+ arr_nullable: d["arrNullable"],
3939 union_with_enum: d.fetch("unionWithEnum"),
4040 )
4141 end
@@ -46,11 +46,11 @@ class TopLevel < Dry::Struct
4646
4747 def to_dynamic
4848 {
49- "arrNullable" => arr_nullable,
50- "arrOne" => arr_one,
51- "nullable" => nullable,
5249 "one" => one,
5350 "optional" => top_level_optional,
51+ "nullable" => nullable,
52+ "arrOne" => arr_one,
53+ "arrNullable" => arr_nullable,
5454 "unionWithEnum" => union_with_enum,
5555 }
5656 end
Mschema-ruby/test/inputs/schema/vega-lite.schema/default/TopLevel.rb+50 −50
@@ -386,6 +386,11 @@ class MarkConfig < Dry::Struct
386386 # __Default value:__ (None)
387387 attribute :fill, Types::String.optional
388388
389+ # The fill opacity (value between [0,1]).
390+ #
391+ # __Default value:__ `1`
392+ attribute :fill_opacity, Types::Double.optional
393+
389394 # Whether the mark's color should be used as fill color instead of stroke color.
390395 #
391396 # __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -395,11 +400,6 @@ class MarkConfig < Dry::Struct
395400 # __Note:__ This property cannot be used in a [style config](mark.html#style-config).
396401 attribute :filled, Types::Bool.optional
397402
398- # The fill opacity (value between [0,1]).
399- #
400- # __Default value:__ `1`
401- attribute :fill_opacity, Types::Double.optional
402-
403403 # The typeface to set the text in (e.g., `"Helvetica Neue"`).
404404 attribute :font, Types::String.optional
405405
@@ -515,8 +515,8 @@ class MarkConfig < Dry::Struct
515515 dx: d["dx"],
516516 dy: d["dy"],
517517 fill: d["fill"],
518- filled: d["filled"],
519518 fill_opacity: d["fillOpacity"],
519+ filled: d["filled"],
520520 font: d["font"],
521521 font_size: d["fontSize"],
522522 font_style: d["fontStyle"],
@@ -554,8 +554,8 @@ class MarkConfig < Dry::Struct
554554 "dx" => dx,
555555 "dy" => dy,
556556 "fill" => fill,
557- "filled" => filled,
558557 "fillOpacity" => fill_opacity,
558+ "filled" => filled,
559559 "font" => font,
560560 "fontSize" => font_size,
561561 "fontStyle" => font_style,
@@ -826,15 +826,15 @@ class AxisConfig < Dry::Struct
826826 # Boolean flag indicating if pixel position values should be rounded to the nearest integer.
827827 attribute :tick_round, Types::Bool.optional
828828
829- # Boolean value that determines whether the axis should include ticks.
830- attribute :ticks, Types::Bool.optional
831-
832829 # The size in pixels of axis ticks.
833830 attribute :tick_size, Types::Double.optional
834831
835832 # The width, in pixels, of ticks.
836833 attribute :tick_width, Types::Double.optional
837834
835+ # Boolean value that determines whether the axis should include ticks.
836+ attribute :ticks, Types::Bool.optional
837+
838838 # Horizontal text alignment of axis titles.
839839 attribute :title_align, Types::String.optional
840840
@@ -899,9 +899,9 @@ class AxisConfig < Dry::Struct
899899 short_time_labels: d["shortTimeLabels"],
900900 tick_color: d["tickColor"],
901901 tick_round: d["tickRound"],
902- ticks: d["ticks"],
903902 tick_size: d["tickSize"],
904903 tick_width: d["tickWidth"],
904+ ticks: d["ticks"],
905905 title_align: d["titleAlign"],
906906 title_angle: d["titleAngle"],
907907 title_baseline: d["titleBaseline"],
@@ -947,9 +947,9 @@ class AxisConfig < Dry::Struct
947947 "shortTimeLabels" => short_time_labels,
948948 "tickColor" => tick_color,
949949 "tickRound" => tick_round,
950- "ticks" => ticks,
951950 "tickSize" => tick_size,
952951 "tickWidth" => tick_width,
952+ "ticks" => ticks,
953953 "titleAlign" => title_align,
954954 "titleAngle" => title_angle,
955955 "titleBaseline" => title_baseline,
@@ -1099,15 +1099,15 @@ class VGAxisConfig < Dry::Struct
10991099 # Boolean flag indicating if pixel position values should be rounded to the nearest integer.
11001100 attribute :tick_round, Types::Bool.optional
11011101
1102- # Boolean value that determines whether the axis should include ticks.
1103- attribute :ticks, Types::Bool.optional
1104-
11051102 # The size in pixels of axis ticks.
11061103 attribute :tick_size, Types::Double.optional
11071104
11081105 # The width, in pixels, of ticks.
11091106 attribute :tick_width, Types::Double.optional
11101107
1108+ # Boolean value that determines whether the axis should include ticks.
1109+ attribute :ticks, Types::Bool.optional
1110+
11111111 # Horizontal text alignment of axis titles.
11121112 attribute :title_align, Types::String.optional
11131113
@@ -1171,9 +1171,9 @@ class VGAxisConfig < Dry::Struct
11711171 min_extent: d["minExtent"],
11721172 tick_color: d["tickColor"],
11731173 tick_round: d["tickRound"],
1174- ticks: d["ticks"],
11751174 tick_size: d["tickSize"],
11761175 tick_width: d["tickWidth"],
1176+ ticks: d["ticks"],
11771177 title_align: d["titleAlign"],
11781178 title_angle: d["titleAngle"],
11791179 title_baseline: d["titleBaseline"],
@@ -1218,9 +1218,9 @@ class VGAxisConfig < Dry::Struct
12181218 "minExtent" => min_extent,
12191219 "tickColor" => tick_color,
12201220 "tickRound" => tick_round,
1221- "ticks" => ticks,
12221221 "tickSize" => tick_size,
12231222 "tickWidth" => tick_width,
1223+ "ticks" => ticks,
12241224 "titleAlign" => title_align,
12251225 "titleAngle" => title_angle,
12261226 "titleBaseline" => title_baseline,
@@ -1295,6 +1295,11 @@ class BarConfig < Dry::Struct
12951295 # __Default value:__ (None)
12961296 attribute :fill, Types::String.optional
12971297
1298+ # The fill opacity (value between [0,1]).
1299+ #
1300+ # __Default value:__ `1`
1301+ attribute :fill_opacity, Types::Double.optional
1302+
12981303 # Whether the mark's color should be used as fill color instead of stroke color.
12991304 #
13001305 # __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -1304,11 +1309,6 @@ class BarConfig < Dry::Struct
13041309 # __Note:__ This property cannot be used in a [style config](mark.html#style-config).
13051310 attribute :filled, Types::Bool.optional
13061311
1307- # The fill opacity (value between [0,1]).
1308- #
1309- # __Default value:__ `1`
1310- attribute :fill_opacity, Types::Double.optional
1311-
13121312 # The typeface to set the text in (e.g., `"Helvetica Neue"`).
13131313 attribute :font, Types::String.optional
13141314
@@ -1427,8 +1427,8 @@ class BarConfig < Dry::Struct
14271427 dx: d["dx"],
14281428 dy: d["dy"],
14291429 fill: d["fill"],
1430- filled: d["filled"],
14311430 fill_opacity: d["fillOpacity"],
1431+ filled: d["filled"],
14321432 font: d["font"],
14331433 font_size: d["fontSize"],
14341434 font_style: d["fontStyle"],
@@ -1469,8 +1469,8 @@ class BarConfig < Dry::Struct
14691469 "dx" => dx,
14701470 "dy" => dy,
14711471 "fill" => fill,
1472- "filled" => filled,
14731472 "fillOpacity" => fill_opacity,
1473+ "filled" => filled,
14741474 "font" => font,
14751475 "fontSize" => font_size,
14761476 "fontStyle" => font_style,
@@ -2973,6 +2973,11 @@ class TextConfig < Dry::Struct
29732973 # __Default value:__ (None)
29742974 attribute :fill, Types::String.optional
29752975
2976+ # The fill opacity (value between [0,1]).
2977+ #
2978+ # __Default value:__ `1`
2979+ attribute :fill_opacity, Types::Double.optional
2980+
29762981 # Whether the mark's color should be used as fill color instead of stroke color.
29772982 #
29782983 # __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -2982,11 +2987,6 @@ class TextConfig < Dry::Struct
29822987 # __Note:__ This property cannot be used in a [style config](mark.html#style-config).
29832988 attribute :filled, Types::Bool.optional
29842989
2985- # The fill opacity (value between [0,1]).
2986- #
2987- # __Default value:__ `1`
2988- attribute :fill_opacity, Types::Double.optional
2989-
29902990 # The typeface to set the text in (e.g., `"Helvetica Neue"`).
29912991 attribute :font, Types::String.optional
29922992
@@ -3105,8 +3105,8 @@ class TextConfig < Dry::Struct
31053105 dx: d["dx"],
31063106 dy: d["dy"],
31073107 fill: d["fill"],
3108- filled: d["filled"],
31093108 fill_opacity: d["fillOpacity"],
3109+ filled: d["filled"],
31103110 font: d["font"],
31113111 font_size: d["fontSize"],
31123112 font_style: d["fontStyle"],
@@ -3145,8 +3145,8 @@ class TextConfig < Dry::Struct
31453145 "dx" => dx,
31463146 "dy" => dy,
31473147 "fill" => fill,
3148- "filled" => filled,
31493148 "fillOpacity" => fill_opacity,
3149+ "filled" => filled,
31503150 "font" => font,
31513151 "fontSize" => font_size,
31523152 "fontStyle" => font_style,
@@ -3220,6 +3220,11 @@ class TickConfig < Dry::Struct
32203220 # __Default value:__ (None)
32213221 attribute :fill, Types::String.optional
32223222
3223+ # The fill opacity (value between [0,1]).
3224+ #
3225+ # __Default value:__ `1`
3226+ attribute :fill_opacity, Types::Double.optional
3227+
32233228 # Whether the mark's color should be used as fill color instead of stroke color.
32243229 #
32253230 # __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -3229,11 +3234,6 @@ class TickConfig < Dry::Struct
32293234 # __Note:__ This property cannot be used in a [style config](mark.html#style-config).
32303235 attribute :filled, Types::Bool.optional
32313236
3232- # The fill opacity (value between [0,1]).
3233- #
3234- # __Default value:__ `1`
3235- attribute :fill_opacity, Types::Double.optional
3236-
32373237 # The typeface to set the text in (e.g., `"Helvetica Neue"`).
32383238 attribute :font, Types::String.optional
32393239
@@ -3355,8 +3355,8 @@ class TickConfig < Dry::Struct
33553355 dx: d["dx"],
33563356 dy: d["dy"],
33573357 fill: d["fill"],
3358- filled: d["filled"],
33593358 fill_opacity: d["fillOpacity"],
3359+ filled: d["filled"],
33603360 font: d["font"],
33613361 font_size: d["fontSize"],
33623362 font_style: d["fontStyle"],
@@ -3396,8 +3396,8 @@ class TickConfig < Dry::Struct
33963396 "dx" => dx,
33973397 "dy" => dy,
33983398 "fill" => fill,
3399- "filled" => filled,
34003399 "fillOpacity" => fill_opacity,
3400+ "filled" => filled,
34013401 "font" => font,
34023402 "fontSize" => font_size,
34033403 "fontStyle" => font_style,
@@ -7184,12 +7184,12 @@ class Axis < Dry::Struct
71847184 # underlying scale's range.
71857185 attribute :tick_count, Types::Double.optional
71867186
7187- # Boolean value that determines whether the axis should include ticks.
7188- attribute :ticks, Types::Bool.optional
7189-
71907187 # The size in pixels of axis ticks.
71917188 attribute :tick_size, Types::Double.optional
71927189
7190+ # Boolean value that determines whether the axis should include ticks.
7191+ attribute :ticks, Types::Bool.optional
7192+
71937193 # A title for the field. If `null`, the title will be removed.
71947194 #
71957195 # __Default value:__ derived from the field's name and transformation function
@@ -7240,8 +7240,8 @@ class Axis < Dry::Struct
72407240 orient: d["orient"],
72417241 position: d["position"],
72427242 tick_count: d["tickCount"],
7243- ticks: d["ticks"],
72447243 tick_size: d["tickSize"],
7244+ ticks: d["ticks"],
72457245 title: d["title"],
72467246 title_max_length: d["titleMaxLength"],
72477247 title_padding: d["titlePadding"],
@@ -7271,8 +7271,8 @@ class Axis < Dry::Struct
72717271 "orient" => orient,
72727272 "position" => position,
72737273 "tickCount" => tick_count,
7274- "ticks" => ticks,
72757274 "tickSize" => tick_size,
7275+ "ticks" => ticks,
72767276 "title" => title,
72777277 "titleMaxLength" => title_max_length,
72787278 "titlePadding" => title_padding,
@@ -7877,6 +7877,11 @@ class MarkDef < Dry::Struct
78777877 # __Default value:__ (None)
78787878 attribute :fill, Types::String.optional
78797879
7880+ # The fill opacity (value between [0,1]).
7881+ #
7882+ # __Default value:__ `1`
7883+ attribute :fill_opacity, Types::Double.optional
7884+
78807885 # Whether the mark's color should be used as fill color instead of stroke color.
78817886 #
78827887 # __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -7886,11 +7891,6 @@ class MarkDef < Dry::Struct
78867891 # __Note:__ This property cannot be used in a [style config](mark.html#style-config).
78877892 attribute :filled, Types::Bool.optional
78887893
7889- # The fill opacity (value between [0,1]).
7890- #
7891- # __Default value:__ `1`
7892- attribute :fill_opacity, Types::Double.optional
7893-
78947894 # The typeface to set the text in (e.g., `"Helvetica Neue"`).
78957895 attribute :font, Types::String.optional
78967896
@@ -8025,8 +8025,8 @@ class MarkDef < Dry::Struct
80258025 dx: d["dx"],
80268026 dy: d["dy"],
80278027 fill: d["fill"],
8028- filled: d["filled"],
80298028 fill_opacity: d["fillOpacity"],
8029+ filled: d["filled"],
80308030 font: d["font"],
80318031 font_size: d["fontSize"],
80328032 font_style: d["fontStyle"],
@@ -8067,8 +8067,8 @@ class MarkDef < Dry::Struct
80678067 "dx" => dx,
80688068 "dy" => dy,
80698069 "fill" => fill,
8070- "filled" => filled,
80718070 "fillOpacity" => fill_opacity,
8071+ "filled" => filled,
80728072 "font" => font,
80738073 "fontSize" => font_size,
80748074 "fontStyle" => font_style,
Mschema-rust/test/inputs/schema/accessors.schema/default/module_under_test.rs+4 −4
@@ -15,16 +15,16 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- #[serde(rename = "bar")]
19- pub barre: String,
18+ #[serde(rename = "union")]
19+ pub unionization: Union,
2020
2121 #[serde(rename = "enum")]
2222 pub enumerification: Enum,
2323
2424 pub foo: String,
2525
26- #[serde(rename = "union")]
27- pub unionization: Union,
26+ #[serde(rename = "bar")]
27+ pub barre: String,
2828 }
2929
3030 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/all-of-additional-properties-false.schema/default/module_under_test.rs+2 −2
@@ -19,10 +19,10 @@ pub struct TopLevel {
1919
2020 pub frequency: Frequency,
2121
22- pub description: Option<String>,
23-
2422 #[serde(rename = "type")]
2523 pub top_level_type: Type,
24+
25+ pub description: Option<String>,
2626 }
2727
2828 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/bool-string.schema/default/module_under_test.rs+4 −4
@@ -16,15 +16,15 @@ use serde::{Serialize, Deserialize};
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 #[serde(rename_all = "camelCase")]
1818 pub struct TopLevel {
19- pub arr_nullable: Option<Vec<Option<String>>>,
19+ pub one: String,
2020
21- pub arr_one: Option<Vec<String>>,
21+ pub optional: Option<String>,
2222
2323 pub nullable: Option<String>,
2424
25- pub one: String,
25+ pub arr_one: Option<Vec<String>>,
2626
27- pub optional: Option<String>,
27+ pub arr_nullable: Option<Vec<Option<String>>>,
2828
2929 pub union_with_bool: UnionWithBool,
Mschema-rust/test/inputs/schema/boolean-subschema.schema/default/module_under_test.rs+2 −2
@@ -15,11 +15,11 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18+ pub foo: String,
19+
1820 pub disallowed: Option<serde_json::Value>,
1921
2022 pub empty: Vec<Option<serde_json::Value>>,
2123
22- pub foo: String,
23-
2424 pub impossible: Option<serde_json::Value>,
2525 }
Mschema-rust/test/inputs/schema/comment-injection.schema/default/module_under_test.rs+9 −9
@@ -28,15 +28,6 @@ use serde::{Serialize, Deserialize};
2828 #[derive(Debug, Clone, Serialize, Deserialize)]
2929 #[serde(rename_all = "camelCase")]
3030 pub struct TopLevel {
31- /// Ends with a backslash \
32- pub trailing_backslash: Option<String>,
33-
34- /// Ends with a quote "
35- pub trailing_quote: Option<String>,
36-
37- /// Ends with a triple quote """
38- pub trailing_triple_quote: Option<String>,
39-
4031 /// Property delimiters:
4132 /// */
4233 /// /*
@@ -50,4 +41,13 @@ pub struct TopLevel {
5041 /// }
5142 /// }
5243 pub value: String,
44+
45+ /// Ends with a backslash \
46+ pub trailing_backslash: Option<String>,
47+
48+ /// Ends with a quote "
49+ pub trailing_quote: Option<String>,
50+
51+ /// Ends with a triple quote """
52+ pub trailing_triple_quote: Option<String>,
5353 }
Mschema-rust/test/inputs/schema/const-non-string.schema/default/module_under_test.rs+4 −4
@@ -15,15 +15,15 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18+ pub version: f64,
19+
1820 pub amount: i64,
1921
22+ pub ratio: f64,
23+
2024 pub enabled: bool,
2125
2226 pub kind: Kind,
23-
24- pub ratio: f64,
25-
26- pub version: f64,
2727 }
2828
2929 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/date-time-or-string.schema/default/module_under_test.rs+2 −2
@@ -15,7 +15,7 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- pub bar: String,
19-
2018 pub foo: String,
19+
20+ pub bar: String,
2121 }
Mschema-rust/test/inputs/schema/date-time.schema/default/module_under_test.rs+4 −4
@@ -16,15 +16,15 @@ use serde::{Serialize, Deserialize};
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 #[serde(rename_all = "kebab-case")]
1818 pub struct TopLevel {
19- pub complex_union_array: Vec<ComplexUnionArray>,
20-
2119 pub date: String,
2220
23- pub date_time: String,
24-
2521 pub time: String,
2622
23+ pub date_time: String,
24+
2725 pub union_array: Vec<String>,
26+
27+ pub complex_union_array: Vec<ComplexUnionArray>,
2828 }
2929
3030 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/description.schema/default/module_under_test.rs+6 −6
@@ -18,8 +18,9 @@ use serde::{Serialize, Deserialize};
1818 #[derive(Debug, Clone, Serialize, Deserialize)]
1919 #[serde(rename_all = "kebab-case")]
2020 pub struct TopLevel {
21- /// A pretty boolean
22- pub bar: Option<bool>,
21+ /// Either a number or a string
22+ #[serde(rename = "union")]
23+ pub top_level_union: Union,
2324
2425 /// An enumeration
2526 #[serde(rename = "enum")]
@@ -27,11 +28,10 @@ pub struct TopLevel {
2728
2829 pub foo: Option<f64>,
2930
30- pub object_or_string: ObjectOrStringUnion,
31+ /// A pretty boolean
32+ pub bar: Option<bool>,
3133
32- /// Either a number or a string
33- #[serde(rename = "union")]
34- pub top_level_union: Union,
34+ pub object_or_string: ObjectOrStringUnion,
3535 }
3636
3737 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/direct-union.schema/default/module_under_test.rs+2 −2
@@ -21,9 +21,9 @@ pub struct TopLevel {
2121
2222 #[derive(Debug, Clone, Serialize, Deserialize)]
2323 pub struct Thing {
24- pub optional: Option<Anything>,
25-
2624 pub required: Option<Anything>,
25+
26+ pub optional: Option<Anything>,
2727 }
2828
2929 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/enum.schema/default/module_under_test.rs+5 −5
@@ -16,16 +16,16 @@ use serde::{Serialize, Deserialize};
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 #[serde(rename_all = "camelCase")]
1818 pub struct TopLevel {
19- pub arr: Option<Vec<Arr>>,
20-
21- #[serde(rename = "for")]
22- pub top_level_for: Option<String>,
19+ pub lvc: Option<Lvc>,
2320
2421 pub gve: Gve,
2522
26- pub lvc: Option<Lvc>,
23+ pub arr: Option<Vec<Arr>>,
2724
2825 pub other_arr: Option<Vec<OtherArr>>,
26+
27+ #[serde(rename = "for")]
28+ pub top_level_for: Option<String>,
2929 }
3030
3131 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/integer-string.schema/default/module_under_test.rs+4 −4
@@ -16,15 +16,15 @@ use serde::{Serialize, Deserialize};
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 #[serde(rename_all = "camelCase")]
1818 pub struct TopLevel {
19- pub arr_nullable: Option<Vec<Option<String>>>,
19+ pub one: String,
2020
21- pub arr_one: Option<Vec<String>>,
21+ pub optional: Option<String>,
2222
2323 pub nullable: Option<String>,
2424
25- pub one: String,
25+ pub arr_one: Option<Vec<String>>,
2626
27- pub optional: Option<String>,
27+ pub arr_nullable: Option<Vec<Option<String>>>,
2828
2929 pub union_with_int: UnionWithInt,
Mschema-rust/test/inputs/schema/integer-type.schema/default/module_under_test.rs+7 −7
@@ -15,21 +15,21 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- pub above_i32_max: i64,
18+ pub small_positive: i32,
1919
20- pub below_i32_min: i64,
20+ pub small_negative: i32,
2121
2222 pub i32_range: i32,
2323
24- pub large_bounds: i64,
24+ pub above_i32_max: i64,
2525
26- pub only_maximum: i64,
26+ pub below_i32_min: i64,
2727
2828 pub only_minimum: i64,
2929
30- pub small_negative: i32,
31-
32- pub small_positive: i32,
30+ pub only_maximum: i64,
3331
3432 pub unbounded: i64,
33+
34+ pub large_bounds: i64,
3535 }
Mschema-rust/test/inputs/schema/integer-type.schema/integer-type-conservative--3a501d5af5e7/module_under_test.rs+7 −7
@@ -15,21 +15,21 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- pub above_i32_max: i64,
18+ pub small_positive: i32,
1919
20- pub below_i32_min: i64,
20+ pub small_negative: i32,
2121
2222 pub i32_range: i32,
2323
24- pub large_bounds: i64,
24+ pub above_i32_max: i64,
2525
26- pub only_maximum: i64,
26+ pub below_i32_min: i64,
2727
2828 pub only_minimum: i64,
2929
30- pub small_negative: i32,
31-
32- pub small_positive: i32,
30+ pub only_maximum: i64,
3331
3432 pub unbounded: i64,
33+
34+ pub large_bounds: i64,
3535 }
Mschema-rust/test/inputs/schema/integer-type.schema/integer-type-force-i64--9c2eded45bf2/module_under_test.rs+7 −7
@@ -15,21 +15,21 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- pub above_i32_max: i64,
18+ pub small_positive: i64,
1919
20- pub below_i32_min: i64,
20+ pub small_negative: i64,
2121
2222 pub i32_range: i64,
2323
24- pub large_bounds: i64,
24+ pub above_i32_max: i64,
2525
26- pub only_maximum: i64,
26+ pub below_i32_min: i64,
2727
2828 pub only_minimum: i64,
2929
30- pub small_negative: i64,
31-
32- pub small_positive: i64,
30+ pub only_maximum: i64,
3331
3432 pub unbounded: i64,
33+
34+ pub large_bounds: i64,
3535 }
Mschema-rust/test/inputs/schema/keyword-unions.schema/default/module_under_test.rs+4 −4
@@ -188,8 +188,6 @@ pub struct TopLevel {
188188
189189 pub double: Option<UnionDouble>,
190190
191- pub dummy: Option<f64>,
192-
193191 pub dynamic: Option<UnionDynamic>,
194192
195193 pub dynamic_cast: Option<UnionDynamicCast>,
@@ -305,10 +303,10 @@ pub struct TopLevel {
305303
306304 pub internal: Option<UnionInternal>,
307305
308- pub is: Option<UnionIs>,
309-
310306 pub iterable: Option<UnionIterable>,
311307
308+ pub is: Option<UnionIs>,
309+
312310 pub jdec: Option<UnionJdec>,
313311
314312 pub jenc: Option<UnionJenc>,
@@ -632,6 +630,8 @@ pub struct TopLevel {
632630
633631 #[serde(rename = "yield")]
634632 pub top_level_yield: Option<UnionYield>,
633+
634+ pub dummy: Option<f64>,
635635 }
636636
637637 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/light.schema/default/module_under_test.rs+2 −2
@@ -21,9 +21,9 @@ pub struct TopLevel {
2121
2222 #[derive(Debug, Clone, Serialize, Deserialize)]
2323 pub struct LightParams {
24- pub app_id: String,
25-
2624 pub outlet_id: String,
2725
26+ pub app_id: String,
27+
2828 pub rgba: String,
2929 }
Mschema-rust/test/inputs/schema/min-max-items.schema/default/module_under_test.rs+2 −2
@@ -16,12 +16,12 @@ use serde::{Serialize, Deserialize};
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 #[serde(rename_all = "camelCase")]
1818 pub struct TopLevel {
19+ pub min_only: Vec<String>,
20+
1921 pub max_only: Vec<i64>,
2022
2123 pub min_and_max: Vec<f64>,
2224
23- pub min_only: Vec<String>,
24-
2525 pub plain: Vec<String>,
2626
2727 pub union_items: Vec<UnionItem>,
Mschema-rust/test/inputs/schema/minmax-integer.schema/default/module_under_test.rs+6 −6
@@ -18,18 +18,18 @@ use serde::{Serialize, Deserialize};
1818 pub struct TopLevel {
1919 pub free: i64,
2020
21- pub intersection: i32,
21+ pub min: i64,
2222
2323 pub max: i64,
2424
25- pub min: i64,
26-
2725 pub minmax: i32,
2826
29- pub min_max_intersection: i32,
27+ #[serde(rename = "union")]
28+ pub top_level_union: i32,
3029
3130 pub min_max_union: i64,
3231
33- #[serde(rename = "union")]
34- pub top_level_union: i32,
32+ pub intersection: i32,
33+
34+ pub min_max_intersection: i32,
3535 }
Mschema-rust/test/inputs/schema/minmax-integer.schema/integer-type-force-i32--513c6f621a11/module_under_test.rs+6 −6
@@ -18,18 +18,18 @@ use serde::{Serialize, Deserialize};
1818 pub struct TopLevel {
1919 pub free: i32,
2020
21- pub intersection: i32,
21+ pub min: i32,
2222
2323 pub max: i32,
2424
25- pub min: i32,
26-
2725 pub minmax: i32,
2826
29- pub min_max_intersection: i32,
27+ #[serde(rename = "union")]
28+ pub top_level_union: i32,
3029
3130 pub min_max_union: i32,
3231
33- #[serde(rename = "union")]
34- pub top_level_union: i32,
32+ pub intersection: i32,
33+
34+ pub min_max_intersection: i32,
3535 }
Mschema-rust/test/inputs/schema/minmax.schema/default/module_under_test.rs+6 −6
@@ -18,18 +18,18 @@ use serde::{Serialize, Deserialize};
1818 pub struct TopLevel {
1919 pub free: f64,
2020
21- pub intersection: f64,
21+ pub min: f64,
2222
2323 pub max: f64,
2424
25- pub min: f64,
26-
2725 pub minmax: f64,
2826
29- pub min_max_intersection: f64,
27+ #[serde(rename = "union")]
28+ pub top_level_union: f64,
3029
3130 pub min_max_union: f64,
3231
33- #[serde(rename = "union")]
34- pub top_level_union: f64,
32+ pub intersection: f64,
33+
34+ pub min_max_intersection: f64,
3535 }
Mschema-rust/test/inputs/schema/minmaxlength.schema/default/module_under_test.rs+8 −8
@@ -16,22 +16,22 @@ use serde::{Serialize, Deserialize};
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 #[serde(rename_all = "camelCase")]
1818 pub struct TopLevel {
19- pub intersection: String,
20-
21- pub in_union: InUnion,
19+ pub minlength: String,
2220
2321 pub maxlength: String,
2422
25- pub minlength: String,
23+ pub minmaxlength: String,
2624
27- pub min_max_intersection: String,
25+ #[serde(rename = "union")]
26+ pub top_level_union: String,
2827
29- pub minmaxlength: String,
28+ pub in_union: InUnion,
3029
3130 pub min_max_union: String,
3231
33- #[serde(rename = "union")]
34- pub top_level_union: String,
32+ pub intersection: String,
33+
34+ pub min_max_intersection: String,
3535 }
3636
3737 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/non-standard-ref.schema/default/module_under_test.rs+2 −2
@@ -15,9 +15,9 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- pub bar: i64,
19-
2018 pub foo: i64,
2119
20+ pub bar: i64,
21+
2222 pub quux: bool,
2323 }
Mschema-rust/test/inputs/schema/nullable-optional-one-of.schema/default/module_under_test.rs+2 −2
@@ -15,9 +15,9 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- pub b: Option<String>,
19-
2018 pub kind: Kind,
19+
20+ pub b: Option<String>,
2121 }
2222
2323 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/optional-any.schema/default/module_under_test.rs+2 −2
@@ -15,7 +15,7 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- pub bar: bool,
19-
2018 pub foo: Option<serde_json::Value>,
19+
20+ pub bar: bool,
2121 }
Mschema-rust/test/inputs/schema/optional-const-ref.schema/default/module_under_test.rs+5 −5
@@ -18,17 +18,17 @@ use serde::{Serialize, Deserialize};
1818 pub struct TopLevel {
1919 pub coordinates: Option<Vec<Coordinate>>,
2020
21+ pub required_coordinates: Vec<Coordinate>,
22+
2123 pub count: Option<i32>,
2224
23- pub label: Option<String>,
25+ pub required_count: i32,
2426
25- pub required_coordinates: Vec<Coordinate>,
27+ pub weight: Option<f64>,
2628
27- pub required_count: i32,
29+ pub label: Option<String>,
2830
2931 pub required_label: String,
30-
31- pub weight: Option<f64>,
3232 }
3333
3434 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/optional-constraints.schema/default/module_under_test.rs+3 −3
@@ -16,13 +16,13 @@ use serde::{Serialize, Deserialize};
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 #[serde(rename_all = "camelCase")]
1818 pub struct TopLevel {
19- pub opt_double: Option<f64>,
19+ pub req_zero_min: i32,
2020
2121 pub opt_int: Option<i32>,
2222
23- pub opt_pattern: Option<String>,
23+ pub opt_double: Option<f64>,
2424
2525 pub opt_string: Option<String>,
2626
27- pub req_zero_min: i32,
27+ pub opt_pattern: Option<String>,
2828 }
Mschema-rust/test/inputs/schema/optional-date-time.schema/default/module_under_test.rs+6 −6
@@ -16,15 +16,15 @@ use serde::{Serialize, Deserialize};
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 #[serde(rename_all = "kebab-case")]
1818 pub struct TopLevel {
19- pub optional_date: Option<String>,
19+ pub required_date: String,
2020
21- pub optional_date_time: Option<String>,
21+ pub required_time: String,
2222
23- pub optional_time: Option<String>,
23+ pub required_date_time: String,
2424
25- pub required_date: String,
25+ pub optional_date: Option<String>,
2626
27- pub required_date_time: String,
27+ pub optional_time: Option<String>,
2828
29- pub required_time: String,
29+ pub optional_date_time: Option<String>,
3030 }
Mschema-rust/test/inputs/schema/prefix-items.schema/default/module_under_test.rs+2 −2
@@ -15,9 +15,9 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- pub open: Vec<Open>,
19-
2018 pub tuple: Vec<Open>,
19+
20+ pub open: Vec<Open>,
2121 }
2222
2323 #[derive(Debug, Clone, Serialize, Deserialize)]
Aschema-rust/test/inputs/schema/property-order.schema/default/module_under_test.rs+38 −0
@@ -0,0 +1,38 @@
1+// Example code that deserializes and serializes the model.
2+// extern crate serde;
3+// #[macro_use]
4+// extern crate serde_derive;
5+// extern crate serde_json;
6+//
7+// use generated_module::TopLevel;
8+//
9+// fn main() {
10+// let json = r#"{"answer": 42}"#;
11+// let model: TopLevel = serde_json::from_str(&json).unwrap();
12+// }
13+
14+use serde::{Serialize, Deserialize};
15+
16+#[derive(Debug, Clone, Serialize, Deserialize)]
17+pub struct TopLevel {
18+ pub zebra: String,
19+
20+ pub mango: f64,
21+
22+ pub apple: bool,
23+
24+ pub delta: String,
25+
26+ pub banana: i64,
27+
28+ pub ordered: Ordered,
29+}
30+
31+#[derive(Debug, Clone, Serialize, Deserialize)]
32+pub struct Ordered {
33+ pub mango: f64,
34+
35+ pub zebra: String,
36+
37+ pub apple: bool,
38+}
Mschema-rust/test/inputs/schema/renaming-bug.schema/default/module_under_test.rs+16 −16
@@ -26,17 +26,17 @@ pub struct TopLevel {
2626 pub struct Fruit {
2727 pub apple: Option<bool>,
2828
29- pub berries: Option<Vec<Berry>>,
30-
3129 pub orange: Option<bool>,
30+
31+ pub berries: Option<Vec<Berry>>,
3232 }
3333
3434 #[derive(Debug, Clone, Serialize, Deserialize)]
3535 pub struct Berry {
36- pub color: Option<Color>,
37-
3836 pub name: Option<String>,
3937
38+ pub color: Option<Color>,
39+
4040 pub shapes: Option<Vec<Shape>>,
4141 }
4242
@@ -47,9 +47,9 @@ pub struct Color {
4747
4848 #[derive(Debug, Clone, Serialize, Deserialize)]
4949 pub struct Shape {
50- pub geometry: Option<Geometry>,
51-
5250 pub history: Option<History>,
51+
52+ pub geometry: Option<Geometry>,
5353 }
5454
5555 #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -73,11 +73,11 @@ pub struct RectShape {
7373
7474 #[derive(Debug, Clone, Serialize, Deserialize)]
7575 pub struct Part {
76- pub depth: Option<String>,
77-
7876 pub length: Option<String>,
7977
8078 pub width: Option<String>,
79+
80+ pub depth: Option<String>,
8181 }
8282
8383 #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -88,18 +88,18 @@ pub struct History {
8888 #[derive(Debug, Clone, Serialize, Deserialize)]
8989 #[serde(rename_all = "camelCase")]
9090 pub struct Vehicle {
91- pub brand: Option<String>,
92-
9391 pub id: Option<String>,
9492
95- pub speed: Option<Speed>,
96-
97- pub sub_module: Option<bool>,
98-
9993 #[serde(rename = "type")]
10094 pub vehicle_type: Option<VehicleType>,
10195
96+ pub speed: Option<Speed>,
97+
10298 pub year: Option<String>,
99+
100+ pub brand: Option<String>,
101+
102+ pub sub_module: Option<bool>,
103103 }
104104
105105 #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -109,9 +109,9 @@ pub struct Speed {
109109
110110 #[derive(Debug, Clone, Serialize, Deserialize)]
111111 pub struct Limit {
112- pub maximum: Option<f64>,
113-
114112 pub minimum: Option<f64>,
113+
114+ pub maximum: Option<f64>,
115115 }
116116
117117 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/rust-cycle-breaker-union.schema/default/module_under_test.rs+4 −4
@@ -15,16 +15,16 @@ use serde::{Serialize, Deserialize};
1515
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 pub struct TopLevel {
18- pub next: Option<Box<Next>>,
19-
2018 pub value: String,
19+
20+ pub next: Option<Box<Next>>,
2121 }
2222
2323 #[derive(Debug, Clone, Serialize, Deserialize)]
2424 pub struct Node {
25- pub next: Option<Box<Next>>,
26-
2725 pub value: String,
26+
27+ pub next: Option<Box<Next>>,
2828 }
2929
3030 #[derive(Debug, Clone, Serialize, Deserialize)]
Mschema-rust/test/inputs/schema/uuid.schema/default/module_under_test.rs+4 −4
@@ -16,15 +16,15 @@ use serde::{Serialize, Deserialize};
1616 #[derive(Debug, Clone, Serialize, Deserialize)]
1717 #[serde(rename_all = "camelCase")]
1818 pub struct TopLevel {
19- pub arr_nullable: Option<Vec<Option<String>>>,
19+ pub one: String,
2020
21- pub arr_one: Option<Vec<String>>,
21+ pub optional: Option<String>,
2222
2323 pub nullable: Option<String>,
2424
25- pub one: String,
25+ pub arr_one: Option<Vec<String>>,
2626
27- pub optional: Option<String>,
27+ pub arr_nullable: Option<Vec<Option<String>>>,
2828
2929 pub union_with_enum: String,
3030 }
Mschema-rust/test/inputs/schema/vega-lite.schema/default/module_under_test.rs+34 −34
@@ -448,6 +448,11 @@ pub struct MarkConfig {
448448 /// __Default value:__ (None)
449449 pub fill: Option<String>,
450450
451+ /// The fill opacity (value between [0,1]).
452+ ///
453+ /// __Default value:__ `1`
454+ pub fill_opacity: Option<f64>,
455+
451456 /// Whether the mark's color should be used as fill color instead of stroke color.
452457 ///
453458 /// __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -457,11 +462,6 @@ pub struct MarkConfig {
457462 /// __Note:__ This property cannot be used in a [style config](mark.html#style-config).
458463 pub filled: Option<bool>,
459464
460- /// The fill opacity (value between [0,1]).
461- ///
462- /// __Default value:__ `1`
463- pub fill_opacity: Option<f64>,
464-
465465 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
466466 pub font: Option<String>,
467467
@@ -918,15 +918,15 @@ pub struct AxisConfig {
918918 /// Boolean flag indicating if pixel position values should be rounded to the nearest integer.
919919 pub tick_round: Option<bool>,
920920
921- /// Boolean value that determines whether the axis should include ticks.
922- pub ticks: Option<bool>,
923-
924921 /// The size in pixels of axis ticks.
925922 pub tick_size: Option<f64>,
926923
927924 /// The width, in pixels, of ticks.
928925 pub tick_width: Option<f64>,
929926
927+ /// Boolean value that determines whether the axis should include ticks.
928+ pub ticks: Option<bool>,
929+
930930 /// Horizontal text alignment of axis titles.
931931 pub title_align: Option<String>,
932932
@@ -1147,15 +1147,15 @@ pub struct VgAxisConfig {
11471147 /// Boolean flag indicating if pixel position values should be rounded to the nearest integer.
11481148 pub tick_round: Option<bool>,
11491149
1150- /// Boolean value that determines whether the axis should include ticks.
1151- pub ticks: Option<bool>,
1152-
11531150 /// The size in pixels of axis ticks.
11541151 pub tick_size: Option<f64>,
11551152
11561153 /// The width, in pixels, of ticks.
11571154 pub tick_width: Option<f64>,
11581155
1156+ /// Boolean value that determines whether the axis should include ticks.
1157+ pub ticks: Option<bool>,
1158+
11591159 /// Horizontal text alignment of axis titles.
11601160 pub title_align: Option<String>,
11611161
@@ -1249,6 +1249,11 @@ pub struct BarConfig {
12491249 /// __Default value:__ (None)
12501250 pub fill: Option<String>,
12511251
1252+ /// The fill opacity (value between [0,1]).
1253+ ///
1254+ /// __Default value:__ `1`
1255+ pub fill_opacity: Option<f64>,
1256+
12521257 /// Whether the mark's color should be used as fill color instead of stroke color.
12531258 ///
12541259 /// __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -1258,11 +1263,6 @@ pub struct BarConfig {
12581263 /// __Note:__ This property cannot be used in a [style config](mark.html#style-config).
12591264 pub filled: Option<bool>,
12601265
1261- /// The fill opacity (value between [0,1]).
1262- ///
1263- /// __Default value:__ `1`
1264- pub fill_opacity: Option<f64>,
1265-
12661266 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
12671267 pub font: Option<String>,
12681268
@@ -2349,6 +2349,11 @@ pub struct TextConfig {
23492349 /// __Default value:__ (None)
23502350 pub fill: Option<String>,
23512351
2352+ /// The fill opacity (value between [0,1]).
2353+ ///
2354+ /// __Default value:__ `1`
2355+ pub fill_opacity: Option<f64>,
2356+
23522357 /// Whether the mark's color should be used as fill color instead of stroke color.
23532358 ///
23542359 /// __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -2358,11 +2363,6 @@ pub struct TextConfig {
23582363 /// __Note:__ This property cannot be used in a [style config](mark.html#style-config).
23592364 pub filled: Option<bool>,
23602365
2361- /// The fill opacity (value between [0,1]).
2362- ///
2363- /// __Default value:__ `1`
2364- pub fill_opacity: Option<f64>,
2365-
23662366 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
23672367 pub font: Option<String>,
23682368
@@ -2516,6 +2516,11 @@ pub struct TickConfig {
25162516 /// __Default value:__ (None)
25172517 pub fill: Option<String>,
25182518
2519+ /// The fill opacity (value between [0,1]).
2520+ ///
2521+ /// __Default value:__ `1`
2522+ pub fill_opacity: Option<f64>,
2523+
25192524 /// Whether the mark's color should be used as fill color instead of stroke color.
25202525 ///
25212526 /// __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -2525,11 +2530,6 @@ pub struct TickConfig {
25252530 /// __Note:__ This property cannot be used in a [style config](mark.html#style-config).
25262531 pub filled: Option<bool>,
25272532
2528- /// The fill opacity (value between [0,1]).
2529- ///
2530- /// __Default value:__ `1`
2531- pub fill_opacity: Option<f64>,
2532-
25332533 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
25342534 pub font: Option<String>,
25352535
@@ -4929,12 +4929,12 @@ pub struct Axis {
49294929 /// underlying scale's range.
49304930 pub tick_count: Option<f64>,
49314931
4932- /// Boolean value that determines whether the axis should include ticks.
4933- pub ticks: Option<bool>,
4934-
49354932 /// The size in pixels of axis ticks.
49364933 pub tick_size: Option<f64>,
49374934
4935+ /// Boolean value that determines whether the axis should include ticks.
4936+ pub ticks: Option<bool>,
4937+
49384938 /// A title for the field. If `null`, the title will be removed.
49394939 ///
49404940 /// __Default value:__ derived from the field's name and transformation function
@@ -5362,6 +5362,11 @@ pub struct MarkDef {
53625362 /// __Default value:__ (None)
53635363 pub fill: Option<String>,
53645364
5365+ /// The fill opacity (value between [0,1]).
5366+ ///
5367+ /// __Default value:__ `1`
5368+ pub fill_opacity: Option<f64>,
5369+
53655370 /// Whether the mark's color should be used as fill color instead of stroke color.
53665371 ///
53675372 /// __Default value:__ `true` for all marks except `point` and `false` for `point`.
@@ -5371,11 +5376,6 @@ pub struct MarkDef {
53715376 /// __Note:__ This property cannot be used in a [style config](mark.html#style-config).
53725377 pub filled: Option<bool>,
53735378
5374- /// The fill opacity (value between [0,1]).
5375- ///
5376- /// __Default value:__ `1`
5377- pub fill_opacity: Option<f64>,
5378-
53795379 /// The typeface to set the text in (e.g., `"Helvetica Neue"`).
53805380 pub font: Option<String>,
Mschema-scala3-upickle/test/inputs/schema/accessors.schema/default/TopLevel.scala+2 −2
@@ -8,10 +8,10 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val bar : String,
11+ val union : Union,
1212 val `enum` : EnumEnum,
1313 val foo : String,
14- val union : Union
14+ val bar : String
1515 ) derives Encoder.AsObject, Decoder
1616
1717 enum EnumEnum :
Mschema-scala3-upickle/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.scala+2 −2
@@ -10,8 +10,8 @@ type NullValue = None.type
1010 case class TopLevel (
1111 val amount : Double,
1212 val frequency : Frequency,
13- val description : Option[String] = None,
14- val `type` : Type
13+ val `type` : Type,
14+ val description : Option[String] = None
1515 ) derives Encoder.AsObject, Decoder
1616
1717 enum Frequency :
Mschema-scala3-upickle/test/inputs/schema/bool-string.schema/default/TopLevel.scala+3 −3
@@ -8,11 +8,11 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val arrNullable : Option[Seq[Option[String]]] = None,
12- val arrOne : Option[Seq[String]] = None,
13- val nullable : Option[String] = None,
1411 val one : String,
1512 val optional : Option[String] = None,
13+ val nullable : Option[String] = None,
14+ val arrOne : Option[Seq[String]] = None,
15+ val arrNullable : Option[Seq[Option[String]]] = None,
1616 val unionWithBool : UnionWithBool,
1717 val unionWithBoolAndEnum : UnionWithBool
1818 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/boolean-subschema.schema/default/TopLevel.scala+1 −1
@@ -8,8 +8,8 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11+ val foo : String,
1112 val disallowed : Option[Json] = None,
1213 val empty : Seq[Option[Json]],
13- val foo : String,
1414 val impossible : Option[Json] = None
1515 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/comment-injection.schema/default/TopLevel.scala+16 −16
@@ -22,21 +22,6 @@ type NullValue = None.type
2222 * }
2323 */
2424 case class TopLevel (
25- /**
26- * Ends with a backslash \
27- */
28- val trailingBackslash : Option[String] = None,
29-
30- /**
31- * Ends with a quote "
32- */
33- val trailingQuote : Option[String] = None,
34-
35- /**
36- * Ends with a triple quote """
37- */
38- val trailingTripleQuote : Option[String] = None,
39-
4025 /**
4126 * Property delimiters:
4227 * * /
@@ -51,5 +36,20 @@ case class TopLevel (
5136 * }
5237 * }
5338 */
54- val value : String
39+ val value : String,
40+
41+ /**
42+ * Ends with a backslash \
43+ */
44+ val trailingBackslash : Option[String] = None,
45+
46+ /**
47+ * Ends with a quote "
48+ */
49+ val trailingQuote : Option[String] = None,
50+
51+ /**
52+ * Ends with a triple quote """
53+ */
54+ val trailingTripleQuote : Option[String] = None
5555 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/const-non-string.schema/default/TopLevel.scala+3 −3
@@ -8,11 +8,11 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11+ val version : Double,
1112 val amount : Long,
12- val enabled : Boolean,
13- val kind : Kind,
1413 val ratio : Double,
15- val version : Double
14+ val enabled : Boolean,
15+ val kind : Kind
1616 ) derives Encoder.AsObject, Decoder
1717
1818 enum Kind :
Mschema-scala3-upickle/test/inputs/schema/date-time-or-string.schema/default/TopLevel.scala+2 −2
@@ -8,6 +8,6 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val bar : String,
12- val foo : String
11+ val foo : String,
12+ val bar : String
1313 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/date-time.schema/default/TopLevel.scala+3 −3
@@ -8,11 +8,11 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val `complex-union-array` : Seq[ComplexUnionArray],
1211 val date : String,
13- val `date-time` : String,
1412 val time : String,
15- val `union-array` : Seq[String]
13+ val `date-time` : String,
14+ val `union-array` : Seq[String],
15+ val `complex-union-array` : Seq[ComplexUnionArray]
1616 ) derives Encoder.AsObject, Decoder
1717
1818 type ComplexUnionArray = Long | String
Mschema-scala3-upickle/test/inputs/schema/description.schema/default/TopLevel.scala+6 −5
@@ -13,9 +13,9 @@ type NullValue = None.type
1313 */
1414 case class TopLevel (
1515 /**
16- * A pretty boolean
16+ * Either a number or a string
1717 */
18- val bar : Option[Boolean] = None,
18+ val union : Union,
1919
2020 /**
2121 * An enumeration
@@ -23,12 +23,13 @@ case class TopLevel (
2323 val `enum` : EnumEnum,
2424
2525 val foo : Option[Double] = None,
26- val `object-or-string` : ObjectOrStringUnion,
2726
2827 /**
29- * Either a number or a string
28+ * A pretty boolean
3029 */
31- val union : Union
30+ val bar : Option[Boolean] = None,
31+
32+ val `object-or-string` : ObjectOrStringUnion
3233 ) derives Encoder.AsObject, Decoder
3334
3435 type ObjectOrStringUnion = ObjectOrStringClass | String
Mschema-scala3-upickle/test/inputs/schema/direct-union.schema/default/TopLevel.scala+2 −2
@@ -12,8 +12,8 @@ case class TopLevel (
1212 ) derives Encoder.AsObject, Decoder
1313
1414 case class Thing (
15- val optional : Option[Anything] = None,
16- val required : Anything
15+ val required : Anything,
16+ val optional : Option[Anything] = None
1717 ) derives Encoder.AsObject, Decoder
1818
1919 type Anything = Seq[Option[Json]] | Map[String, Option[Json]] | Boolean | Double | Long | String | NullValue
Mschema-scala3-upickle/test/inputs/schema/enum.schema/default/TopLevel.scala+4 −4
@@ -8,11 +8,11 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val arr : Option[Seq[Arr]] = None,
12- val `for` : Option[String] = None,
13- val gve : Gve,
1411 val lvc : Option[Lvc] = None,
15- val otherArr : Option[Seq[OtherArr]] = None
12+ val gve : Gve,
13+ val arr : Option[Seq[Arr]] = None,
14+ val otherArr : Option[Seq[OtherArr]] = None,
15+ val `for` : Option[String] = None
1616 ) derives Encoder.AsObject, Decoder
1717
1818 type Arr = OtherArr | Long
Mschema-scala3-upickle/test/inputs/schema/integer-string.schema/default/TopLevel.scala+3 −3
@@ -8,11 +8,11 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val arrNullable : Option[Seq[Option[String]]] = None,
12- val arrOne : Option[Seq[String]] = None,
13- val nullable : Option[String] = None,
1411 val one : String,
1512 val optional : Option[String] = None,
13+ val nullable : Option[String] = None,
14+ val arrOne : Option[Seq[String]] = None,
15+ val arrNullable : Option[Seq[Option[String]]] = None,
1616 val unionWithInt : UnionWithInt,
1717 val unionWithIntAndEnum : UnionWithInt
1818 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/integer-type.schema/default/TopLevel.scala+6 −6
@@ -8,13 +8,13 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11+ val small_positive : Long,
12+ val small_negative : Long,
13+ val i32_range : Long,
1114 val above_i32_max : Long,
1215 val below_i32_min : Long,
13- val i32_range : Long,
14- val large_bounds : Long,
15- val only_maximum : Long,
1616 val only_minimum : Long,
17- val small_negative : Long,
18- val small_positive : Long,
19- val unbounded : Long
17+ val only_maximum : Long,
18+ val unbounded : Long,
19+ val large_bounds : Long
2020 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/light.schema/default/TopLevel.scala+1 −1
@@ -12,7 +12,7 @@ case class TopLevel (
1212 ) derives Encoder.AsObject, Decoder
1313
1414 case class LightParams (
15- val app_id : String,
1615 val outlet_id : String,
16+ val app_id : String,
1717 val rgba : String
1818 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/min-max-items.schema/default/TopLevel.scala+1 −1
@@ -8,9 +8,9 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11+ val minOnly : Seq[String],
1112 val maxOnly : Seq[Long],
1213 val minAndMax : Seq[Double],
13- val minOnly : Seq[String],
1414 val plain : Seq[String],
1515 val unionItems : Seq[UnionItem]
1616 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/minmax-integer.schema/default/TopLevel.scala+4 −4
@@ -9,11 +9,11 @@ type NullValue = None.type
99
1010 case class TopLevel (
1111 val free : Long,
12- val intersection : Long,
13- val max : Long,
1412 val min : Long,
13+ val max : Long,
1514 val minmax : Long,
16- val minMaxIntersection : Long,
15+ val union : Long,
1716 val minMaxUnion : Long,
18- val union : Long
17+ val intersection : Long,
18+ val minMaxIntersection : Long
1919 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/minmax.schema/default/TopLevel.scala+4 −4
@@ -9,11 +9,11 @@ type NullValue = None.type
99
1010 case class TopLevel (
1111 val free : Double,
12- val intersection : Double,
13- val max : Double,
1412 val min : Double,
13+ val max : Double,
1514 val minmax : Double,
16- val minMaxIntersection : Double,
15+ val union : Double,
1716 val minMaxUnion : Double,
18- val union : Double
17+ val intersection : Double,
18+ val minMaxIntersection : Double
1919 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/minmaxlength.schema/default/TopLevel.scala+5 −5
@@ -8,14 +8,14 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val intersection : String,
12- val inUnion : InUnion,
13- val maxlength : String,
1411 val minlength : String,
15- val minMaxIntersection : String,
12+ val maxlength : String,
1613 val minmaxlength : String,
14+ val union : String,
15+ val inUnion : InUnion,
1716 val minMaxUnion : String,
18- val union : String
17+ val intersection : String,
18+ val minMaxIntersection : String
1919 ) derives Encoder.AsObject, Decoder
2020
2121 type InUnion = Double | String
Mschema-scala3-upickle/test/inputs/schema/non-standard-ref.schema/default/TopLevel.scala+1 −1
@@ -8,7 +8,7 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val bar : Long,
1211 val foo : Long,
12+ val bar : Long,
1313 val quux : Boolean
1414 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.scala+2 −2
@@ -8,8 +8,8 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val b : Option[String] = None,
12- val kind : Kind
11+ val kind : Kind,
12+ val b : Option[String] = None
1313 ) derives Encoder.AsObject, Decoder
1414
1515 enum Kind :
Mschema-scala3-upickle/test/inputs/schema/optional-any.schema/default/TopLevel.scala+2 −2
@@ -8,6 +8,6 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val bar : Boolean,
12- val foo : Option[Json] = None
11+ val foo : Option[Json] = None,
12+ val bar : Boolean
1313 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/optional-const-ref.schema/default/TopLevel.scala+4 −4
@@ -9,12 +9,12 @@ type NullValue = None.type
99
1010 case class TopLevel (
1111 val coordinates : Option[Seq[Coordinate]] = None,
12- val count : Option[Long] = None,
13- val label : Option[String] = None,
1412 val requiredCoordinates : Seq[Coordinate],
13+ val count : Option[Long] = None,
1514 val requiredCount : Long,
16- val requiredLabel : String,
17- val weight : Option[Double] = None
15+ val weight : Option[Double] = None,
16+ val label : Option[String] = None,
17+ val requiredLabel : String
1818 ) derives Encoder.AsObject, Decoder
1919
2020 case class Coordinate (
Mschema-scala3-upickle/test/inputs/schema/optional-constraints.schema/default/TopLevel.scala+3 −3
@@ -8,9 +8,9 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val optDouble : Option[Double] = None,
11+ val reqZeroMin : Long,
1212 val optInt : Option[Long] = None,
13- val optPattern : Option[String] = None,
13+ val optDouble : Option[Double] = None,
1414 val optString : Option[String] = None,
15- val reqZeroMin : Long
15+ val optPattern : Option[String] = None
1616 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/optional-date-time.schema/default/TopLevel.scala+4 −4
@@ -8,10 +8,10 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val `optional-date` : Option[String] = None,
12- val `optional-date-time` : Option[String] = None,
13- val `optional-time` : Option[String] = None,
1411 val `required-date` : String,
12+ val `required-time` : String,
1513 val `required-date-time` : String,
16- val `required-time` : String
14+ val `optional-date` : Option[String] = None,
15+ val `optional-time` : Option[String] = None,
16+ val `optional-date-time` : Option[String] = None
1717 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/prefix-items.schema/default/TopLevel.scala+2 −2
@@ -8,8 +8,8 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val open : Seq[Open],
12- val tuple : Seq[Open]
11+ val tuple : Seq[Open],
12+ val open : Seq[Open]
1313 ) derives Encoder.AsObject, Decoder
1414
1515 type Open = Boolean | Long
Aschema-scala3-upickle/test/inputs/schema/property-order.schema/default/TopLevel.scala+23 −0
@@ -0,0 +1,23 @@
1+package quicktype
2+
3+import io.circe.syntax._
4+import io.circe._
5+import cats.syntax.functor._
6+
7+// If a union has a null in, then we'll need this too...
8+type NullValue = None.type
9+
10+case class TopLevel (
11+ val zebra : String,
12+ val mango : Double,
13+ val apple : Boolean,
14+ val delta : String,
15+ val banana : Long,
16+ val ordered : Ordered
17+) derives Encoder.AsObject, Decoder
18+
19+case class Ordered (
20+ val mango : Double,
21+ val zebra : String,
22+ val apple : Boolean
23+) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/renaming-bug.schema/default/TopLevel.scala+13 −13
@@ -15,13 +15,13 @@ case class TopLevel (
1515
1616 case class Fruit (
1717 val apple : Option[Boolean] = None,
18- val berries : Option[Seq[Berry]] = None,
19- val orange : Option[Boolean] = None
18+ val orange : Option[Boolean] = None,
19+ val berries : Option[Seq[Berry]] = None
2020 ) derives Encoder.AsObject, Decoder
2121
2222 case class Berry (
23- val color : Option[Color] = None,
2423 val name : Option[String] = None,
24+ val color : Option[Color] = None,
2525 val shapes : Option[Seq[Shape]] = None
2626 ) derives Encoder.AsObject, Decoder
2727
@@ -30,8 +30,8 @@ case class Color (
3030 ) derives Encoder.AsObject, Decoder
3131
3232 case class Shape (
33- val geometry : Option[Geometry] = None,
34- val history : Option[History] = None
33+ val history : Option[History] = None,
34+ val geometry : Option[Geometry] = None
3535 ) derives Encoder.AsObject, Decoder
3636
3737 case class Geometry (
@@ -48,9 +48,9 @@ case class RectShape (
4848 ) derives Encoder.AsObject, Decoder
4949
5050 case class Part (
51- val depth : Option[String] = None,
5251 val length : Option[String] = None,
53- val width : Option[String] = None
52+ val width : Option[String] = None,
53+ val depth : Option[String] = None
5454 ) derives Encoder.AsObject, Decoder
5555
5656 case class History (
@@ -58,12 +58,12 @@ case class History (
5858 ) derives Encoder.AsObject, Decoder
5959
6060 case class Vehicle (
61- val brand : Option[String] = None,
6261 val id : Option[String] = None,
63- val speed : Option[Speed] = None,
64- val subModule : Option[Boolean] = None,
6562 val `type` : Option[VehicleType] = None,
66- val year : Option[String] = None
63+ val speed : Option[Speed] = None,
64+ val year : Option[String] = None,
65+ val brand : Option[String] = None,
66+ val subModule : Option[Boolean] = None
6767 ) derives Encoder.AsObject, Decoder
6868
6969 case class Speed (
@@ -71,8 +71,8 @@ case class Speed (
7171 ) derives Encoder.AsObject, Decoder
7272
7373 case class Limit (
74- val maximum : Option[Double] = None,
75- val minimum : Option[Double] = None
74+ val minimum : Option[Double] = None,
75+ val maximum : Option[Double] = None
7676 ) derives Encoder.AsObject, Decoder
7777
7878 case class VehicleType (
Mschema-scala3-upickle/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.scala+4 −4
@@ -8,13 +8,13 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val next : Option[Next] = None,
12- val value : String
11+ val value : String,
12+ val next : Option[Next] = None
1313 ) derives Encoder.AsObject, Decoder
1414
1515 case class Node (
16- val next : Option[Next] = None,
17- val value : String
16+ val value : String,
17+ val next : Option[Next] = None
1818 ) derives Encoder.AsObject, Decoder
1919
2020 type Next = Node | String | NullValue
Mschema-scala3-upickle/test/inputs/schema/uuid.schema/default/TopLevel.scala+3 −3
@@ -8,10 +8,10 @@ import cats.syntax.functor._
88 type NullValue = None.type
99
1010 case class TopLevel (
11- val arrNullable : Option[Seq[Option[String]]] = None,
12- val arrOne : Option[Seq[String]] = None,
13- val nullable : Option[String] = None,
1411 val one : String,
1512 val optional : Option[String] = None,
13+ val nullable : Option[String] = None,
14+ val arrOne : Option[Seq[String]] = None,
15+ val arrNullable : Option[Seq[Option[String]]] = None,
1616 val unionWithEnum : String
1717 ) derives Encoder.AsObject, Decoder
Mschema-scala3-upickle/test/inputs/schema/vega-lite.schema/default/TopLevel.scala+49 −49
@@ -604,6 +604,13 @@ case class MarkConfig (
604604 */
605605 val fill : Option[String] = None,
606606
607+ /**
608+ * The fill opacity (value between [0,1]).
609+ *
610+ * __Default value:__ `1`
611+ */
612+ val fillOpacity : Option[Double] = None,
613+
607614 /**
608615 * Whether the mark's color should be used as fill color instead of stroke color.
609616 *
@@ -615,13 +622,6 @@ case class MarkConfig (
615622 */
616623 val filled : Option[Boolean] = None,
617624
618- /**
619- * The fill opacity (value between [0,1]).
620- *
621- * __Default value:__ `1`
622- */
623- val fillOpacity : Option[Double] = None,
624-
625625 /**
626626 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
627627 */
@@ -1251,11 +1251,6 @@ case class AxisConfig (
12511251 */
12521252 val tickRound : Option[Boolean] = None,
12531253
1254- /**
1255- * Boolean value that determines whether the axis should include ticks.
1256- */
1257- val ticks : Option[Boolean] = None,
1258-
12591254 /**
12601255 * The size in pixels of axis ticks.
12611256 */
@@ -1266,6 +1261,11 @@ case class AxisConfig (
12661261 */
12671262 val tickWidth : Option[Double] = None,
12681263
1264+ /**
1265+ * Boolean value that determines whether the axis should include ticks.
1266+ */
1267+ val ticks : Option[Boolean] = None,
1268+
12691269 /**
12701270 * Horizontal text alignment of axis titles.
12711271 */
@@ -1581,11 +1581,6 @@ case class VGAxisConfig (
15811581 */
15821582 val tickRound : Option[Boolean] = None,
15831583
1584- /**
1585- * Boolean value that determines whether the axis should include ticks.
1586- */
1587- val ticks : Option[Boolean] = None,
1588-
15891584 /**
15901585 * The size in pixels of axis ticks.
15911586 */
@@ -1596,6 +1591,11 @@ case class VGAxisConfig (
15961591 */
15971592 val tickWidth : Option[Double] = None,
15981593
1594+ /**
1595+ * Boolean value that determines whether the axis should include ticks.
1596+ */
1597+ val ticks : Option[Boolean] = None,
1598+
15991599 /**
16001600 * Horizontal text alignment of axis titles.
16011601 */
@@ -1735,6 +1735,13 @@ case class BarConfig (
17351735 */
17361736 val fill : Option[String] = None,
17371737
1738+ /**
1739+ * The fill opacity (value between [0,1]).
1740+ *
1741+ * __Default value:__ `1`
1742+ */
1743+ val fillOpacity : Option[Double] = None,
1744+
17381745 /**
17391746 * Whether the mark's color should be used as fill color instead of stroke color.
17401747 *
@@ -1746,13 +1753,6 @@ case class BarConfig (
17461753 */
17471754 val filled : Option[Boolean] = None,
17481755
1749- /**
1750- * The fill opacity (value between [0,1]).
1751- *
1752- * __Default value:__ `1`
1753- */
1754- val fillOpacity : Option[Double] = None,
1755-
17561756 /**
17571757 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
17581758 */
@@ -3221,6 +3221,13 @@ case class TextConfig (
32213221 */
32223222 val fill : Option[String] = None,
32233223
3224+ /**
3225+ * The fill opacity (value between [0,1]).
3226+ *
3227+ * __Default value:__ `1`
3228+ */
3229+ val fillOpacity : Option[Double] = None,
3230+
32243231 /**
32253232 * Whether the mark's color should be used as fill color instead of stroke color.
32263233 *
@@ -3232,13 +3239,6 @@ case class TextConfig (
32323239 */
32333240 val filled : Option[Boolean] = None,
32343241
3235- /**
3236- * The fill opacity (value between [0,1]).
3237- *
3238- * __Default value:__ `1`
3239- */
3240- val fillOpacity : Option[Double] = None,
3241-
32423242 /**
32433243 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
32443244 */
@@ -3452,6 +3452,13 @@ case class TickConfig (
34523452 */
34533453 val fill : Option[String] = None,
34543454
3455+ /**
3456+ * The fill opacity (value between [0,1]).
3457+ *
3458+ * __Default value:__ `1`
3459+ */
3460+ val fillOpacity : Option[Double] = None,
3461+
34553462 /**
34563463 * Whether the mark's color should be used as fill color instead of stroke color.
34573464 *
@@ -3463,13 +3470,6 @@ case class TickConfig (
34633470 */
34643471 val filled : Option[Boolean] = None,
34653472
3466- /**
3467- * The fill opacity (value between [0,1]).
3468- *
3469- * __Default value:__ `1`
3470- */
3471- val fillOpacity : Option[Double] = None,
3472-
34733473 /**
34743474 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
34753475 */
@@ -6536,14 +6536,14 @@ case class Axis (
65366536 val tickCount : Option[Double] = None,
65376537
65386538 /**
6539- * Boolean value that determines whether the axis should include ticks.
6539+ * The size in pixels of axis ticks.
65406540 */
6541- val ticks : Option[Boolean] = None,
6541+ val tickSize : Option[Double] = None,
65426542
65436543 /**
6544- * The size in pixels of axis ticks.
6544+ * Boolean value that determines whether the axis should include ticks.
65456545 */
6546- val tickSize : Option[Double] = None,
6546+ val ticks : Option[Boolean] = None,
65476547
65486548 /**
65496549 * A title for the field. If `null`, the title will be removed.
@@ -7117,6 +7117,13 @@ case class MarkDef (
71177117 */
71187118 val fill : Option[String] = None,
71197119
7120+ /**
7121+ * The fill opacity (value between [0,1]).
7122+ *
7123+ * __Default value:__ `1`
7124+ */
7125+ val fillOpacity : Option[Double] = None,
7126+
71207127 /**
71217128 * Whether the mark's color should be used as fill color instead of stroke color.
71227129 *
@@ -7128,13 +7135,6 @@ case class MarkDef (
71287135 */
71297136 val filled : Option[Boolean] = None,
71307137
7131- /**
7132- * The fill opacity (value between [0,1]).
7133- *
7134- * __Default value:__ `1`
7135- */
7136- val fillOpacity : Option[Double] = None,
7137-
71387138 /**
71397139 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
71407140 */
Mschema-scala3/test/inputs/schema/accessors.schema/default/TopLevel.scala+2 −2
@@ -66,10 +66,10 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val bar : String,
69+ val union : Union,
7070 val `enum` : EnumEnum,
7171 val foo : String,
72- val union : Union
72+ val bar : String
7373 ) derives OptionPickler.ReadWriter
7474
7575 enum EnumEnum :
Mschema-scala3/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.scala+2 −2
@@ -68,8 +68,8 @@ end JsonExt
6868 case class TopLevel (
6969 val amount : Double,
7070 val frequency : Frequency,
71- val description : Option[String] = None,
72- val `type` : Type
71+ val `type` : Type,
72+ val description : Option[String] = None
7373 ) derives OptionPickler.ReadWriter
7474
7575 enum Frequency :
Mschema-scala3/test/inputs/schema/bool-string.schema/default/TopLevel.scala+3 −3
@@ -66,11 +66,11 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val arrNullable : Option[Seq[Option[String]]] = None,
70- val arrOne : Option[Seq[String]] = None,
71- val nullable : Option[String] = None,
7269 val one : String,
7370 val optional : Option[String] = None,
71+ val nullable : Option[String] = None,
72+ val arrOne : Option[Seq[String]] = None,
73+ val arrNullable : Option[Seq[Option[String]]] = None,
7474 val unionWithBool : UnionWithBool,
7575 val unionWithBoolAndEnum : UnionWithBool
7676 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/boolean-subschema.schema/default/TopLevel.scala+1 −1
@@ -66,8 +66,8 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69+ val foo : String,
6970 val disallowed : Option[ujson.Value] = None,
7071 val empty : Seq[Option[ujson.Value]],
71- val foo : String,
7272 val impossible : Option[ujson.Value] = None
7373 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/comment-injection.schema/default/TopLevel.scala+16 −16
@@ -80,21 +80,6 @@ end JsonExt
8080 * }
8181 */
8282 case class TopLevel (
83- /**
84- * Ends with a backslash \
85- */
86- val trailingBackslash : Option[String] = None,
87-
88- /**
89- * Ends with a quote "
90- */
91- val trailingQuote : Option[String] = None,
92-
93- /**
94- * Ends with a triple quote """
95- */
96- val trailingTripleQuote : Option[String] = None,
97-
9883 /**
9984 * Property delimiters:
10085 * * /
@@ -109,5 +94,20 @@ case class TopLevel (
10994 * }
11095 * }
11196 */
112- val value : String
97+ val value : String,
98+
99+ /**
100+ * Ends with a backslash \
101+ */
102+ val trailingBackslash : Option[String] = None,
103+
104+ /**
105+ * Ends with a quote "
106+ */
107+ val trailingQuote : Option[String] = None,
108+
109+ /**
110+ * Ends with a triple quote """
111+ */
112+ val trailingTripleQuote : Option[String] = None
113113 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/const-non-string.schema/default/TopLevel.scala+3 −3
@@ -66,11 +66,11 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69+ val version : Double,
6970 val amount : Long,
70- val enabled : Boolean,
71- val kind : Kind,
7271 val ratio : Double,
73- val version : Double
72+ val enabled : Boolean,
73+ val kind : Kind
7474 ) derives OptionPickler.ReadWriter
7575
7676 enum Kind :
Mschema-scala3/test/inputs/schema/date-time-or-string.schema/default/TopLevel.scala+2 −2
@@ -66,6 +66,6 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val bar : String,
70- val foo : String
69+ val foo : String,
70+ val bar : String
7171 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/date-time.schema/default/TopLevel.scala+3 −3
@@ -66,11 +66,11 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val `complex-union-array` : Seq[ComplexUnionArray],
7069 val date : String,
71- val `date-time` : String,
7270 val time : String,
73- val `union-array` : Seq[String]
71+ val `date-time` : String,
72+ val `union-array` : Seq[String],
73+ val `complex-union-array` : Seq[ComplexUnionArray]
7474 ) derives OptionPickler.ReadWriter
7575
7676 type ComplexUnionArray = Long | String
Mschema-scala3/test/inputs/schema/description.schema/default/TopLevel.scala+6 −5
@@ -71,9 +71,9 @@ end JsonExt
7171 */
7272 case class TopLevel (
7373 /**
74- * A pretty boolean
74+ * Either a number or a string
7575 */
76- val bar : Option[Boolean] = None,
76+ val union : Union,
7777
7878 /**
7979 * An enumeration
@@ -81,12 +81,13 @@ case class TopLevel (
8181 val `enum` : EnumEnum,
8282
8383 val foo : Option[Double] = None,
84- val `object-or-string` : ObjectOrStringUnion,
8584
8685 /**
87- * Either a number or a string
86+ * A pretty boolean
8887 */
89- val union : Union
88+ val bar : Option[Boolean] = None,
89+
90+ val `object-or-string` : ObjectOrStringUnion
9091 ) derives OptionPickler.ReadWriter
9192
9293 type ObjectOrStringUnion = ObjectOrStringClass | String
Mschema-scala3/test/inputs/schema/direct-union.schema/default/TopLevel.scala+2 −2
@@ -70,8 +70,8 @@ case class TopLevel (
7070 ) derives OptionPickler.ReadWriter
7171
7272 case class Thing (
73- val optional : Option[Anything] = None,
74- val required : Anything
73+ val required : Anything,
74+ val optional : Option[Anything] = None
7575 ) derives OptionPickler.ReadWriter
7676
7777 type Anything = Seq[Option[ujson.Value]] | Map[String, Option[ujson.Value]] | Boolean | Double | Long | String | NullValue
Mschema-scala3/test/inputs/schema/enum.schema/default/TopLevel.scala+4 −4
@@ -66,11 +66,11 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val arr : Option[Seq[Arr]] = None,
70- val `for` : Option[String] = None,
71- val gve : Gve,
7269 val lvc : Option[Lvc] = None,
73- val otherArr : Option[Seq[OtherArr]] = None
70+ val gve : Gve,
71+ val arr : Option[Seq[Arr]] = None,
72+ val otherArr : Option[Seq[OtherArr]] = None,
73+ val `for` : Option[String] = None
7474 ) derives OptionPickler.ReadWriter
7575
7676 type Arr = OtherArr | Long
Mschema-scala3/test/inputs/schema/integer-string.schema/default/TopLevel.scala+3 −3
@@ -66,11 +66,11 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val arrNullable : Option[Seq[Option[String]]] = None,
70- val arrOne : Option[Seq[String]] = None,
71- val nullable : Option[String] = None,
7269 val one : String,
7370 val optional : Option[String] = None,
71+ val nullable : Option[String] = None,
72+ val arrOne : Option[Seq[String]] = None,
73+ val arrNullable : Option[Seq[Option[String]]] = None,
7474 val unionWithInt : UnionWithInt,
7575 val unionWithIntAndEnum : UnionWithInt
7676 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/integer-type.schema/default/TopLevel.scala+6 −6
@@ -66,13 +66,13 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69+ val small_positive : Long,
70+ val small_negative : Long,
71+ val i32_range : Long,
6972 val above_i32_max : Long,
7073 val below_i32_min : Long,
71- val i32_range : Long,
72- val large_bounds : Long,
73- val only_maximum : Long,
7474 val only_minimum : Long,
75- val small_negative : Long,
76- val small_positive : Long,
77- val unbounded : Long
75+ val only_maximum : Long,
76+ val unbounded : Long,
77+ val large_bounds : Long
7878 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/light.schema/default/TopLevel.scala+1 −1
@@ -70,7 +70,7 @@ case class TopLevel (
7070 ) derives OptionPickler.ReadWriter
7171
7272 case class LightParams (
73- val app_id : String,
7473 val outlet_id : String,
74+ val app_id : String,
7575 val rgba : String
7676 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/min-max-items.schema/default/TopLevel.scala+1 −1
@@ -66,9 +66,9 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69+ val minOnly : Seq[String],
6970 val maxOnly : Seq[Long],
7071 val minAndMax : Seq[Double],
71- val minOnly : Seq[String],
7272 val plain : Seq[String],
7373 val unionItems : Seq[UnionItem]
7474 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/minmax-integer.schema/default/TopLevel.scala+4 −4
@@ -67,11 +67,11 @@ end JsonExt
6767
6868 case class TopLevel (
6969 val free : Long,
70- val intersection : Long,
71- val max : Long,
7270 val min : Long,
71+ val max : Long,
7372 val minmax : Long,
74- val minMaxIntersection : Long,
73+ val union : Long,
7574 val minMaxUnion : Long,
76- val union : Long
75+ val intersection : Long,
76+ val minMaxIntersection : Long
7777 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/minmax.schema/default/TopLevel.scala+4 −4
@@ -67,11 +67,11 @@ end JsonExt
6767
6868 case class TopLevel (
6969 val free : Double,
70- val intersection : Double,
71- val max : Double,
7270 val min : Double,
71+ val max : Double,
7372 val minmax : Double,
74- val minMaxIntersection : Double,
73+ val union : Double,
7574 val minMaxUnion : Double,
76- val union : Double
75+ val intersection : Double,
76+ val minMaxIntersection : Double
7777 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/minmaxlength.schema/default/TopLevel.scala+5 −5
@@ -66,14 +66,14 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val intersection : String,
70- val inUnion : InUnion,
71- val maxlength : String,
7269 val minlength : String,
73- val minMaxIntersection : String,
70+ val maxlength : String,
7471 val minmaxlength : String,
72+ val union : String,
73+ val inUnion : InUnion,
7574 val minMaxUnion : String,
76- val union : String
75+ val intersection : String,
76+ val minMaxIntersection : String
7777 ) derives OptionPickler.ReadWriter
7878
7979 type InUnion = Double | String
Mschema-scala3/test/inputs/schema/non-standard-ref.schema/default/TopLevel.scala+1 −1
@@ -66,7 +66,7 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val bar : Long,
7069 val foo : Long,
70+ val bar : Long,
7171 val quux : Boolean
7272 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.scala+2 −2
@@ -66,8 +66,8 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val b : Option[String] = None,
70- val kind : Kind
69+ val kind : Kind,
70+ val b : Option[String] = None
7171 ) derives OptionPickler.ReadWriter
7272
7373 enum Kind :
Mschema-scala3/test/inputs/schema/optional-any.schema/default/TopLevel.scala+2 −2
@@ -66,6 +66,6 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val bar : Boolean,
70- val foo : Option[ujson.Value] = None
69+ val foo : Option[ujson.Value] = None,
70+ val bar : Boolean
7171 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/optional-const-ref.schema/default/TopLevel.scala+4 −4
@@ -67,12 +67,12 @@ end JsonExt
6767
6868 case class TopLevel (
6969 val coordinates : Option[Seq[Coordinate]] = None,
70- val count : Option[Long] = None,
71- val label : Option[String] = None,
7270 val requiredCoordinates : Seq[Coordinate],
71+ val count : Option[Long] = None,
7372 val requiredCount : Long,
74- val requiredLabel : String,
75- val weight : Option[Double] = None
73+ val weight : Option[Double] = None,
74+ val label : Option[String] = None,
75+ val requiredLabel : String
7676 ) derives OptionPickler.ReadWriter
7777
7878 case class Coordinate (
Mschema-scala3/test/inputs/schema/optional-constraints.schema/default/TopLevel.scala+3 −3
@@ -66,9 +66,9 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val optDouble : Option[Double] = None,
69+ val reqZeroMin : Long,
7070 val optInt : Option[Long] = None,
71- val optPattern : Option[String] = None,
71+ val optDouble : Option[Double] = None,
7272 val optString : Option[String] = None,
73- val reqZeroMin : Long
73+ val optPattern : Option[String] = None
7474 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/optional-date-time.schema/default/TopLevel.scala+4 −4
@@ -66,10 +66,10 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val `optional-date` : Option[String] = None,
70- val `optional-date-time` : Option[String] = None,
71- val `optional-time` : Option[String] = None,
7269 val `required-date` : String,
70+ val `required-time` : String,
7371 val `required-date-time` : String,
74- val `required-time` : String
72+ val `optional-date` : Option[String] = None,
73+ val `optional-time` : Option[String] = None,
74+ val `optional-date-time` : Option[String] = None
7575 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/prefix-items.schema/default/TopLevel.scala+2 −2
@@ -66,8 +66,8 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val open : Seq[Open],
70- val tuple : Seq[Open]
69+ val tuple : Seq[Open],
70+ val open : Seq[Open]
7171 ) derives OptionPickler.ReadWriter
7272
7373 type Open = Boolean | Long
Aschema-scala3/test/inputs/schema/property-order.schema/default/TopLevel.scala+81 −0
@@ -0,0 +1,81 @@
1+package quicktype
2+
3+// Custom pickler so that missing keys and JSON nulls both read as None,
4+// and None is left out when writing (upickle's default for Option is a
5+// JSON array).
6+object OptionPickler extends upickle.AttributeTagged:
7+ import upickle.default.Writer
8+ import upickle.default.Reader
9+ override implicit def OptionWriter[T: Writer]: Writer[Option[T]] =
10+ implicitly[Writer[T]].comap[Option[T]] {
11+ case None => null.asInstanceOf[T]
12+ case Some(x) => x
13+ }
14+
15+ override implicit def OptionReader[T: Reader]: Reader[Option[T]] = {
16+ new Reader.Delegate[Any, Option[T]](implicitly[Reader[T]].map(Some(_))){
17+ override def visitNull(index: Int) = None
18+ }
19+ }
20+end OptionPickler
21+
22+// If a union has a null in, then we'll need this too...
23+type NullValue = None.type
24+given OptionPickler.ReadWriter[NullValue] = OptionPickler.readwriter[ujson.Value].bimap[NullValue](
25+ _ => ujson.Null,
26+ json => if json.isNull then None else throw new upickle.core.Abort("not null")
27+)
28+
29+object JsonExt:
30+ val valueReader = OptionPickler.readwriter[ujson.Value]
31+
32+ // upickle's built-in primitive readers are lenient -- the numeric and
33+ // boolean readers accept strings, and the string reader accepts
34+ // numbers and booleans -- so untagged unions need strict readers to
35+ // pick the right member.
36+ val strictString: OptionPickler.Reader[String] = valueReader.map {
37+ case ujson.Str(s) => s
38+ case json => throw new upickle.core.Abort("expected string, got " + json)
39+ }
40+ val strictLong: OptionPickler.Reader[Long] = valueReader.map {
41+ case ujson.Num(n) if n.isWhole => n.toLong
42+ case json => throw new upickle.core.Abort("expected integer, got " + json)
43+ }
44+ val strictDouble: OptionPickler.Reader[Double] = valueReader.map {
45+ case ujson.Num(n) => n
46+ case json => throw new upickle.core.Abort("expected number, got " + json)
47+ }
48+ val strictBoolean: OptionPickler.Reader[Boolean] = valueReader.map {
49+ case ujson.Bool(b) => b
50+ case json => throw new upickle.core.Abort("expected boolean, got " + json)
51+ }
52+
53+ def badMerge[T](r1: => OptionPickler.Reader[?], rest: OptionPickler.Reader[?]*): OptionPickler.Reader[T] = valueReader.map { json =>
54+ var t: T | Null = null
55+ val stack = Vector.newBuilder[Throwable]
56+ (r1 +: rest).foreach { reader =>
57+ if t == null then
58+ try
59+ t = OptionPickler.read[T](json, trace = true)(using reader.asInstanceOf[OptionPickler.Reader[T]])
60+ catch
61+ case exc => stack += exc
62+ }
63+ if t != null then t.nn else throw new Exception(json.toString(), stack.result().headOption.getOrElse(null))
64+ }
65+end JsonExt
66+
67+
68+case class TopLevel (
69+ val zebra : String,
70+ val mango : Double,
71+ val apple : Boolean,
72+ val delta : String,
73+ val banana : Long,
74+ val ordered : Ordered
75+) derives OptionPickler.ReadWriter
76+
77+case class Ordered (
78+ val mango : Double,
79+ val zebra : String,
80+ val apple : Boolean
81+) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/renaming-bug.schema/default/TopLevel.scala+13 −13
@@ -73,13 +73,13 @@ case class TopLevel (
7373
7474 case class Fruit (
7575 val apple : Option[Boolean] = None,
76- val berries : Option[Seq[Berry]] = None,
77- val orange : Option[Boolean] = None
76+ val orange : Option[Boolean] = None,
77+ val berries : Option[Seq[Berry]] = None
7878 ) derives OptionPickler.ReadWriter
7979
8080 case class Berry (
81- val color : Option[Color] = None,
8281 val name : Option[String] = None,
82+ val color : Option[Color] = None,
8383 val shapes : Option[Seq[Shape]] = None
8484 ) derives OptionPickler.ReadWriter
8585
@@ -88,8 +88,8 @@ case class Color (
8888 ) derives OptionPickler.ReadWriter
8989
9090 case class Shape (
91- val geometry : Option[Geometry] = None,
92- val history : Option[History] = None
91+ val history : Option[History] = None,
92+ val geometry : Option[Geometry] = None
9393 ) derives OptionPickler.ReadWriter
9494
9595 case class Geometry (
@@ -106,9 +106,9 @@ case class RectShape (
106106 ) derives OptionPickler.ReadWriter
107107
108108 case class Part (
109- val depth : Option[String] = None,
110109 val length : Option[String] = None,
111- val width : Option[String] = None
110+ val width : Option[String] = None,
111+ val depth : Option[String] = None
112112 ) derives OptionPickler.ReadWriter
113113
114114 case class History (
@@ -116,12 +116,12 @@ case class History (
116116 ) derives OptionPickler.ReadWriter
117117
118118 case class Vehicle (
119- val brand : Option[String] = None,
120119 val id : Option[String] = None,
121- val speed : Option[Speed] = None,
122- val subModule : Option[Boolean] = None,
123120 val `type` : Option[VehicleType] = None,
124- val year : Option[String] = None
121+ val speed : Option[Speed] = None,
122+ val year : Option[String] = None,
123+ val brand : Option[String] = None,
124+ val subModule : Option[Boolean] = None
125125 ) derives OptionPickler.ReadWriter
126126
127127 case class Speed (
@@ -129,8 +129,8 @@ case class Speed (
129129 ) derives OptionPickler.ReadWriter
130130
131131 case class Limit (
132- val maximum : Option[Double] = None,
133- val minimum : Option[Double] = None
132+ val minimum : Option[Double] = None,
133+ val maximum : Option[Double] = None
134134 ) derives OptionPickler.ReadWriter
135135
136136 case class VehicleType (
Mschema-scala3/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.scala+4 −4
@@ -66,13 +66,13 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val next : Option[Next] = None,
70- val value : String
69+ val value : String,
70+ val next : Option[Next] = None
7171 ) derives OptionPickler.ReadWriter
7272
7373 case class Node (
74- val next : Option[Next] = None,
75- val value : String
74+ val value : String,
75+ val next : Option[Next] = None
7676 ) derives OptionPickler.ReadWriter
7777
7878 type Next = Node | String | NullValue
Mschema-scala3/test/inputs/schema/uuid.schema/default/TopLevel.scala+3 −3
@@ -66,10 +66,10 @@ end JsonExt
6666
6767
6868 case class TopLevel (
69- val arrNullable : Option[Seq[Option[String]]] = None,
70- val arrOne : Option[Seq[String]] = None,
71- val nullable : Option[String] = None,
7269 val one : String,
7370 val optional : Option[String] = None,
71+ val nullable : Option[String] = None,
72+ val arrOne : Option[Seq[String]] = None,
73+ val arrNullable : Option[Seq[Option[String]]] = None,
7474 val unionWithEnum : String
7575 ) derives OptionPickler.ReadWriter
Mschema-scala3/test/inputs/schema/vega-lite.schema/default/TopLevel.scala+49 −49
@@ -665,6 +665,13 @@ case class MarkConfig (
665665 */
666666 val fill : Option[String] = None,
667667
668+ /**
669+ * The fill opacity (value between [0,1]).
670+ *
671+ * __Default value:__ `1`
672+ */
673+ val fillOpacity : Option[Double] = None,
674+
668675 /**
669676 * Whether the mark's color should be used as fill color instead of stroke color.
670677 *
@@ -676,13 +683,6 @@ case class MarkConfig (
676683 */
677684 val filled : Option[Boolean] = None,
678685
679- /**
680- * The fill opacity (value between [0,1]).
681- *
682- * __Default value:__ `1`
683- */
684- val fillOpacity : Option[Double] = None,
685-
686686 /**
687687 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
688688 */
@@ -1325,11 +1325,6 @@ case class AxisConfig (
13251325 */
13261326 val tickRound : Option[Boolean] = None,
13271327
1328- /**
1329- * Boolean value that determines whether the axis should include ticks.
1330- */
1331- val ticks : Option[Boolean] = None,
1332-
13331328 /**
13341329 * The size in pixels of axis ticks.
13351330 */
@@ -1340,6 +1335,11 @@ case class AxisConfig (
13401335 */
13411336 val tickWidth : Option[Double] = None,
13421337
1338+ /**
1339+ * Boolean value that determines whether the axis should include ticks.
1340+ */
1341+ val ticks : Option[Boolean] = None,
1342+
13431343 /**
13441344 * Horizontal text alignment of axis titles.
13451345 */
@@ -1654,11 +1654,6 @@ case class VGAxisConfig (
16541654 */
16551655 val tickRound : Option[Boolean] = None,
16561656
1657- /**
1658- * Boolean value that determines whether the axis should include ticks.
1659- */
1660- val ticks : Option[Boolean] = None,
1661-
16621657 /**
16631658 * The size in pixels of axis ticks.
16641659 */
@@ -1669,6 +1664,11 @@ case class VGAxisConfig (
16691664 */
16701665 val tickWidth : Option[Double] = None,
16711666
1667+ /**
1668+ * Boolean value that determines whether the axis should include ticks.
1669+ */
1670+ val ticks : Option[Boolean] = None,
1671+
16721672 /**
16731673 * Horizontal text alignment of axis titles.
16741674 */
@@ -1808,6 +1808,13 @@ case class BarConfig (
18081808 */
18091809 val fill : Option[String] = None,
18101810
1811+ /**
1812+ * The fill opacity (value between [0,1]).
1813+ *
1814+ * __Default value:__ `1`
1815+ */
1816+ val fillOpacity : Option[Double] = None,
1817+
18111818 /**
18121819 * Whether the mark's color should be used as fill color instead of stroke color.
18131820 *
@@ -1819,13 +1826,6 @@ case class BarConfig (
18191826 */
18201827 val filled : Option[Boolean] = None,
18211828
1822- /**
1823- * The fill opacity (value between [0,1]).
1824- *
1825- * __Default value:__ `1`
1826- */
1827- val fillOpacity : Option[Double] = None,
1828-
18291829 /**
18301830 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
18311831 */
@@ -3309,6 +3309,13 @@ case class TextConfig (
33093309 */
33103310 val fill : Option[String] = None,
33113311
3312+ /**
3313+ * The fill opacity (value between [0,1]).
3314+ *
3315+ * __Default value:__ `1`
3316+ */
3317+ val fillOpacity : Option[Double] = None,
3318+
33123319 /**
33133320 * Whether the mark's color should be used as fill color instead of stroke color.
33143321 *
@@ -3320,13 +3327,6 @@ case class TextConfig (
33203327 */
33213328 val filled : Option[Boolean] = None,
33223329
3323- /**
3324- * The fill opacity (value between [0,1]).
3325- *
3326- * __Default value:__ `1`
3327- */
3328- val fillOpacity : Option[Double] = None,
3329-
33303330 /**
33313331 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
33323332 */
@@ -3540,6 +3540,13 @@ case class TickConfig (
35403540 */
35413541 val fill : Option[String] = None,
35423542
3543+ /**
3544+ * The fill opacity (value between [0,1]).
3545+ *
3546+ * __Default value:__ `1`
3547+ */
3548+ val fillOpacity : Option[Double] = None,
3549+
35433550 /**
35443551 * Whether the mark's color should be used as fill color instead of stroke color.
35453552 *
@@ -3551,13 +3558,6 @@ case class TickConfig (
35513558 */
35523559 val filled : Option[Boolean] = None,
35533560
3554- /**
3555- * The fill opacity (value between [0,1]).
3556- *
3557- * __Default value:__ `1`
3558- */
3559- val fillOpacity : Option[Double] = None,
3560-
35613561 /**
35623562 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
35633563 */
@@ -6630,14 +6630,14 @@ case class Axis (
66306630 val tickCount : Option[Double] = None,
66316631
66326632 /**
6633- * Boolean value that determines whether the axis should include ticks.
6633+ * The size in pixels of axis ticks.
66346634 */
6635- val ticks : Option[Boolean] = None,
6635+ val tickSize : Option[Double] = None,
66366636
66376637 /**
6638- * The size in pixels of axis ticks.
6638+ * Boolean value that determines whether the axis should include ticks.
66396639 */
6640- val tickSize : Option[Double] = None,
6640+ val ticks : Option[Boolean] = None,
66416641
66426642 /**
66436643 * A title for the field. If `null`, the title will be removed.
@@ -7209,6 +7209,13 @@ case class MarkDef (
72097209 */
72107210 val fill : Option[String] = None,
72117211
7212+ /**
7213+ * The fill opacity (value between [0,1]).
7214+ *
7215+ * __Default value:__ `1`
7216+ */
7217+ val fillOpacity : Option[Double] = None,
7218+
72127219 /**
72137220 * Whether the mark's color should be used as fill color instead of stroke color.
72147221 *
@@ -7220,13 +7227,6 @@ case class MarkDef (
72207227 */
72217228 val filled : Option[Boolean] = None,
72227229
7223- /**
7224- * The fill opacity (value between [0,1]).
7225- *
7226- * __Default value:__ `1`
7227- */
7228- val fillOpacity : Option[Double] = None,
7229-
72307230 /**
72317231 * The typeface to set the text in (e.g., `"Helvetica Neue"`).
72327232 */
Mschema-schema/test/inputs/schema/accessors.schema/default/TopLevel.schema+4 −4
@@ -6,8 +6,8 @@
66 "type": "object",
77 "additionalProperties": false,
88 "properties": {
9- "bar": {
10- "type": "string"
9+ "union": {
10+ "$ref": "#/definitions/Union"
1111 },
1212 "enum": {
1313 "$ref": "#/definitions/Enum"
@@ -15,8 +15,8 @@
1515 "foo": {
1616 "type": "string"
1717 },
18- "union": {
19- "$ref": "#/definitions/Union"
18+ "bar": {
19+ "type": "string"
2020 }
2121 },
2222 "required": [
Mschema-schema/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.schema+3 −3
@@ -12,11 +12,11 @@
1212 "frequency": {
1313 "$ref": "#/definitions/Frequency"
1414 },
15- "description": {
16- "type": "string"
17- },
1815 "type": {
1916 "$ref": "#/definitions/Type"
17+ },
18+ "description": {
19+ "type": "string"
2020 }
2121 },
2222 "required": [
Mschema-schema/test/inputs/schema/bool-string.schema/default/TopLevel.schema+25 −25
@@ -6,26 +6,13 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "arrNullable": {
10- "type": "array",
11- "items": {
12- "anyOf": [
13- {
14- "type": "string",
15- "format": "boolean"
16- },
17- {
18- "type": "null"
19- }
20- ]
21- }
9+ "one": {
10+ "type": "string",
11+ "format": "boolean"
2212 },
23- "arrOne": {
24- "type": "array",
25- "items": {
26- "type": "string",
27- "format": "boolean"
28- }
13+ "optional": {
14+ "type": "string",
15+ "format": "boolean"
2916 },
3017 "nullable": {
3118 "anyOf": [
@@ -38,13 +25,26 @@
3825 }
3926 ]
4027 },
41- "one": {
42- "type": "string",
43- "format": "boolean"
28+ "arrOne": {
29+ "type": "array",
30+ "items": {
31+ "type": "string",
32+ "format": "boolean"
33+ }
4434 },
45- "optional": {
46- "type": "string",
47- "format": "boolean"
35+ "arrNullable": {
36+ "type": "array",
37+ "items": {
38+ "anyOf": [
39+ {
40+ "type": "string",
41+ "format": "boolean"
42+ },
43+ {
44+ "type": "null"
45+ }
46+ ]
47+ }
4848 },
4949 "unionWithBool": {
5050 "$ref": "#/definitions/UnionWithBool"
Mschema-schema/test/inputs/schema/boolean-subschema.schema/default/TopLevel.schema+3 −3
@@ -6,14 +6,14 @@
66 "type": "object",
77 "additionalProperties": false,
88 "properties": {
9+ "foo": {
10+ "type": "string"
11+ },
912 "disallowed": {},
1013 "empty": {
1114 "type": "array",
1215 "items": {}
1316 },
14- "foo": {
15- "type": "string"
16- },
1717 "impossible": {}
1818 },
1919 "required": [
Mschema-schema/test/inputs/schema/comment-injection.schema/default/TopLevel.schema+4 −4
@@ -6,6 +6,10 @@
66 "type": "object",
77 "additionalProperties": false,
88 "properties": {
9+ "value": {
10+ "type": "string",
11+ "description": "Property delimiters:\n*/\n/*\n{-\n-}\n\"\"\"\n</summary> & <br>\n}\n}\n}\n}\n}"
12+ },
913 "trailingBackslash": {
1014 "type": "string",
1115 "description": "Ends with a backslash \\"
@@ -17,10 +21,6 @@
1721 "trailingTripleQuote": {
1822 "type": "string",
1923 "description": "Ends with a triple quote \"\"\""
20- },
21- "value": {
22- "type": "string",
23- "description": "Property delimiters:\n*/\n/*\n{-\n-}\n\"\"\"\n</summary> & <br>\n}\n}\n}\n}\n}"
2424 }
2525 },
2626 "required": [
Mschema-schema/test/inputs/schema/const-non-string.schema/default/TopLevel.schema+6 −6
@@ -6,20 +6,20 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9+ "version": {
10+ "type": "number"
11+ },
912 "amount": {
1013 "type": "integer"
1114 },
15+ "ratio": {
16+ "type": "number"
17+ },
1218 "enabled": {
1319 "type": "boolean"
1420 },
1521 "kind": {
1622 "$ref": "#/definitions/Kind"
17- },
18- "ratio": {
19- "type": "number"
20- },
21- "version": {
22- "type": "number"
2323 }
2424 },
2525 "required": [
Mschema-schema/test/inputs/schema/date-time-or-string.schema/default/TopLevel.schema+3 −3
@@ -6,11 +6,11 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "bar": {
10- "$ref": "#/definitions/BarUnion"
11- },
129 "foo": {
1310 "type": "string"
11+ },
12+ "bar": {
13+ "$ref": "#/definitions/BarUnion"
1414 }
1515 },
1616 "required": [
Mschema-schema/test/inputs/schema/date-time.schema/default/TopLevel.schema+10 −10
@@ -6,29 +6,29 @@
66 "type": "object",
77 "additionalProperties": false,
88 "properties": {
9- "complex-union-array": {
10- "type": "array",
11- "items": {
12- "$ref": "#/definitions/ComplexUnionArrayElement"
13- }
14- },
159 "date": {
1610 "type": "string",
1711 "format": "date"
1812 },
19- "date-time": {
20- "type": "string",
21- "format": "date-time"
22- },
2313 "time": {
2414 "type": "string",
2515 "format": "time"
2616 },
17+ "date-time": {
18+ "type": "string",
19+ "format": "date-time"
20+ },
2721 "union-array": {
2822 "type": "array",
2923 "items": {
3024 "$ref": "#/definitions/UnionArray"
3125 }
26+ },
27+ "complex-union-array": {
28+ "type": "array",
29+ "items": {
30+ "$ref": "#/definitions/ComplexUnionArrayElement"
31+ }
3232 }
3333 },
3434 "required": [
Mschema-schema/test/inputs/schema/description.schema/default/TopLevel.schema+7 −7
@@ -6,9 +6,9 @@
66 "type": "object",
77 "additionalProperties": false,
88 "properties": {
9- "bar": {
10- "type": "boolean",
11- "description": "A pretty boolean"
9+ "union": {
10+ "$ref": "#/definitions/Union",
11+ "description": "Either a number or a string"
1212 },
1313 "enum": {
1414 "$ref": "#/definitions/Enum",
@@ -17,12 +17,12 @@
1717 "foo": {
1818 "type": "number"
1919 },
20+ "bar": {
21+ "type": "boolean",
22+ "description": "A pretty boolean"
23+ },
2024 "object-or-string": {
2125 "$ref": "#/definitions/ObjectOrStringUnion"
22- },
23- "union": {
24- "$ref": "#/definitions/Union",
25- "description": "Either a number or a string"
2626 }
2727 },
2828 "required": [
Mschema-schema/test/inputs/schema/direct-union.schema/default/TopLevel.schema+2 −2
@@ -22,10 +22,10 @@
2222 "type": "object",
2323 "additionalProperties": false,
2424 "properties": {
25- "optional": {
25+ "required": {
2626 "$ref": "#/definitions/Anything"
2727 },
28- "required": {
28+ "optional": {
2929 "$ref": "#/definitions/Anything"
3030 }
3131 },
Mschema-schema/test/inputs/schema/enum.schema/default/TopLevel.schema+9 −9
@@ -6,26 +6,26 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9+ "lvc": {
10+ "$ref": "#/definitions/Lvc"
11+ },
12+ "gve": {
13+ "$ref": "#/definitions/Gve"
14+ },
915 "arr": {
1016 "type": "array",
1117 "items": {
1218 "$ref": "#/definitions/Arr"
1319 }
1420 },
15- "for": {
16- "type": "string"
17- },
18- "gve": {
19- "$ref": "#/definitions/Gve"
20- },
21- "lvc": {
22- "$ref": "#/definitions/Lvc"
23- },
2421 "otherArr": {
2522 "type": "array",
2623 "items": {
2724 "$ref": "#/definitions/OtherArr"
2825 }
26+ },
27+ "for": {
28+ "type": "string"
2929 }
3030 },
3131 "required": [
Mschema-schema/test/inputs/schema/integer-string.schema/default/TopLevel.schema+25 −25
@@ -6,26 +6,13 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "arrNullable": {
10- "type": "array",
11- "items": {
12- "anyOf": [
13- {
14- "type": "string",
15- "format": "integer"
16- },
17- {
18- "type": "null"
19- }
20- ]
21- }
9+ "one": {
10+ "type": "string",
11+ "format": "integer"
2212 },
23- "arrOne": {
24- "type": "array",
25- "items": {
26- "type": "string",
27- "format": "integer"
28- }
13+ "optional": {
14+ "type": "string",
15+ "format": "integer"
2916 },
3017 "nullable": {
3118 "anyOf": [
@@ -38,13 +25,26 @@
3825 }
3926 ]
4027 },
41- "one": {
42- "type": "string",
43- "format": "integer"
28+ "arrOne": {
29+ "type": "array",
30+ "items": {
31+ "type": "string",
32+ "format": "integer"
33+ }
4434 },
45- "optional": {
46- "type": "string",
47- "format": "integer"
35+ "arrNullable": {
36+ "type": "array",
37+ "items": {
38+ "anyOf": [
39+ {
40+ "type": "string",
41+ "format": "integer"
42+ },
43+ {
44+ "type": "null"
45+ }
46+ ]
47+ }
4848 },
4949 "unionWithInt": {
5050 "$ref": "#/definitions/UnionWithInt"
Mschema-schema/test/inputs/schema/integer-type.schema/default/TopLevel.schema+15 −15
@@ -6,14 +6,14 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "above_i32_max": {
9+ "small_positive": {
1010 "type": "integer",
1111 "minimum": 0,
12- "maximum": 2147483648
12+ "maximum": 100
1313 },
14- "below_i32_min": {
14+ "small_negative": {
1515 "type": "integer",
16- "minimum": -2147483649,
16+ "minimum": -100,
1717 "maximum": 0
1818 },
1919 "i32_range": {
@@ -21,31 +21,31 @@
2121 "minimum": -2147483648,
2222 "maximum": 2147483647
2323 },
24- "large_bounds": {
24+ "above_i32_max": {
2525 "type": "integer",
26- "minimum": -9007199254740991,
27- "maximum": 9007199254740991
26+ "minimum": 0,
27+ "maximum": 2147483648
2828 },
29- "only_maximum": {
29+ "below_i32_min": {
3030 "type": "integer",
31+ "minimum": -2147483649,
3132 "maximum": 0
3233 },
3334 "only_minimum": {
3435 "type": "integer",
3536 "minimum": 0
3637 },
37- "small_negative": {
38+ "only_maximum": {
3839 "type": "integer",
39- "minimum": -100,
4040 "maximum": 0
4141 },
42- "small_positive": {
43- "type": "integer",
44- "minimum": 0,
45- "maximum": 100
46- },
4742 "unbounded": {
4843 "type": "integer"
44+ },
45+ "large_bounds": {
46+ "type": "integer",
47+ "minimum": -9007199254740991,
48+ "maximum": 9007199254740991
4949 }
5050 },
5151 "required": [
Mschema-schema/test/inputs/schema/keyword-unions.schema/default/TopLevel.schema+6 −6
@@ -234,9 +234,6 @@
234234 "double": {
235235 "$ref": "#/definitions/UnionDouble"
236236 },
237- "dummy": {
238- "type": "number"
239- },
240237 "dynamic": {
241238 "$ref": "#/definitions/UnionDynamic"
242239 },
@@ -393,12 +390,12 @@
393390 "internal": {
394391 "$ref": "#/definitions/UnionInternal"
395392 },
396- "is": {
397- "$ref": "#/definitions/UnionIs"
398- },
399393 "iterable": {
400394 "$ref": "#/definitions/UnionIterable"
401395 },
396+ "is": {
397+ "$ref": "#/definitions/UnionIs"
398+ },
402399 "jdec": {
403400 "$ref": "#/definitions/UnionJdec"
404401 },
@@ -836,6 +833,9 @@
836833 },
837834 "yield": {
838835 "$ref": "#/definitions/UnionYield"
836+ },
837+ "dummy": {
838+ "type": "number"
839839 }
840840 },
841841 "required": [],
Mschema-schema/test/inputs/schema/light.schema/default/TopLevel.schema+2 −2
@@ -19,10 +19,10 @@
1919 "type": "object",
2020 "additionalProperties": false,
2121 "properties": {
22- "app_id": {
22+ "outlet_id": {
2323 "type": "string"
2424 },
25- "outlet_id": {
25+ "app_id": {
2626 "type": "string"
2727 },
2828 "rgba": {
Mschema-schema/test/inputs/schema/min-max-items.schema/default/TopLevel.schema+7 −7
@@ -6,6 +6,13 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9+ "minOnly": {
10+ "type": "array",
11+ "items": {
12+ "type": "string"
13+ },
14+ "minItems": 2
15+ },
916 "maxOnly": {
1017 "type": "array",
1118 "items": {
@@ -21,13 +28,6 @@
2128 "minItems": 1,
2229 "maxItems": 4
2330 },
24- "minOnly": {
25- "type": "array",
26- "items": {
27- "type": "string"
28- },
29- "minItems": 2
30- },
3131 "plain": {
3232 "type": "array",
3333 "items": {
Mschema-schema/test/inputs/schema/minmax-integer.schema/default/TopLevel.schema+11 −11
@@ -9,36 +9,36 @@
99 "free": {
1010 "type": "integer"
1111 },
12- "intersection": {
12+ "min": {
1313 "type": "integer",
14- "minimum": 4,
15- "maximum": 5
14+ "minimum": 3
1615 },
1716 "max": {
1817 "type": "integer",
1918 "maximum": 5
2019 },
21- "min": {
22- "type": "integer",
23- "minimum": 3
24- },
2520 "minmax": {
2621 "type": "integer",
2722 "minimum": 3,
2823 "maximum": 5
2924 },
30- "minMaxIntersection": {
25+ "union": {
3126 "type": "integer",
3227 "minimum": 3,
33- "maximum": 5
28+ "maximum": 6
3429 },
3530 "minMaxUnion": {
3631 "type": "integer"
3732 },
38- "union": {
33+ "intersection": {
34+ "type": "integer",
35+ "minimum": 4,
36+ "maximum": 5
37+ },
38+ "minMaxIntersection": {
3939 "type": "integer",
4040 "minimum": 3,
41- "maximum": 6
41+ "maximum": 5
4242 }
4343 },
4444 "required": [
Mschema-schema/test/inputs/schema/minmax.schema/default/TopLevel.schema+11 −11
@@ -9,36 +9,36 @@
99 "free": {
1010 "type": "number"
1111 },
12- "intersection": {
12+ "min": {
1313 "type": "number",
14- "minimum": 4,
15- "maximum": 5
14+ "minimum": 3
1615 },
1716 "max": {
1817 "type": "number",
1918 "maximum": 5
2019 },
21- "min": {
22- "type": "number",
23- "minimum": 3
24- },
2520 "minmax": {
2621 "type": "number",
2722 "minimum": 3,
2823 "maximum": 5
2924 },
30- "minMaxIntersection": {
25+ "union": {
3126 "type": "number",
3227 "minimum": 3,
33- "maximum": 5
28+ "maximum": 6
3429 },
3530 "minMaxUnion": {
3631 "type": "number"
3732 },
38- "union": {
33+ "intersection": {
34+ "type": "number",
35+ "minimum": 4,
36+ "maximum": 5
37+ },
38+ "minMaxIntersection": {
3939 "type": "number",
4040 "minimum": 3,
41- "maximum": 6
41+ "maximum": 5
4242 }
4343 },
4444 "required": [
Mschema-schema/test/inputs/schema/minmaxlength.schema/default/TopLevel.schema+15 −15
@@ -6,39 +6,39 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "intersection": {
9+ "minlength": {
1010 "type": "string",
11- "minLength": 4,
12- "maxLength": 5
13- },
14- "inUnion": {
15- "$ref": "#/definitions/InUnion"
11+ "minLength": 3
1612 },
1713 "maxlength": {
1814 "type": "string",
1915 "maxLength": 5
2016 },
21- "minlength": {
22- "type": "string",
23- "minLength": 3
24- },
25- "minMaxIntersection": {
17+ "minmaxlength": {
2618 "type": "string",
2719 "minLength": 3,
2820 "maxLength": 5
2921 },
30- "minmaxlength": {
22+ "union": {
3123 "type": "string",
3224 "minLength": 3,
33- "maxLength": 5
25+ "maxLength": 6
26+ },
27+ "inUnion": {
28+ "$ref": "#/definitions/InUnion"
3429 },
3530 "minMaxUnion": {
3631 "type": "string"
3732 },
38- "union": {
33+ "intersection": {
34+ "type": "string",
35+ "minLength": 4,
36+ "maxLength": 5
37+ },
38+ "minMaxIntersection": {
3939 "type": "string",
4040 "minLength": 3,
41- "maxLength": 6
41+ "maxLength": 5
4242 }
4343 },
4444 "required": [
Mschema-schema/test/inputs/schema/non-standard-ref.schema/default/TopLevel.schema+2 −2
@@ -6,10 +6,10 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "bar": {
9+ "foo": {
1010 "type": "integer"
1111 },
12- "foo": {
12+ "bar": {
1313 "type": "integer"
1414 },
1515 "quux": {
Mschema-schema/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.schema+3 −3
@@ -6,6 +6,9 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9+ "kind": {
10+ "$ref": "#/definitions/Kind"
11+ },
912 "b": {
1013 "anyOf": [
1114 {
@@ -15,9 +18,6 @@
1518 "type": "string"
1619 }
1720 ]
18- },
19- "kind": {
20- "$ref": "#/definitions/Kind"
2121 }
2222 },
2323 "required": [
Mschema-schema/test/inputs/schema/optional-any.schema/default/TopLevel.schema+2 −2
@@ -6,10 +6,10 @@
66 "type": "object",
77 "additionalProperties": false,
88 "properties": {
9+ "foo": {},
910 "bar": {
1011 "type": "boolean"
11- },
12- "foo": {}
12+ }
1313 },
1414 "required": [
1515 "bar"
Mschema-schema/test/inputs/schema/optional-const-ref.schema/default/TopLevel.schema+15 −15
@@ -12,36 +12,36 @@
1212 "$ref": "#/definitions/Coordinate"
1313 }
1414 },
15- "count": {
16- "type": "integer",
17- "minimum": 1,
18- "maximum": 100
19- },
20- "label": {
21- "type": "string",
22- "minLength": 2,
23- "maxLength": 16
24- },
2515 "requiredCoordinates": {
2616 "type": "array",
2717 "items": {
2818 "$ref": "#/definitions/Coordinate"
2919 }
3020 },
31- "requiredCount": {
21+ "count": {
3222 "type": "integer",
3323 "minimum": 1,
3424 "maximum": 100
3525 },
36- "requiredLabel": {
37- "type": "string",
38- "minLength": 2,
39- "maxLength": 16
26+ "requiredCount": {
27+ "type": "integer",
28+ "minimum": 1,
29+ "maximum": 100
4030 },
4131 "weight": {
4232 "type": "number",
4333 "minimum": 0.5,
4434 "maximum": 99.5
35+ },
36+ "label": {
37+ "type": "string",
38+ "minLength": 2,
39+ "maxLength": 16
40+ },
41+ "requiredLabel": {
42+ "type": "string",
43+ "minLength": 2,
44+ "maxLength": 16
4545 }
4646 },
4747 "required": [
Mschema-schema/test/inputs/schema/optional-constraints.schema/default/TopLevel.schema+11 −11
@@ -6,29 +6,29 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "optDouble": {
10- "type": "number",
11- "minimum": 0.5,
12- "maximum": 99.5
9+ "reqZeroMin": {
10+ "type": "integer",
11+ "minimum": 0,
12+ "maximum": 100
1313 },
1414 "optInt": {
1515 "type": "integer",
1616 "minimum": 0,
1717 "maximum": 100
1818 },
19- "optPattern": {
20- "type": "string",
21- "pattern": "^[a-z]+$"
19+ "optDouble": {
20+ "type": "number",
21+ "minimum": 0.5,
22+ "maximum": 99.5
2223 },
2324 "optString": {
2425 "type": "string",
2526 "minLength": 3,
2627 "maxLength": 10
2728 },
28- "reqZeroMin": {
29- "type": "integer",
30- "minimum": 0,
31- "maximum": 100
29+ "optPattern": {
30+ "type": "string",
31+ "pattern": "^[a-z]+$"
3232 }
3333 },
3434 "required": [
Mschema-schema/test/inputs/schema/optional-date-time.schema/default/TopLevel.schema+10 −10
@@ -6,29 +6,29 @@
66 "type": "object",
77 "additionalProperties": false,
88 "properties": {
9- "optional-date": {
9+ "required-date": {
1010 "type": "string",
1111 "format": "date"
1212 },
13- "optional-date-time": {
13+ "required-time": {
1414 "type": "string",
15- "format": "date-time"
15+ "format": "time"
1616 },
17- "optional-time": {
17+ "required-date-time": {
1818 "type": "string",
19- "format": "time"
19+ "format": "date-time"
2020 },
21- "required-date": {
21+ "optional-date": {
2222 "type": "string",
2323 "format": "date"
2424 },
25- "required-date-time": {
25+ "optional-time": {
2626 "type": "string",
27- "format": "date-time"
27+ "format": "time"
2828 },
29- "required-time": {
29+ "optional-date-time": {
3030 "type": "string",
31- "format": "time"
31+ "format": "date-time"
3232 }
3333 },
3434 "required": [
Mschema-schema/test/inputs/schema/prefix-items.schema/default/TopLevel.schema+2 −2
@@ -6,13 +6,13 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "open": {
9+ "tuple": {
1010 "type": "array",
1111 "items": {
1212 "$ref": "#/definitions/Open"
1313 }
1414 },
15- "tuple": {
15+ "open": {
1616 "type": "array",
1717 "items": {
1818 "$ref": "#/definitions/Open"
Aschema-schema/test/inputs/schema/property-order.schema/default/TopLevel.schema+60 −0
@@ -0,0 +1,60 @@
1+{
2+ "$schema": "http://json-schema.org/draft-06/schema#",
3+ "$ref": "#/definitions/TopLevel",
4+ "definitions": {
5+ "TopLevel": {
6+ "type": "object",
7+ "additionalProperties": false,
8+ "properties": {
9+ "zebra": {
10+ "type": "string"
11+ },
12+ "mango": {
13+ "type": "number"
14+ },
15+ "apple": {
16+ "type": "boolean"
17+ },
18+ "delta": {
19+ "type": "string"
20+ },
21+ "banana": {
22+ "type": "integer"
23+ },
24+ "ordered": {
25+ "$ref": "#/definitions/Ordered"
26+ }
27+ },
28+ "required": [
29+ "apple",
30+ "banana",
31+ "delta",
32+ "mango",
33+ "ordered",
34+ "zebra"
35+ ],
36+ "title": "TopLevel"
37+ },
38+ "Ordered": {
39+ "type": "object",
40+ "additionalProperties": false,
41+ "properties": {
42+ "mango": {
43+ "type": "number"
44+ },
45+ "zebra": {
46+ "type": "string"
47+ },
48+ "apple": {
49+ "type": "boolean"
50+ }
51+ },
52+ "required": [
53+ "apple",
54+ "mango",
55+ "zebra"
56+ ],
57+ "title": "Ordered"
58+ }
59+ }
60+}
Mschema-schema/test/inputs/schema/renaming-bug.schema/default/TopLevel.schema+23 −23
@@ -33,14 +33,14 @@
3333 "apple": {
3434 "type": "boolean"
3535 },
36+ "orange": {
37+ "type": "boolean"
38+ },
3639 "berries": {
3740 "type": "array",
3841 "items": {
3942 "$ref": "#/definitions/Berry"
4043 }
41- },
42- "orange": {
43- "type": "boolean"
4444 }
4545 },
4646 "required": [],
@@ -50,13 +50,13 @@
5050 "type": "object",
5151 "additionalProperties": {},
5252 "properties": {
53- "color": {
54- "$ref": "#/definitions/Color"
55- },
5653 "name": {
5754 "type": "string",
5855 "minLength": 1
5956 },
57+ "color": {
58+ "$ref": "#/definitions/Color"
59+ },
6060 "shapes": {
6161 "type": "array",
6262 "items": {
@@ -82,11 +82,11 @@
8282 "type": "object",
8383 "additionalProperties": {},
8484 "properties": {
85- "geometry": {
86- "$ref": "#/definitions/Geometry"
87- },
8885 "history": {
8986 "$ref": "#/definitions/History"
87+ },
88+ "geometry": {
89+ "$ref": "#/definitions/Geometry"
9090 }
9191 },
9292 "required": [],
@@ -138,14 +138,14 @@
138138 "type": "object",
139139 "additionalProperties": {},
140140 "properties": {
141- "depth": {
142- "type": "string"
143- },
144141 "length": {
145142 "type": "string"
146143 },
147144 "width": {
148145 "type": "string"
146+ },
147+ "depth": {
148+ "type": "string"
149149 }
150150 },
151151 "required": [],
@@ -166,24 +166,24 @@
166166 "type": "object",
167167 "additionalProperties": {},
168168 "properties": {
169- "brand": {
170- "type": "string"
171- },
172169 "id": {
173170 "type": "string",
174171 "minLength": 1
175172 },
176- "speed": {
177- "$ref": "#/definitions/Speed"
178- },
179- "subModule": {
180- "type": "boolean"
181- },
182173 "type": {
183174 "$ref": "#/definitions/VehicleType"
184175 },
176+ "speed": {
177+ "$ref": "#/definitions/Speed"
178+ },
185179 "year": {
186180 "type": "string"
181+ },
182+ "brand": {
183+ "type": "string"
184+ },
185+ "subModule": {
186+ "type": "boolean"
187187 }
188188 },
189189 "required": [],
@@ -204,10 +204,10 @@
204204 "type": "object",
205205 "additionalProperties": {},
206206 "properties": {
207- "maximum": {
207+ "minimum": {
208208 "type": "number"
209209 },
210- "minimum": {
210+ "maximum": {
211211 "type": "number"
212212 }
213213 },
Mschema-schema/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.schema+6 −6
@@ -6,11 +6,11 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "next": {
10- "$ref": "#/definitions/Next"
11- },
129 "value": {
1310 "type": "string"
11+ },
12+ "next": {
13+ "$ref": "#/definitions/Next"
1414 }
1515 },
1616 "required": [
@@ -22,11 +22,11 @@
2222 "type": "object",
2323 "additionalProperties": {},
2424 "properties": {
25- "next": {
26- "$ref": "#/definitions/Next"
27- },
2825 "value": {
2926 "type": "string"
27+ },
28+ "next": {
29+ "$ref": "#/definitions/Next"
3030 }
3131 },
3232 "required": [
Mschema-schema/test/inputs/schema/uuid.schema/default/TopLevel.schema+25 −25
@@ -6,26 +6,13 @@
66 "type": "object",
77 "additionalProperties": {},
88 "properties": {
9- "arrNullable": {
10- "type": "array",
11- "items": {
12- "anyOf": [
13- {
14- "type": "null"
15- },
16- {
17- "type": "string",
18- "format": "uuid"
19- }
20- ]
21- }
9+ "one": {
10+ "type": "string",
11+ "format": "uuid"
2212 },
23- "arrOne": {
24- "type": "array",
25- "items": {
26- "type": "string",
27- "format": "uuid"
28- }
13+ "optional": {
14+ "type": "string",
15+ "format": "uuid"
2916 },
3017 "nullable": {
3118 "anyOf": [
@@ -38,13 +25,26 @@
3825 }
3926 ]
4027 },
41- "one": {
42- "type": "string",
43- "format": "uuid"
28+ "arrOne": {
29+ "type": "array",
30+ "items": {
31+ "type": "string",
32+ "format": "uuid"
33+ }
4434 },
45- "optional": {
46- "type": "string",
47- "format": "uuid"
35+ "arrNullable": {
36+ "type": "array",
37+ "items": {
38+ "anyOf": [
39+ {
40+ "type": "null"
41+ },
42+ {
43+ "type": "string",
44+ "format": "uuid"
45+ }
46+ ]
47+ }
4848 },
4949 "unionWithEnum": {
5050 "$ref": "#/definitions/UnionWithEnumUnion"
Mschema-schema/test/inputs/schema/vega-lite.schema/default/TopLevel.schema+32 −32
@@ -335,16 +335,16 @@
335335 "type": "string",
336336 "description": "Default Fill Color. This has higher precedence than config.color\n\n__Default value:__ (None)"
337337 },
338- "filled": {
339- "type": "boolean",
340- "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
341- },
342338 "fillOpacity": {
343339 "type": "number",
344340 "minimum": 0,
345341 "maximum": 1,
346342 "description": "The fill opacity (value between [0,1]).\n\n__Default value:__ `1`"
347343 },
344+ "filled": {
345+ "type": "boolean",
346+ "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
347+ },
348348 "font": {
349349 "type": "string",
350350 "description": "The typeface to set the text in (e.g., `\"Helvetica Neue\"`)."
@@ -552,10 +552,6 @@
552552 "type": "boolean",
553553 "description": "Boolean flag indicating if pixel position values should be rounded to the nearest integer."
554554 },
555- "ticks": {
556- "type": "boolean",
557- "description": "Boolean value that determines whether the axis should include ticks."
558- },
559555 "tickSize": {
560556 "type": "number",
561557 "minimum": 0,
@@ -566,6 +562,10 @@
566562 "minimum": 0,
567563 "description": "The width, in pixels, of ticks."
568564 },
565+ "ticks": {
566+ "type": "boolean",
567+ "description": "Boolean value that determines whether the axis should include ticks."
568+ },
569569 "titleAlign": {
570570 "type": "string",
571571 "description": "Horizontal text alignment of axis titles."
@@ -725,10 +725,6 @@
725725 "type": "boolean",
726726 "description": "Boolean flag indicating if pixel position values should be rounded to the nearest integer."
727727 },
728- "ticks": {
729- "type": "boolean",
730- "description": "Boolean value that determines whether the axis should include ticks."
731- },
732728 "tickSize": {
733729 "type": "number",
734730 "minimum": 0,
@@ -739,6 +735,10 @@
739735 "minimum": 0,
740736 "description": "The width, in pixels, of ticks."
741737 },
738+ "ticks": {
739+ "type": "boolean",
740+ "description": "Boolean value that determines whether the axis should include ticks."
741+ },
742742 "titleAlign": {
743743 "type": "string",
744744 "description": "Horizontal text alignment of axis titles."
@@ -846,16 +846,16 @@
846846 "type": "string",
847847 "description": "Default Fill Color. This has higher precedence than config.color\n\n__Default value:__ (None)"
848848 },
849- "filled": {
850- "type": "boolean",
851- "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
852- },
853849 "fillOpacity": {
854850 "type": "number",
855851 "minimum": 0,
856852 "maximum": 1,
857853 "description": "The fill opacity (value between [0,1]).\n\n__Default value:__ `1`"
858854 },
855+ "filled": {
856+ "type": "boolean",
857+ "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
858+ },
859859 "font": {
860860 "type": "string",
861861 "description": "The typeface to set the text in (e.g., `\"Helvetica Neue\"`)."
@@ -1795,16 +1795,16 @@
17951795 "type": "string",
17961796 "description": "Default Fill Color. This has higher precedence than config.color\n\n__Default value:__ (None)"
17971797 },
1798- "filled": {
1799- "type": "boolean",
1800- "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
1801- },
18021798 "fillOpacity": {
18031799 "type": "number",
18041800 "minimum": 0,
18051801 "maximum": 1,
18061802 "description": "The fill opacity (value between [0,1]).\n\n__Default value:__ `1`"
18071803 },
1804+ "filled": {
1805+ "type": "boolean",
1806+ "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
1807+ },
18081808 "font": {
18091809 "type": "string",
18101810 "description": "The typeface to set the text in (e.g., `\"Helvetica Neue\"`)."
@@ -1950,16 +1950,16 @@
19501950 "type": "string",
19511951 "description": "Default Fill Color. This has higher precedence than config.color\n\n__Default value:__ (None)"
19521952 },
1953- "filled": {
1954- "type": "boolean",
1955- "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
1956- },
19571953 "fillOpacity": {
19581954 "type": "number",
19591955 "minimum": 0,
19601956 "maximum": 1,
19611957 "description": "The fill opacity (value between [0,1]).\n\n__Default value:__ `1`"
19621958 },
1959+ "filled": {
1960+ "type": "boolean",
1961+ "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
1962+ },
19631963 "font": {
19641964 "type": "string",
19651965 "description": "The typeface to set the text in (e.g., `\"Helvetica Neue\"`)."
@@ -3316,15 +3316,15 @@
33163316 "type": "number",
33173317 "description": "A desired number of ticks, for axes visualizing quantitative scales. The resulting number\nmay be different so that values are \"nice\" (multiples of 2, 5, 10) and lie within the\nunderlying scale's range."
33183318 },
3319- "ticks": {
3320- "type": "boolean",
3321- "description": "Boolean value that determines whether the axis should include ticks."
3322- },
33233319 "tickSize": {
33243320 "type": "number",
33253321 "minimum": 0,
33263322 "description": "The size in pixels of axis ticks."
33273323 },
3324+ "ticks": {
3325+ "type": "boolean",
3326+ "description": "Boolean value that determines whether the axis should include ticks."
3327+ },
33283328 "title": {
33293329 "anyOf": [
33303330 {
@@ -3679,16 +3679,16 @@
36793679 "type": "string",
36803680 "description": "Default Fill Color. This has higher precedence than config.color\n\n__Default value:__ (None)"
36813681 },
3682- "filled": {
3683- "type": "boolean",
3684- "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
3685- },
36863682 "fillOpacity": {
36873683 "type": "number",
36883684 "minimum": 0,
36893685 "maximum": 1,
36903686 "description": "The fill opacity (value between [0,1]).\n\n__Default value:__ `1`"
36913687 },
3688+ "filled": {
3689+ "type": "boolean",
3690+ "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `true` for all marks except `point` and `false` for `point`.\n\n__Applicable for:__ `bar`, `point`, `circle`, `square`, and `area` marks.\n\n__Note:__ This property cannot be used in a [style config](mark.html#style-config)."
3691+ },
36923692 "font": {
36933693 "type": "string",
36943694 "description": "The typeface to set the text in (e.g., `\"Helvetica Neue\"`)."
Mschema-swift/test/inputs/schema/accessors.schema/default/quicktype.swift+8 −8
@@ -7,16 +7,16 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let barre: String
10+ let unionization: Union
1111 let enumerification: Enum
1212 let foo: String
13- let unionization: Union
13+ let barre: String
1414
1515 enum CodingKeys: String, CodingKey {
16- case barre = "bar"
16+ case unionization = "union"
1717 case enumerification = "enum"
1818 case foo = "foo"
19- case unionization = "union"
19+ case barre = "bar"
2020 }
2121 }
2222
@@ -39,16 +39,16 @@ extension TopLevel {
3939 }
4040
4141 func with(
42- barre: String? = nil,
42+ unionization: Union? = nil,
4343 enumerification: Enum? = nil,
4444 foo: String? = nil,
45- unionization: Union? = nil
45+ barre: String? = nil
4646 ) -> TopLevel {
4747 return TopLevel(
48- barre: barre ?? self.barre,
48+ unionization: unionization ?? self.unionization,
4949 enumerification: enumerification ?? self.enumerification,
5050 foo: foo ?? self.foo,
51- unionization: unionization ?? self.unionization
51+ barre: barre ?? self.barre
5252 )
5353 }
Mschema-swift/test/inputs/schema/bool-string.schema/default/quicktype.swift+12 −12
@@ -7,20 +7,20 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let arrNullable: [String?]?
11- let arrOne: [String]?
12- let nullable: String?
1310 let one: String
1411 let topLevelOptional: String?
12+ let nullable: String?
13+ let arrOne: [String]?
14+ let arrNullable: [String?]?
1515 let unionWithBool: UnionWithBool
1616 let unionWithBoolAndEnum: UnionWithBool
1717
1818 enum CodingKeys: String, CodingKey {
19- case arrNullable = "arrNullable"
20- case arrOne = "arrOne"
21- case nullable = "nullable"
2219 case one = "one"
2320 case topLevelOptional = "optional"
21+ case nullable = "nullable"
22+ case arrOne = "arrOne"
23+ case arrNullable = "arrNullable"
2424 case unionWithBool = "unionWithBool"
2525 case unionWithBoolAndEnum = "unionWithBoolAndEnum"
2626 }
@@ -45,20 +45,20 @@ extension TopLevel {
4545 }
4646
4747 func with(
48- arrNullable: [String?]?? = nil,
49- arrOne: [String]?? = nil,
50- nullable: String?? = nil,
5148 one: String? = nil,
5249 topLevelOptional: String?? = nil,
50+ nullable: String?? = nil,
51+ arrOne: [String]?? = nil,
52+ arrNullable: [String?]?? = nil,
5353 unionWithBool: UnionWithBool? = nil,
5454 unionWithBoolAndEnum: UnionWithBool? = nil
5555 ) -> TopLevel {
5656 return TopLevel(
57- arrNullable: arrNullable ?? self.arrNullable,
58- arrOne: arrOne ?? self.arrOne,
59- nullable: nullable ?? self.nullable,
6057 one: one ?? self.one,
6158 topLevelOptional: topLevelOptional ?? self.topLevelOptional,
59+ nullable: nullable ?? self.nullable,
60+ arrOne: arrOne ?? self.arrOne,
61+ arrNullable: arrNullable ?? self.arrNullable,
6262 unionWithBool: unionWithBool ?? self.unionWithBool,
6363 unionWithBoolAndEnum: unionWithBoolAndEnum ?? self.unionWithBoolAndEnum
6464 )
Mschema-swift/test/inputs/schema/boolean-subschema.schema/default/quicktype.swift+4 −4
@@ -7,15 +7,15 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10+ let foo: String
1011 let disallowed: JSONAny?
1112 let empty: [JSONAny]
12- let foo: String
1313 let impossible: JSONAny?
1414
1515 enum CodingKeys: String, CodingKey {
16+ case foo = "foo"
1617 case disallowed = "disallowed"
1718 case empty = "empty"
18- case foo = "foo"
1919 case impossible = "impossible"
2020 }
2121 }
@@ -39,15 +39,15 @@ extension TopLevel {
3939 }
4040
4141 func with(
42+ foo: String? = nil,
4243 disallowed: JSONAny?? = nil,
4344 empty: [JSONAny]? = nil,
44- foo: String? = nil,
4545 impossible: JSONAny?? = nil
4646 ) -> TopLevel {
4747 return TopLevel(
48+ foo: foo ?? self.foo,
4849 disallowed: disallowed ?? self.disallowed,
4950 empty: empty ?? self.empty,
50- foo: foo ?? self.foo,
5151 impossible: impossible ?? self.impossible
5252 )
5353 }
Mschema-swift/test/inputs/schema/comment-injection.schema/default/quicktype.swift+11 −11
@@ -19,12 +19,6 @@ import Foundation
1919 /// }
2020 // MARK: - TopLevel
2121 struct TopLevel: Codable {
22- /// Ends with a backslash \
23- let trailingBackslash: String?
24- /// Ends with a quote "
25- let trailingQuote: String?
26- /// Ends with a triple quote """
27- let trailingTripleQuote: String?
2822 /// Property delimiters:
2923 /// */
3024 /// /*
@@ -38,12 +32,18 @@ struct TopLevel: Codable {
3832 /// }
3933 /// }
4034 let value: String
35+ /// Ends with a backslash \
36+ let trailingBackslash: String?
37+ /// Ends with a quote "
38+ let trailingQuote: String?
39+ /// Ends with a triple quote """
40+ let trailingTripleQuote: String?
4141
4242 enum CodingKeys: String, CodingKey {
43+ case value = "value"
4344 case trailingBackslash = "trailingBackslash"
4445 case trailingQuote = "trailingQuote"
4546 case trailingTripleQuote = "trailingTripleQuote"
46- case value = "value"
4747 }
4848 }
4949
@@ -66,16 +66,16 @@ extension TopLevel {
6666 }
6767
6868 func with(
69+ value: String? = nil,
6970 trailingBackslash: String?? = nil,
7071 trailingQuote: String?? = nil,
71- trailingTripleQuote: String?? = nil,
72- value: String? = nil
72+ trailingTripleQuote: String?? = nil
7373 ) -> TopLevel {
7474 return TopLevel(
75+ value: value ?? self.value,
7576 trailingBackslash: trailingBackslash ?? self.trailingBackslash,
7677 trailingQuote: trailingQuote ?? self.trailingQuote,
77- trailingTripleQuote: trailingTripleQuote ?? self.trailingTripleQuote,
78- value: value ?? self.value
78+ trailingTripleQuote: trailingTripleQuote ?? self.trailingTripleQuote
7979 )
8080 }
Mschema-swift/test/inputs/schema/date-time-or-string.schema/default/quicktype.swift+6 −6
@@ -7,12 +7,12 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let bar: BarUnion
1110 let foo: String
11+ let bar: BarUnion
1212
1313 enum CodingKeys: String, CodingKey {
14- case bar = "bar"
1514 case foo = "foo"
15+ case bar = "bar"
1616 }
1717 }
1818
@@ -35,12 +35,12 @@ extension TopLevel {
3535 }
3636
3737 func with(
38- bar: BarUnion? = nil,
39- foo: String? = nil
38+ foo: String? = nil,
39+ bar: BarUnion? = nil
4040 ) -> TopLevel {
4141 return TopLevel(
42- bar: bar ?? self.bar,
43- foo: foo ?? self.foo
42+ foo: foo ?? self.foo,
43+ bar: bar ?? self.bar
4444 )
4545 }
Mschema-swift/test/inputs/schema/description.schema/default/quicktype.swift+12 −12
@@ -9,21 +9,21 @@ import Foundation
99 /// Its description has two lines.
1010 // MARK: - TopLevel
1111 struct TopLevel: Codable {
12- /// A pretty boolean
13- let bar: Bool?
12+ /// Either a number or a string
13+ let union: Union
1414 /// An enumeration
1515 let topLevelEnum: Enum
1616 let foo: Double?
17+ /// A pretty boolean
18+ let bar: Bool?
1719 let objectOrString: ObjectOrStringUnion
18- /// Either a number or a string
19- let union: Union
2020
2121 enum CodingKeys: String, CodingKey {
22- case bar = "bar"
22+ case union = "union"
2323 case topLevelEnum = "enum"
2424 case foo = "foo"
25+ case bar = "bar"
2526 case objectOrString = "object-or-string"
26- case union = "union"
2727 }
2828 }
2929
@@ -46,18 +46,18 @@ extension TopLevel {
4646 }
4747
4848 func with(
49- bar: Bool?? = nil,
49+ union: Union? = nil,
5050 topLevelEnum: Enum? = nil,
5151 foo: Double?? = nil,
52- objectOrString: ObjectOrStringUnion? = nil,
53- union: Union? = nil
52+ bar: Bool?? = nil,
53+ objectOrString: ObjectOrStringUnion? = nil
5454 ) -> TopLevel {
5555 return TopLevel(
56- bar: bar ?? self.bar,
56+ union: union ?? self.union,
5757 topLevelEnum: topLevelEnum ?? self.topLevelEnum,
5858 foo: foo ?? self.foo,
59- objectOrString: objectOrString ?? self.objectOrString,
60- union: union ?? self.union
59+ bar: bar ?? self.bar,
60+ objectOrString: objectOrString ?? self.objectOrString
6161 )
6262 }
Mschema-swift/test/inputs/schema/direct-union.schema/default/quicktype.swift+6 −6
@@ -51,12 +51,12 @@ extension TopLevel {
5151
5252 // MARK: - Thing
5353 struct Thing: Codable {
54- let thingOptional: Anything?
5554 let thingRequired: Anything
55+ let thingOptional: Anything?
5656
5757 enum CodingKeys: String, CodingKey {
58- case thingOptional = "optional"
5958 case thingRequired = "required"
59+ case thingOptional = "optional"
6060 }
6161 }
6262
@@ -79,12 +79,12 @@ extension Thing {
7979 }
8080
8181 func with(
82- thingOptional: Anything?? = nil,
83- thingRequired: Anything? = nil
82+ thingRequired: Anything? = nil,
83+ thingOptional: Anything?? = nil
8484 ) -> Thing {
8585 return Thing(
86- thingOptional: thingOptional ?? self.thingOptional,
87- thingRequired: thingRequired ?? self.thingRequired
86+ thingRequired: thingRequired ?? self.thingRequired,
87+ thingOptional: thingOptional ?? self.thingOptional
8888 )
8989 }
Mschema-swift/test/inputs/schema/integer-string.schema/default/quicktype.swift+12 −12
@@ -7,20 +7,20 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let arrNullable: [String?]?
11- let arrOne: [String]?
12- let nullable: String?
1310 let one: String
1411 let topLevelOptional: String?
12+ let nullable: String?
13+ let arrOne: [String]?
14+ let arrNullable: [String?]?
1515 let unionWithInt: UnionWithInt
1616 let unionWithIntAndEnum: UnionWithInt
1717
1818 enum CodingKeys: String, CodingKey {
19- case arrNullable = "arrNullable"
20- case arrOne = "arrOne"
21- case nullable = "nullable"
2219 case one = "one"
2320 case topLevelOptional = "optional"
21+ case nullable = "nullable"
22+ case arrOne = "arrOne"
23+ case arrNullable = "arrNullable"
2424 case unionWithInt = "unionWithInt"
2525 case unionWithIntAndEnum = "unionWithIntAndEnum"
2626 }
@@ -45,20 +45,20 @@ extension TopLevel {
4545 }
4646
4747 func with(
48- arrNullable: [String?]?? = nil,
49- arrOne: [String]?? = nil,
50- nullable: String?? = nil,
5148 one: String? = nil,
5249 topLevelOptional: String?? = nil,
50+ nullable: String?? = nil,
51+ arrOne: [String]?? = nil,
52+ arrNullable: [String?]?? = nil,
5353 unionWithInt: UnionWithInt? = nil,
5454 unionWithIntAndEnum: UnionWithInt? = nil
5555 ) -> TopLevel {
5656 return TopLevel(
57- arrNullable: arrNullable ?? self.arrNullable,
58- arrOne: arrOne ?? self.arrOne,
59- nullable: nullable ?? self.nullable,
6057 one: one ?? self.one,
6158 topLevelOptional: topLevelOptional ?? self.topLevelOptional,
59+ nullable: nullable ?? self.nullable,
60+ arrOne: arrOne ?? self.arrOne,
61+ arrNullable: arrNullable ?? self.arrNullable,
6262 unionWithInt: unionWithInt ?? self.unionWithInt,
6363 unionWithIntAndEnum: unionWithIntAndEnum ?? self.unionWithIntAndEnum
6464 )
Mschema-swift/test/inputs/schema/integer-type.schema/default/quicktype.swift+22 −22
@@ -7,26 +7,26 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10+ let smallPositive: Int
11+ let smallNegative: Int
12+ let i32Range: Int
1013 let aboveI32Max: Int
1114 let belowI32Min: Int
12- let i32Range: Int
13- let largeBounds: Int
14- let onlyMaximum: Int
1515 let onlyMinimum: Int
16- let smallNegative: Int
17- let smallPositive: Int
16+ let onlyMaximum: Int
1817 let unbounded: Int
18+ let largeBounds: Int
1919
2020 enum CodingKeys: String, CodingKey {
21+ case smallPositive = "small_positive"
22+ case smallNegative = "small_negative"
23+ case i32Range = "i32_range"
2124 case aboveI32Max = "above_i32_max"
2225 case belowI32Min = "below_i32_min"
23- case i32Range = "i32_range"
24- case largeBounds = "large_bounds"
25- case onlyMaximum = "only_maximum"
2626 case onlyMinimum = "only_minimum"
27- case smallNegative = "small_negative"
28- case smallPositive = "small_positive"
27+ case onlyMaximum = "only_maximum"
2928 case unbounded = "unbounded"
29+ case largeBounds = "large_bounds"
3030 }
3131 }
3232
@@ -49,26 +49,26 @@ extension TopLevel {
4949 }
5050
5151 func with(
52+ smallPositive: Int? = nil,
53+ smallNegative: Int? = nil,
54+ i32Range: Int? = nil,
5255 aboveI32Max: Int? = nil,
5356 belowI32Min: Int? = nil,
54- i32Range: Int? = nil,
55- largeBounds: Int? = nil,
56- onlyMaximum: Int? = nil,
5757 onlyMinimum: Int? = nil,
58- smallNegative: Int? = nil,
59- smallPositive: Int? = nil,
60- unbounded: Int? = nil
58+ onlyMaximum: Int? = nil,
59+ unbounded: Int? = nil,
60+ largeBounds: Int? = nil
6161 ) -> TopLevel {
6262 return TopLevel(
63+ smallPositive: smallPositive ?? self.smallPositive,
64+ smallNegative: smallNegative ?? self.smallNegative,
65+ i32Range: i32Range ?? self.i32Range,
6366 aboveI32Max: aboveI32Max ?? self.aboveI32Max,
6467 belowI32Min: belowI32Min ?? self.belowI32Min,
65- i32Range: i32Range ?? self.i32Range,
66- largeBounds: largeBounds ?? self.largeBounds,
67- onlyMaximum: onlyMaximum ?? self.onlyMaximum,
6868 onlyMinimum: onlyMinimum ?? self.onlyMinimum,
69- smallNegative: smallNegative ?? self.smallNegative,
70- smallPositive: smallPositive ?? self.smallPositive,
71- unbounded: unbounded ?? self.unbounded
69+ onlyMaximum: onlyMaximum ?? self.onlyMaximum,
70+ unbounded: unbounded ?? self.unbounded,
71+ largeBounds: largeBounds ?? self.largeBounds
7272 )
7373 }
Mschema-swift/test/inputs/schema/keyword-unions.schema/default/quicktype.swift+10 −10
@@ -83,7 +83,6 @@ struct TopLevel: Codable {
8383 let topLevelDidSet: UnionDidSet?
8484 let topLevelDo: UnionDo?
8585 let double: UnionDouble?
86- let dummy: Double?
8786 let topLevelDynamic: UnionDynamic?
8887 let dynamicCast: UnionDynamicCast?
8988 let elif: UnionElif?
@@ -136,8 +135,8 @@ struct TopLevel: Codable {
136135 let int: UnionInt?
137136 let interface: UnionInterface?
138137 let topLevelInternal: UnionInternal?
139- let topLevelIs: UnionIs?
140138 let iterable: UnionIterable?
139+ let topLevelIs: UnionIs?
141140 let jdec: UnionJdec?
142141 let jenc: UnionJenc?
143142 let jpipe: UnionJpipe?
@@ -284,6 +283,7 @@ struct TopLevel: Codable {
284283 let xorEq: UnionXorEq?
285284 let yes: UnionYES?
286285 let yield: UnionYield?
286+ let dummy: Double?
287287
288288 enum CodingKeys: String, CodingKey {
289289 case empty = "_"
@@ -362,7 +362,6 @@ struct TopLevel: Codable {
362362 case topLevelDidSet = "didSet"
363363 case topLevelDo = "do"
364364 case double = "double"
365- case dummy = "dummy"
366365 case topLevelDynamic = "dynamic"
367366 case dynamicCast = "dynamic_cast"
368367 case elif = "elif"
@@ -415,8 +414,8 @@ struct TopLevel: Codable {
415414 case int = "int"
416415 case interface = "interface"
417416 case topLevelInternal = "internal"
418- case topLevelIs = "is"
419417 case iterable = "iterable"
418+ case topLevelIs = "is"
420419 case jdec = "jdec"
421420 case jenc = "jenc"
422421 case jpipe = "jpipe"
@@ -563,6 +562,7 @@ struct TopLevel: Codable {
563562 case xorEq = "xor_eq"
564563 case yes = "YES"
565564 case yield = "yield"
565+ case dummy = "dummy"
566566 }
567567 }
568568
@@ -661,7 +661,6 @@ extension TopLevel {
661661 topLevelDidSet: UnionDidSet?? = nil,
662662 topLevelDo: UnionDo?? = nil,
663663 double: UnionDouble?? = nil,
664- dummy: Double?? = nil,
665664 topLevelDynamic: UnionDynamic?? = nil,
666665 dynamicCast: UnionDynamicCast?? = nil,
667666 elif: UnionElif?? = nil,
@@ -714,8 +713,8 @@ extension TopLevel {
714713 int: UnionInt?? = nil,
715714 interface: UnionInterface?? = nil,
716715 topLevelInternal: UnionInternal?? = nil,
717- topLevelIs: UnionIs?? = nil,
718716 iterable: UnionIterable?? = nil,
717+ topLevelIs: UnionIs?? = nil,
719718 jdec: UnionJdec?? = nil,
720719 jenc: UnionJenc?? = nil,
721720 jpipe: UnionJpipe?? = nil,
@@ -861,7 +860,8 @@ extension TopLevel {
861860 xor: UnionXor?? = nil,
862861 xorEq: UnionXorEq?? = nil,
863862 yes: UnionYES?? = nil,
864- yield: UnionYield?? = nil
863+ yield: UnionYield?? = nil,
864+ dummy: Double?? = nil
865865 ) -> TopLevel {
866866 return TopLevel(
867867 empty: empty ?? self.empty,
@@ -940,7 +940,6 @@ extension TopLevel {
940940 topLevelDidSet: topLevelDidSet ?? self.topLevelDidSet,
941941 topLevelDo: topLevelDo ?? self.topLevelDo,
942942 double: double ?? self.double,
943- dummy: dummy ?? self.dummy,
944943 topLevelDynamic: topLevelDynamic ?? self.topLevelDynamic,
945944 dynamicCast: dynamicCast ?? self.dynamicCast,
946945 elif: elif ?? self.elif,
@@ -993,8 +992,8 @@ extension TopLevel {
993992 int: int ?? self.int,
994993 interface: interface ?? self.interface,
995994 topLevelInternal: topLevelInternal ?? self.topLevelInternal,
996- topLevelIs: topLevelIs ?? self.topLevelIs,
997995 iterable: iterable ?? self.iterable,
996+ topLevelIs: topLevelIs ?? self.topLevelIs,
998997 jdec: jdec ?? self.jdec,
999998 jenc: jenc ?? self.jenc,
1000999 jpipe: jpipe ?? self.jpipe,
@@ -1140,7 +1139,8 @@ extension TopLevel {
11401139 xor: xor ?? self.xor,
11411140 xorEq: xorEq ?? self.xorEq,
11421141 yes: yes ?? self.yes,
1143- yield: yield ?? self.yield
1142+ yield: yield ?? self.yield,
1143+ dummy: dummy ?? self.dummy
11441144 )
11451145 }
Mschema-swift/test/inputs/schema/light.schema/default/quicktype.swift+4 −4
@@ -51,13 +51,13 @@ extension TopLevel {
5151
5252 // MARK: - LightParams
5353 struct LightParams: Codable {
54- let appID: String
5554 let outletID: String
55+ let appID: String
5656 let rgba: String
5757
5858 enum CodingKeys: String, CodingKey {
59- case appID = "app_id"
6059 case outletID = "outlet_id"
60+ case appID = "app_id"
6161 case rgba = "rgba"
6262 }
6363 }
@@ -81,13 +81,13 @@ extension LightParams {
8181 }
8282
8383 func with(
84- appID: String? = nil,
8584 outletID: String? = nil,
85+ appID: String? = nil,
8686 rgba: String? = nil
8787 ) -> LightParams {
8888 return LightParams(
89- appID: appID ?? self.appID,
9089 outletID: outletID ?? self.outletID,
90+ appID: appID ?? self.appID,
9191 rgba: rgba ?? self.rgba
9292 )
9393 }
Mschema-swift/test/inputs/schema/min-max-items.schema/default/quicktype.swift+4 −4
@@ -7,16 +7,16 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10+ let minOnly: [String]
1011 let maxOnly: [Int]
1112 let minAndMax: [Double]
12- let minOnly: [String]
1313 let plain: [String]
1414 let unionItems: [UnionItem]
1515
1616 enum CodingKeys: String, CodingKey {
17+ case minOnly = "minOnly"
1718 case maxOnly = "maxOnly"
1819 case minAndMax = "minAndMax"
19- case minOnly = "minOnly"
2020 case plain = "plain"
2121 case unionItems = "unionItems"
2222 }
@@ -41,16 +41,16 @@ extension TopLevel {
4141 }
4242
4343 func with(
44+ minOnly: [String]? = nil,
4445 maxOnly: [Int]? = nil,
4546 minAndMax: [Double]? = nil,
46- minOnly: [String]? = nil,
4747 plain: [String]? = nil,
4848 unionItems: [UnionItem]? = nil
4949 ) -> TopLevel {
5050 return TopLevel(
51+ minOnly: minOnly ?? self.minOnly,
5152 maxOnly: maxOnly ?? self.maxOnly,
5253 minAndMax: minAndMax ?? self.minAndMax,
53- minOnly: minOnly ?? self.minOnly,
5454 plain: plain ?? self.plain,
5555 unionItems: unionItems ?? self.unionItems
5656 )
Mschema-swift/test/inputs/schema/minmax-integer.schema/default/quicktype.swift+16 −16
@@ -8,23 +8,23 @@ import Foundation
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
1010 let free: Int
11- let intersection: Int
12- let max: Int
1311 let min: Int
12+ let max: Int
1413 let minmax: Int
15- let minMaxIntersection: Int
16- let minMaxUnion: Int
1714 let union: Int
15+ let minMaxUnion: Int
16+ let intersection: Int
17+ let minMaxIntersection: Int
1818
1919 enum CodingKeys: String, CodingKey {
2020 case free = "free"
21- case intersection = "intersection"
22- case max = "max"
2321 case min = "min"
22+ case max = "max"
2423 case minmax = "minmax"
25- case minMaxIntersection = "minMaxIntersection"
26- case minMaxUnion = "minMaxUnion"
2724 case union = "union"
25+ case minMaxUnion = "minMaxUnion"
26+ case intersection = "intersection"
27+ case minMaxIntersection = "minMaxIntersection"
2828 }
2929 }
3030
@@ -48,23 +48,23 @@ extension TopLevel {
4848
4949 func with(
5050 free: Int? = nil,
51- intersection: Int? = nil,
52- max: Int? = nil,
5351 min: Int? = nil,
52+ max: Int? = nil,
5453 minmax: Int? = nil,
55- minMaxIntersection: Int? = nil,
54+ union: Int? = nil,
5655 minMaxUnion: Int? = nil,
57- union: Int? = nil
56+ intersection: Int? = nil,
57+ minMaxIntersection: Int? = nil
5858 ) -> TopLevel {
5959 return TopLevel(
6060 free: free ?? self.free,
61- intersection: intersection ?? self.intersection,
62- max: max ?? self.max,
6361 min: min ?? self.min,
62+ max: max ?? self.max,
6463 minmax: minmax ?? self.minmax,
65- minMaxIntersection: minMaxIntersection ?? self.minMaxIntersection,
64+ union: union ?? self.union,
6665 minMaxUnion: minMaxUnion ?? self.minMaxUnion,
67- union: union ?? self.union
66+ intersection: intersection ?? self.intersection,
67+ minMaxIntersection: minMaxIntersection ?? self.minMaxIntersection
6868 )
6969 }
Mschema-swift/test/inputs/schema/minmax.schema/default/quicktype.swift+16 −16
@@ -8,23 +8,23 @@ import Foundation
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
1010 let free: Double
11- let intersection: Double
12- let max: Double
1311 let min: Double
12+ let max: Double
1413 let minmax: Double
15- let minMaxIntersection: Double
16- let minMaxUnion: Double
1714 let union: Double
15+ let minMaxUnion: Double
16+ let intersection: Double
17+ let minMaxIntersection: Double
1818
1919 enum CodingKeys: String, CodingKey {
2020 case free = "free"
21- case intersection = "intersection"
22- case max = "max"
2321 case min = "min"
22+ case max = "max"
2423 case minmax = "minmax"
25- case minMaxIntersection = "minMaxIntersection"
26- case minMaxUnion = "minMaxUnion"
2724 case union = "union"
25+ case minMaxUnion = "minMaxUnion"
26+ case intersection = "intersection"
27+ case minMaxIntersection = "minMaxIntersection"
2828 }
2929 }
3030
@@ -48,23 +48,23 @@ extension TopLevel {
4848
4949 func with(
5050 free: Double? = nil,
51- intersection: Double? = nil,
52- max: Double? = nil,
5351 min: Double? = nil,
52+ max: Double? = nil,
5453 minmax: Double? = nil,
55- minMaxIntersection: Double? = nil,
54+ union: Double? = nil,
5655 minMaxUnion: Double? = nil,
57- union: Double? = nil
56+ intersection: Double? = nil,
57+ minMaxIntersection: Double? = nil
5858 ) -> TopLevel {
5959 return TopLevel(
6060 free: free ?? self.free,
61- intersection: intersection ?? self.intersection,
62- max: max ?? self.max,
6361 min: min ?? self.min,
62+ max: max ?? self.max,
6463 minmax: minmax ?? self.minmax,
65- minMaxIntersection: minMaxIntersection ?? self.minMaxIntersection,
64+ union: union ?? self.union,
6665 minMaxUnion: minMaxUnion ?? self.minMaxUnion,
67- union: union ?? self.union
66+ intersection: intersection ?? self.intersection,
67+ minMaxIntersection: minMaxIntersection ?? self.minMaxIntersection
6868 )
6969 }
Mschema-swift/test/inputs/schema/minmaxlength.schema/default/quicktype.swift+20 −20
@@ -7,24 +7,24 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let intersection: String
11- let inUnion: InUnion
12- let maxlength: String
1310 let minlength: String
14- let minMaxIntersection: String
11+ let maxlength: String
1512 let minmaxlength: String
16- let minMaxUnion: String
1713 let union: String
14+ let inUnion: InUnion
15+ let minMaxUnion: String
16+ let intersection: String
17+ let minMaxIntersection: String
1818
1919 enum CodingKeys: String, CodingKey {
20- case intersection = "intersection"
21- case inUnion = "inUnion"
22- case maxlength = "maxlength"
2320 case minlength = "minlength"
24- case minMaxIntersection = "minMaxIntersection"
21+ case maxlength = "maxlength"
2522 case minmaxlength = "minmaxlength"
26- case minMaxUnion = "minMaxUnion"
2723 case union = "union"
24+ case inUnion = "inUnion"
25+ case minMaxUnion = "minMaxUnion"
26+ case intersection = "intersection"
27+ case minMaxIntersection = "minMaxIntersection"
2828 }
2929 }
3030
@@ -47,24 +47,24 @@ extension TopLevel {
4747 }
4848
4949 func with(
50- intersection: String? = nil,
51- inUnion: InUnion? = nil,
52- maxlength: String? = nil,
5350 minlength: String? = nil,
54- minMaxIntersection: String? = nil,
51+ maxlength: String? = nil,
5552 minmaxlength: String? = nil,
53+ union: String? = nil,
54+ inUnion: InUnion? = nil,
5655 minMaxUnion: String? = nil,
57- union: String? = nil
56+ intersection: String? = nil,
57+ minMaxIntersection: String? = nil
5858 ) -> TopLevel {
5959 return TopLevel(
60- intersection: intersection ?? self.intersection,
61- inUnion: inUnion ?? self.inUnion,
62- maxlength: maxlength ?? self.maxlength,
6360 minlength: minlength ?? self.minlength,
64- minMaxIntersection: minMaxIntersection ?? self.minMaxIntersection,
61+ maxlength: maxlength ?? self.maxlength,
6562 minmaxlength: minmaxlength ?? self.minmaxlength,
63+ union: union ?? self.union,
64+ inUnion: inUnion ?? self.inUnion,
6665 minMaxUnion: minMaxUnion ?? self.minMaxUnion,
67- union: union ?? self.union
66+ intersection: intersection ?? self.intersection,
67+ minMaxIntersection: minMaxIntersection ?? self.minMaxIntersection
6868 )
6969 }
Mschema-swift/test/inputs/schema/non-standard-ref.schema/default/quicktype.swift+4 −4
@@ -7,13 +7,13 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let bar: Int
1110 let foo: Int
11+ let bar: Int
1212 let quux: Bool
1313
1414 enum CodingKeys: String, CodingKey {
15- case bar = "bar"
1615 case foo = "foo"
16+ case bar = "bar"
1717 case quux = "quux"
1818 }
1919 }
@@ -37,13 +37,13 @@ extension TopLevel {
3737 }
3838
3939 func with(
40- bar: Int? = nil,
4140 foo: Int? = nil,
41+ bar: Int? = nil,
4242 quux: Bool? = nil
4343 ) -> TopLevel {
4444 return TopLevel(
45- bar: bar ?? self.bar,
4645 foo: foo ?? self.foo,
46+ bar: bar ?? self.bar,
4747 quux: quux ?? self.quux
4848 )
4949 }
Mschema-swift/test/inputs/schema/optional-any.schema/default/quicktype.swift+6 −6
@@ -7,12 +7,12 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let bar: Bool
1110 let foo: JSONAny?
11+ let bar: Bool
1212
1313 enum CodingKeys: String, CodingKey {
14- case bar = "bar"
1514 case foo = "foo"
15+ case bar = "bar"
1616 }
1717 }
1818
@@ -35,12 +35,12 @@ extension TopLevel {
3535 }
3636
3737 func with(
38- bar: Bool? = nil,
39- foo: JSONAny?? = nil
38+ foo: JSONAny?? = nil,
39+ bar: Bool? = nil
4040 ) -> TopLevel {
4141 return TopLevel(
42- bar: bar ?? self.bar,
43- foo: foo ?? self.foo
42+ foo: foo ?? self.foo,
43+ bar: bar ?? self.bar
4444 )
4545 }
Mschema-swift/test/inputs/schema/optional-const-ref.schema/default/quicktype.swift+14 −14
@@ -8,21 +8,21 @@ import Foundation
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
1010 let coordinates: [Coordinate]?
11- let count: Int?
12- let label: String?
1311 let requiredCoordinates: [Coordinate]
12+ let count: Int?
1413 let requiredCount: Int
15- let requiredLabel: String
1614 let weight: Double?
15+ let label: String?
16+ let requiredLabel: String
1717
1818 enum CodingKeys: String, CodingKey {
1919 case coordinates = "coordinates"
20- case count = "count"
21- case label = "label"
2220 case requiredCoordinates = "requiredCoordinates"
21+ case count = "count"
2322 case requiredCount = "requiredCount"
24- case requiredLabel = "requiredLabel"
2523 case weight = "weight"
24+ case label = "label"
25+ case requiredLabel = "requiredLabel"
2626 }
2727 }
2828
@@ -46,21 +46,21 @@ extension TopLevel {
4646
4747 func with(
4848 coordinates: [Coordinate]?? = nil,
49- count: Int?? = nil,
50- label: String?? = nil,
5149 requiredCoordinates: [Coordinate]? = nil,
50+ count: Int?? = nil,
5251 requiredCount: Int? = nil,
53- requiredLabel: String? = nil,
54- weight: Double?? = nil
52+ weight: Double?? = nil,
53+ label: String?? = nil,
54+ requiredLabel: String? = nil
5555 ) -> TopLevel {
5656 return TopLevel(
5757 coordinates: coordinates ?? self.coordinates,
58- count: count ?? self.count,
59- label: label ?? self.label,
6058 requiredCoordinates: requiredCoordinates ?? self.requiredCoordinates,
59+ count: count ?? self.count,
6160 requiredCount: requiredCount ?? self.requiredCount,
62- requiredLabel: requiredLabel ?? self.requiredLabel,
63- weight: weight ?? self.weight
61+ weight: weight ?? self.weight,
62+ label: label ?? self.label,
63+ requiredLabel: requiredLabel ?? self.requiredLabel
6464 )
6565 }
Mschema-swift/test/inputs/schema/optional-constraints.schema/default/quicktype.swift+12 −12
@@ -7,18 +7,18 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let optDouble: Double?
10+ let reqZeroMin: Int
1111 let optInt: Int?
12- let optPattern: String?
12+ let optDouble: Double?
1313 let optString: String?
14- let reqZeroMin: Int
14+ let optPattern: String?
1515
1616 enum CodingKeys: String, CodingKey {
17- case optDouble = "optDouble"
17+ case reqZeroMin = "reqZeroMin"
1818 case optInt = "optInt"
19- case optPattern = "optPattern"
19+ case optDouble = "optDouble"
2020 case optString = "optString"
21- case reqZeroMin = "reqZeroMin"
21+ case optPattern = "optPattern"
2222 }
2323 }
2424
@@ -41,18 +41,18 @@ extension TopLevel {
4141 }
4242
4343 func with(
44- optDouble: Double?? = nil,
44+ reqZeroMin: Int? = nil,
4545 optInt: Int?? = nil,
46- optPattern: String?? = nil,
46+ optDouble: Double?? = nil,
4747 optString: String?? = nil,
48- reqZeroMin: Int? = nil
48+ optPattern: String?? = nil
4949 ) -> TopLevel {
5050 return TopLevel(
51- optDouble: optDouble ?? self.optDouble,
51+ reqZeroMin: reqZeroMin ?? self.reqZeroMin,
5252 optInt: optInt ?? self.optInt,
53- optPattern: optPattern ?? self.optPattern,
53+ optDouble: optDouble ?? self.optDouble,
5454 optString: optString ?? self.optString,
55- reqZeroMin: reqZeroMin ?? self.reqZeroMin
55+ optPattern: optPattern ?? self.optPattern
5656 )
5757 }
Mschema-swift/test/inputs/schema/optional-date-time.schema/default/quicktype.swift+16 −16
@@ -7,20 +7,20 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let optionalDate: String?
11- let optionalDateTime: Date?
12- let optionalTime: String?
1310 let requiredDate: String
14- let requiredDateTime: Date
1511 let requiredTime: String
12+ let requiredDateTime: Date
13+ let optionalDate: String?
14+ let optionalTime: String?
15+ let optionalDateTime: Date?
1616
1717 enum CodingKeys: String, CodingKey {
18- case optionalDate = "optional-date"
19- case optionalDateTime = "optional-date-time"
20- case optionalTime = "optional-time"
2118 case requiredDate = "required-date"
22- case requiredDateTime = "required-date-time"
2319 case requiredTime = "required-time"
20+ case requiredDateTime = "required-date-time"
21+ case optionalDate = "optional-date"
22+ case optionalTime = "optional-time"
23+ case optionalDateTime = "optional-date-time"
2424 }
2525 }
2626
@@ -43,20 +43,20 @@ extension TopLevel {
4343 }
4444
4545 func with(
46- optionalDate: String?? = nil,
47- optionalDateTime: Date?? = nil,
48- optionalTime: String?? = nil,
4946 requiredDate: String? = nil,
47+ requiredTime: String? = nil,
5048 requiredDateTime: Date? = nil,
51- requiredTime: String? = nil
49+ optionalDate: String?? = nil,
50+ optionalTime: String?? = nil,
51+ optionalDateTime: Date?? = nil
5252 ) -> TopLevel {
5353 return TopLevel(
54- optionalDate: optionalDate ?? self.optionalDate,
55- optionalDateTime: optionalDateTime ?? self.optionalDateTime,
56- optionalTime: optionalTime ?? self.optionalTime,
5754 requiredDate: requiredDate ?? self.requiredDate,
55+ requiredTime: requiredTime ?? self.requiredTime,
5856 requiredDateTime: requiredDateTime ?? self.requiredDateTime,
59- requiredTime: requiredTime ?? self.requiredTime
57+ optionalDate: optionalDate ?? self.optionalDate,
58+ optionalTime: optionalTime ?? self.optionalTime,
59+ optionalDateTime: optionalDateTime ?? self.optionalDateTime
6060 )
6161 }
Mschema-swift/test/inputs/schema/prefix-items.schema/default/quicktype.swift+6 −6
@@ -7,12 +7,12 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let topLevelOpen: [Open]
1110 let tuple: [Open]
11+ let topLevelOpen: [Open]
1212
1313 enum CodingKeys: String, CodingKey {
14- case topLevelOpen = "open"
1514 case tuple = "tuple"
15+ case topLevelOpen = "open"
1616 }
1717 }
1818
@@ -35,12 +35,12 @@ extension TopLevel {
3535 }
3636
3737 func with(
38- topLevelOpen: [Open]? = nil,
39- tuple: [Open]? = nil
38+ tuple: [Open]? = nil,
39+ topLevelOpen: [Open]? = nil
4040 ) -> TopLevel {
4141 return TopLevel(
42- topLevelOpen: topLevelOpen ?? self.topLevelOpen,
43- tuple: tuple ?? self.tuple
42+ tuple: tuple ?? self.tuple,
43+ topLevelOpen: topLevelOpen ?? self.topLevelOpen
4444 )
4545 }
Aschema-swift/test/inputs/schema/property-order.schema/default/quicktype.swift+158 −0
@@ -0,0 +1,158 @@
1+// This file was generated from JSON Schema using quicktype, do not modify it directly.
2+// To parse the JSON, add this file to your project and do:
3+//
4+// let topLevel = try TopLevel(json)
5+
6+import Foundation
7+
8+// MARK: - TopLevel
9+struct TopLevel: Codable {
10+ let zebra: String
11+ let mango: Double
12+ let apple: Bool
13+ let delta: String
14+ let banana: Int
15+ let ordered: Ordered
16+
17+ enum CodingKeys: String, CodingKey {
18+ case zebra = "zebra"
19+ case mango = "mango"
20+ case apple = "apple"
21+ case delta = "delta"
22+ case banana = "banana"
23+ case ordered = "ordered"
24+ }
25+}
26+
27+// MARK: TopLevel convenience initializers and mutators
28+
29+extension TopLevel {
30+ init(data: Data) throws {
31+ self = try newJSONDecoder().decode(TopLevel.self, from: data)
32+ }
33+
34+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
35+ guard let data = json.data(using: encoding) else {
36+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
37+ }
38+ try self.init(data: data)
39+ }
40+
41+ init(fromURL url: URL) throws {
42+ try self.init(data: try Data(contentsOf: url))
43+ }
44+
45+ func with(
46+ zebra: String? = nil,
47+ mango: Double? = nil,
48+ apple: Bool? = nil,
49+ delta: String? = nil,
50+ banana: Int? = nil,
51+ ordered: Ordered? = nil
52+ ) -> TopLevel {
53+ return TopLevel(
54+ zebra: zebra ?? self.zebra,
55+ mango: mango ?? self.mango,
56+ apple: apple ?? self.apple,
57+ delta: delta ?? self.delta,
58+ banana: banana ?? self.banana,
59+ ordered: ordered ?? self.ordered
60+ )
61+ }
62+
63+ func jsonData() throws -> Data {
64+ return try newJSONEncoder().encode(self)
65+ }
66+
67+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
68+ return String(data: try self.jsonData(), encoding: encoding)
69+ }
70+}
71+
72+// MARK: - Ordered
73+struct Ordered: Codable {
74+ let mango: Double
75+ let zebra: String
76+ let apple: Bool
77+
78+ enum CodingKeys: String, CodingKey {
79+ case mango = "mango"
80+ case zebra = "zebra"
81+ case apple = "apple"
82+ }
83+}
84+
85+// MARK: Ordered convenience initializers and mutators
86+
87+extension Ordered {
88+ init(data: Data) throws {
89+ self = try newJSONDecoder().decode(Ordered.self, from: data)
90+ }
91+
92+ init(_ json: String, using encoding: String.Encoding = .utf8) throws {
93+ guard let data = json.data(using: encoding) else {
94+ throw NSError(domain: "JSONDecoding", code: 0, userInfo: nil)
95+ }
96+ try self.init(data: data)
97+ }
98+
99+ init(fromURL url: URL) throws {
100+ try self.init(data: try Data(contentsOf: url))
101+ }
102+
103+ func with(
104+ mango: Double? = nil,
105+ zebra: String? = nil,
106+ apple: Bool? = nil
107+ ) -> Ordered {
108+ return Ordered(
109+ mango: mango ?? self.mango,
110+ zebra: zebra ?? self.zebra,
111+ apple: apple ?? self.apple
112+ )
113+ }
114+
115+ func jsonData() throws -> Data {
116+ return try newJSONEncoder().encode(self)
117+ }
118+
119+ func jsonString(encoding: String.Encoding = .utf8) throws -> String? {
120+ return String(data: try self.jsonData(), encoding: encoding)
121+ }
122+}
123+
124+// MARK: - Helper functions for creating encoders and decoders
125+
126+func newJSONDecoder() -> JSONDecoder {
127+ let decoder = JSONDecoder()
128+ decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in
129+ let container = try decoder.singleValueContainer()
130+ let dateStr = try container.decode(String.self)
131+
132+ let formatter = DateFormatter()
133+ formatter.calendar = Calendar(identifier: .iso8601)
134+ formatter.locale = Locale(identifier: "en_US_POSIX")
135+ formatter.timeZone = TimeZone(secondsFromGMT: 0)
136+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
137+ if let date = formatter.date(from: dateStr) {
138+ return date
139+ }
140+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXXXX"
141+ if let date = formatter.date(from: dateStr) {
142+ return date
143+ }
144+ throw DecodingError.typeMismatch(Date.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Could not decode date"))
145+ })
146+ return decoder
147+}
148+
149+func newJSONEncoder() -> JSONEncoder {
150+ let encoder = JSONEncoder()
151+ let formatter = DateFormatter()
152+ formatter.calendar = Calendar(identifier: .iso8601)
153+ formatter.locale = Locale(identifier: "en_US_POSIX")
154+ formatter.timeZone = TimeZone(secondsFromGMT: 0)
155+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXXXX"
156+ encoder.dateEncodingStrategy = .formatted(formatter)
157+ return encoder
158+}
Mschema-swift/test/inputs/schema/renaming-bug.schema/default/quicktype.swift+42 −42
@@ -60,13 +60,13 @@ extension TopLevel {
6060 // MARK: - Fruit
6161 struct Fruit: Codable {
6262 let apple: Bool?
63- let berries: [Berry]?
6463 let orange: Bool?
64+ let berries: [Berry]?
6565
6666 enum CodingKeys: String, CodingKey {
6767 case apple = "apple"
68- case berries = "berries"
6968 case orange = "orange"
69+ case berries = "berries"
7070 }
7171 }
7272
@@ -90,13 +90,13 @@ extension Fruit {
9090
9191 func with(
9292 apple: Bool?? = nil,
93- berries: [Berry]?? = nil,
94- orange: Bool?? = nil
93+ orange: Bool?? = nil,
94+ berries: [Berry]?? = nil
9595 ) -> Fruit {
9696 return Fruit(
9797 apple: apple ?? self.apple,
98- berries: berries ?? self.berries,
99- orange: orange ?? self.orange
98+ orange: orange ?? self.orange,
99+ berries: berries ?? self.berries
100100 )
101101 }
102102
@@ -111,13 +111,13 @@ extension Fruit {
111111
112112 // MARK: - Berry
113113 struct Berry: Codable {
114- let color: Color?
115114 let name: String?
115+ let color: Color?
116116 let shapes: [Shape]?
117117
118118 enum CodingKeys: String, CodingKey {
119- case color = "color"
120119 case name = "name"
120+ case color = "color"
121121 case shapes = "shapes"
122122 }
123123 }
@@ -141,13 +141,13 @@ extension Berry {
141141 }
142142
143143 func with(
144- color: Color?? = nil,
145144 name: String?? = nil,
145+ color: Color?? = nil,
146146 shapes: [Shape]?? = nil
147147 ) -> Berry {
148148 return Berry(
149- color: color ?? self.color,
150149 name: name ?? self.name,
150+ color: color ?? self.color,
151151 shapes: shapes ?? self.shapes
152152 )
153153 }
@@ -207,12 +207,12 @@ extension Color {
207207
208208 // MARK: - Shape
209209 struct Shape: Codable {
210- let geometry: Geometry?
211210 let history: History?
211+ let geometry: Geometry?
212212
213213 enum CodingKeys: String, CodingKey {
214- case geometry = "geometry"
215214 case history = "history"
215+ case geometry = "geometry"
216216 }
217217 }
218218
@@ -235,12 +235,12 @@ extension Shape {
235235 }
236236
237237 func with(
238- geometry: Geometry?? = nil,
239- history: History?? = nil
238+ history: History?? = nil,
239+ geometry: Geometry?? = nil
240240 ) -> Shape {
241241 return Shape(
242- geometry: geometry ?? self.geometry,
243- history: history ?? self.history
242+ history: history ?? self.history,
243+ geometry: geometry ?? self.geometry
244244 )
245245 }
246246
@@ -391,14 +391,14 @@ extension RectShape {
391391
392392 // MARK: - Part
393393 struct Part: Codable {
394- let depth: String?
395394 let length: String?
396395 let width: String?
396+ let depth: String?
397397
398398 enum CodingKeys: String, CodingKey {
399- case depth = "depth"
400399 case length = "length"
401400 case width = "width"
401+ case depth = "depth"
402402 }
403403 }
404404
@@ -421,14 +421,14 @@ extension Part {
421421 }
422422
423423 func with(
424- depth: String?? = nil,
425424 length: String?? = nil,
426- width: String?? = nil
425+ width: String?? = nil,
426+ depth: String?? = nil
427427 ) -> Part {
428428 return Part(
429- depth: depth ?? self.depth,
430429 length: length ?? self.length,
431- width: width ?? self.width
430+ width: width ?? self.width,
431+ depth: depth ?? self.depth
432432 )
433433 }
434434
@@ -487,20 +487,20 @@ extension History {
487487
488488 // MARK: - Vehicle
489489 struct Vehicle: Codable {
490- let brand: String?
491490 let id: String?
492- let speed: Speed?
493- let subModule: Bool?
494491 let type: VehicleType?
492+ let speed: Speed?
495493 let year: String?
494+ let brand: String?
495+ let subModule: Bool?
496496
497497 enum CodingKeys: String, CodingKey {
498- case brand = "brand"
499498 case id = "id"
500- case speed = "speed"
501- case subModule = "subModule"
502499 case type = "type"
500+ case speed = "speed"
503501 case year = "year"
502+ case brand = "brand"
503+ case subModule = "subModule"
504504 }
505505 }
506506
@@ -523,20 +523,20 @@ extension Vehicle {
523523 }
524524
525525 func with(
526- brand: String?? = nil,
527526 id: String?? = nil,
528- speed: Speed?? = nil,
529- subModule: Bool?? = nil,
530527 type: VehicleType?? = nil,
531- year: String?? = nil
528+ speed: Speed?? = nil,
529+ year: String?? = nil,
530+ brand: String?? = nil,
531+ subModule: Bool?? = nil
532532 ) -> Vehicle {
533533 return Vehicle(
534- brand: brand ?? self.brand,
535534 id: id ?? self.id,
536- speed: speed ?? self.speed,
537- subModule: subModule ?? self.subModule,
538535 type: type ?? self.type,
539- year: year ?? self.year
536+ speed: speed ?? self.speed,
537+ year: year ?? self.year,
538+ brand: brand ?? self.brand,
539+ subModule: subModule ?? self.subModule
540540 )
541541 }
542542
@@ -595,12 +595,12 @@ extension Speed {
595595
596596 // MARK: - Limit
597597 struct Limit: Codable {
598- let maximum: Double?
599598 let minimum: Double?
599+ let maximum: Double?
600600
601601 enum CodingKeys: String, CodingKey {
602- case maximum = "maximum"
603602 case minimum = "minimum"
603+ case maximum = "maximum"
604604 }
605605 }
606606
@@ -623,12 +623,12 @@ extension Limit {
623623 }
624624
625625 func with(
626- maximum: Double?? = nil,
627- minimum: Double?? = nil
626+ minimum: Double?? = nil,
627+ maximum: Double?? = nil
628628 ) -> Limit {
629629 return Limit(
630- maximum: maximum ?? self.maximum,
631- minimum: minimum ?? self.minimum
630+ minimum: minimum ?? self.minimum,
631+ maximum: maximum ?? self.maximum
632632 )
633633 }
Mschema-swift/test/inputs/schema/rust-cycle-breaker-union.schema/default/quicktype.swift+12 −12
@@ -7,12 +7,12 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let next: Next?
1110 let value: String
11+ let next: Next?
1212
1313 enum CodingKeys: String, CodingKey {
14- case next = "next"
1514 case value = "value"
15+ case next = "next"
1616 }
1717 }
1818
@@ -35,12 +35,12 @@ extension TopLevel {
3535 }
3636
3737 func with(
38- next: Next?? = nil,
39- value: String? = nil
38+ value: String? = nil,
39+ next: Next?? = nil
4040 ) -> TopLevel {
4141 return TopLevel(
42- next: next ?? self.next,
43- value: value ?? self.value
42+ value: value ?? self.value,
43+ next: next ?? self.next
4444 )
4545 }
4646
@@ -55,12 +55,12 @@ extension TopLevel {
5555
5656 // MARK: - Node
5757 struct Node: Codable {
58- let next: Next?
5958 let value: String
59+ let next: Next?
6060
6161 enum CodingKeys: String, CodingKey {
62- case next = "next"
6362 case value = "value"
63+ case next = "next"
6464 }
6565 }
6666
@@ -83,12 +83,12 @@ extension Node {
8383 }
8484
8585 func with(
86- next: Next?? = nil,
87- value: String? = nil
86+ value: String? = nil,
87+ next: Next?? = nil
8888 ) -> Node {
8989 return Node(
90- next: next ?? self.next,
91- value: value ?? self.value
90+ value: value ?? self.value,
91+ next: next ?? self.next
9292 )
9393 }
Mschema-swift/test/inputs/schema/uuid.schema/default/quicktype.swift+12 −12
@@ -7,19 +7,19 @@ import Foundation
77
88 // MARK: - TopLevel
99 struct TopLevel: Codable {
10- let arrNullable: [String?]?
11- let arrOne: [String]?
12- let nullable: String?
1310 let one: String
1411 let topLevelOptional: String?
12+ let nullable: String?
13+ let arrOne: [String]?
14+ let arrNullable: [String?]?
1515 let unionWithEnum: String
1616
1717 enum CodingKeys: String, CodingKey {
18- case arrNullable = "arrNullable"
19- case arrOne = "arrOne"
20- case nullable = "nullable"
2118 case one = "one"
2219 case topLevelOptional = "optional"
20+ case nullable = "nullable"
21+ case arrOne = "arrOne"
22+ case arrNullable = "arrNullable"
2323 case unionWithEnum = "unionWithEnum"
2424 }
2525 }
@@ -43,19 +43,19 @@ extension TopLevel {
4343 }
4444
4545 func with(
46- arrNullable: [String?]?? = nil,
47- arrOne: [String]?? = nil,
48- nullable: String?? = nil,
4946 one: String? = nil,
5047 topLevelOptional: String?? = nil,
48+ nullable: String?? = nil,
49+ arrOne: [String]?? = nil,
50+ arrNullable: [String?]?? = nil,
5151 unionWithEnum: String? = nil
5252 ) -> TopLevel {
5353 return TopLevel(
54- arrNullable: arrNullable ?? self.arrNullable,
55- arrOne: arrOne ?? self.arrOne,
56- nullable: nullable ?? self.nullable,
5754 one: one ?? self.one,
5855 topLevelOptional: topLevelOptional ?? self.topLevelOptional,
56+ nullable: nullable ?? self.nullable,
57+ arrOne: arrOne ?? self.arrOne,
58+ arrNullable: arrNullable ?? self.arrNullable,
5959 unionWithEnum: unionWithEnum ?? self.unionWithEnum
6060 )
6161 }
Mschema-typescript-zod/test/inputs/schema/accessors.schema/default/TopLevel.ts+4 −4
@@ -8,10 +8,10 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- bar: string;
11+ union: Union;
1212 enum: Enum;
1313 foo: string;
14- union: Union;
14+ bar: string;
1515 }
1616
1717 export type Enum = "red" | "green" | "blue";
@@ -185,10 +185,10 @@ function r(name: string) {
185185
186186 const typeMap: any = {
187187 "TopLevel": o([
188- { json: "bar", js: "bar", typ: "" },
188+ { json: "union", js: "union", typ: u(true, 3.14) },
189189 { json: "enum", js: "enum", typ: r("Enum") },
190190 { json: "foo", js: "foo", typ: "" },
191- { json: "union", js: "union", typ: u(true, 3.14) },
191+ { json: "bar", js: "bar", typ: "" },
192192 ], false),
193193 "Enum": [
194194 "red",
Mschema-typescript-zod/test/inputs/schema/bool-string.schema/default/TopLevel.ts+2 −2
@@ -10,8 +10,8 @@
1010 export interface TopLevel {
1111 amount: number;
1212 frequency: Frequency;
13- description?: string;
1413 type: Type;
14+ description?: string;
1515 }
1616
1717 export type Frequency = "Weekly" | "Monthly" | "Annually";
@@ -187,8 +187,8 @@ const typeMap: any = {
187187 "TopLevel": o([
188188 { json: "amount", js: "amount", typ: 3.14 },
189189 { json: "frequency", js: "frequency", typ: r("Frequency") },
190- { json: "description", js: "description", typ: u(undefined, "") },
191190 { json: "type", js: "type", typ: r("Type") },
191+ { json: "description", js: "description", typ: u(undefined, "") },
192192 ], false),
193193 "Frequency": [
194194 "Weekly",
Mschema-typescript-zod/test/inputs/schema/boolean-subschema.schema/default/TopLevel.ts+6 −6
@@ -8,11 +8,11 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- arrNullable?: (null | string)[];
12- arrOne?: string[];
13- nullable: null | string;
1411 one: string;
1512 optional?: string;
13+ nullable: null | string;
14+ arrOne?: string[];
15+ arrNullable?: (null | string)[];
1616 unionWithBool: UnionWithBool;
1717 unionWithBoolAndEnum: UnionWithBool;
1818 [property: string]: unknown;
@@ -187,11 +187,11 @@ function r(name: string) {
187187
188188 const typeMap: any = {
189189 "TopLevel": o([
190- { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
191- { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
192- { json: "nullable", js: "nullable", typ: u(null, "") },
193190 { json: "one", js: "one", typ: "" },
194191 { json: "optional", js: "optional", typ: u(undefined, "") },
192+ { json: "nullable", js: "nullable", typ: u(null, "") },
193+ { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
194+ { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
195195 { json: "unionWithBool", js: "unionWithBool", typ: u(true, "") },
196196 { json: "unionWithBoolAndEnum", js: "unionWithBoolAndEnum", typ: u(true, "") },
197197 ], "any"),
Mschema-typescript-zod/test/inputs/schema/comment-injection.schema/default/TopLevel.ts+2 −2
@@ -8,9 +8,9 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11+ foo: string;
1112 disallowed?: unknown;
1213 empty: unknown[];
13- foo: string;
1414 impossible?: unknown;
1515 }
1616
@@ -181,9 +181,9 @@ function r(name: string) {
181181
182182 const typeMap: any = {
183183 "TopLevel": o([
184+ { json: "foo", js: "foo", typ: "" },
184185 { json: "disallowed", js: "disallowed", typ: u(undefined, "any") },
185186 { json: "empty", js: "empty", typ: a("any") },
186- { json: "foo", js: "foo", typ: "" },
187187 { json: "impossible", js: "impossible", typ: u(undefined, "any") },
188188 ], false),
189189 };
Mschema-typescript-zod/test/inputs/schema/date-time-or-string.schema/default/TopLevel.ts+13 −13
@@ -22,18 +22,6 @@
2222 * }
2323 */
2424 export interface TopLevel {
25- /**
26- * Ends with a backslash \
27- */
28- trailingBackslash?: string;
29- /**
30- * Ends with a quote "
31- */
32- trailingQuote?: string;
33- /**
34- * Ends with a triple quote """
35- */
36- trailingTripleQuote?: string;
3725 /**
3826 * Property delimiters:
3927 * * /
@@ -49,6 +37,18 @@ export interface TopLevel {
4937 * }
5038 */
5139 value: string;
40+ /**
41+ * Ends with a backslash \
42+ */
43+ trailingBackslash?: string;
44+ /**
45+ * Ends with a quote "
46+ */
47+ trailingQuote?: string;
48+ /**
49+ * Ends with a triple quote """
50+ */
51+ trailingTripleQuote?: string;
5252 }
5353
5454 // Converts JSON strings to/from your types
@@ -218,9 +218,9 @@ function r(name: string) {
218218
219219 const typeMap: any = {
220220 "TopLevel": o([
221+ { json: "value", js: "value", typ: "" },
221222 { json: "trailingBackslash", js: "trailingBackslash", typ: u(undefined, "") },
222223 { json: "trailingQuote", js: "trailingQuote", typ: u(undefined, "") },
223224 { json: "trailingTripleQuote", js: "trailingTripleQuote", typ: u(undefined, "") },
224- { json: "value", js: "value", typ: "" },
225225 ], false),
226226 };
Mschema-typescript-zod/test/inputs/schema/description.schema/default/TopLevel.ts+4 −4
@@ -8,11 +8,11 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11+ version: number;
1112 amount: number;
13+ ratio: number;
1214 enabled: boolean;
1315 kind: Kind;
14- ratio: number;
15- version: number;
1616 [property: string]: unknown;
1717 }
1818
@@ -185,11 +185,11 @@ function r(name: string) {
185185
186186 const typeMap: any = {
187187 "TopLevel": o([
188+ { json: "version", js: "version", typ: 3.14 },
188189 { json: "amount", js: "amount", typ: 0 },
190+ { json: "ratio", js: "ratio", typ: 3.14 },
189191 { json: "enabled", js: "enabled", typ: true },
190192 { json: "kind", js: "kind", typ: r("Kind") },
191- { json: "ratio", js: "ratio", typ: 3.14 },
192- { json: "version", js: "version", typ: 3.14 },
193193 ], "any"),
194194 "Kind": [
195195 "widget",
Mschema-typescript-zod/test/inputs/schema/integer-string.schema/default/TopLevel.ts+2 −2
@@ -8,8 +8,8 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- bar: BarUnion;
1211 foo: string;
12+ bar: BarUnion;
1313 [property: string]: unknown;
1414 }
1515
@@ -184,8 +184,8 @@ function r(name: string) {
184184
185185 const typeMap: any = {
186186 "TopLevel": o([
187- { json: "bar", js: "bar", typ: u(Date, r("BarEnum")) },
188187 { json: "foo", js: "foo", typ: "" },
188+ { json: "bar", js: "bar", typ: u(Date, r("BarEnum")) },
189189 ], "any"),
190190 "BarEnum": [
191191 "quux",
Mschema-typescript-zod/test/inputs/schema/integer-type.schema/default/TopLevel.ts+4 −4
@@ -8,11 +8,11 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- "complex-union-array": ComplexUnionArrayElement[];
1211 date: Date;
13- "date-time": Date;
1412 time: string;
13+ "date-time": Date;
1514 "union-array": string[];
15+ "complex-union-array": ComplexUnionArrayElement[];
1616 }
1717
1818 export type ComplexUnionArrayElement = Date | ComplexUnionArrayEnum | number;
@@ -186,11 +186,11 @@ function r(name: string) {
186186
187187 const typeMap: any = {
188188 "TopLevel": o([
189- { json: "complex-union-array", js: "complex-union-array", typ: a(u(Date, r("ComplexUnionArrayEnum"), 0)) },
190189 { json: "date", js: "date", typ: Date },
191- { json: "date-time", js: "date-time", typ: Date },
192190 { json: "time", js: "time", typ: "" },
191+ { json: "date-time", js: "date-time", typ: Date },
193192 { json: "union-array", js: "union-array", typ: a("") },
193+ { json: "complex-union-array", js: "complex-union-array", typ: a(u(Date, r("ComplexUnionArrayEnum"), 0)) },
194194 ], false),
195195 "ComplexUnionArrayEnum": [
196196 "foo",
Mschema-typescript-zod/test/inputs/schema/light.schema/default/TopLevel.ts+9 −9
@@ -13,19 +13,19 @@
1313 */
1414 export interface TopLevel {
1515 /**
16- * A pretty boolean
16+ * Either a number or a string
1717 */
18- bar?: boolean;
18+ union: Union;
1919 /**
2020 * An enumeration
2121 */
22- enum: Enum;
23- foo?: number;
24- "object-or-string": ObjectOrStringUnion;
22+ enum: Enum;
23+ foo?: number;
2524 /**
26- * Either a number or a string
25+ * A pretty boolean
2726 */
28- union: Union;
27+ bar?: boolean;
28+ "object-or-string": ObjectOrStringUnion;
2929 }
3030
3131 /**
@@ -215,11 +215,11 @@ function r(name: string) {
215215
216216 const typeMap: any = {
217217 "TopLevel": o([
218- { json: "bar", js: "bar", typ: u(undefined, true) },
218+ { json: "union", js: "union", typ: u(3.14, "") },
219219 { json: "enum", js: "enum", typ: r("Enum") },
220220 { json: "foo", js: "foo", typ: u(undefined, 3.14) },
221+ { json: "bar", js: "bar", typ: u(undefined, true) },
221222 { json: "object-or-string", js: "object-or-string", typ: u(r("ObjectOrStringObject"), "") },
222- { json: "union", js: "union", typ: u(3.14, "") },
223223 ], false),
224224 "ObjectOrStringObject": o([
225225 { json: "prop", js: "prop", typ: 3.14 },
Mschema-typescript-zod/test/inputs/schema/min-max-items.schema/default/TopLevel.ts+2 −2
@@ -12,8 +12,8 @@ export interface TopLevel {
1212 }
1313
1414 export interface Thing {
15- optional?: Anything;
1615 required: Anything;
16+ optional?: Anything;
1717 }
1818
1919 export type Anything = unknown[] | boolean | number | number | { [key: string]: unknown } | null | string;
@@ -188,7 +188,7 @@ const typeMap: any = {
188188 { json: "stuff", js: "stuff", typ: m(r("Thing")) },
189189 ], false),
190190 "Thing": o([
191- { json: "optional", js: "optional", typ: u(undefined, u(a("any"), true, 3.14, 0, m("any"), null, "")) },
192191 { json: "required", js: "required", typ: u(a("any"), true, 3.14, 0, m("any"), null, "") },
192+ { json: "optional", js: "optional", typ: u(undefined, u(a("any"), true, 3.14, 0, m("any"), null, "")) },
193193 ], false),
194194 };
Mschema-typescript-zod/test/inputs/schema/minmax-integer.schema/default/TopLevel.ts+6 −6
@@ -8,11 +8,11 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- arr?: Arr[];
12- for?: string;
13- gve: Gve;
1411 lvc?: Lvc;
12+ gve: Gve;
13+ arr?: Arr[];
1514 otherArr?: OtherArr[];
15+ for?: string;
1616 [property: string]: unknown;
1717 }
1818
@@ -191,11 +191,11 @@ function r(name: string) {
191191
192192 const typeMap: any = {
193193 "TopLevel": o([
194- { json: "arr", js: "arr", typ: u(undefined, a(u(r("OtherArr"), 0))) },
195- { json: "for", js: "for", typ: u(undefined, "") },
196- { json: "gve", js: "gve", typ: r("Gve") },
197194 { json: "lvc", js: "lvc", typ: u(undefined, r("Lvc")) },
195+ { json: "gve", js: "gve", typ: r("Gve") },
196+ { json: "arr", js: "arr", typ: u(undefined, a(u(r("OtherArr"), 0))) },
198197 { json: "otherArr", js: "otherArr", typ: u(undefined, a(r("OtherArr"))) },
198+ { json: "for", js: "for", typ: u(undefined, "") },
199199 ], "any"),
200200 "OtherArr": [
201201 "foo",
Mschema-typescript-zod/test/inputs/schema/minmax.schema/default/TopLevel.ts+6 −6
@@ -8,11 +8,11 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- arrNullable?: (null | string)[];
12- arrOne?: string[];
13- nullable: null | string;
1411 one: string;
1512 optional?: string;
13+ nullable: null | string;
14+ arrOne?: string[];
15+ arrNullable?: (null | string)[];
1616 unionWithInt: UnionWithInt;
1717 unionWithIntAndEnum: UnionWithInt;
1818 [property: string]: unknown;
@@ -187,11 +187,11 @@ function r(name: string) {
187187
188188 const typeMap: any = {
189189 "TopLevel": o([
190- { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
191- { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
192- { json: "nullable", js: "nullable", typ: u(null, "") },
193190 { json: "one", js: "one", typ: "" },
194191 { json: "optional", js: "optional", typ: u(undefined, "") },
192+ { json: "nullable", js: "nullable", typ: u(null, "") },
193+ { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
194+ { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
195195 { json: "unionWithInt", js: "unionWithInt", typ: u(0, "") },
196196 { json: "unionWithIntAndEnum", js: "unionWithIntAndEnum", typ: u(0, "") },
197197 ], "any"),
Mschema-typescript-zod/test/inputs/schema/minmaxlength.schema/default/TopLevel.ts+10 −10
@@ -8,15 +8,15 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11+ small_positive: number;
12+ small_negative: number;
13+ i32_range: number;
1114 above_i32_max: number;
1215 below_i32_min: number;
13- i32_range: number;
14- large_bounds: number;
15- only_maximum: number;
1616 only_minimum: number;
17- small_negative: number;
18- small_positive: number;
17+ only_maximum: number;
1918 unbounded: number;
19+ large_bounds: number;
2020 [property: string]: unknown;
2121 }
2222
@@ -187,14 +187,14 @@ function r(name: string) {
187187
188188 const typeMap: any = {
189189 "TopLevel": o([
190+ { json: "small_positive", js: "small_positive", typ: 0 },
191+ { json: "small_negative", js: "small_negative", typ: 0 },
192+ { json: "i32_range", js: "i32_range", typ: 0 },
190193 { json: "above_i32_max", js: "above_i32_max", typ: 0 },
191194 { json: "below_i32_min", js: "below_i32_min", typ: 0 },
192- { json: "i32_range", js: "i32_range", typ: 0 },
193- { json: "large_bounds", js: "large_bounds", typ: 0 },
194- { json: "only_maximum", js: "only_maximum", typ: 0 },
195195 { json: "only_minimum", js: "only_minimum", typ: 0 },
196- { json: "small_negative", js: "small_negative", typ: 0 },
197- { json: "small_positive", js: "small_positive", typ: 0 },
196+ { json: "only_maximum", js: "only_maximum", typ: 0 },
198197 { json: "unbounded", js: "unbounded", typ: 0 },
198+ { json: "large_bounds", js: "large_bounds", typ: 0 },
199199 ], "any"),
200200 };
Mschema-typescript-zod/test/inputs/schema/non-standard-ref.schema/default/TopLevel.ts+2 −2
@@ -12,8 +12,8 @@ export interface TopLevel {
1212 }
1313
1414 export interface LightParams {
15- app_id: string;
1615 outlet_id: string;
16+ app_id: string;
1717 rgba: string;
1818 }
1919
@@ -187,8 +187,8 @@ const typeMap: any = {
187187 { json: "LightParams", js: "LightParams", typ: r("LightParams") },
188188 ], false),
189189 "LightParams": o([
190- { json: "app_id", js: "app_id", typ: "" },
191190 { json: "outlet_id", js: "outlet_id", typ: "" },
191+ { json: "app_id", js: "app_id", typ: "" },
192192 { json: "rgba", js: "rgba", typ: "" },
193193 ], false),
194194 };
Mschema-typescript-zod/test/inputs/schema/optional-const-ref.schema/default/TopLevel.ts+2 −2
@@ -8,9 +8,9 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11+ minOnly: [string, string, ...string[]];
1112 maxOnly: number[];
1213 minAndMax: [number, ...number[]];
13- minOnly: [string, string, ...string[]];
1414 plain: string[];
1515 unionItems: [UnionItem, UnionItem, ...UnionItem[]];
1616 [property: string]: unknown;
@@ -185,9 +185,9 @@ function r(name: string) {
185185
186186 const typeMap: any = {
187187 "TopLevel": o([
188+ { json: "minOnly", js: "minOnly", typ: a("") },
188189 { json: "maxOnly", js: "maxOnly", typ: a(0) },
189190 { json: "minAndMax", js: "minAndMax", typ: a(3.14) },
190- { json: "minOnly", js: "minOnly", typ: a("") },
191191 { json: "plain", js: "plain", typ: a("") },
192192 { json: "unionItems", js: "unionItems", typ: a(u(0, "")) },
193193 ], "any"),
Mschema-typescript-zod/test/inputs/schema/optional-constraints.schema/default/TopLevel.ts+8 −8
@@ -9,13 +9,13 @@
99
1010 export interface TopLevel {
1111 free: number;
12- intersection: number;
13- max: number;
1412 min: number;
13+ max: number;
1514 minmax: number;
16- minMaxIntersection: number;
17- minMaxUnion: number;
1815 union: number;
16+ minMaxUnion: number;
17+ intersection: number;
18+ minMaxIntersection: number;
1919 [property: string]: unknown;
2020 }
2121
@@ -187,12 +187,12 @@ function r(name: string) {
187187 const typeMap: any = {
188188 "TopLevel": o([
189189 { json: "free", js: "free", typ: 0 },
190- { json: "intersection", js: "intersection", typ: 0 },
191- { json: "max", js: "max", typ: 0 },
192190 { json: "min", js: "min", typ: 0 },
191+ { json: "max", js: "max", typ: 0 },
193192 { json: "minmax", js: "minmax", typ: 0 },
194- { json: "minMaxIntersection", js: "minMaxIntersection", typ: 0 },
195- { json: "minMaxUnion", js: "minMaxUnion", typ: 0 },
196193 { json: "union", js: "union", typ: 0 },
194+ { json: "minMaxUnion", js: "minMaxUnion", typ: 0 },
195+ { json: "intersection", js: "intersection", typ: 0 },
196+ { json: "minMaxIntersection", js: "minMaxIntersection", typ: 0 },
197197 ], "any"),
198198 };
Mschema-typescript-zod/test/inputs/schema/optional-date-time.schema/default/TopLevel.ts+8 −8
@@ -9,13 +9,13 @@
99
1010 export interface TopLevel {
1111 free: number;
12- intersection: number;
13- max: number;
1412 min: number;
13+ max: number;
1514 minmax: number;
16- minMaxIntersection: number;
17- minMaxUnion: number;
1815 union: number;
16+ minMaxUnion: number;
17+ intersection: number;
18+ minMaxIntersection: number;
1919 [property: string]: unknown;
2020 }
2121
@@ -187,12 +187,12 @@ function r(name: string) {
187187 const typeMap: any = {
188188 "TopLevel": o([
189189 { json: "free", js: "free", typ: 3.14 },
190- { json: "intersection", js: "intersection", typ: 3.14 },
191- { json: "max", js: "max", typ: 3.14 },
192190 { json: "min", js: "min", typ: 3.14 },
191+ { json: "max", js: "max", typ: 3.14 },
193192 { json: "minmax", js: "minmax", typ: 3.14 },
194- { json: "minMaxIntersection", js: "minMaxIntersection", typ: 3.14 },
195- { json: "minMaxUnion", js: "minMaxUnion", typ: 3.14 },
196193 { json: "union", js: "union", typ: 3.14 },
194+ { json: "minMaxUnion", js: "minMaxUnion", typ: 3.14 },
195+ { json: "intersection", js: "intersection", typ: 3.14 },
196+ { json: "minMaxIntersection", js: "minMaxIntersection", typ: 3.14 },
197197 ], "any"),
198198 };
Mschema-typescript-zod/test/inputs/schema/prefix-items.schema/default/TopLevel.ts+10 −10
@@ -8,14 +8,14 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- intersection: string;
12- inUnion: InUnion;
13- maxlength: string;
1411 minlength: string;
15- minMaxIntersection: string;
12+ maxlength: string;
1613 minmaxlength: string;
17- minMaxUnion: string;
1814 union: string;
15+ inUnion: InUnion;
16+ minMaxUnion: string;
17+ intersection: string;
18+ minMaxIntersection: string;
1919 [property: string]: unknown;
2020 }
2121
@@ -188,13 +188,13 @@ function r(name: string) {
188188
189189 const typeMap: any = {
190190 "TopLevel": o([
191- { json: "intersection", js: "intersection", typ: "" },
192- { json: "inUnion", js: "inUnion", typ: u(3.14, "") },
193- { json: "maxlength", js: "maxlength", typ: "" },
194191 { json: "minlength", js: "minlength", typ: "" },
195- { json: "minMaxIntersection", js: "minMaxIntersection", typ: "" },
192+ { json: "maxlength", js: "maxlength", typ: "" },
196193 { json: "minmaxlength", js: "minmaxlength", typ: "" },
197- { json: "minMaxUnion", js: "minMaxUnion", typ: "" },
198194 { json: "union", js: "union", typ: "" },
195+ { json: "inUnion", js: "inUnion", typ: u(3.14, "") },
196+ { json: "minMaxUnion", js: "minMaxUnion", typ: "" },
197+ { json: "intersection", js: "intersection", typ: "" },
198+ { json: "minMaxIntersection", js: "minMaxIntersection", typ: "" },
199199 ], "any"),
200200 };
Aschema-typescript-zod/test/inputs/schema/property-order.schema/default/TopLevel.ts+2 −2
@@ -8,8 +8,8 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- bar: number;
1211 foo: number;
12+ bar: number;
1313 quux: boolean;
1414 [property: string]: unknown;
1515 }
@@ -181,8 +181,8 @@ function r(name: string) {
181181
182182 const typeMap: any = {
183183 "TopLevel": o([
184- { json: "bar", js: "bar", typ: 0 },
185184 { json: "foo", js: "foo", typ: 0 },
185+ { json: "bar", js: "bar", typ: 0 },
186186 { json: "quux", js: "quux", typ: true },
187187 ], "any"),
188188 };
Mschema-typescript-zod/test/inputs/schema/renaming-bug.schema/default/TopLevel.ts+2 −2
@@ -8,8 +8,8 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- b?: null | string;
1211 kind: Kind;
12+ b?: null | string;
1313 [property: string]: unknown;
1414 }
1515
@@ -182,8 +182,8 @@ function r(name: string) {
182182
183183 const typeMap: any = {
184184 "TopLevel": o([
185- { json: "b", js: "b", typ: u(undefined, u(null, "")) },
186185 { json: "kind", js: "kind", typ: r("Kind") },
186+ { json: "b", js: "b", typ: u(undefined, u(null, "")) },
187187 ], "any"),
188188 "Kind": [
189189 "one",
Mschema-typescript-zod/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.ts+2 −2
@@ -8,8 +8,8 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- bar: boolean;
1211 foo?: unknown;
12+ bar: boolean;
1313 }
1414
1515 // Converts JSON strings to/from your types
@@ -179,7 +179,7 @@ function r(name: string) {
179179
180180 const typeMap: any = {
181181 "TopLevel": o([
182- { json: "bar", js: "bar", typ: true },
183182 { json: "foo", js: "foo", typ: u(undefined, "any") },
183+ { json: "bar", js: "bar", typ: true },
184184 ], false),
185185 };
Mschema-typescript-zod/test/inputs/schema/uuid.schema/default/TopLevel.ts+6 −6
@@ -9,12 +9,12 @@
99
1010 export interface TopLevel {
1111 coordinates?: Coordinate[];
12- count?: number;
13- label?: string;
1412 requiredCoordinates: Coordinate[];
13+ count?: number;
1514 requiredCount: number;
16- requiredLabel: string;
1715 weight?: number;
16+ label?: string;
17+ requiredLabel: string;
1818 }
1919
2020 export interface Coordinate {
@@ -190,12 +190,12 @@ function r(name: string) {
190190 const typeMap: any = {
191191 "TopLevel": o([
192192 { json: "coordinates", js: "coordinates", typ: u(undefined, a(r("Coordinate"))) },
193- { json: "count", js: "count", typ: u(undefined, 0) },
194- { json: "label", js: "label", typ: u(undefined, "") },
195193 { json: "requiredCoordinates", js: "requiredCoordinates", typ: a(r("Coordinate")) },
194+ { json: "count", js: "count", typ: u(undefined, 0) },
196195 { json: "requiredCount", js: "requiredCount", typ: 0 },
197- { json: "requiredLabel", js: "requiredLabel", typ: "" },
198196 { json: "weight", js: "weight", typ: u(undefined, 3.14) },
197+ { json: "label", js: "label", typ: u(undefined, "") },
198+ { json: "requiredLabel", js: "requiredLabel", typ: "" },
199199 ], false),
200200 "Coordinate": o([
201201 { json: "latitude", js: "latitude", typ: 3.14 },
Mschema-typescript-zod/test/inputs/schema/vega-lite.schema/default/TopLevel.ts+6 −6
@@ -8,11 +8,11 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- optDouble?: number;
11+ reqZeroMin: number;
1212 optInt?: number;
13- optPattern?: string;
13+ optDouble?: number;
1414 optString?: string;
15- reqZeroMin: number;
15+ optPattern?: string;
1616 [property: string]: unknown;
1717 }
1818
@@ -183,10 +183,10 @@ function r(name: string) {
183183
184184 const typeMap: any = {
185185 "TopLevel": o([
186- { json: "optDouble", js: "optDouble", typ: u(undefined, 3.14) },
186+ { json: "reqZeroMin", js: "reqZeroMin", typ: 0 },
187187 { json: "optInt", js: "optInt", typ: u(undefined, 0) },
188- { json: "optPattern", js: "optPattern", typ: u(undefined, "") },
188+ { json: "optDouble", js: "optDouble", typ: u(undefined, 3.14) },
189189 { json: "optString", js: "optString", typ: u(undefined, "") },
190- { json: "reqZeroMin", js: "reqZeroMin", typ: 0 },
190+ { json: "optPattern", js: "optPattern", typ: u(undefined, "") },
191191 ], "any"),
192192 };
Mschema-typescript/test/inputs/schema/accessors.schema/default/TopLevel.ts+8 −8
@@ -8,12 +8,12 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- "optional-date"?: Date;
12- "optional-date-time"?: Date;
13- "optional-time"?: string;
1411 "required-date": Date;
15- "required-date-time": Date;
1612 "required-time": string;
13+ "required-date-time": Date;
14+ "optional-date"?: Date;
15+ "optional-time"?: string;
16+ "optional-date-time"?: Date;
1717 }
1818
1919 // Converts JSON strings to/from your types
@@ -183,11 +183,11 @@ function r(name: string) {
183183
184184 const typeMap: any = {
185185 "TopLevel": o([
186- { json: "optional-date", js: "optional-date", typ: u(undefined, Date) },
187- { json: "optional-date-time", js: "optional-date-time", typ: u(undefined, Date) },
188- { json: "optional-time", js: "optional-time", typ: u(undefined, "") },
189186 { json: "required-date", js: "required-date", typ: Date },
190- { json: "required-date-time", js: "required-date-time", typ: Date },
191187 { json: "required-time", js: "required-time", typ: "" },
188+ { json: "required-date-time", js: "required-date-time", typ: Date },
189+ { json: "optional-date", js: "optional-date", typ: u(undefined, Date) },
190+ { json: "optional-time", js: "optional-time", typ: u(undefined, "") },
191+ { json: "optional-date-time", js: "optional-date-time", typ: u(undefined, Date) },
192192 ], false),
193193 };
Mschema-typescript/test/inputs/schema/all-of-additional-properties-false.schema/default/TopLevel.ts+2 −2
@@ -8,8 +8,8 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- open: Open[];
1211 tuple: Open[];
12+ open: Open[];
1313 [property: string]: unknown;
1414 }
1515
@@ -182,7 +182,7 @@ function r(name: string) {
182182
183183 const typeMap: any = {
184184 "TopLevel": o([
185- { json: "open", js: "open", typ: a(u(true, 0)) },
186185 { json: "tuple", js: "tuple", typ: a(u(true, 0)) },
186+ { json: "open", js: "open", typ: a(u(true, 0)) },
187187 ], "any"),
188188 };
Mschema-typescript/test/inputs/schema/bool-string.schema/default/TopLevel.ts+204 −0
@@ -0,0 +1,204 @@
1+// To parse this data:
2+//
3+// import { Convert, TopLevel } from "./TopLevel";
4+//
5+// const topLevel = Convert.toTopLevel(json);
6+//
7+// These functions will throw an error if the JSON doesn't
8+// match the expected interface, even if the JSON is valid.
9+
10+export interface TopLevel {
11+ zebra: string;
12+ mango: number;
13+ apple: boolean;
14+ delta: string;
15+ banana: number;
16+ ordered: Ordered;
17+}
18+
19+export interface Ordered {
20+ mango: number;
21+ zebra: string;
22+ apple: boolean;
23+}
24+
25+// Converts JSON strings to/from your types
26+// and asserts the results of JSON.parse at runtime
27+export class Convert {
28+ public static toTopLevel(json: string): TopLevel {
29+ return cast(JSON.parse(json), r("TopLevel"));
30+ }
31+
32+ public static topLevelToJson(value: TopLevel): string {
33+ return JSON.stringify(uncast(value, r("TopLevel")), null, 2);
34+ }
35+}
36+
37+function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
38+ const prettyTyp = prettyTypeName(typ);
39+ const parentText = parent ? ` on ${parent}` : '';
40+ const keyText = key ? ` for key "${key}"` : '';
41+ throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
42+}
43+
44+function prettyTypeName(typ: any): string {
45+ if (Array.isArray(typ)) {
46+ if (typ.length === 2 && typ[0] === undefined) {
47+ return `an optional ${prettyTypeName(typ[1])}`;
48+ } else {
49+ return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
50+ }
51+ } else if (typeof typ === "object" && typ.literal !== undefined) {
52+ return typ.literal;
53+ } else {
54+ return typeof typ;
55+ }
56+}
57+
58+function jsonToJSProps(typ: any): any {
59+ if (typ.jsonToJS === undefined) {
60+ const map: any = {};
61+ typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
62+ typ.jsonToJS = map;
63+ }
64+ return typ.jsonToJS;
65+}
66+
67+function jsToJSONProps(typ: any): any {
68+ if (typ.jsToJSON === undefined) {
69+ const map: any = {};
70+ typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
71+ typ.jsToJSON = map;
72+ }
73+ return typ.jsToJSON;
74+}
75+
76+function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
77+ function transformPrimitive(typ: string, val: any): any {
78+ if (typeof typ === typeof val) return val;
79+ return invalidValue(typ, val, key, parent);
80+ }
81+
82+ function transformUnion(typs: any[], val: any): any {
83+ // val must validate against one typ in typs
84+ const l = typs.length;
85+ for (let i = 0; i < l; i++) {
86+ const typ = typs[i];
87+ try {
88+ return transform(val, typ, getProps);
89+ } catch (_) {}
90+ }
91+ return invalidValue(typs, val, key, parent);
92+ }
93+
94+ function transformEnum(cases: string[], val: any): any {
95+ if (cases.indexOf(val) !== -1) return val;
96+ return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
97+ }
98+
99+ function transformArray(typ: any, val: any): any {
100+ // val must be an array with no invalid elements
101+ if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
102+ return val.map(el => transform(el, typ, getProps));
103+ }
104+
105+ function transformDate(val: any): any {
106+ if (val === null) {
107+ return null;
108+ }
109+ const d = new Date(val);
110+ if (isNaN(d.valueOf())) {
111+ return invalidValue(l("Date"), val, key, parent);
112+ }
113+ return d;
114+ }
115+
116+ function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
117+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
118+ return invalidValue(l(ref || "object"), val, key, parent);
119+ }
120+ const result: any = {};
121+ Object.getOwnPropertyNames(props).forEach(key => {
122+ const prop = props[key];
123+ const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
124+ result[prop.key] = transform(v, prop.typ, getProps, key, ref);
125+ });
126+ Object.getOwnPropertyNames(val).forEach(key => {
127+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
128+ result[key] = transform(val[key], additional, getProps, key, ref);
129+ }
130+ });
131+ return result;
132+ }
133+
134+ if (typ === "any") return val;
135+ if (typ === null) {
136+ if (val === null) return val;
137+ return invalidValue(typ, val, key, parent);
138+ }
139+ if (typ === false) return invalidValue(typ, val, key, parent);
140+ let ref: any = undefined;
141+ while (typeof typ === "object" && typ.ref !== undefined) {
142+ ref = typ.ref;
143+ typ = typeMap[typ.ref];
144+ }
145+ if (Array.isArray(typ)) return transformEnum(typ, val);
146+ if (typeof typ === "object") {
147+ return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
148+ : typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
149+ : typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
150+ : invalidValue(typ, val, key, parent);
151+ }
152+ // Numbers can be parsed by Date but shouldn't be.
153+ if (typ === Date && typeof val !== "number") return transformDate(val);
154+ return transformPrimitive(typ, val);
155+}
156+
157+function cast<T>(val: any, typ: any): T {
158+ return transform(val, typ, jsonToJSProps);
159+}
160+
161+function uncast<T>(val: T, typ: any): any {
162+ return transform(val, typ, jsToJSONProps);
163+}
164+
165+function l(typ: any) {
166+ return { literal: typ };
167+}
168+
169+function a(typ: any) {
170+ return { arrayItems: typ };
171+}
172+
173+function u(...typs: any[]) {
174+ return { unionMembers: typs };
175+}
176+
177+function o(props: any[], additional: any) {
178+ return { props, additional };
179+}
180+
181+function m(additional: any) {
182+ const props: any[] = [];
183+ return { props, additional };
184+}
185+
186+function r(name: string) {
187+ return { ref: name };
188+}
189+
190+const typeMap: any = {
191+ "TopLevel": o([
192+ { json: "zebra", js: "zebra", typ: "" },
193+ { json: "mango", js: "mango", typ: 3.14 },
194+ { json: "apple", js: "apple", typ: true },
195+ { json: "delta", js: "delta", typ: "" },
196+ { json: "banana", js: "banana", typ: 0 },
197+ { json: "ordered", js: "ordered", typ: r("Ordered") },
198+ ], false),
199+ "Ordered": o([
200+ { json: "mango", js: "mango", typ: 3.14 },
201+ { json: "zebra", js: "zebra", typ: "" },
202+ { json: "apple", js: "apple", typ: true },
203+ ], false),
204+};
Mschema-typescript/test/inputs/schema/boolean-subschema.schema/default/TopLevel.ts+16 −16
@@ -16,14 +16,14 @@ export interface TopLevel {
1616
1717 export interface Fruit {
1818 apple?: boolean;
19- berries?: Berry[];
2019 orange?: boolean;
20+ berries?: Berry[];
2121 [property: string]: unknown;
2222 }
2323
2424 export interface Berry {
25- color?: Color;
2625 name?: string;
26+ color?: Color;
2727 shapes?: Shape[];
2828 [property: string]: unknown;
2929 }
@@ -34,8 +34,8 @@ export interface Color {
3434 }
3535
3636 export interface Shape {
37- geometry?: Geometry;
3837 history?: History;
38+ geometry?: Geometry;
3939 [property: string]: unknown;
4040 }
4141
@@ -56,9 +56,9 @@ export interface RectShape {
5656 }
5757
5858 export interface Part {
59- depth?: string;
6059 length?: string;
6160 width?: string;
61+ depth?: string;
6262 [property: string]: unknown;
6363 }
6464
@@ -68,12 +68,12 @@ export interface History {
6868 }
6969
7070 export interface Vehicle {
71- brand?: string;
7271 id?: string;
73- speed?: Speed;
74- subModule?: boolean;
7572 type?: VehicleType;
73+ speed?: Speed;
7674 year?: string;
75+ brand?: string;
76+ subModule?: boolean;
7777 [property: string]: unknown;
7878 }
7979
@@ -83,8 +83,8 @@ export interface Speed {
8383 }
8484
8585 export interface Limit {
86- maximum?: number;
8786 minimum?: number;
87+ maximum?: number;
8888 [property: string]: unknown;
8989 }
9090
@@ -272,20 +272,20 @@ const typeMap: any = {
272272 ], "any"),
273273 "Fruit": o([
274274 { json: "apple", js: "apple", typ: u(undefined, true) },
275- { json: "berries", js: "berries", typ: u(undefined, a(r("Berry"))) },
276275 { json: "orange", js: "orange", typ: u(undefined, true) },
276+ { json: "berries", js: "berries", typ: u(undefined, a(r("Berry"))) },
277277 ], "any"),
278278 "Berry": o([
279- { json: "color", js: "color", typ: u(undefined, r("Color")) },
280279 { json: "name", js: "name", typ: u(undefined, "") },
280+ { json: "color", js: "color", typ: u(undefined, r("Color")) },
281281 { json: "shapes", js: "shapes", typ: u(undefined, a(r("Shape"))) },
282282 ], "any"),
283283 "Color": o([
284284 { json: "rgb", js: "rgb", typ: u(undefined, 3.14) },
285285 ], "any"),
286286 "Shape": o([
287- { json: "geometry", js: "geometry", typ: u(undefined, r("Geometry")) },
288287 { json: "history", js: "history", typ: u(undefined, r("History")) },
288+ { json: "geometry", js: "geometry", typ: u(undefined, r("Geometry")) },
289289 ], "any"),
290290 "Geometry": o([
291291 { json: "rectShape", js: "rectShape", typ: u(undefined, r("RectShape")) },
@@ -298,27 +298,27 @@ const typeMap: any = {
298298 { json: "parts", js: "parts", typ: u(undefined, a(r("Part"))) },
299299 ], "any"),
300300 "Part": o([
301- { json: "depth", js: "depth", typ: u(undefined, "") },
302301 { json: "length", js: "length", typ: u(undefined, "") },
303302 { json: "width", js: "width", typ: u(undefined, "") },
303+ { json: "depth", js: "depth", typ: u(undefined, "") },
304304 ], "any"),
305305 "History": o([
306306 { json: "class", js: "class", typ: u(undefined, "") },
307307 ], "any"),
308308 "Vehicle": o([
309- { json: "brand", js: "brand", typ: u(undefined, "") },
310309 { json: "id", js: "id", typ: u(undefined, "") },
311- { json: "speed", js: "speed", typ: u(undefined, r("Speed")) },
312- { json: "subModule", js: "subModule", typ: u(undefined, true) },
313310 { json: "type", js: "type", typ: u(undefined, r("VehicleType")) },
311+ { json: "speed", js: "speed", typ: u(undefined, r("Speed")) },
314312 { json: "year", js: "year", typ: u(undefined, "") },
313+ { json: "brand", js: "brand", typ: u(undefined, "") },
314+ { json: "subModule", js: "subModule", typ: u(undefined, true) },
315315 ], "any"),
316316 "Speed": o([
317317 { json: "velocity", js: "velocity", typ: u(undefined, r("Limit")) },
318318 ], "any"),
319319 "Limit": o([
320- { json: "maximum", js: "maximum", typ: u(undefined, 3.14) },
321320 { json: "minimum", js: "minimum", typ: u(undefined, 3.14) },
321+ { json: "maximum", js: "maximum", typ: u(undefined, 3.14) },
322322 ], "any"),
323323 "VehicleType": o([
324324 { json: "name", js: "name", typ: u(undefined, r("Name")) },
Mschema-typescript/test/inputs/schema/comment-injection.schema/default/TopLevel.ts+4 −4
@@ -8,14 +8,14 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- next?: Next;
1211 value: string;
12+ next?: Next;
1313 [property: string]: unknown;
1414 }
1515
1616 export interface Node {
17- next?: Next;
1817 value: string;
18+ next?: Next;
1919 [property: string]: unknown;
2020 }
2121
@@ -188,11 +188,11 @@ function r(name: string) {
188188
189189 const typeMap: any = {
190190 "TopLevel": o([
191- { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
192191 { json: "value", js: "value", typ: "" },
192+ { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
193193 ], "any"),
194194 "Node": o([
195- { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
196195 { json: "value", js: "value", typ: "" },
196+ { json: "next", js: "next", typ: u(undefined, u(null, r("Node"), "")) },
197197 ], "any"),
198198 };
Mschema-typescript/test/inputs/schema/const-non-string.schema/default/TopLevel.ts+6 −6
@@ -8,11 +8,11 @@
88 // match the expected interface, even if the JSON is valid.
99
1010 export interface TopLevel {
11- arrNullable?: (null | string)[];
12- arrOne?: string[];
13- nullable: null | string;
1411 one: string;
1512 optional?: string;
13+ nullable: null | string;
14+ arrOne?: string[];
15+ arrNullable?: (null | string)[];
1616 unionWithEnum: string;
1717 [property: string]: unknown;
1818 }
@@ -184,11 +184,11 @@ function r(name: string) {
184184
185185 const typeMap: any = {
186186 "TopLevel": o([
187- { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
188- { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
189- { json: "nullable", js: "nullable", typ: u(null, "") },
190187 { json: "one", js: "one", typ: "" },
191188 { json: "optional", js: "optional", typ: u(undefined, "") },
189+ { json: "nullable", js: "nullable", typ: u(null, "") },
190+ { json: "arrOne", js: "arrOne", typ: u(undefined, a("")) },
191+ { json: "arrNullable", js: "arrNullable", typ: u(undefined, a(u(null, ""))) },
192192 { json: "unionWithEnum", js: "unionWithEnum", typ: "" },
193193 ], "any"),
194194 };
Mschema-typescript/test/inputs/schema/date-time-or-string.schema/default/TopLevel.ts+2 −2
@@ -9,9 +9,9 @@ export const EnumSchema = z.enum([
99 export type Enum = z.infer<typeof EnumSchema>;
1010
1111 export const TopLevelSchema = z.object({
12- "bar": z.string(),
12+ "union": z.union([z.boolean(), z.number()]),
1313 "enum": EnumSchema,
1414 "foo": z.string(),
15- "union": z.union([z.boolean(), z.number()]),
15+ "bar": z.string(),
1616 });
1717 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/date-time.schema/default/TopLevel.ts+3 −3
@@ -2,11 +2,11 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5- "arrNullable": z.array(z.union([z.null(), z.string()])).optional(),
6- "arrOne": z.array(z.string()).optional(),
7- "nullable": z.union([z.null(), z.string()]),
85 "one": z.string(),
96 "optional": z.string().optional(),
7+ "nullable": z.union([z.null(), z.string()]),
8+ "arrOne": z.array(z.string()).optional(),
9+ "arrNullable": z.array(z.union([z.null(), z.string()])).optional(),
1010 "unionWithBool": z.union([z.boolean(), z.string()]),
1111 "unionWithBoolAndEnum": z.union([z.boolean(), z.string()]),
1212 });
Mschema-typescript/test/inputs/schema/description.schema/default/TopLevel.ts+1 −1
@@ -2,9 +2,9 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5+ "foo": z.string(),
56 "disallowed": z.any().optional(),
67 "empty": z.array(z.any()),
7- "foo": z.string(),
88 "impossible": z.any().optional(),
99 });
1010 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/direct-union.schema/default/TopLevel.ts+1 −1
@@ -2,9 +2,9 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5+ "value": z.string(),
56 "trailingBackslash": z.string().optional(),
67 "trailingQuote": z.string().optional(),
78 "trailingTripleQuote": z.string().optional(),
8- "value": z.string(),
99 });
1010 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/enum.schema/default/TopLevel.ts+1 −1
@@ -7,7 +7,7 @@ export const BarEnumSchema = z.enum([
77 export type BarEnum = z.infer<typeof BarEnumSchema>;
88
99 export const TopLevelSchema = z.object({
10- "bar": z.union([z.coerce.date(), BarEnumSchema]),
1110 "foo": z.string(),
11+ "bar": z.union([z.coerce.date(), BarEnumSchema]),
1212 });
1313 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/integer-string.schema/default/TopLevel.ts+2 −2
@@ -14,10 +14,10 @@ export const ObjectOrStringClassSchema = z.object({
1414 export type ObjectOrStringClass = z.infer<typeof ObjectOrStringClassSchema>;
1515
1616 export const TopLevelSchema = z.object({
17- "bar": z.boolean().optional(),
17+ "union": z.union([z.number(), z.string()]),
1818 "enum": EnumSchema,
1919 "foo": z.number().optional(),
20+ "bar": z.boolean().optional(),
2021 "object-or-string": z.union([ObjectOrStringClassSchema, z.string()]),
21- "union": z.union([z.number(), z.string()]),
2222 });
2323 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/integer-type.schema/default/TopLevel.ts+3 −3
@@ -2,11 +2,11 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5- "arrNullable": z.array(z.union([z.null(), z.string()])).optional(),
6- "arrOne": z.array(z.string()).optional(),
7- "nullable": z.union([z.null(), z.string()]),
85 "one": z.string(),
96 "optional": z.string().optional(),
7+ "nullable": z.union([z.null(), z.string()]),
8+ "arrOne": z.array(z.string()).optional(),
9+ "arrNullable": z.array(z.union([z.null(), z.string()])).optional(),
1010 "unionWithInt": z.union([z.number(), z.string()]),
1111 "unionWithIntAndEnum": z.union([z.number(), z.string()]),
1212 });
Mschema-typescript/test/inputs/schema/light.schema/default/TopLevel.ts+5 −5
@@ -2,14 +2,14 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5+ "small_positive": z.number(),
6+ "small_negative": z.number(),
7+ "i32_range": z.number(),
58 "above_i32_max": z.number(),
69 "below_i32_min": z.number(),
7- "i32_range": z.number(),
8- "large_bounds": z.number(),
9- "only_maximum": z.number(),
1010 "only_minimum": z.number(),
11- "small_negative": z.number(),
12- "small_positive": z.number(),
11+ "only_maximum": z.number(),
1312 "unbounded": z.number(),
13+ "large_bounds": z.number(),
1414 });
1515 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/min-max-items.schema/default/TopLevel.ts+1 −1
@@ -2,8 +2,8 @@ import * as z from "zod";
22
33
44 export const LightParamsSchema = z.object({
5- "app_id": z.string(),
65 "outlet_id": z.string(),
6+ "app_id": z.string(),
77 "rgba": z.string(),
88 });
99 export type LightParams = z.infer<typeof LightParamsSchema>;
Mschema-typescript/test/inputs/schema/minmax-integer.schema/default/TopLevel.ts+1 −1
@@ -2,9 +2,9 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5+ "minOnly": z.array(z.string()).min(2),
56 "maxOnly": z.array(z.number()).max(3),
67 "minAndMax": z.array(z.number()).min(1).max(4),
7- "minOnly": z.array(z.string()).min(2),
88 "plain": z.array(z.string()),
99 "unionItems": z.array(z.union([z.number(), z.string()])).min(2),
1010 });
Mschema-typescript/test/inputs/schema/minmax.schema/default/TopLevel.ts+4 −4
@@ -3,12 +3,12 @@ import * as z from "zod";
33
44 export const TopLevelSchema = z.object({
55 "free": z.number(),
6- "intersection": z.number(),
7- "max": z.number(),
86 "min": z.number(),
7+ "max": z.number(),
98 "minmax": z.number(),
10- "minMaxIntersection": z.number(),
11- "minMaxUnion": z.number(),
129 "union": z.number(),
10+ "minMaxUnion": z.number(),
11+ "intersection": z.number(),
12+ "minMaxIntersection": z.number(),
1313 });
1414 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/minmaxlength.schema/default/TopLevel.ts+4 −4
@@ -3,12 +3,12 @@ import * as z from "zod";
33
44 export const TopLevelSchema = z.object({
55 "free": z.number(),
6- "intersection": z.number(),
7- "max": z.number(),
86 "min": z.number(),
7+ "max": z.number(),
98 "minmax": z.number(),
10- "minMaxIntersection": z.number(),
11- "minMaxUnion": z.number(),
129 "union": z.number(),
10+ "minMaxUnion": z.number(),
11+ "intersection": z.number(),
12+ "minMaxIntersection": z.number(),
1313 });
1414 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/non-standard-ref.schema/default/TopLevel.ts+5 −5
@@ -2,13 +2,13 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5- "intersection": z.string(),
6- "inUnion": z.union([z.number(), z.string()]),
7- "maxlength": z.string(),
85 "minlength": z.string(),
9- "minMaxIntersection": z.string(),
6+ "maxlength": z.string(),
107 "minmaxlength": z.string(),
11- "minMaxUnion": z.string(),
128 "union": z.string(),
9+ "inUnion": z.union([z.number(), z.string()]),
10+ "minMaxUnion": z.string(),
11+ "intersection": z.string(),
12+ "minMaxIntersection": z.string(),
1313 });
1414 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/nullable-optional-one-of.schema/default/TopLevel.ts+1 −1
@@ -2,8 +2,8 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5- "bar": z.number(),
65 "foo": z.number(),
6+ "bar": z.number(),
77 "quux": z.boolean(),
88 });
99 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/optional-any.schema/default/TopLevel.ts+3 −3
@@ -9,11 +9,11 @@ export type Coordinate = z.infer<typeof CoordinateSchema>;
99
1010 export const TopLevelSchema = z.object({
1111 "coordinates": z.array(CoordinateSchema).optional(),
12- "count": z.number().optional(),
13- "label": z.string().optional(),
1412 "requiredCoordinates": z.array(CoordinateSchema),
13+ "count": z.number().optional(),
1514 "requiredCount": z.number(),
16- "requiredLabel": z.string(),
1715 "weight": z.number().optional(),
16+ "label": z.string().optional(),
17+ "requiredLabel": z.string(),
1818 });
1919 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/optional-const-ref.schema/default/TopLevel.ts+3 −3
@@ -2,10 +2,10 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5- "optDouble": z.number().optional(),
5+ "reqZeroMin": z.number(),
66 "optInt": z.number().optional(),
7- "optPattern": z.string().optional(),
7+ "optDouble": z.number().optional(),
88 "optString": z.string().optional(),
9- "reqZeroMin": z.number(),
9+ "optPattern": z.string().optional(),
1010 });
1111 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/optional-constraints.schema/default/TopLevel.ts+4 −4
@@ -2,11 +2,11 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5- "optional-date": z.string().optional(),
6- "optional-date-time": z.coerce.date().optional(),
7- "optional-time": z.string().optional(),
85 "required-date": z.string(),
9- "required-date-time": z.coerce.date(),
106 "required-time": z.string(),
7+ "required-date-time": z.coerce.date(),
8+ "optional-date": z.string().optional(),
9+ "optional-time": z.string().optional(),
10+ "optional-date-time": z.coerce.date().optional(),
1111 });
1212 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/optional-date-time.schema/default/TopLevel.ts+1 −1
@@ -2,7 +2,7 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5- "open": z.array(z.union([z.boolean(), z.number()])),
65 "tuple": z.array(z.union([z.boolean(), z.number()])),
6+ "open": z.array(z.union([z.boolean(), z.number()])),
77 });
88 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/prefix-items.schema/default/TopLevel.ts+19 −0
@@ -0,0 +1,19 @@
1+import * as z from "zod";
2+
3+
4+export const OrderedSchema = z.object({
5+ "mango": z.number(),
6+ "zebra": z.string(),
7+ "apple": z.boolean(),
8+});
9+export type Ordered = z.infer<typeof OrderedSchema>;
10+
11+export const TopLevelSchema = z.object({
12+ "zebra": z.string(),
13+ "mango": z.number(),
14+ "apple": z.boolean(),
15+ "delta": z.string(),
16+ "banana": z.number(),
17+ "ordered": OrderedSchema,
18+});
19+export type TopLevel = z.infer<typeof TopLevelSchema>;
Aschema-typescript/test/inputs/schema/property-order.schema/default/TopLevel.ts+8 −8
@@ -36,9 +36,9 @@ export const CircularShapeSchema = z.object({
3636 export type CircularShape = z.infer<typeof CircularShapeSchema>;
3737
3838 export const PartSchema = z.object({
39- "depth": z.string().optional(),
4039 "length": z.string().optional(),
4140 "width": z.string().optional(),
41+ "depth": z.string().optional(),
4242 });
4343 export type Part = z.infer<typeof PartSchema>;
4444
@@ -48,8 +48,8 @@ export const HistorySchema = z.object({
4848 export type History = z.infer<typeof HistorySchema>;
4949
5050 export const LimitSchema = z.object({
51- "maximum": z.number().optional(),
5251 "minimum": z.number().optional(),
52+ "maximum": z.number().optional(),
5353 });
5454 export type Limit = z.infer<typeof LimitSchema>;
5555
@@ -77,32 +77,32 @@ export const GeometrySchema = z.object({
7777 export type Geometry = z.infer<typeof GeometrySchema>;
7878
7979 export const VehicleSchema = z.object({
80- "brand": z.string().optional(),
8180 "id": z.string().optional(),
82- "speed": SpeedSchema.optional(),
83- "subModule": z.boolean().optional(),
8481 "type": VehicleTypeSchema.optional(),
82+ "speed": SpeedSchema.optional(),
8583 "year": z.string().optional(),
84+ "brand": z.string().optional(),
85+ "subModule": z.boolean().optional(),
8686 });
8787 export type Vehicle = z.infer<typeof VehicleSchema>;
8888
8989 export const ShapeSchema = z.object({
90- "geometry": GeometrySchema.optional(),
9190 "history": HistorySchema.optional(),
91+ "geometry": GeometrySchema.optional(),
9292 });
9393 export type Shape = z.infer<typeof ShapeSchema>;
9494
9595 export const BerrySchema = z.object({
96- "color": ColorSchema.optional(),
9796 "name": z.string().optional(),
97+ "color": ColorSchema.optional(),
9898 "shapes": z.array(ShapeSchema).optional(),
9999 });
100100 export type Berry = z.infer<typeof BerrySchema>;
101101
102102 export const FruitSchema = z.object({
103103 "apple": z.boolean().optional(),
104- "berries": z.array(BerrySchema).optional(),
105104 "orange": z.boolean().optional(),
105+ "berries": z.array(BerrySchema).optional(),
106106 });
107107 export type Fruit = z.infer<typeof FruitSchema>;
Mschema-typescript/test/inputs/schema/renaming-bug.schema/default/TopLevel.ts+3 −3
@@ -2,18 +2,18 @@ import * as z from "zod";
22
33
44 export type Node = {
5- "next"?: Node | null | string;
65 "value": string;
6+ "next"?: Node | null | string;
77 };
88 export const NodeSchema: z.ZodType<Node> = z.lazy(() =>
99 z.object({
10- "next": z.union([z.null(), NodeSchema, z.string()]).optional(),
1110 "value": z.string(),
11+ "next": z.union([z.null(), NodeSchema, z.string()]).optional(),
1212 })
1313 );
1414
1515 export const TopLevelSchema = z.object({
16- "next": z.union([z.null(), NodeSchema, z.string()]).optional(),
1716 "value": z.string(),
17+ "next": z.union([z.null(), NodeSchema, z.string()]).optional(),
1818 });
1919 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/rust-cycle-breaker-union.schema/default/TopLevel.ts+3 −3
@@ -2,11 +2,11 @@ import * as z from "zod";
22
33
44 export const TopLevelSchema = z.object({
5- "arrNullable": z.array(z.union([z.null(), z.string()])).optional(),
6- "arrOne": z.array(z.string()).optional(),
7- "nullable": z.union([z.null(), z.string()]),
85 "one": z.string(),
96 "optional": z.string().optional(),
7+ "nullable": z.union([z.null(), z.string()]),
8+ "arrOne": z.array(z.string()).optional(),
9+ "arrNullable": z.array(z.union([z.null(), z.string()])).optional(),
1010 "unionWithEnum": z.string(),
1111 });
1212 export type TopLevel = z.infer<typeof TopLevelSchema>;
Mschema-typescript/test/inputs/schema/uuid.schema/default/TopLevel.ts+8 −8
@@ -717,8 +717,8 @@ export const MarkConfigSchema = z.object({
717717 "dx": z.number().optional(),
718718 "dy": z.number().optional(),
719719 "fill": z.string().optional(),
720- "filled": z.boolean().optional(),
721720 "fillOpacity": z.number().optional(),
721+ "filled": z.boolean().optional(),
722722 "font": z.string().optional(),
723723 "fontSize": z.number().optional(),
724724 "fontStyle": FontStyleSchema.optional(),
@@ -767,9 +767,9 @@ export const AxisConfigSchema = z.object({
767767 "shortTimeLabels": z.boolean().optional(),
768768 "tickColor": z.string().optional(),
769769 "tickRound": z.boolean().optional(),
770- "ticks": z.boolean().optional(),
771770 "tickSize": z.number().optional(),
772771 "tickWidth": z.number().optional(),
772+ "ticks": z.boolean().optional(),
773773 "titleAlign": z.string().optional(),
774774 "titleAngle": z.number().optional(),
775775 "titleBaseline": z.string().optional(),
@@ -809,9 +809,9 @@ export const VgAxisConfigSchema = z.object({
809809 "minExtent": z.number().optional(),
810810 "tickColor": z.string().optional(),
811811 "tickRound": z.boolean().optional(),
812- "ticks": z.boolean().optional(),
813812 "tickSize": z.number().optional(),
814813 "tickWidth": z.number().optional(),
814+ "ticks": z.boolean().optional(),
815815 "titleAlign": z.string().optional(),
816816 "titleAngle": z.number().optional(),
817817 "titleBaseline": z.string().optional(),
@@ -839,8 +839,8 @@ export const BarConfigSchema = z.object({
839839 "dx": z.number().optional(),
840840 "dy": z.number().optional(),
841841 "fill": z.string().optional(),
842- "filled": z.boolean().optional(),
843842 "fillOpacity": z.number().optional(),
843+ "filled": z.boolean().optional(),
844844 "font": z.string().optional(),
845845 "fontSize": z.number().optional(),
846846 "fontStyle": FontStyleSchema.optional(),
@@ -1035,8 +1035,8 @@ export const TextConfigSchema = z.object({
10351035 "dx": z.number().optional(),
10361036 "dy": z.number().optional(),
10371037 "fill": z.string().optional(),
1038- "filled": z.boolean().optional(),
10391038 "fillOpacity": z.number().optional(),
1039+ "filled": z.boolean().optional(),
10401040 "font": z.string().optional(),
10411041 "fontSize": z.number().optional(),
10421042 "fontStyle": FontStyleSchema.optional(),
@@ -1071,8 +1071,8 @@ export const TickConfigSchema = z.object({
10711071 "dx": z.number().optional(),
10721072 "dy": z.number().optional(),
10731073 "fill": z.string().optional(),
1074- "filled": z.boolean().optional(),
10751074 "fillOpacity": z.number().optional(),
1075+ "filled": z.boolean().optional(),
10761076 "font": z.string().optional(),
10771077 "fontSize": z.number().optional(),
10781078 "fontStyle": FontStyleSchema.optional(),
@@ -1285,8 +1285,8 @@ export const AxisSchema = z.object({
12851285 "orient": TitleOrientSchema.optional(),
12861286 "position": z.number().optional(),
12871287 "tickCount": z.number().optional(),
1288- "ticks": z.boolean().optional(),
12891288 "tickSize": z.number().optional(),
1289+ "ticks": z.boolean().optional(),
12901290 "title": z.union([z.null(), z.string()]).optional(),
12911291 "titleMaxLength": z.number().optional(),
12921292 "titlePadding": z.number().optional(),
@@ -1315,8 +1315,8 @@ export const MarkDefSchema = z.object({
13151315 "dx": z.number().optional(),
13161316 "dy": z.number().optional(),
13171317 "fill": z.string().optional(),
1318- "filled": z.boolean().optional(),
13191318 "fillOpacity": z.number().optional(),
1319+ "filled": z.boolean().optional(),
13201320 "font": z.string().optional(),
13211321 "fontSize": z.number().optional(),
13221322 "fontStyle": FontStyleSchema.optional(),
No generated files match these filters.