[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

@ -11,11 +11,16 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_create(
OpenAPI_list_t *add_redirect_info,
bool is_mute_notif,
int mute_notif,
bool is_traffic_steering_pol_id_dl_null,
char *traffic_steering_pol_id_dl,
bool is_traffic_steering_pol_id_ul_null,
char *traffic_steering_pol_id_ul,
bool is_route_to_locs_null,
OpenAPI_list_t *route_to_locs,
bool is_max_allowed_up_lat_null,
bool is_max_allowed_up_lat,
int max_allowed_up_lat,
bool is_eas_ip_replace_infos_null,
OpenAPI_list_t *eas_ip_replace_infos,
bool is_traff_corre_ind,
int traff_corre_ind,
@ -23,6 +28,7 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_create(
int sim_conn_ind,
bool is_sim_conn_term,
int sim_conn_term,
bool is_up_path_chg_event_null,
OpenAPI_up_path_chg_event_t *up_path_chg_event,
OpenAPI_steering_functionality_e steer_fun,
OpenAPI_steering_mode_t *steer_mode_dl,
@ -39,11 +45,16 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_create(
traffic_control_data_local_var->add_redirect_info = add_redirect_info;
traffic_control_data_local_var->is_mute_notif = is_mute_notif;
traffic_control_data_local_var->mute_notif = mute_notif;
traffic_control_data_local_var->is_traffic_steering_pol_id_dl_null = is_traffic_steering_pol_id_dl_null;
traffic_control_data_local_var->traffic_steering_pol_id_dl = traffic_steering_pol_id_dl;
traffic_control_data_local_var->is_traffic_steering_pol_id_ul_null = is_traffic_steering_pol_id_ul_null;
traffic_control_data_local_var->traffic_steering_pol_id_ul = traffic_steering_pol_id_ul;
traffic_control_data_local_var->is_route_to_locs_null = is_route_to_locs_null;
traffic_control_data_local_var->route_to_locs = route_to_locs;
traffic_control_data_local_var->is_max_allowed_up_lat_null = is_max_allowed_up_lat_null;
traffic_control_data_local_var->is_max_allowed_up_lat = is_max_allowed_up_lat;
traffic_control_data_local_var->max_allowed_up_lat = max_allowed_up_lat;
traffic_control_data_local_var->is_eas_ip_replace_infos_null = is_eas_ip_replace_infos_null;
traffic_control_data_local_var->eas_ip_replace_infos = eas_ip_replace_infos;
traffic_control_data_local_var->is_traff_corre_ind = is_traff_corre_ind;
traffic_control_data_local_var->traff_corre_ind = traff_corre_ind;
@ -51,6 +62,7 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_create(
traffic_control_data_local_var->sim_conn_ind = sim_conn_ind;
traffic_control_data_local_var->is_sim_conn_term = is_sim_conn_term;
traffic_control_data_local_var->sim_conn_term = sim_conn_term;
traffic_control_data_local_var->is_up_path_chg_event_null = is_up_path_chg_event_null;
traffic_control_data_local_var->up_path_chg_event = up_path_chg_event;
traffic_control_data_local_var->steer_fun = steer_fun;
traffic_control_data_local_var->steer_mode_dl = steer_mode_dl;
@ -187,6 +199,11 @@ cJSON *OpenAPI_traffic_control_data_convertToJSON(OpenAPI_traffic_control_data_t
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [traffic_steering_pol_id_dl]");
goto end;
}
} else if (traffic_control_data->is_traffic_steering_pol_id_dl_null) {
if (cJSON_AddNullToObject(item, "trafficSteeringPolIdDl") == NULL) {
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [traffic_steering_pol_id_dl]");
goto end;
}
}
if (traffic_control_data->traffic_steering_pol_id_ul) {
@ -194,6 +211,11 @@ cJSON *OpenAPI_traffic_control_data_convertToJSON(OpenAPI_traffic_control_data_t
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [traffic_steering_pol_id_ul]");
goto end;
}
} else if (traffic_control_data->is_traffic_steering_pol_id_ul_null) {
if (cJSON_AddNullToObject(item, "trafficSteeringPolIdUl") == NULL) {
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [traffic_steering_pol_id_ul]");
goto end;
}
}
if (traffic_control_data->route_to_locs) {
@ -210,6 +232,11 @@ cJSON *OpenAPI_traffic_control_data_convertToJSON(OpenAPI_traffic_control_data_t
}
cJSON_AddItemToArray(route_to_locsList, itemLocal);
}
} else if (traffic_control_data->is_route_to_locs_null) {
if (cJSON_AddNullToObject(item, "routeToLocs") == NULL) {
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [route_to_locs]");
goto end;
}
}
if (traffic_control_data->is_max_allowed_up_lat) {
@ -217,6 +244,11 @@ cJSON *OpenAPI_traffic_control_data_convertToJSON(OpenAPI_traffic_control_data_t
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [max_allowed_up_lat]");
goto end;
}
} else if (traffic_control_data->is_max_allowed_up_lat_null) {
if (cJSON_AddNullToObject(item, "maxAllowedUpLat") == NULL) {
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [max_allowed_up_lat]");
goto end;
}
}
if (traffic_control_data->eas_ip_replace_infos) {
@ -233,6 +265,11 @@ cJSON *OpenAPI_traffic_control_data_convertToJSON(OpenAPI_traffic_control_data_t
}
cJSON_AddItemToArray(eas_ip_replace_infosList, itemLocal);
}
} else if (traffic_control_data->is_eas_ip_replace_infos_null) {
if (cJSON_AddNullToObject(item, "easIpReplaceInfos") == NULL) {
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [eas_ip_replace_infos]");
goto end;
}
}
if (traffic_control_data->is_traff_corre_ind) {
@ -267,6 +304,11 @@ cJSON *OpenAPI_traffic_control_data_convertToJSON(OpenAPI_traffic_control_data_t
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [up_path_chg_event]");
goto end;
}
} else if (traffic_control_data->is_up_path_chg_event_null) {
if (cJSON_AddNullToObject(item, "upPathChgEvent") == NULL) {
ogs_error("OpenAPI_traffic_control_data_convertToJSON() failed [up_path_chg_event]");
goto end;
}
}
if (traffic_control_data->steer_fun != OpenAPI_steering_functionality_NULL) {
@ -407,22 +449,27 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_parseFromJSON(cJSON
traffic_steering_pol_id_dl = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "trafficSteeringPolIdDl");
if (traffic_steering_pol_id_dl) {
if (!cJSON_IsNull(traffic_steering_pol_id_dl)) {
if (!cJSON_IsString(traffic_steering_pol_id_dl) && !cJSON_IsNull(traffic_steering_pol_id_dl)) {
ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [traffic_steering_pol_id_dl]");
goto end;
}
}
}
traffic_steering_pol_id_ul = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "trafficSteeringPolIdUl");
if (traffic_steering_pol_id_ul) {
if (!cJSON_IsNull(traffic_steering_pol_id_ul)) {
if (!cJSON_IsString(traffic_steering_pol_id_ul) && !cJSON_IsNull(traffic_steering_pol_id_ul)) {
ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [traffic_steering_pol_id_ul]");
goto end;
}
}
}
route_to_locs = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "routeToLocs");
if (route_to_locs) {
if (!cJSON_IsNull(route_to_locs)) {
cJSON *route_to_locs_local = NULL;
if (!cJSON_IsArray(route_to_locs)) {
ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [route_to_locs]");
@ -444,17 +491,21 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_parseFromJSON(cJSON
OpenAPI_list_add(route_to_locsList, route_to_locsItem);
}
}
}
max_allowed_up_lat = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "maxAllowedUpLat");
if (max_allowed_up_lat) {
if (!cJSON_IsNull(max_allowed_up_lat)) {
if (!cJSON_IsNumber(max_allowed_up_lat)) {
ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [max_allowed_up_lat]");
goto end;
}
}
}
eas_ip_replace_infos = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "easIpReplaceInfos");
if (eas_ip_replace_infos) {
if (!cJSON_IsNull(eas_ip_replace_infos)) {
cJSON *eas_ip_replace_infos_local = NULL;
if (!cJSON_IsArray(eas_ip_replace_infos)) {
ogs_error("OpenAPI_traffic_control_data_parseFromJSON() failed [eas_ip_replace_infos]");
@ -476,6 +527,7 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_parseFromJSON(cJSON
OpenAPI_list_add(eas_ip_replace_infosList, eas_ip_replace_infosItem);
}
}
}
traff_corre_ind = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "traffCorreInd");
if (traff_corre_ind) {
@ -503,12 +555,14 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_parseFromJSON(cJSON
up_path_chg_event = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "upPathChgEvent");
if (up_path_chg_event) {
if (!cJSON_IsNull(up_path_chg_event)) {
up_path_chg_event_local_nonprim = OpenAPI_up_path_chg_event_parseFromJSON(up_path_chg_event);
if (!up_path_chg_event_local_nonprim) {
ogs_error("OpenAPI_up_path_chg_event_parseFromJSON failed [up_path_chg_event]");
goto end;
}
}
}
steer_fun = cJSON_GetObjectItemCaseSensitive(traffic_control_dataJSON, "steerFun");
if (steer_fun) {
@ -553,11 +607,16 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_parseFromJSON(cJSON
add_redirect_info ? add_redirect_infoList : NULL,
mute_notif ? true : false,
mute_notif ? mute_notif->valueint : 0,
traffic_steering_pol_id_dl && cJSON_IsNull(traffic_steering_pol_id_dl) ? true : false,
traffic_steering_pol_id_dl && !cJSON_IsNull(traffic_steering_pol_id_dl) ? ogs_strdup(traffic_steering_pol_id_dl->valuestring) : NULL,
traffic_steering_pol_id_ul && cJSON_IsNull(traffic_steering_pol_id_ul) ? true : false,
traffic_steering_pol_id_ul && !cJSON_IsNull(traffic_steering_pol_id_ul) ? ogs_strdup(traffic_steering_pol_id_ul->valuestring) : NULL,
route_to_locs && cJSON_IsNull(route_to_locs) ? true : false,
route_to_locs ? route_to_locsList : NULL,
max_allowed_up_lat && cJSON_IsNull(max_allowed_up_lat) ? true : false,
max_allowed_up_lat ? true : false,
max_allowed_up_lat ? max_allowed_up_lat->valuedouble : 0,
eas_ip_replace_infos && cJSON_IsNull(eas_ip_replace_infos) ? true : false,
eas_ip_replace_infos ? eas_ip_replace_infosList : NULL,
traff_corre_ind ? true : false,
traff_corre_ind ? traff_corre_ind->valueint : 0,
@ -565,6 +624,7 @@ OpenAPI_traffic_control_data_t *OpenAPI_traffic_control_data_parseFromJSON(cJSON
sim_conn_ind ? sim_conn_ind->valueint : 0,
sim_conn_term ? true : false,
sim_conn_term ? sim_conn_term->valuedouble : 0,
up_path_chg_event && cJSON_IsNull(up_path_chg_event) ? true : false,
up_path_chg_event ? up_path_chg_event_local_nonprim : NULL,
steer_fun ? steer_funVariable : 0,
steer_mode_dl ? steer_mode_dl_local_nonprim : NULL,