[openapi] Add support for nullable fields

Depending on the OpenAPI yaml files, fields can be marked as "nullable".
Which means that the field can be either present, not present, or null.

This feature is important for example in SmContextUpdateData structure,
where many fields are described similar as the following:
This IE shall be included for the modification .... For deleting the
field, it shall contain the Null value.
This commit is contained in:
Bostjan Meglic 2023-10-05 13:39:14 +02:00 committed by Sukchan Lee
parent 7ea37ef618
commit 50464d174e
154 changed files with 2773 additions and 0 deletions

View file

@ -5,10 +5,13 @@
#include "tsn_qos_container_rm.h"
OpenAPI_tsn_qos_container_rm_t *OpenAPI_tsn_qos_container_rm_create(
bool is_max_tsc_burst_size_null,
bool is_max_tsc_burst_size,
int max_tsc_burst_size,
bool is_tsc_pack_delay_null,
bool is_tsc_pack_delay,
int tsc_pack_delay,
bool is_tsc_prio_level_null,
bool is_tsc_prio_level,
int tsc_prio_level
)
@ -16,10 +19,13 @@ OpenAPI_tsn_qos_container_rm_t *OpenAPI_tsn_qos_container_rm_create(
OpenAPI_tsn_qos_container_rm_t *tsn_qos_container_rm_local_var = ogs_malloc(sizeof(OpenAPI_tsn_qos_container_rm_t));
ogs_assert(tsn_qos_container_rm_local_var);
tsn_qos_container_rm_local_var->is_max_tsc_burst_size_null = is_max_tsc_burst_size_null;
tsn_qos_container_rm_local_var->is_max_tsc_burst_size = is_max_tsc_burst_size;
tsn_qos_container_rm_local_var->max_tsc_burst_size = max_tsc_burst_size;
tsn_qos_container_rm_local_var->is_tsc_pack_delay_null = is_tsc_pack_delay_null;
tsn_qos_container_rm_local_var->is_tsc_pack_delay = is_tsc_pack_delay;
tsn_qos_container_rm_local_var->tsc_pack_delay = tsc_pack_delay;
tsn_qos_container_rm_local_var->is_tsc_prio_level_null = is_tsc_prio_level_null;
tsn_qos_container_rm_local_var->is_tsc_prio_level = is_tsc_prio_level;
tsn_qos_container_rm_local_var->tsc_prio_level = tsc_prio_level;
@ -52,6 +58,11 @@ cJSON *OpenAPI_tsn_qos_container_rm_convertToJSON(OpenAPI_tsn_qos_container_rm_t
ogs_error("OpenAPI_tsn_qos_container_rm_convertToJSON() failed [max_tsc_burst_size]");
goto end;
}
} else if (tsn_qos_container_rm->is_max_tsc_burst_size_null) {
if (cJSON_AddNullToObject(item, "maxTscBurstSize") == NULL) {
ogs_error("OpenAPI_tsn_qos_container_rm_convertToJSON() failed [max_tsc_burst_size]");
goto end;
}
}
if (tsn_qos_container_rm->is_tsc_pack_delay) {
@ -59,6 +70,11 @@ cJSON *OpenAPI_tsn_qos_container_rm_convertToJSON(OpenAPI_tsn_qos_container_rm_t
ogs_error("OpenAPI_tsn_qos_container_rm_convertToJSON() failed [tsc_pack_delay]");
goto end;
}
} else if (tsn_qos_container_rm->is_tsc_pack_delay_null) {
if (cJSON_AddNullToObject(item, "tscPackDelay") == NULL) {
ogs_error("OpenAPI_tsn_qos_container_rm_convertToJSON() failed [tsc_pack_delay]");
goto end;
}
}
if (tsn_qos_container_rm->is_tsc_prio_level) {
@ -66,6 +82,11 @@ cJSON *OpenAPI_tsn_qos_container_rm_convertToJSON(OpenAPI_tsn_qos_container_rm_t
ogs_error("OpenAPI_tsn_qos_container_rm_convertToJSON() failed [tsc_prio_level]");
goto end;
}
} else if (tsn_qos_container_rm->is_tsc_prio_level_null) {
if (cJSON_AddNullToObject(item, "tscPrioLevel") == NULL) {
ogs_error("OpenAPI_tsn_qos_container_rm_convertToJSON() failed [tsc_prio_level]");
goto end;
}
}
end:
@ -81,33 +102,42 @@ OpenAPI_tsn_qos_container_rm_t *OpenAPI_tsn_qos_container_rm_parseFromJSON(cJSON
cJSON *tsc_prio_level = NULL;
max_tsc_burst_size = cJSON_GetObjectItemCaseSensitive(tsn_qos_container_rmJSON, "maxTscBurstSize");
if (max_tsc_burst_size) {
if (!cJSON_IsNull(max_tsc_burst_size)) {
if (!cJSON_IsNumber(max_tsc_burst_size)) {
ogs_error("OpenAPI_tsn_qos_container_rm_parseFromJSON() failed [max_tsc_burst_size]");
goto end;
}
}
}
tsc_pack_delay = cJSON_GetObjectItemCaseSensitive(tsn_qos_container_rmJSON, "tscPackDelay");
if (tsc_pack_delay) {
if (!cJSON_IsNull(tsc_pack_delay)) {
if (!cJSON_IsNumber(tsc_pack_delay)) {
ogs_error("OpenAPI_tsn_qos_container_rm_parseFromJSON() failed [tsc_pack_delay]");
goto end;
}
}
}
tsc_prio_level = cJSON_GetObjectItemCaseSensitive(tsn_qos_container_rmJSON, "tscPrioLevel");
if (tsc_prio_level) {
if (!cJSON_IsNull(tsc_prio_level)) {
if (!cJSON_IsNumber(tsc_prio_level)) {
ogs_error("OpenAPI_tsn_qos_container_rm_parseFromJSON() failed [tsc_prio_level]");
goto end;
}
}
}
tsn_qos_container_rm_local_var = OpenAPI_tsn_qos_container_rm_create (
max_tsc_burst_size && cJSON_IsNull(max_tsc_burst_size) ? true : false,
max_tsc_burst_size ? true : false,
max_tsc_burst_size ? max_tsc_burst_size->valuedouble : 0,
tsc_pack_delay && cJSON_IsNull(tsc_pack_delay) ? true : false,
tsc_pack_delay ? true : false,
tsc_pack_delay ? tsc_pack_delay->valuedouble : 0,
tsc_prio_level && cJSON_IsNull(tsc_prio_level) ? true : false,
tsc_prio_level ? true : false,
tsc_prio_level ? tsc_prio_level->valuedouble : 0
);