forked from loafle/openapi-generator-original
[C][Client] Check cJSON_IsNull when the data type is string (#14332)
This commit is contained in:
parent
88fa9ef3c2
commit
04ebe9e1a0
@ -635,7 +635,7 @@ fail:
|
|||||||
{{^isEnum}}
|
{{^isEnum}}
|
||||||
{{#isString}}
|
{{#isString}}
|
||||||
{{^required}}if ({{{name}}}) { {{/required}}
|
{{^required}}if ({{{name}}}) { {{/required}}
|
||||||
if(!cJSON_IsString({{{name}}}))
|
if(!cJSON_IsString({{{name}}}){{^required}} && !cJSON_IsNull({{{name}}}){{/required}})
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -880,7 +880,7 @@ fail:
|
|||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{^isEnum}}
|
{{^isEnum}}
|
||||||
{{#isString}}
|
{{#isString}}
|
||||||
{{^required}}{{{name}}} ? {{/required}}strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
{{^required}}{{{name}}} && !cJSON_IsNull({{{name}}}) ? {{/required}}strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
||||||
{{/isString}}
|
{{/isString}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{#isByteArray}}
|
{{#isByteArray}}
|
||||||
|
@ -88,7 +88,7 @@ api_response_t *api_response_parseFromJSON(cJSON *api_responseJSON){
|
|||||||
// api_response->type
|
// api_response->type
|
||||||
cJSON *type = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "type");
|
cJSON *type = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "type");
|
||||||
if (type) {
|
if (type) {
|
||||||
if(!cJSON_IsString(type))
|
if(!cJSON_IsString(type) && !cJSON_IsNull(type))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ api_response_t *api_response_parseFromJSON(cJSON *api_responseJSON){
|
|||||||
// api_response->message
|
// api_response->message
|
||||||
cJSON *message = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "message");
|
cJSON *message = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "message");
|
||||||
if (message) {
|
if (message) {
|
||||||
if(!cJSON_IsString(message))
|
if(!cJSON_IsString(message) && !cJSON_IsNull(message))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -106,8 +106,8 @@ api_response_t *api_response_parseFromJSON(cJSON *api_responseJSON){
|
|||||||
|
|
||||||
api_response_local_var = api_response_create (
|
api_response_local_var = api_response_create (
|
||||||
code ? code->valuedouble : 0,
|
code ? code->valuedouble : 0,
|
||||||
type ? strdup(type->valuestring) : NULL,
|
type && !cJSON_IsNull(type) ? strdup(type->valuestring) : NULL,
|
||||||
message ? strdup(message->valuestring) : NULL
|
message && !cJSON_IsNull(message) ? strdup(message->valuestring) : NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
return api_response_local_var;
|
return api_response_local_var;
|
||||||
|
@ -74,7 +74,7 @@ category_t *category_parseFromJSON(cJSON *categoryJSON){
|
|||||||
// category->name
|
// category->name
|
||||||
cJSON *name = cJSON_GetObjectItemCaseSensitive(categoryJSON, "name");
|
cJSON *name = cJSON_GetObjectItemCaseSensitive(categoryJSON, "name");
|
||||||
if (name) {
|
if (name) {
|
||||||
if(!cJSON_IsString(name))
|
if(!cJSON_IsString(name) && !cJSON_IsNull(name))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ category_t *category_parseFromJSON(cJSON *categoryJSON){
|
|||||||
|
|
||||||
category_local_var = category_create (
|
category_local_var = category_create (
|
||||||
id ? id->valuedouble : 0,
|
id ? id->valuedouble : 0,
|
||||||
name ? strdup(name->valuestring) : NULL
|
name && !cJSON_IsNull(name) ? strdup(name->valuestring) : NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
return category_local_var;
|
return category_local_var;
|
||||||
|
@ -74,7 +74,7 @@ tag_t *tag_parseFromJSON(cJSON *tagJSON){
|
|||||||
// tag->name
|
// tag->name
|
||||||
cJSON *name = cJSON_GetObjectItemCaseSensitive(tagJSON, "name");
|
cJSON *name = cJSON_GetObjectItemCaseSensitive(tagJSON, "name");
|
||||||
if (name) {
|
if (name) {
|
||||||
if(!cJSON_IsString(name))
|
if(!cJSON_IsString(name) && !cJSON_IsNull(name))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ tag_t *tag_parseFromJSON(cJSON *tagJSON){
|
|||||||
|
|
||||||
tag_local_var = tag_create (
|
tag_local_var = tag_create (
|
||||||
id ? id->valuedouble : 0,
|
id ? id->valuedouble : 0,
|
||||||
name ? strdup(name->valuestring) : NULL
|
name && !cJSON_IsNull(name) ? strdup(name->valuestring) : NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
return tag_local_var;
|
return tag_local_var;
|
||||||
|
@ -154,7 +154,7 @@ user_t *user_parseFromJSON(cJSON *userJSON){
|
|||||||
// user->username
|
// user->username
|
||||||
cJSON *username = cJSON_GetObjectItemCaseSensitive(userJSON, "username");
|
cJSON *username = cJSON_GetObjectItemCaseSensitive(userJSON, "username");
|
||||||
if (username) {
|
if (username) {
|
||||||
if(!cJSON_IsString(username))
|
if(!cJSON_IsString(username) && !cJSON_IsNull(username))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ user_t *user_parseFromJSON(cJSON *userJSON){
|
|||||||
// user->first_name
|
// user->first_name
|
||||||
cJSON *first_name = cJSON_GetObjectItemCaseSensitive(userJSON, "firstName");
|
cJSON *first_name = cJSON_GetObjectItemCaseSensitive(userJSON, "firstName");
|
||||||
if (first_name) {
|
if (first_name) {
|
||||||
if(!cJSON_IsString(first_name))
|
if(!cJSON_IsString(first_name) && !cJSON_IsNull(first_name))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ user_t *user_parseFromJSON(cJSON *userJSON){
|
|||||||
// user->last_name
|
// user->last_name
|
||||||
cJSON *last_name = cJSON_GetObjectItemCaseSensitive(userJSON, "lastName");
|
cJSON *last_name = cJSON_GetObjectItemCaseSensitive(userJSON, "lastName");
|
||||||
if (last_name) {
|
if (last_name) {
|
||||||
if(!cJSON_IsString(last_name))
|
if(!cJSON_IsString(last_name) && !cJSON_IsNull(last_name))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ user_t *user_parseFromJSON(cJSON *userJSON){
|
|||||||
// user->email
|
// user->email
|
||||||
cJSON *email = cJSON_GetObjectItemCaseSensitive(userJSON, "email");
|
cJSON *email = cJSON_GetObjectItemCaseSensitive(userJSON, "email");
|
||||||
if (email) {
|
if (email) {
|
||||||
if(!cJSON_IsString(email))
|
if(!cJSON_IsString(email) && !cJSON_IsNull(email))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ user_t *user_parseFromJSON(cJSON *userJSON){
|
|||||||
// user->password
|
// user->password
|
||||||
cJSON *password = cJSON_GetObjectItemCaseSensitive(userJSON, "password");
|
cJSON *password = cJSON_GetObjectItemCaseSensitive(userJSON, "password");
|
||||||
if (password) {
|
if (password) {
|
||||||
if(!cJSON_IsString(password))
|
if(!cJSON_IsString(password) && !cJSON_IsNull(password))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ user_t *user_parseFromJSON(cJSON *userJSON){
|
|||||||
// user->phone
|
// user->phone
|
||||||
cJSON *phone = cJSON_GetObjectItemCaseSensitive(userJSON, "phone");
|
cJSON *phone = cJSON_GetObjectItemCaseSensitive(userJSON, "phone");
|
||||||
if (phone) {
|
if (phone) {
|
||||||
if(!cJSON_IsString(phone))
|
if(!cJSON_IsString(phone) && !cJSON_IsNull(phone))
|
||||||
{
|
{
|
||||||
goto end; //String
|
goto end; //String
|
||||||
}
|
}
|
||||||
@ -217,12 +217,12 @@ user_t *user_parseFromJSON(cJSON *userJSON){
|
|||||||
|
|
||||||
user_local_var = user_create (
|
user_local_var = user_create (
|
||||||
id ? id->valuedouble : 0,
|
id ? id->valuedouble : 0,
|
||||||
username ? strdup(username->valuestring) : NULL,
|
username && !cJSON_IsNull(username) ? strdup(username->valuestring) : NULL,
|
||||||
first_name ? strdup(first_name->valuestring) : NULL,
|
first_name && !cJSON_IsNull(first_name) ? strdup(first_name->valuestring) : NULL,
|
||||||
last_name ? strdup(last_name->valuestring) : NULL,
|
last_name && !cJSON_IsNull(last_name) ? strdup(last_name->valuestring) : NULL,
|
||||||
email ? strdup(email->valuestring) : NULL,
|
email && !cJSON_IsNull(email) ? strdup(email->valuestring) : NULL,
|
||||||
password ? strdup(password->valuestring) : NULL,
|
password && !cJSON_IsNull(password) ? strdup(password->valuestring) : NULL,
|
||||||
phone ? strdup(phone->valuestring) : NULL,
|
phone && !cJSON_IsNull(phone) ? strdup(phone->valuestring) : NULL,
|
||||||
user_status ? user_status->valuedouble : 0
|
user_status ? user_status->valuedouble : 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user