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,11 +5,17 @@
|
|||
#include "pcf_binding_patch.h"
|
||||
|
||||
OpenAPI_pcf_binding_patch_t *OpenAPI_pcf_binding_patch_create(
|
||||
bool is_ipv4_addr_null,
|
||||
char *ipv4_addr,
|
||||
bool is_ip_domain_null,
|
||||
char *ip_domain,
|
||||
bool is_ipv6_prefix_null,
|
||||
char *ipv6_prefix,
|
||||
bool is_add_ipv6_prefixes_null,
|
||||
OpenAPI_list_t *add_ipv6_prefixes,
|
||||
bool is_mac_addr48_null,
|
||||
char *mac_addr48,
|
||||
bool is_add_mac_addrs_null,
|
||||
OpenAPI_list_t *add_mac_addrs,
|
||||
char *pcf_id,
|
||||
char *pcf_fqdn,
|
||||
|
|
@ -21,11 +27,17 @@ OpenAPI_pcf_binding_patch_t *OpenAPI_pcf_binding_patch_create(
|
|||
OpenAPI_pcf_binding_patch_t *pcf_binding_patch_local_var = ogs_malloc(sizeof(OpenAPI_pcf_binding_patch_t));
|
||||
ogs_assert(pcf_binding_patch_local_var);
|
||||
|
||||
pcf_binding_patch_local_var->is_ipv4_addr_null = is_ipv4_addr_null;
|
||||
pcf_binding_patch_local_var->ipv4_addr = ipv4_addr;
|
||||
pcf_binding_patch_local_var->is_ip_domain_null = is_ip_domain_null;
|
||||
pcf_binding_patch_local_var->ip_domain = ip_domain;
|
||||
pcf_binding_patch_local_var->is_ipv6_prefix_null = is_ipv6_prefix_null;
|
||||
pcf_binding_patch_local_var->ipv6_prefix = ipv6_prefix;
|
||||
pcf_binding_patch_local_var->is_add_ipv6_prefixes_null = is_add_ipv6_prefixes_null;
|
||||
pcf_binding_patch_local_var->add_ipv6_prefixes = add_ipv6_prefixes;
|
||||
pcf_binding_patch_local_var->is_mac_addr48_null = is_mac_addr48_null;
|
||||
pcf_binding_patch_local_var->mac_addr48 = mac_addr48;
|
||||
pcf_binding_patch_local_var->is_add_mac_addrs_null = is_add_mac_addrs_null;
|
||||
pcf_binding_patch_local_var->add_mac_addrs = add_mac_addrs;
|
||||
pcf_binding_patch_local_var->pcf_id = pcf_id;
|
||||
pcf_binding_patch_local_var->pcf_fqdn = pcf_fqdn;
|
||||
|
|
@ -115,6 +127,11 @@ cJSON *OpenAPI_pcf_binding_patch_convertToJSON(OpenAPI_pcf_binding_patch_t *pcf_
|
|||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [ipv4_addr]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pcf_binding_patch->is_ipv4_addr_null) {
|
||||
if (cJSON_AddNullToObject(item, "ipv4Addr") == NULL) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [ipv4_addr]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pcf_binding_patch->ip_domain) {
|
||||
|
|
@ -122,6 +139,11 @@ cJSON *OpenAPI_pcf_binding_patch_convertToJSON(OpenAPI_pcf_binding_patch_t *pcf_
|
|||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [ip_domain]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pcf_binding_patch->is_ip_domain_null) {
|
||||
if (cJSON_AddNullToObject(item, "ipDomain") == NULL) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [ip_domain]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pcf_binding_patch->ipv6_prefix) {
|
||||
|
|
@ -129,6 +151,11 @@ cJSON *OpenAPI_pcf_binding_patch_convertToJSON(OpenAPI_pcf_binding_patch_t *pcf_
|
|||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [ipv6_prefix]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pcf_binding_patch->is_ipv6_prefix_null) {
|
||||
if (cJSON_AddNullToObject(item, "ipv6Prefix") == NULL) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [ipv6_prefix]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pcf_binding_patch->add_ipv6_prefixes) {
|
||||
|
|
@ -143,6 +170,11 @@ cJSON *OpenAPI_pcf_binding_patch_convertToJSON(OpenAPI_pcf_binding_patch_t *pcf_
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
} else if (pcf_binding_patch->is_add_ipv6_prefixes_null) {
|
||||
if (cJSON_AddNullToObject(item, "addIpv6Prefixes") == NULL) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [add_ipv6_prefixes]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pcf_binding_patch->mac_addr48) {
|
||||
|
|
@ -150,6 +182,11 @@ cJSON *OpenAPI_pcf_binding_patch_convertToJSON(OpenAPI_pcf_binding_patch_t *pcf_
|
|||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [mac_addr48]");
|
||||
goto end;
|
||||
}
|
||||
} else if (pcf_binding_patch->is_mac_addr48_null) {
|
||||
if (cJSON_AddNullToObject(item, "macAddr48") == NULL) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [mac_addr48]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pcf_binding_patch->add_mac_addrs) {
|
||||
|
|
@ -164,6 +201,11 @@ cJSON *OpenAPI_pcf_binding_patch_convertToJSON(OpenAPI_pcf_binding_patch_t *pcf_
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
} else if (pcf_binding_patch->is_add_mac_addrs_null) {
|
||||
if (cJSON_AddNullToObject(item, "addMacAddrs") == NULL) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_convertToJSON() failed [add_mac_addrs]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (pcf_binding_patch->pcf_id) {
|
||||
|
|
@ -234,30 +276,37 @@ OpenAPI_pcf_binding_patch_t *OpenAPI_pcf_binding_patch_parseFromJSON(cJSON *pcf_
|
|||
cJSON *pcf_diam_realm = NULL;
|
||||
ipv4_addr = cJSON_GetObjectItemCaseSensitive(pcf_binding_patchJSON, "ipv4Addr");
|
||||
if (ipv4_addr) {
|
||||
if (!cJSON_IsNull(ipv4_addr)) {
|
||||
if (!cJSON_IsString(ipv4_addr) && !cJSON_IsNull(ipv4_addr)) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_parseFromJSON() failed [ipv4_addr]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ip_domain = cJSON_GetObjectItemCaseSensitive(pcf_binding_patchJSON, "ipDomain");
|
||||
if (ip_domain) {
|
||||
if (!cJSON_IsNull(ip_domain)) {
|
||||
if (!cJSON_IsString(ip_domain) && !cJSON_IsNull(ip_domain)) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_parseFromJSON() failed [ip_domain]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipv6_prefix = cJSON_GetObjectItemCaseSensitive(pcf_binding_patchJSON, "ipv6Prefix");
|
||||
if (ipv6_prefix) {
|
||||
if (!cJSON_IsNull(ipv6_prefix)) {
|
||||
if (!cJSON_IsString(ipv6_prefix) && !cJSON_IsNull(ipv6_prefix)) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_parseFromJSON() failed [ipv6_prefix]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_ipv6_prefixes = cJSON_GetObjectItemCaseSensitive(pcf_binding_patchJSON, "addIpv6Prefixes");
|
||||
if (add_ipv6_prefixes) {
|
||||
if (!cJSON_IsNull(add_ipv6_prefixes)) {
|
||||
cJSON *add_ipv6_prefixes_local = NULL;
|
||||
if (!cJSON_IsArray(add_ipv6_prefixes)) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_parseFromJSON() failed [add_ipv6_prefixes]");
|
||||
|
|
@ -276,17 +325,21 @@ OpenAPI_pcf_binding_patch_t *OpenAPI_pcf_binding_patch_parseFromJSON(cJSON *pcf_
|
|||
OpenAPI_list_add(add_ipv6_prefixesList, ogs_strdup(add_ipv6_prefixes_local->valuestring));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mac_addr48 = cJSON_GetObjectItemCaseSensitive(pcf_binding_patchJSON, "macAddr48");
|
||||
if (mac_addr48) {
|
||||
if (!cJSON_IsNull(mac_addr48)) {
|
||||
if (!cJSON_IsString(mac_addr48) && !cJSON_IsNull(mac_addr48)) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_parseFromJSON() failed [mac_addr48]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_mac_addrs = cJSON_GetObjectItemCaseSensitive(pcf_binding_patchJSON, "addMacAddrs");
|
||||
if (add_mac_addrs) {
|
||||
if (!cJSON_IsNull(add_mac_addrs)) {
|
||||
cJSON *add_mac_addrs_local = NULL;
|
||||
if (!cJSON_IsArray(add_mac_addrs)) {
|
||||
ogs_error("OpenAPI_pcf_binding_patch_parseFromJSON() failed [add_mac_addrs]");
|
||||
|
|
@ -305,6 +358,7 @@ OpenAPI_pcf_binding_patch_t *OpenAPI_pcf_binding_patch_parseFromJSON(cJSON *pcf_
|
|||
OpenAPI_list_add(add_mac_addrsList, ogs_strdup(add_mac_addrs_local->valuestring));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pcf_id = cJSON_GetObjectItemCaseSensitive(pcf_binding_patchJSON, "pcfId");
|
||||
if (pcf_id) {
|
||||
|
|
@ -363,11 +417,17 @@ OpenAPI_pcf_binding_patch_t *OpenAPI_pcf_binding_patch_parseFromJSON(cJSON *pcf_
|
|||
}
|
||||
|
||||
pcf_binding_patch_local_var = OpenAPI_pcf_binding_patch_create (
|
||||
ipv4_addr && cJSON_IsNull(ipv4_addr) ? true : false,
|
||||
ipv4_addr && !cJSON_IsNull(ipv4_addr) ? ogs_strdup(ipv4_addr->valuestring) : NULL,
|
||||
ip_domain && cJSON_IsNull(ip_domain) ? true : false,
|
||||
ip_domain && !cJSON_IsNull(ip_domain) ? ogs_strdup(ip_domain->valuestring) : NULL,
|
||||
ipv6_prefix && cJSON_IsNull(ipv6_prefix) ? true : false,
|
||||
ipv6_prefix && !cJSON_IsNull(ipv6_prefix) ? ogs_strdup(ipv6_prefix->valuestring) : NULL,
|
||||
add_ipv6_prefixes && cJSON_IsNull(add_ipv6_prefixes) ? true : false,
|
||||
add_ipv6_prefixes ? add_ipv6_prefixesList : NULL,
|
||||
mac_addr48 && cJSON_IsNull(mac_addr48) ? true : false,
|
||||
mac_addr48 && !cJSON_IsNull(mac_addr48) ? ogs_strdup(mac_addr48->valuestring) : NULL,
|
||||
add_mac_addrs && cJSON_IsNull(add_mac_addrs) ? true : false,
|
||||
add_mac_addrs ? add_mac_addrsList : NULL,
|
||||
pcf_id && !cJSON_IsNull(pcf_id) ? ogs_strdup(pcf_id->valuestring) : NULL,
|
||||
pcf_fqdn && !cJSON_IsNull(pcf_fqdn) ? ogs_strdup(pcf_fqdn->valuestring) : NULL,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue