File tree 2 files changed +4
-4
lines changed
modules/openapi-generator/src/main/resources/C-libcurl
samples/client/petstore/c/model
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -669,7 +669,7 @@ fail:
669
669
{ {/isDate} }
670
670
{ {#isDateTime} }
671
671
{ {^required} }if ({ {{name} }}) { {{/required} }
672
- if(!cJSON_IsString({ {{name} }}))
672
+ if(!cJSON_IsString({ {{name} }}) && !cJSON_IsNull( { {{name } }}) )
673
673
{
674
674
goto end; //DateTime
675
675
}
@@ -893,7 +893,7 @@ fail:
893
893
{ {^required} }{ {{name} }} ? { {/required} }strdup({ {{name} }}->valuestring){ {^required} } : NULL{ {/required} }{ {^-last} },{ {/-last} }
894
894
{ {/isDate} }
895
895
{ {#isDateTime} }
896
- { {^required} }{ {{name} }} ? { {/required} }strdup({ {{name} }}->valuestring){ {^required} } : NULL{ {/required} }{ {^-last} },{ {/-last} }
896
+ { {^required} }{ {{name} }} && !cJSON_IsNull( { {{name } }}) ? { {/required} }strdup({ {{name} }}->valuestring){ {^required} } : NULL{ {/required} }{ {^-last} },{ {/-last} }
897
897
{ {/isDateTime} }
898
898
{ {/isPrimitiveType} }
899
899
{ {/isContainer} }
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ order_t *order_parseFromJSON(cJSON *orderJSON){
150
150
// order->ship_date
151
151
cJSON * ship_date = cJSON_GetObjectItemCaseSensitive (orderJSON , "shipDate" );
152
152
if (ship_date ) {
153
- if (!cJSON_IsString (ship_date ))
153
+ if (!cJSON_IsString (ship_date ) && ! cJSON_IsNull ( ship_date ) )
154
154
{
155
155
goto end ; //DateTime
156
156
}
@@ -181,7 +181,7 @@ order_t *order_parseFromJSON(cJSON *orderJSON){
181
181
id ? id -> valuedouble : 0 ,
182
182
pet_id ? pet_id -> valuedouble : 0 ,
183
183
quantity ? quantity -> valuedouble : 0 ,
184
- ship_date ? strdup (ship_date -> valuestring ) : NULL ,
184
+ ship_date && ! cJSON_IsNull ( ship_date ) ? strdup (ship_date -> valuestring ) : NULL ,
185
185
status ? statusVariable : -1 ,
186
186
complete ? complete -> valueint : 0
187
187
);
You can’t perform that action at this time.
0 commit comments