mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-05 15:24:14 +00:00
[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:
parent
7ea37ef618
commit
50464d174e
154 changed files with 2773 additions and 0 deletions
|
|
@ -5,28 +5,40 @@
|
|||
#include "pp_data.h"
|
||||
|
||||
OpenAPI_pp_data_t *OpenAPI_pp_data_create(
|
||||
bool is_communication_characteristics_null,
|
||||
OpenAPI_communication_characteristics_t *communication_characteristics,
|
||||
char *supported_features,
|
||||
bool is_expected_ue_behaviour_parameters_null,
|
||||
OpenAPI_expected_ue_behaviour_t *expected_ue_behaviour_parameters,
|
||||
bool is_ec_restriction_null,
|
||||
OpenAPI_ec_restriction_t *ec_restriction,
|
||||
OpenAPI_acs_info_rm_t *acs_info,
|
||||
bool is_stn_sr_null,
|
||||
char *stn_sr,
|
||||
bool is_lcs_privacy_null,
|
||||
OpenAPI_lcs_privacy_t *lcs_privacy,
|
||||
OpenAPI_sor_info_t *sor_info,
|
||||
bool is__5mbs_authorization_info_null,
|
||||
OpenAPI_model_5_mbs_authorization_info_t *_5mbs_authorization_info
|
||||
)
|
||||
{
|
||||
OpenAPI_pp_data_t *pp_data_local_var = ogs_malloc(sizeof(OpenAPI_pp_data_t));
|
||||
ogs_assert(pp_data_local_var);
|
||||
|
||||
pp_data_local_var->is_communication_characteristics_null = is_communication_characteristics_null;
|
||||
pp_data_local_var->communication_characteristics = communication_characteristics;
|
||||
pp_data_local_var->supported_features = supported_features;
|
||||
pp_data_local_var->is_expected_ue_behaviour_parameters_null = is_expected_ue_behaviour_parameters_null;
|
||||
pp_data_local_var->expected_ue_behaviour_parameters = expected_ue_behaviour_parameters;
|
||||
pp_data_local_var->is_ec_restriction_null = is_ec_restriction_null;
|
||||
pp_data_local_var->ec_restriction = ec_restriction;
|
||||
pp_data_local_var->acs_info = acs_info;
|
||||
pp_data_local_var->is_stn_sr_null = is_stn_sr_null;
|
||||
pp_data_local_var->stn_sr = stn_sr;
|
||||
pp_data_local_var->is_lcs_privacy_null = is_lcs_privacy_null;
|
||||
pp_data_local_var->lcs_privacy = lcs_privacy;
|
||||
pp_data_local_var->sor_info = sor_info;
|
||||
pp_data_local_var->is__5mbs_authorization_info_null = is__5mbs_authorization_info_null;
|
||||
pp_data_local_var->_5mbs_authorization_info = _5mbs_authorization_info;
|
||||
|
||||
return pp_data_local_var;
|
||||
|
|
@ -100,6 +112,11 @@ cJSON *OpenAPI_pp_data_convertToJSON(OpenAPI_pp_data_t *pp_data)
|
|||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [communication_characteristics]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pp_data->is_communication_characteristics_null) {
|
||||
if (cJSON_AddNullToObject(item, "communicationCharacteristics") == NULL) {
|
||||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [communication_characteristics]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pp_data->supported_features) {
|
||||
|
|
@ -120,6 +137,11 @@ cJSON *OpenAPI_pp_data_convertToJSON(OpenAPI_pp_data_t *pp_data)
|
|||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [expected_ue_behaviour_parameters]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pp_data->is_expected_ue_behaviour_parameters_null) {
|
||||
if (cJSON_AddNullToObject(item, "expectedUeBehaviourParameters") == NULL) {
|
||||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [expected_ue_behaviour_parameters]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pp_data->ec_restriction) {
|
||||
|
|
@ -133,6 +155,11 @@ cJSON *OpenAPI_pp_data_convertToJSON(OpenAPI_pp_data_t *pp_data)
|
|||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [ec_restriction]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pp_data->is_ec_restriction_null) {
|
||||
if (cJSON_AddNullToObject(item, "ecRestriction") == NULL) {
|
||||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [ec_restriction]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pp_data->acs_info) {
|
||||
|
|
@ -153,6 +180,11 @@ cJSON *OpenAPI_pp_data_convertToJSON(OpenAPI_pp_data_t *pp_data)
|
|||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [stn_sr]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pp_data->is_stn_sr_null) {
|
||||
if (cJSON_AddNullToObject(item, "stnSr") == NULL) {
|
||||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [stn_sr]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pp_data->lcs_privacy) {
|
||||
|
|
@ -166,6 +198,11 @@ cJSON *OpenAPI_pp_data_convertToJSON(OpenAPI_pp_data_t *pp_data)
|
|||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [lcs_privacy]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pp_data->is_lcs_privacy_null) {
|
||||
if (cJSON_AddNullToObject(item, "lcsPrivacy") == NULL) {
|
||||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [lcs_privacy]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pp_data->sor_info) {
|
||||
|
|
@ -192,6 +229,11 @@ cJSON *OpenAPI_pp_data_convertToJSON(OpenAPI_pp_data_t *pp_data)
|
|||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [_5mbs_authorization_info]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pp_data->is__5mbs_authorization_info_null) {
|
||||
if (cJSON_AddNullToObject(item, "5mbsAuthorizationInfo") == NULL) {
|
||||
ogs_error("OpenAPI_pp_data_convertToJSON() failed [_5mbs_authorization_info]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
|
@ -220,12 +262,14 @@ OpenAPI_pp_data_t *OpenAPI_pp_data_parseFromJSON(cJSON *pp_dataJSON)
|
|||
OpenAPI_model_5_mbs_authorization_info_t *_5mbs_authorization_info_local_nonprim = NULL;
|
||||
communication_characteristics = cJSON_GetObjectItemCaseSensitive(pp_dataJSON, "communicationCharacteristics");
|
||||
if (communication_characteristics) {
|
||||
if (!cJSON_IsNull(communication_characteristics)) {
|
||||
communication_characteristics_local_nonprim = OpenAPI_communication_characteristics_parseFromJSON(communication_characteristics);
|
||||
if (!communication_characteristics_local_nonprim) {
|
||||
ogs_error("OpenAPI_communication_characteristics_parseFromJSON failed [communication_characteristics]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
supported_features = cJSON_GetObjectItemCaseSensitive(pp_dataJSON, "supportedFeatures");
|
||||
if (supported_features) {
|
||||
|
|
@ -237,21 +281,25 @@ OpenAPI_pp_data_t *OpenAPI_pp_data_parseFromJSON(cJSON *pp_dataJSON)
|
|||
|
||||
expected_ue_behaviour_parameters = cJSON_GetObjectItemCaseSensitive(pp_dataJSON, "expectedUeBehaviourParameters");
|
||||
if (expected_ue_behaviour_parameters) {
|
||||
if (!cJSON_IsNull(expected_ue_behaviour_parameters)) {
|
||||
expected_ue_behaviour_parameters_local_nonprim = OpenAPI_expected_ue_behaviour_parseFromJSON(expected_ue_behaviour_parameters);
|
||||
if (!expected_ue_behaviour_parameters_local_nonprim) {
|
||||
ogs_error("OpenAPI_expected_ue_behaviour_parseFromJSON failed [expected_ue_behaviour_parameters]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ec_restriction = cJSON_GetObjectItemCaseSensitive(pp_dataJSON, "ecRestriction");
|
||||
if (ec_restriction) {
|
||||
if (!cJSON_IsNull(ec_restriction)) {
|
||||
ec_restriction_local_nonprim = OpenAPI_ec_restriction_parseFromJSON(ec_restriction);
|
||||
if (!ec_restriction_local_nonprim) {
|
||||
ogs_error("OpenAPI_ec_restriction_parseFromJSON failed [ec_restriction]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
acs_info = cJSON_GetObjectItemCaseSensitive(pp_dataJSON, "acsInfo");
|
||||
if (acs_info) {
|
||||
|
|
@ -264,20 +312,24 @@ OpenAPI_pp_data_t *OpenAPI_pp_data_parseFromJSON(cJSON *pp_dataJSON)
|
|||
|
||||
stn_sr = cJSON_GetObjectItemCaseSensitive(pp_dataJSON, "stnSr");
|
||||
if (stn_sr) {
|
||||
if (!cJSON_IsNull(stn_sr)) {
|
||||
if (!cJSON_IsString(stn_sr) && !cJSON_IsNull(stn_sr)) {
|
||||
ogs_error("OpenAPI_pp_data_parseFromJSON() failed [stn_sr]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lcs_privacy = cJSON_GetObjectItemCaseSensitive(pp_dataJSON, "lcsPrivacy");
|
||||
if (lcs_privacy) {
|
||||
if (!cJSON_IsNull(lcs_privacy)) {
|
||||
lcs_privacy_local_nonprim = OpenAPI_lcs_privacy_parseFromJSON(lcs_privacy);
|
||||
if (!lcs_privacy_local_nonprim) {
|
||||
ogs_error("OpenAPI_lcs_privacy_parseFromJSON failed [lcs_privacy]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sor_info = cJSON_GetObjectItemCaseSensitive(pp_dataJSON, "sorInfo");
|
||||
if (sor_info) {
|
||||
|
|
@ -290,22 +342,30 @@ OpenAPI_pp_data_t *OpenAPI_pp_data_parseFromJSON(cJSON *pp_dataJSON)
|
|||
|
||||
_5mbs_authorization_info = cJSON_GetObjectItemCaseSensitive(pp_dataJSON, "5mbsAuthorizationInfo");
|
||||
if (_5mbs_authorization_info) {
|
||||
if (!cJSON_IsNull(_5mbs_authorization_info)) {
|
||||
_5mbs_authorization_info_local_nonprim = OpenAPI_model_5_mbs_authorization_info_parseFromJSON(_5mbs_authorization_info);
|
||||
if (!_5mbs_authorization_info_local_nonprim) {
|
||||
ogs_error("OpenAPI_model_5_mbs_authorization_info_parseFromJSON failed [_5mbs_authorization_info]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pp_data_local_var = OpenAPI_pp_data_create (
|
||||
communication_characteristics && cJSON_IsNull(communication_characteristics) ? true : false,
|
||||
communication_characteristics ? communication_characteristics_local_nonprim : NULL,
|
||||
supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL,
|
||||
expected_ue_behaviour_parameters && cJSON_IsNull(expected_ue_behaviour_parameters) ? true : false,
|
||||
expected_ue_behaviour_parameters ? expected_ue_behaviour_parameters_local_nonprim : NULL,
|
||||
ec_restriction && cJSON_IsNull(ec_restriction) ? true : false,
|
||||
ec_restriction ? ec_restriction_local_nonprim : NULL,
|
||||
acs_info ? acs_info_local_nonprim : NULL,
|
||||
stn_sr && cJSON_IsNull(stn_sr) ? true : false,
|
||||
stn_sr && !cJSON_IsNull(stn_sr) ? ogs_strdup(stn_sr->valuestring) : NULL,
|
||||
lcs_privacy && cJSON_IsNull(lcs_privacy) ? true : false,
|
||||
lcs_privacy ? lcs_privacy_local_nonprim : NULL,
|
||||
sor_info ? sor_info_local_nonprim : NULL,
|
||||
_5mbs_authorization_info && cJSON_IsNull(_5mbs_authorization_info) ? true : false,
|
||||
_5mbs_authorization_info ? _5mbs_authorization_info_local_nonprim : NULL
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue