mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-05 15:24:14 +00:00
[SBI] Crash occurs when ENUM in the MAP (#2103)
This commit is contained in:
parent
ce668c556c
commit
969c116e77
1097 changed files with 266728 additions and 42047 deletions
|
|
@ -93,6 +93,12 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_create(
|
|||
OpenAPI_{{classVarName}}_{{name}}_e {{name}}{{^-last}},{{/-last}}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#isString}}
|
||||
{{datatype}} *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
{{datatype}} *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isByteArray}}
|
||||
{{#isNumeric}}
|
||||
{{^required}}
|
||||
bool is_{{name}},
|
||||
|
|
@ -105,13 +111,7 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_create(
|
|||
{{/required}}
|
||||
{{datatype}} {{name}}{{^-last}},{{/-last}}
|
||||
{{/isBoolean}}
|
||||
{{#isString}}
|
||||
{{datatype}} *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
{{datatype}} *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
OpenAPI_{{datatype}} {{name}}{{^-last}},{{/-last}}
|
||||
{{/isBinary}}
|
||||
|
|
@ -161,10 +161,11 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_create(
|
|||
|
||||
void OpenAPI_{{classname}}_free(OpenAPI_{{classname}}_t *{{classname}})
|
||||
{
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if (NULL == {{classname}}) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
{{#vars}}
|
||||
{{^isContainer}}
|
||||
{{^isPrimitiveType}}
|
||||
|
|
@ -211,13 +212,13 @@ void OpenAPI_{{classname}}_free(OpenAPI_{{classname}}_t *{{classname}})
|
|||
{{classname}}->{{name}} = NULL;
|
||||
}
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
{{#isByteArray}}
|
||||
if ({{{classname}}}->{{{name}}}) {
|
||||
ogs_free({{{classname}}}->{{{name}}});
|
||||
{{classname}}->{{name}} = NULL;
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{/isByteArray}}
|
||||
{{/isEnum}}
|
||||
{{#isBinary}}
|
||||
if ({{{classname}}}->{{{name}}}) {
|
||||
ogs_free({{{classname}}}->{{{name}}}->data);
|
||||
|
|
@ -260,12 +261,14 @@ void OpenAPI_{{classname}}_free(OpenAPI_{{classname}}_t *{{classname}})
|
|||
OpenAPI_list_for_each({{classname}}->{{name}}, node) {
|
||||
OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data;
|
||||
ogs_free(localKeyValue->key);
|
||||
{{#isPrimitiveType}}
|
||||
{{^isEnum}}
|
||||
{{#isPrimitiveType}}
|
||||
ogs_free(localKeyValue->value);
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
OpenAPI_{{complexType}}_free(localKeyValue->value);
|
||||
{{/isPrimitiveType}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isEnum}}
|
||||
OpenAPI_map_free(localKeyValue);
|
||||
}
|
||||
OpenAPI_list_free({{classname}}->{{name}});
|
||||
|
|
@ -280,6 +283,7 @@ void OpenAPI_{{classname}}_free(OpenAPI_{{classname}}_t *{{classname}})
|
|||
cJSON *OpenAPI_{{classname}}_convertToJSON(OpenAPI_{{classname}}_t *{{classname}})
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
OpenAPI_lnode_t *node = NULL;
|
||||
|
||||
if ({{classname}} == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
|
|
@ -346,6 +350,18 @@ cJSON *OpenAPI_{{classname}}_convertToJSON(OpenAPI_{{classname}}_t *{{classname}
|
|||
}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#isString}}
|
||||
if (cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
if (cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isNumeric}}
|
||||
if (cJSON_AddNumberToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
|
|
@ -358,19 +374,7 @@ cJSON *OpenAPI_{{classname}}_convertToJSON(OpenAPI_{{classname}}_t *{{classname}
|
|||
goto end;
|
||||
}
|
||||
{{/isBoolean}}
|
||||
{{#isString}}
|
||||
if (cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
if (cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
char* encoded_str_{{{name}}} = OpenAPI_base64encode({{{classname}}}->{{{name}}}->data,{{{classname}}}->{{{name}}}->len);
|
||||
if (cJSON_AddStringToObject(item, "{{{baseName}}}", encoded_str_{{{name}}}) == NULL) {
|
||||
|
|
@ -455,72 +459,57 @@ cJSON *OpenAPI_{{classname}}_convertToJSON(OpenAPI_{{classname}}_t *{{classname}
|
|||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#isArray}}
|
||||
{{#isEnum}}
|
||||
cJSON *{{{name}}} = cJSON_AddArrayToObject(item, "{{{baseName}}}");
|
||||
if ({{{name}}} == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_lnode_t *{{{name}}}_node;
|
||||
OpenAPI_list_for_each({{classname}}->{{{name}}}, {{{name}}}_node) {
|
||||
if (cJSON_AddStringToObject({{{name}}}, "", OpenAPI_{{{complexType}}}_ToString((intptr_t){{{name}}}_node->data)) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#isPrimitiveType}}
|
||||
cJSON *{{{name}}} = cJSON_AddArrayToObject(item, "{{{baseName}}}");
|
||||
if ({{{name}}} == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *{{{name}}}_node;
|
||||
OpenAPI_list_for_each({{{classname}}}->{{{name}}}, {{{name}}}_node) {
|
||||
{{#items}}
|
||||
{{#isString}}
|
||||
if (cJSON_AddStringToObject({{{name}}}, "", (char*){{{name}}}_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isString}}
|
||||
{{#isBoolean}}
|
||||
if (cJSON_AddBoolToObject({{{name}}}, "", *(cJSON_bool *){{{name}}}_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isBoolean}}
|
||||
{{#isNumeric}}
|
||||
if (cJSON_AddNumberToObject({{{name}}}, "", *(double *){{{name}}}_node->data) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isNumeric}}
|
||||
{{/items}}
|
||||
}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
cJSON *{{{name}}}List = cJSON_AddArrayToObject(item, "{{{baseName}}}");
|
||||
if ({{{name}}}List == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_lnode_t *{{{name}}}_node;
|
||||
if ({{{classname}}}->{{{name}}}) {
|
||||
OpenAPI_list_for_each({{classname}}->{{{name}}}, {{{name}}}_node) {
|
||||
cJSON *itemLocal = OpenAPI_{{complexType}}_convertToJSON({{#isEnum}}{{#items}}(intptr_t){{/items}}{{/isEnum}}{{{name}}}_node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray({{{name}}}List, itemLocal);
|
||||
OpenAPI_list_for_each({{classname}}->{{{name}}}, node) {
|
||||
{{#isEnum}}
|
||||
if (cJSON_AddStringToObject({{{name}}}List, "", OpenAPI_{{{complexType}}}_ToString((intptr_t)node->data)) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#items}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isString}}
|
||||
if (cJSON_AddStringToObject({{{name}}}List, "", (char*)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
if (cJSON_AddStringToObject({{{name}}}List, "", (char*)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isNumeric}}
|
||||
if (cJSON_AddNumberToObject({{{name}}}List, "", (uintptr_t)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isNumeric}}
|
||||
{{#isBoolean}}
|
||||
if (cJSON_AddBoolToObject({{{name}}}List, "", (uintptr_t)node->data) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isBoolean}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
cJSON *itemLocal = OpenAPI_{{complexType}}_convertToJSON(node->data);
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToArray({{{name}}}List, itemLocal);
|
||||
{{/isPrimitiveType}}
|
||||
{{/items}}
|
||||
{{/isEnum}}
|
||||
}
|
||||
{{/isArray}}
|
||||
{{#isMap}}
|
||||
cJSON *{{{name}}} = cJSON_AddObjectToObject(item, "{{{baseName}}}");
|
||||
|
|
@ -529,50 +518,57 @@ cJSON *OpenAPI_{{classname}}_convertToJSON(OpenAPI_{{classname}}_t *{{classname}
|
|||
goto end;
|
||||
}
|
||||
cJSON *localMapObject = {{{name}}};
|
||||
OpenAPI_lnode_t *{{{name}}}_node;
|
||||
if ({{{classname}}}->{{{name}}}) {
|
||||
OpenAPI_list_for_each({{{classname}}}->{{{name}}}, {{{name}}}_node) {
|
||||
OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*){{{name}}}_node->data;
|
||||
{{#items}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isString}}
|
||||
if (cJSON_AddStringToObject(localMapObject, localKeyValue->key, (char*)localKeyValue->value) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isString}}
|
||||
{{#isNumeric}}
|
||||
if (cJSON_AddNumberToObject(localMapObject, localKeyValue->key, *(double *)localKeyValue->value) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isNumeric}}
|
||||
{{#isByteArray}}
|
||||
if(cJSON_AddStringToObject(localMapObject, localKeyValue->key, (char*)localKeyValue->value) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isBoolean}}
|
||||
if (cJSON_AddBoolToObject(localMapObject, localKeyValue->key, *(cJSON_bool *)localKeyValue->value) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isBoolean}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
cJSON *itemLocal = localKeyValue->value ?
|
||||
OpenAPI_{{complexType}}_convertToJSON(localKeyValue->value) :
|
||||
cJSON_CreateNull();
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToObject(localMapObject, localKeyValue->key, itemLocal);
|
||||
{{/isPrimitiveType}}
|
||||
{{/items}}
|
||||
OpenAPI_list_for_each({{{classname}}}->{{{name}}}, node) {
|
||||
OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data;
|
||||
{{#isEnum}}
|
||||
if (cJSON_AddStringToObject(localMapObject, localKeyValue->key, OpenAPI_{{{complexType}}}_ToString((intptr_t)localKeyValue->value)) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#items}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isString}}
|
||||
if (cJSON_AddStringToObject(localMapObject, localKeyValue->key, (char*)localKeyValue->value) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
if(cJSON_AddStringToObject(localMapObject, localKeyValue->key, (char*)localKeyValue->value) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isNumeric}}
|
||||
if (cJSON_AddNumberToObject(localMapObject, localKeyValue->key, (uintptr_t)localKeyValue->value) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isNumeric}}
|
||||
{{#isBoolean}}
|
||||
if (cJSON_AddBoolToObject(localMapObject, localKeyValue->key, (uintptr_t)localKeyValue->value) == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isBoolean}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
cJSON *itemLocal = localKeyValue->value ?
|
||||
OpenAPI_{{complexType}}_convertToJSON(localKeyValue->value) :
|
||||
cJSON_CreateNull();
|
||||
if (itemLocal == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToObject(localMapObject, localKeyValue->key, itemLocal);
|
||||
{{/isPrimitiveType}}
|
||||
{{/items}}
|
||||
{{/isEnum}}
|
||||
}
|
||||
}
|
||||
{{/isMap}}
|
||||
{{/isContainer}}
|
||||
{{^required}}
|
||||
|
|
@ -648,6 +644,18 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
{{name}}Variable = OpenAPI_{{name}}{{classname}}_FromString({{{name}}}->valuestring);
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#isString}}
|
||||
if (!cJSON_IsString({{{name}}}){{^required}} && !cJSON_IsNull({{{name}}}){{/required}}) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
if (!cJSON_IsString({{{name}}}){{^required}} && !cJSON_IsNull({{{name}}}){{/required}}) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isNumeric}}
|
||||
if (!cJSON_IsNumber({{{name}}})) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
|
|
@ -660,19 +668,7 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
goto end;
|
||||
}
|
||||
{{/isBoolean}}
|
||||
{{#isString}}
|
||||
if (!cJSON_IsString({{{name}}}){{^required}} && !cJSON_IsNull({{{name}}}){{/required}}) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
if (!cJSON_IsString({{{name}}})) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
decoded_str_{{{name}}} = ogs_malloc(sizeof(OpenAPI_binary_t));
|
||||
ogs_assert(decoded_str_{{{name}}});
|
||||
|
|
@ -740,8 +736,7 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
{{/isContainer}}
|
||||
{{#isContainer}}
|
||||
{{#isArray}}
|
||||
{{#isEnum}}
|
||||
cJSON *{{{name}}}_local_nonprimitive = NULL;
|
||||
cJSON *{{{name}}}_local = NULL;
|
||||
if (!cJSON_IsArray({{{name}}})) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
|
|
@ -749,84 +744,78 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
|
||||
{{{name}}}List = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach({{{name}}}_local_nonprimitive, {{{name}}} ) {
|
||||
if (!cJSON_IsString({{{name}}}_local_nonprimitive)){
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_list_add({{{name}}}List, (void *)OpenAPI_{{{complexType}}}_FromString({{{name}}}_local_nonprimitive->valuestring));
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#isPrimitiveType}}
|
||||
cJSON *{{{name}}}_local;
|
||||
if (!cJSON_IsArray({{{name}}})) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{{name}}}List = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach({{{name}}}_local, {{{name}}}) {
|
||||
{{#items}}
|
||||
{{#isString}}
|
||||
if (!cJSON_IsString({{{name}}}_local)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add({{{name}}}List, ogs_strdup({{{name}}}_local->valuestring));
|
||||
{{/isString}}
|
||||
{{#isNumeric}}
|
||||
if (!cJSON_IsNumber({{{name}}}_local)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
double *{{{name}}}_local_value = (double *)ogs_calloc(1, sizeof(double));
|
||||
if(!{{{name}}}_local_value) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
*{{{name}}}_local_value = {{{name}}}_local->valuedouble;
|
||||
OpenAPI_list_add({{{name}}}List, {{{name}}}_local_value);
|
||||
{{/isNumeric}}
|
||||
{{#isBoolean}}
|
||||
if (!cJSON_IsBool({{{name}}}_local)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add({{{name}}}List, {{{name}}}_local->valueint);
|
||||
{{/isBoolean}}
|
||||
{{/items}}
|
||||
}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
cJSON *{{{name}}}_local_nonprimitive;
|
||||
if (!cJSON_IsArray({{{name}}})){
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
{{{name}}}List = OpenAPI_list_create();
|
||||
|
||||
cJSON_ArrayForEach({{{name}}}_local_nonprimitive, {{{name}}} ) {
|
||||
if (!cJSON_IsObject({{{name}}}_local_nonprimitive)) {
|
||||
{{#isEnum}}
|
||||
if (!cJSON_IsString({{{name}}}_local)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{#isEnum}}{{#items}}{{datatypeWithEnum}}_e {{/items}}{{/isEnum}}{{^isEnum}}OpenAPI_{{complexType}}_t *{{/isEnum}}{{{name}}}Item = OpenAPI_{{complexType}}_parseFromJSON({{{name}}}_local_nonprimitive);
|
||||
|
||||
OpenAPI_list_add({{{name}}}List, (void *)OpenAPI_{{{complexType}}}_FromString({{{name}}}_local->valuestring));
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#isPrimitiveType}}
|
||||
double *localDouble = NULL;
|
||||
int *localInt = NULL;
|
||||
{{/isPrimitiveType}}
|
||||
{{#items}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isString}}
|
||||
if (!cJSON_IsString({{{name}}}_local)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add({{{name}}}List, ogs_strdup({{{name}}}_local->valuestring));
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
if (!cJSON_IsString({{{name}}}_local)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add({{{name}}}List, ogs_strdup({{{name}}}_local->valuestring));
|
||||
{{/isByteArray}}
|
||||
{{#isNumeric}}
|
||||
if (!cJSON_IsNumber({{{name}}}_local)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localDouble = (double *)ogs_calloc(1, sizeof(double));
|
||||
if (!localDouble) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
*localDouble = {{{name}}}_local->valuedouble;
|
||||
OpenAPI_list_add({{{name}}}List, localDouble);
|
||||
{{/isNumeric}}
|
||||
{{#isBoolean}}
|
||||
if (!cJSON_IsBool({{{name}}}_local)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localInt = (int *)ogs_calloc(1, sizeof(int));
|
||||
if (!localInt) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
*localInt = {{{name}}}_local->valueint;
|
||||
OpenAPI_list_add({{{name}}}List, localInt);
|
||||
{{/isBoolean}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
if (!cJSON_IsObject({{{name}}}_local)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_{{complexType}}_t *{{{name}}}Item = OpenAPI_{{complexType}}_parseFromJSON({{{name}}}_local);
|
||||
if (!{{{name}}}Item) {
|
||||
ogs_error("No {{{name}}}Item");
|
||||
OpenAPI_list_free({{{name}}}List);
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add({{{name}}}List, {{{name}}}Item);
|
||||
{{/isPrimitiveType}}
|
||||
{{/items}}
|
||||
{{/isEnum}}
|
||||
|
||||
OpenAPI_list_add({{{name}}}List, {{#isEnum}}{{#items}}(void *){{/items}}{{/isEnum}}{{{name}}}Item);
|
||||
}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isEnum}}
|
||||
{{/isArray}}
|
||||
{{#isMap}}
|
||||
cJSON *{{{name}}}_local_map = NULL;
|
||||
|
|
@ -839,38 +828,62 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
OpenAPI_map_t *localMapKeyPair = NULL;
|
||||
cJSON_ArrayForEach({{{name}}}_local_map, {{{name}}}) {
|
||||
cJSON *localMapObject = {{{name}}}_local_map;
|
||||
{{#items}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isString}}
|
||||
{{#isEnum}}
|
||||
if (!cJSON_IsString(localMapObject)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string),ogs_strdup(localMapObject->valuestring));
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
if (!cJSON_IsString(localMapObject)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string),ogs_strdup(localMapObject->valuestring));
|
||||
{{/isByteArray}}
|
||||
{{#isBoolean}}
|
||||
if (!cJSON_IsBool(localMapObject)) {
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), (void *)OpenAPI_{{{complexType}}}_FromString(localMapObject->string));
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#isPrimitiveType}}
|
||||
double *localDouble = NULL;
|
||||
int *localInt = NULL;
|
||||
{{/isPrimitiveType}}
|
||||
{{#items}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isString}}
|
||||
if (!cJSON_IsString(localMapObject)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), &localMapObject->valueint);
|
||||
{{/isBoolean}}
|
||||
{{#isNumeric}}
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), ogs_strdup(localMapObject->valuestring));
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
if (!cJSON_IsString(localMapObject)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), ogs_strdup(localMapObject->valuestring));
|
||||
{{/isByteArray}}
|
||||
{{#isNumeric}}
|
||||
if (!cJSON_IsNumber(localMapObject)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string),&localMapObject->valuedouble );
|
||||
{{/isNumeric}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
localDouble = (double *)ogs_calloc(1, sizeof(double));
|
||||
if (!localDouble) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
*localDouble = localMapObject->valuedouble;
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), localDouble);
|
||||
{{/isNumeric}}
|
||||
{{#isBoolean}}
|
||||
if (!cJSON_IsBool(localMapObject)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localInt = (int *)ogs_calloc(1, sizeof(int));
|
||||
if (!localInt) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
*localInt = localMapObject->valueint;
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), localInt);
|
||||
{{/isBoolean}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
if (cJSON_IsObject(localMapObject)) {
|
||||
localMapKeyPair = OpenAPI_map_create(
|
||||
ogs_strdup(localMapObject->string), OpenAPI_{{complexType}}_parseFromJSON(localMapObject));
|
||||
|
|
@ -880,8 +893,9 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isPrimitiveType}}
|
||||
{{/items}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/items}}
|
||||
{{/isEnum}}
|
||||
OpenAPI_list_add({{{name}}}List, localMapKeyPair);
|
||||
}
|
||||
}
|
||||
|
|
@ -935,10 +949,10 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
{{#isString}}
|
||||
{{^required}}{{{name}}} && !cJSON_IsNull({{{name}}}) ? {{/required}}ogs_strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
||||
{{/isString}}
|
||||
{{#isByteArray}}
|
||||
{{^required}}{{{name}}} && !cJSON_IsNull({{{name}}}) ? {{/required}}ogs_strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
||||
{{/isByteArray}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
||||
{{/isByteArray}}
|
||||
{{#isBinary}}
|
||||
{{^required}}{{{name}}} ? {{/required}}decoded_str_{{{name}}}{{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
||||
{{/isBinary}}
|
||||
|
|
@ -1012,12 +1026,14 @@ end:
|
|||
OpenAPI_list_for_each({{{name}}}List, node) {
|
||||
OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*) node->data;
|
||||
ogs_free(localKeyValue->key);
|
||||
{{#isPrimitiveType}}
|
||||
{{^isEnum}}
|
||||
{{#isPrimitiveType}}
|
||||
ogs_free(localKeyValue->value);
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
OpenAPI_{{complexType}}_free(localKeyValue->value);
|
||||
{{/isPrimitiveType}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isEnum}}
|
||||
OpenAPI_map_free(localKeyValue);
|
||||
}
|
||||
OpenAPI_list_free({{{name}}}List);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue