Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
2test cases
3files differ
1modified
2new
0deleted
321changed lines
+321 −0insertions / deletions
Base 1824a2856c8e527dec01320c8b65c0b85a447532 · PR merge 689349a85731179adb52989217c279b237f8c3a5 · Head 8bc8a4e28a4c9ca6bc2e3245853f5f54dc7e4e8e · raw patch
Test case

test/inputs/schema/minmaxlength.schema

2 generated files · +319 −0
Aschema-cjsondefault / TopLevel.c+248 −0
@@ -0,0 +1,248 @@
1+/**
2+ * TopLevel.c
3+ * This file has been autogenerated using quicktype https://github.com/quicktype/quicktype - DO NOT EDIT
4+ */
5+
6+#include "TopLevel.h"
7+
8+struct InUnion * cJSON_GetInUnionValue(const cJSON * j) {
9+ struct InUnion * x = cJSON_malloc(sizeof(struct InUnion));
10+ if (NULL != x) {
11+ memset(x, 0, sizeof(struct InUnion));
12+ if (cJSON_IsNumber(j)) {
13+ x->type = cJSON_Number;
14+ x->value.number = cJSON_GetNumberValue(j);
15+ }
16+ else if (cJSON_IsString(j)) {
17+ x->type = cJSON_String;
18+ x->value.string = strdup(cJSON_GetStringValue(j));
19+ }
20+ }
21+ return x;
22+}
23+
24+cJSON * cJSON_CreateInUnion(const struct InUnion * x) {
25+ cJSON * j = NULL;
26+ if (NULL != x) {
27+ if (cJSON_Number == x->type) {
28+ j = cJSON_CreateNumber(x->value.number);
29+ }
30+ else if (cJSON_String == x->type) {
31+ j = cJSON_CreateString(x->value.string);
32+ }
33+ }
34+ return j;
35+}
36+
37+void cJSON_DeleteInUnion(struct InUnion * x) {
38+ if (NULL != x) {
39+ if (cJSON_Number == x->type) {
40+ }
41+ else if (cJSON_String == x->type) {
42+ cJSON_free(x->value.string);
43+ }
44+ cJSON_free(x);
45+ }
46+}
47+
48+struct TopLevel * cJSON_ParseTopLevel(const char * s) {
49+ struct TopLevel * x = NULL;
50+ if (NULL != s) {
51+ cJSON * j = cJSON_Parse(s);
52+ if (NULL != j) {
53+ x = cJSON_GetTopLevelValue(j);
54+ cJSON_Delete(j);
55+ }
56+ }
57+ return x;
58+}
59+
60+struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
61+ struct TopLevel * x = NULL;
62+ if (NULL != j) {
63+ if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
64+ memset(x, 0, sizeof(struct TopLevel));
65+ if (!cJSON_HasObjectItem(j, "intersection")) { cJSON_DeleteTopLevel(x); return NULL; }
66+ if (cJSON_HasObjectItem(j, "intersection")) {
67+ if (!cJSON_IsString(cJSON_GetObjectItemCaseSensitive(j, "intersection"))) { cJSON_DeleteTopLevel(x); return NULL; }
68+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "intersection")->valuestring) < 4) { cJSON_DeleteTopLevel(x); return NULL; }
69+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "intersection")->valuestring) > 5) { cJSON_DeleteTopLevel(x); return NULL; }
70+ x->intersection = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "intersection")));
71+ }
72+ else {
73+ if (NULL != (x->intersection = cJSON_malloc(sizeof(char)))) {
74+ x->intersection[0] = '\0';
75+ }
76+ }
77+ if (!cJSON_HasObjectItem(j, "inUnion")) { cJSON_DeleteTopLevel(x); return NULL; }
78+ if (cJSON_HasObjectItem(j, "inUnion")) {
79+ if (!cJSON_IsInUnion(cJSON_GetObjectItemCaseSensitive(j, "inUnion"))) { cJSON_DeleteTopLevel(x); return NULL; }
80+ x->in_union = cJSON_GetInUnionValue(cJSON_GetObjectItemCaseSensitive(j, "inUnion"));
81+ if (NULL == x->in_union) { cJSON_DeleteTopLevel(x); return NULL; }
82+ }
83+ if (!cJSON_HasObjectItem(j, "maxlength")) { cJSON_DeleteTopLevel(x); return NULL; }
84+ if (cJSON_HasObjectItem(j, "maxlength")) {
85+ if (!cJSON_IsString(cJSON_GetObjectItemCaseSensitive(j, "maxlength"))) { cJSON_DeleteTopLevel(x); return NULL; }
86+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "maxlength")->valuestring) > 5) { cJSON_DeleteTopLevel(x); return NULL; }
87+ x->maxlength = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "maxlength")));
88+ }
89+ else {
90+ if (NULL != (x->maxlength = cJSON_malloc(sizeof(char)))) {
91+ x->maxlength[0] = '\0';
92+ }
93+ }
94+ if (!cJSON_HasObjectItem(j, "minlength")) { cJSON_DeleteTopLevel(x); return NULL; }
95+ if (cJSON_HasObjectItem(j, "minlength")) {
96+ if (!cJSON_IsString(cJSON_GetObjectItemCaseSensitive(j, "minlength"))) { cJSON_DeleteTopLevel(x); return NULL; }
97+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "minlength")->valuestring) < 3) { cJSON_DeleteTopLevel(x); return NULL; }
98+ x->minlength = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "minlength")));
99+ }
100+ else {
101+ if (NULL != (x->minlength = cJSON_malloc(sizeof(char)))) {
102+ x->minlength[0] = '\0';
103+ }
104+ }
105+ if (!cJSON_HasObjectItem(j, "minMaxIntersection")) { cJSON_DeleteTopLevel(x); return NULL; }
106+ if (cJSON_HasObjectItem(j, "minMaxIntersection")) {
107+ if (!cJSON_IsString(cJSON_GetObjectItemCaseSensitive(j, "minMaxIntersection"))) { cJSON_DeleteTopLevel(x); return NULL; }
108+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "minMaxIntersection")->valuestring) < 3) { cJSON_DeleteTopLevel(x); return NULL; }
109+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "minMaxIntersection")->valuestring) > 5) { cJSON_DeleteTopLevel(x); return NULL; }
110+ x->min_max_intersection = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "minMaxIntersection")));
111+ }
112+ else {
113+ if (NULL != (x->min_max_intersection = cJSON_malloc(sizeof(char)))) {
114+ x->min_max_intersection[0] = '\0';
115+ }
116+ }
117+ if (!cJSON_HasObjectItem(j, "minmaxlength")) { cJSON_DeleteTopLevel(x); return NULL; }
118+ if (cJSON_HasObjectItem(j, "minmaxlength")) {
119+ if (!cJSON_IsString(cJSON_GetObjectItemCaseSensitive(j, "minmaxlength"))) { cJSON_DeleteTopLevel(x); return NULL; }
120+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "minmaxlength")->valuestring) < 3) { cJSON_DeleteTopLevel(x); return NULL; }
121+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "minmaxlength")->valuestring) > 5) { cJSON_DeleteTopLevel(x); return NULL; }
122+ x->minmaxlength = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "minmaxlength")));
123+ }
124+ else {
125+ if (NULL != (x->minmaxlength = cJSON_malloc(sizeof(char)))) {
126+ x->minmaxlength[0] = '\0';
127+ }
128+ }
129+ if (!cJSON_HasObjectItem(j, "minMaxUnion")) { cJSON_DeleteTopLevel(x); return NULL; }
130+ if (cJSON_HasObjectItem(j, "minMaxUnion")) {
131+ if (!cJSON_IsString(cJSON_GetObjectItemCaseSensitive(j, "minMaxUnion"))) { cJSON_DeleteTopLevel(x); return NULL; }
132+ x->min_max_union = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "minMaxUnion")));
133+ }
134+ else {
135+ if (NULL != (x->min_max_union = cJSON_malloc(sizeof(char)))) {
136+ x->min_max_union[0] = '\0';
137+ }
138+ }
139+ if (!cJSON_HasObjectItem(j, "union")) { cJSON_DeleteTopLevel(x); return NULL; }
140+ if (cJSON_HasObjectItem(j, "union")) {
141+ if (!cJSON_IsString(cJSON_GetObjectItemCaseSensitive(j, "union"))) { cJSON_DeleteTopLevel(x); return NULL; }
142+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "union")->valuestring) < 3) { cJSON_DeleteTopLevel(x); return NULL; }
143+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "union")->valuestring) > 6) { cJSON_DeleteTopLevel(x); return NULL; }
144+ x->top_level_union = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "union")));
145+ }
146+ else {
147+ if (NULL != (x->top_level_union = cJSON_malloc(sizeof(char)))) {
148+ x->top_level_union[0] = '\0';
149+ }
150+ }
151+ }
152+ }
153+ return x;
154+}
155+
156+cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
157+ cJSON * j = NULL;
158+ if (NULL != x) {
159+ if (NULL != (j = cJSON_CreateObject())) {
160+ if (NULL != x->intersection) {
161+ cJSON_AddStringToObject(j, "intersection", x->intersection);
162+ }
163+ else {
164+ cJSON_AddStringToObject(j, "intersection", "");
165+ }
166+ cJSON_AddItemToObject(j, "inUnion", cJSON_CreateInUnion(x->in_union));
167+ if (NULL != x->maxlength) {
168+ cJSON_AddStringToObject(j, "maxlength", x->maxlength);
169+ }
170+ else {
171+ cJSON_AddStringToObject(j, "maxlength", "");
172+ }
173+ if (NULL != x->minlength) {
174+ cJSON_AddStringToObject(j, "minlength", x->minlength);
175+ }
176+ else {
177+ cJSON_AddStringToObject(j, "minlength", "");
178+ }
179+ if (NULL != x->min_max_intersection) {
180+ cJSON_AddStringToObject(j, "minMaxIntersection", x->min_max_intersection);
181+ }
182+ else {
183+ cJSON_AddStringToObject(j, "minMaxIntersection", "");
184+ }
185+ if (NULL != x->minmaxlength) {
186+ cJSON_AddStringToObject(j, "minmaxlength", x->minmaxlength);
187+ }
188+ else {
189+ cJSON_AddStringToObject(j, "minmaxlength", "");
190+ }
191+ if (NULL != x->min_max_union) {
192+ cJSON_AddStringToObject(j, "minMaxUnion", x->min_max_union);
193+ }
194+ else {
195+ cJSON_AddStringToObject(j, "minMaxUnion", "");
196+ }
197+ if (NULL != x->top_level_union) {
198+ cJSON_AddStringToObject(j, "union", x->top_level_union);
199+ }
200+ else {
201+ cJSON_AddStringToObject(j, "union", "");
202+ }
203+ }
204+ }
205+ return j;
206+}
207+
208+char * cJSON_PrintTopLevel(const struct TopLevel * x) {
209+ char * s = NULL;
210+ if (NULL != x) {
211+ cJSON * j = cJSON_CreateTopLevel(x);
212+ if (NULL != j) {
213+ s = cJSON_Print(j);
214+ cJSON_Delete(j);
215+ }
216+ }
217+ return s;
218+}
219+
220+void cJSON_DeleteTopLevel(struct TopLevel * x) {
221+ if (NULL != x) {
222+ if (NULL != x->intersection) {
223+ cJSON_free(x->intersection);
224+ }
225+ if (NULL != x->in_union) {
226+ cJSON_DeleteInUnion(x->in_union);
227+ }
228+ if (NULL != x->maxlength) {
229+ cJSON_free(x->maxlength);
230+ }
231+ if (NULL != x->minlength) {
232+ cJSON_free(x->minlength);
233+ }
234+ if (NULL != x->min_max_intersection) {
235+ cJSON_free(x->min_max_intersection);
236+ }
237+ if (NULL != x->minmaxlength) {
238+ cJSON_free(x->minmaxlength);
239+ }
240+ if (NULL != x->min_max_union) {
241+ cJSON_free(x->min_max_union);
242+ }
243+ if (NULL != x->top_level_union) {
244+ cJSON_free(x->top_level_union);
245+ }
246+ cJSON_free(x);
247+ }
248+}
Aschema-cjsondefault / TopLevel.h+71 −0
@@ -0,0 +1,71 @@
1+/**
2+ * TopLevel.h
3+ * This file has been autogenerated using quicktype https://github.com/quicktype/quicktype - DO NOT EDIT
4+ * This file depends of https://github.com/DaveGamble/cJSON, https://github.com/joelguittet/c-list and https://github.com/joelguittet/c-hashtable
5+ * To parse json data from json string use the following: struct <type> * data = cJSON_Parse<type>(<string>);
6+ * To get json data from cJSON object use the following: struct <type> * data = cJSON_Get<type>Value(<cjson>);
7+ * To get cJSON object from json data use the following: cJSON * cjson = cJSON_Create<type>(<data>);
8+ * To print json string from json data use the following: char * string = cJSON_Print<type>(<data>);
9+ * To delete json data use the following: cJSON_Delete<type>(<data>);
10+ */
11+
12+#ifndef __TOPLEVEL_H__
13+#define __TOPLEVEL_H__
14+
15+#ifdef __cplusplus
16+extern "C" {
17+#endif
18+
19+#include <stdint.h>
20+#include <stdbool.h>
21+#include <stdlib.h>
22+#include <string.h>
23+#include <cJSON.h>
24+#include <hashtable.h>
25+#include <list.h>
26+
27+#ifndef cJSON_Bool
28+#define cJSON_Bool (cJSON_True | cJSON_False)
29+#endif
30+#ifndef cJSON_Map
31+#define cJSON_Map (1 << 16)
32+#endif
33+#ifndef cJSON_Enum
34+#define cJSON_Enum (1 << 17)
35+#endif
36+
37+struct InUnion {
38+ int type;
39+ union {
40+ double number;
41+ char * string;
42+ } value;
43+};
44+
45+struct TopLevel {
46+ char * intersection;
47+ struct InUnion * in_union;
48+ char * maxlength;
49+ char * minlength;
50+ char * min_max_intersection;
51+ char * minmaxlength;
52+ char * min_max_union;
53+ char * top_level_union;
54+};
55+
56+#define cJSON_IsInUnion(j) (cJSON_IsNumber(j) || cJSON_IsString(j))
57+struct InUnion * cJSON_GetInUnionValue(const cJSON * j);
58+cJSON * cJSON_CreateInUnion(const struct InUnion * x);
59+void cJSON_DeleteInUnion(struct InUnion * x);
60+
61+struct TopLevel * cJSON_ParseTopLevel(const char * s);
62+struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j);
63+cJSON * cJSON_CreateTopLevel(const struct TopLevel * x);
64+char * cJSON_PrintTopLevel(const struct TopLevel * x);
65+void cJSON_DeleteTopLevel(struct TopLevel * x);
66+
67+#ifdef __cplusplus
68+}
69+#endif
70+
71+#endif /* __TOPLEVEL_H__ */
Test case

test/inputs/schema/renaming-bug.schema

1 generated file · +2 −0
Mschema-cjsondefault / TopLevel.c+2 −0
@@ -591,6 +591,7 @@ struct Berry * cJSON_GetBerryValue(const cJSON * j) {
591591 }
592592 if (cJSON_HasObjectItem(j, "name")) {
593593 if (!cJSON_IsString(cJSON_GetObjectItemCaseSensitive(j, "name"))) { cJSON_DeleteBerry(x); return NULL; }
594+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "name")->valuestring) < 1) { cJSON_DeleteBerry(x); return NULL; }
594595 x->name = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "name")));
595596 }
596597 if (cJSON_HasObjectItem(j, "shapes")) {
@@ -1020,6 +1021,7 @@ struct Vehicle * cJSON_GetVehicleValue(const cJSON * j) {
10201021 }
10211022 if (cJSON_HasObjectItem(j, "id")) {
10221023 if (!cJSON_IsString(cJSON_GetObjectItemCaseSensitive(j, "id"))) { cJSON_DeleteVehicle(x); return NULL; }
1024+ if (strlen(cJSON_GetObjectItemCaseSensitive(j, "id")->valuestring) < 1) { cJSON_DeleteVehicle(x); return NULL; }
10231025 x->id = strdup(cJSON_GetStringValue(cJSON_GetObjectItemCaseSensitive(j, "id")));
10241026 }
10251027 if (cJSON_HasObjectItem(j, "speed")) {
No generated files match these filters.