Skip to content

Commit

Permalink
[C][Client] Fix default enum value being -1
Browse files Browse the repository at this point in the history
  • Loading branch information
bookerdj authored and Dan Booker committed Mar 6, 2024
1 parent 8eaeb2a commit 5c5f791
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ fail:
{{^isPrimitiveType}}
{{#isModel}}
{{#isEnum}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_nonprim_enum{{^required}} : -1{{/required}}{{^-last}},{{/-last}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_nonprim_enum{{^required}} : {{projectName}}_{{classVarName}}_{{enumName}}_NULL{{/required}}{{^-last}},{{/-last}}
{{/isEnum}}
{{^isEnum}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_nonprim{{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
Expand Down Expand Up @@ -875,7 +875,7 @@ fail:
{{/isBoolean}}
{{#isEnum}}
{{#isString}}
{{^required}}{{{name}}} ? {{/required}}{{name}}Variable{{^required}} : -1{{/required}}{{^-last}},{{/-last}}
{{^required}}{{{name}}} ? {{/required}}{{name}}Variable{{^required}} : {{projectName}}_{{classVarName}}_{{enumName}}_NULL{{/required}}{{^-last}},{{/-last}}
{{/isString}}
{{/isEnum}}
{{^isEnum}}
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/c/model/order.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ order_t *order_parseFromJSON(cJSON *orderJSON){
pet_id ? pet_id->valuedouble : 0,
quantity ? quantity->valuedouble : 0,
ship_date && !cJSON_IsNull(ship_date) ? strdup(ship_date->valuestring) : NULL,
status ? statusVariable : -1,
status ? statusVariable : openapi_petstore_order_STATUS_NULL,
complete ? complete->valueint : 0
);

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/c/model/pet.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ pet_t *pet_parseFromJSON(cJSON *petJSON){
strdup(name->valuestring),
photo_urlsList,
tags ? tagsList : NULL,
status ? statusVariable : -1
status ? statusVariable : openapi_petstore_pet_STATUS_NULL
);

return pet_local_var;
Expand Down

0 comments on commit 5c5f791

Please sign in to comment.