[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

@ -19,6 +19,7 @@ OpenAPI_sms_management_subscription_data_t *OpenAPI_sms_management_subscription_
bool is_mo_sms_barring_roaming,
int mo_sms_barring_roaming,
OpenAPI_list_t *shared_sms_mng_data_ids,
bool is_trace_data_null,
OpenAPI_trace_data_t *trace_data
)
{
@ -39,6 +40,7 @@ OpenAPI_sms_management_subscription_data_t *OpenAPI_sms_management_subscription_
sms_management_subscription_data_local_var->is_mo_sms_barring_roaming = is_mo_sms_barring_roaming;
sms_management_subscription_data_local_var->mo_sms_barring_roaming = mo_sms_barring_roaming;
sms_management_subscription_data_local_var->shared_sms_mng_data_ids = shared_sms_mng_data_ids;
sms_management_subscription_data_local_var->is_trace_data_null = is_trace_data_null;
sms_management_subscription_data_local_var->trace_data = trace_data;
return sms_management_subscription_data_local_var;
@ -154,6 +156,11 @@ cJSON *OpenAPI_sms_management_subscription_data_convertToJSON(OpenAPI_sms_manage
ogs_error("OpenAPI_sms_management_subscription_data_convertToJSON() failed [trace_data]");
goto end;
}
} else if (sms_management_subscription_data->is_trace_data_null) {
if (cJSON_AddNullToObject(item, "traceData") == NULL) {
ogs_error("OpenAPI_sms_management_subscription_data_convertToJSON() failed [trace_data]");
goto end;
}
}
end:
@ -254,12 +261,14 @@ OpenAPI_sms_management_subscription_data_t *OpenAPI_sms_management_subscription_
trace_data = cJSON_GetObjectItemCaseSensitive(sms_management_subscription_dataJSON, "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;
}
}
}
sms_management_subscription_data_local_var = OpenAPI_sms_management_subscription_data_create (
supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL,
@ -276,6 +285,7 @@ OpenAPI_sms_management_subscription_data_t *OpenAPI_sms_management_subscription_
mo_sms_barring_roaming ? true : false,
mo_sms_barring_roaming ? mo_sms_barring_roaming->valueint : 0,
shared_sms_mng_data_ids ? shared_sms_mng_data_idsList : NULL,
trace_data && cJSON_IsNull(trace_data) ? true : false,
trace_data ? trace_data_local_nonprim : NULL
);