[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

@ -46,6 +46,7 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_create(
OpenAPI_list_t *mm_context_list,
OpenAPI_list_t *session_context_list,
OpenAPI_eps_interworking_info_t *eps_interworking_info,
bool is_trace_data_null,
OpenAPI_trace_data_t *trace_data,
char *service_gap_expiry_time,
char *stn_sr,
@ -79,6 +80,7 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_create(
OpenAPI_list_t* pra_in_ue_policy,
OpenAPI_updp_subscription_data_t *updp_subscription_data,
OpenAPI_list_t *sm_policy_notify_pdu_list,
bool is_pcf_ue_callback_info_null,
OpenAPI_pcf_ue_callback_info_t *pcf_ue_callback_info,
char *ue_positioning_cap,
bool is_asti_distribution_indication,
@ -87,6 +89,7 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_create(
int ts_error_budget,
bool is_snpn_onboard_ind,
int snpn_onboard_ind,
bool is_smf_sel_info_null,
OpenAPI_smf_selection_data_t *smf_sel_info,
OpenAPI_list_t* pcf_ue_slice_mbr_list,
char *smsf_set_id,
@ -141,6 +144,7 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_create(
ue_context_local_var->mm_context_list = mm_context_list;
ue_context_local_var->session_context_list = session_context_list;
ue_context_local_var->eps_interworking_info = eps_interworking_info;
ue_context_local_var->is_trace_data_null = is_trace_data_null;
ue_context_local_var->trace_data = trace_data;
ue_context_local_var->service_gap_expiry_time = service_gap_expiry_time;
ue_context_local_var->stn_sr = stn_sr;
@ -174,6 +178,7 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_create(
ue_context_local_var->pra_in_ue_policy = pra_in_ue_policy;
ue_context_local_var->updp_subscription_data = updp_subscription_data;
ue_context_local_var->sm_policy_notify_pdu_list = sm_policy_notify_pdu_list;
ue_context_local_var->is_pcf_ue_callback_info_null = is_pcf_ue_callback_info_null;
ue_context_local_var->pcf_ue_callback_info = pcf_ue_callback_info;
ue_context_local_var->ue_positioning_cap = ue_positioning_cap;
ue_context_local_var->is_asti_distribution_indication = is_asti_distribution_indication;
@ -182,6 +187,7 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_create(
ue_context_local_var->ts_error_budget = ts_error_budget;
ue_context_local_var->is_snpn_onboard_ind = is_snpn_onboard_ind;
ue_context_local_var->snpn_onboard_ind = snpn_onboard_ind;
ue_context_local_var->is_smf_sel_info_null = is_smf_sel_info_null;
ue_context_local_var->smf_sel_info = smf_sel_info;
ue_context_local_var->pcf_ue_slice_mbr_list = pcf_ue_slice_mbr_list;
ue_context_local_var->smsf_set_id = smsf_set_id;
@ -916,6 +922,11 @@ cJSON *OpenAPI_ue_context_convertToJSON(OpenAPI_ue_context_t *ue_context)
ogs_error("OpenAPI_ue_context_convertToJSON() failed [trace_data]");
goto end;
}
} else if (ue_context->is_trace_data_null) {
if (cJSON_AddNullToObject(item, "traceData") == NULL) {
ogs_error("OpenAPI_ue_context_convertToJSON() failed [trace_data]");
goto end;
}
}
if (ue_context->service_gap_expiry_time) {
@ -1260,6 +1271,11 @@ cJSON *OpenAPI_ue_context_convertToJSON(OpenAPI_ue_context_t *ue_context)
ogs_error("OpenAPI_ue_context_convertToJSON() failed [pcf_ue_callback_info]");
goto end;
}
} else if (ue_context->is_pcf_ue_callback_info_null) {
if (cJSON_AddNullToObject(item, "pcfUeCallbackInfo") == NULL) {
ogs_error("OpenAPI_ue_context_convertToJSON() failed [pcf_ue_callback_info]");
goto end;
}
}
if (ue_context->ue_positioning_cap) {
@ -1301,6 +1317,11 @@ cJSON *OpenAPI_ue_context_convertToJSON(OpenAPI_ue_context_t *ue_context)
ogs_error("OpenAPI_ue_context_convertToJSON() failed [smf_sel_info]");
goto end;
}
} else if (ue_context->is_smf_sel_info_null) {
if (cJSON_AddNullToObject(item, "smfSelInfo") == NULL) {
ogs_error("OpenAPI_ue_context_convertToJSON() failed [smf_sel_info]");
goto end;
}
}
if (ue_context->pcf_ue_slice_mbr_list) {
@ -1975,12 +1996,14 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_parseFromJSON(cJSON *ue_contextJSON)
trace_data = cJSON_GetObjectItemCaseSensitive(ue_contextJSON, "traceData");
if (trace_data) {
if (!cJSON_IsNull(trace_data)) {
trace_data_local_nonprim = OpenAPI_trace_data_parseFromJSON(trace_data);
if (!trace_data_local_nonprim) {
ogs_error("OpenAPI_trace_data_parseFromJSON failed [trace_data]");
goto end;
}
}
}
service_gap_expiry_time = cJSON_GetObjectItemCaseSensitive(ue_contextJSON, "serviceGapExpiryTime");
if (service_gap_expiry_time) {
@ -2339,12 +2362,14 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_parseFromJSON(cJSON *ue_contextJSON)
pcf_ue_callback_info = cJSON_GetObjectItemCaseSensitive(ue_contextJSON, "pcfUeCallbackInfo");
if (pcf_ue_callback_info) {
if (!cJSON_IsNull(pcf_ue_callback_info)) {
pcf_ue_callback_info_local_nonprim = OpenAPI_pcf_ue_callback_info_parseFromJSON(pcf_ue_callback_info);
if (!pcf_ue_callback_info_local_nonprim) {
ogs_error("OpenAPI_pcf_ue_callback_info_parseFromJSON failed [pcf_ue_callback_info]");
goto end;
}
}
}
ue_positioning_cap = cJSON_GetObjectItemCaseSensitive(ue_contextJSON, "uePositioningCap");
if (ue_positioning_cap) {
@ -2380,12 +2405,14 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_parseFromJSON(cJSON *ue_contextJSON)
smf_sel_info = cJSON_GetObjectItemCaseSensitive(ue_contextJSON, "smfSelInfo");
if (smf_sel_info) {
if (!cJSON_IsNull(smf_sel_info)) {
smf_sel_info_local_nonprim = OpenAPI_smf_selection_data_parseFromJSON(smf_sel_info);
if (!smf_sel_info_local_nonprim) {
ogs_error("OpenAPI_smf_selection_data_parseFromJSON failed [smf_sel_info]");
goto end;
}
}
}
pcf_ue_slice_mbr_list = cJSON_GetObjectItemCaseSensitive(ue_contextJSON, "pcfUeSliceMbrList");
if (pcf_ue_slice_mbr_list) {
@ -2496,6 +2523,7 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_parseFromJSON(cJSON *ue_contextJSON)
mm_context_list ? mm_context_listList : NULL,
session_context_list ? session_context_listList : NULL,
eps_interworking_info ? eps_interworking_info_local_nonprim : NULL,
trace_data && cJSON_IsNull(trace_data) ? true : false,
trace_data ? trace_data_local_nonprim : NULL,
service_gap_expiry_time && !cJSON_IsNull(service_gap_expiry_time) ? ogs_strdup(service_gap_expiry_time->valuestring) : NULL,
stn_sr && !cJSON_IsNull(stn_sr) ? ogs_strdup(stn_sr->valuestring) : NULL,
@ -2529,6 +2557,7 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_parseFromJSON(cJSON *ue_contextJSON)
pra_in_ue_policy ? pra_in_ue_policyList : NULL,
updp_subscription_data ? updp_subscription_data_local_nonprim : NULL,
sm_policy_notify_pdu_list ? sm_policy_notify_pdu_listList : NULL,
pcf_ue_callback_info && cJSON_IsNull(pcf_ue_callback_info) ? true : false,
pcf_ue_callback_info ? pcf_ue_callback_info_local_nonprim : NULL,
ue_positioning_cap && !cJSON_IsNull(ue_positioning_cap) ? ogs_strdup(ue_positioning_cap->valuestring) : NULL,
asti_distribution_indication ? true : false,
@ -2537,6 +2566,7 @@ OpenAPI_ue_context_t *OpenAPI_ue_context_parseFromJSON(cJSON *ue_contextJSON)
ts_error_budget ? ts_error_budget->valuedouble : 0,
snpn_onboard_ind ? true : false,
snpn_onboard_ind ? snpn_onboard_ind->valueint : 0,
smf_sel_info && cJSON_IsNull(smf_sel_info) ? true : false,
smf_sel_info ? smf_sel_info_local_nonprim : NULL,
pcf_ue_slice_mbr_list ? pcf_ue_slice_mbr_listList : NULL,
smsf_set_id && !cJSON_IsNull(smsf_set_id) ? ogs_strdup(smsf_set_id->valuestring) : NULL,