forked from acouzens/open5gs
OpenAPI: Generate patch_item.[ch] from OpenAPI specifications
This commit is contained in:
parent
36734cac7c
commit
b85ad61e2b
|
@ -22,7 +22,6 @@ libsbi_sources = files('''
|
|||
|
||||
custom/links.c
|
||||
custom/ue_authentication_ctx.c
|
||||
custom/patch_item.c
|
||||
|
||||
yuarel.c
|
||||
types.c
|
||||
|
|
|
@ -77,10 +77,10 @@
|
|||
#include "model/deregistration_data.h"
|
||||
#include "model/sdm_subscription.h"
|
||||
#include "model/modification_notification.h"
|
||||
#include "model/patch_item.h"
|
||||
|
||||
#include "custom/links.h"
|
||||
#include "custom/ue_authentication_ctx.h"
|
||||
#include "custom/patch_item.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
|
@ -498,6 +498,7 @@ libsbi_openapi_sources = files('''
|
|||
model/partial_record_method_any_of.c
|
||||
model/partial_record_method.c
|
||||
model/partial_success_report.c
|
||||
model/patch_item.c
|
||||
model/patch_operation.c
|
||||
model/patch_result.c
|
||||
model/pc5_flow_bit_rates.c
|
||||
|
|
|
@ -2,63 +2,88 @@
|
|||
|
||||
bool OpenAPI_IsInvalid(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Invalid;
|
||||
return item && cJSON_IsInvalid(item->json);
|
||||
}
|
||||
bool OpenAPI_IsFalse(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_False;
|
||||
return item && cJSON_IsFalse(item->json);
|
||||
}
|
||||
bool OpenAPI_IsTrue(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xff) == OpenAPI_True;
|
||||
return item && cJSON_IsTrue(item->json);
|
||||
}
|
||||
bool OpenAPI_IsBool(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & (OpenAPI_True | OpenAPI_False)) != 0;
|
||||
return item && cJSON_IsBool(item->json);
|
||||
}
|
||||
bool OpenAPI_IsNull(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_NULL;
|
||||
return item && cJSON_IsNull(item->json);
|
||||
}
|
||||
bool OpenAPI_IsNumber(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Number;
|
||||
return item && cJSON_IsNumber(item->json);
|
||||
}
|
||||
bool OpenAPI_IsString(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_String;
|
||||
return item && cJSON_IsString(item->json);
|
||||
}
|
||||
bool OpenAPI_IsArray(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Array;
|
||||
return item && cJSON_IsArray(item->json);
|
||||
}
|
||||
bool OpenAPI_IsObject(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Object;
|
||||
return item && cJSON_IsObject(item->json);
|
||||
}
|
||||
bool OpenAPI_IsRaw(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
return item && cJSON_IsRaw(item->json);
|
||||
}
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Raw;
|
||||
static OpenAPI_any_type_t *any_create(cJSON *json) {
|
||||
OpenAPI_any_type_t *any_type = NULL;
|
||||
|
||||
if (!json) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
any_type = ogs_calloc(1, sizeof(*any_type));
|
||||
if (!any_type) {
|
||||
cJSON_Delete(json);
|
||||
}
|
||||
any_type->json = json;
|
||||
|
||||
return any_type;
|
||||
}
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create(cJSON *json) {
|
||||
OpenAPI_any_type_t *any_type_local_var =
|
||||
any_create(cJSON_Duplicate(json, true));
|
||||
ogs_assert(any_type_local_var);
|
||||
|
||||
return any_type_local_var;
|
||||
}
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_parseFromJSON(cJSON *json) {
|
||||
return OpenAPI_any_type_create(json);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_any_type_convertToJSON(OpenAPI_any_type_t *any_type) {
|
||||
cJSON *item = NULL;
|
||||
|
||||
if (any_type == NULL) {
|
||||
ogs_error("OpenAPI_any_type_convertToJSON() failed [AnyType]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = cJSON_Duplicate(any_type->json, true);
|
||||
if (item == NULL) {
|
||||
ogs_error("OpenAPI_any_type_convertToJSON() failed [AnyType]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_true(void)
|
||||
|
@ -73,48 +98,24 @@ OpenAPI_any_type_t *OpenAPI_any_type_create_false(void)
|
|||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_bool(bool boolean)
|
||||
{
|
||||
OpenAPI_any_type_t *any_type = NULL;
|
||||
|
||||
any_type = ogs_calloc(1, sizeof(*any_type));
|
||||
if (any_type) {
|
||||
any_type->type = boolean ? OpenAPI_True : OpenAPI_False;
|
||||
}
|
||||
|
||||
return any_type;
|
||||
return any_create(boolean ? cJSON_CreateTrue() : cJSON_CreateFalse());
|
||||
}
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_number(double num)
|
||||
{
|
||||
OpenAPI_any_type_t *any_type = NULL;
|
||||
|
||||
any_type = ogs_calloc(1, sizeof(*any_type));
|
||||
if (any_type) {
|
||||
any_type->type = OpenAPI_Number;
|
||||
any_type->valuedouble = num;
|
||||
}
|
||||
|
||||
return any_type;
|
||||
return any_create(cJSON_CreateNumber(num));
|
||||
}
|
||||
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_string(const char *string)
|
||||
{
|
||||
OpenAPI_any_type_t *any_type = NULL;
|
||||
|
||||
any_type = ogs_calloc(1, sizeof(*any_type));
|
||||
if (any_type) {
|
||||
any_type->type = OpenAPI_String;
|
||||
any_type->valuestring = ogs_strdup(string);
|
||||
}
|
||||
|
||||
return any_type;
|
||||
return any_create(cJSON_CreateString(string));
|
||||
}
|
||||
|
||||
void OpenAPI_any_type_free(OpenAPI_any_type_t *any_type)
|
||||
{
|
||||
if (any_type) {
|
||||
if (any_type->type == OpenAPI_String) {
|
||||
ogs_free(any_type->valuestring);
|
||||
}
|
||||
cJSON_Delete(any_type->json);
|
||||
ogs_free(any_type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef OGS_SBI_ANY_TYPE_H
|
||||
#define OGS_SBI_ANY_TYPE_H
|
||||
|
||||
#include "../external/cJSON.h"
|
||||
#include "ogs-core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -22,10 +23,7 @@ extern "C" {
|
|||
|
||||
typedef struct OpenAPI_any_type_s OpenAPI_any_type_t;
|
||||
typedef struct OpenAPI_any_type_s {
|
||||
int type;
|
||||
|
||||
char *valuestring;
|
||||
double valuedouble;
|
||||
cJSON *json;
|
||||
} OpenAPI_any_type_t;
|
||||
|
||||
bool OpenAPI_IsInvalid(const OpenAPI_any_type_t * const item);
|
||||
|
@ -39,6 +37,10 @@ bool OpenAPI_IsArray(const OpenAPI_any_type_t * const item);
|
|||
bool OpenAPI_IsObject(const OpenAPI_any_type_t * const item);
|
||||
bool OpenAPI_IsRaw(const OpenAPI_any_type_t * const item);
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create(cJSON *json);
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_parseFromJSON(cJSON *json);
|
||||
cJSON *OpenAPI_any_type_convertToJSON(OpenAPI_any_type_t *any_type);
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_true(void);
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_false(void);
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_bool(bool boolean);
|
||||
|
|
|
@ -2193,6 +2193,10 @@ OpenAPI_nf_profile_t *OpenAPI_nf_profile_parseFromJSON(cJSON *nf_profileJSON)
|
|||
|
||||
OpenAPI_object_t *custom_info_local_object = NULL;
|
||||
if (custom_info) {
|
||||
if (!cJSON_IsObject(custom_info)) {
|
||||
ogs_error("OpenAPI_nf_profile_parseFromJSON() failed [custom_info]");
|
||||
goto end;
|
||||
}
|
||||
custom_info_local_object = OpenAPI_object_parseFromJSON(custom_info);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ void OpenAPI_patch_item_free(OpenAPI_patch_item_t *patch_item)
|
|||
if (NULL == patch_item) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(patch_item->path);
|
||||
ogs_free(patch_item->from);
|
||||
OpenAPI_any_type_free(patch_item->value);
|
||||
|
@ -61,26 +62,16 @@ cJSON *OpenAPI_patch_item_convertToJSON(OpenAPI_patch_item_t *patch_item)
|
|||
}
|
||||
|
||||
if (patch_item->value) {
|
||||
if (OpenAPI_IsString(patch_item->value)) {
|
||||
ogs_assert(patch_item->value->valuestring);
|
||||
if (cJSON_AddStringToObject(
|
||||
item, "value", patch_item->value->valuestring) == NULL) {
|
||||
ogs_error("OpenAPI_patch_item_convertToJSON() failed [value]");
|
||||
goto end;
|
||||
}
|
||||
} else if (OpenAPI_IsNumber(patch_item->value)) {
|
||||
if (cJSON_AddNumberToObject(
|
||||
item, "value", patch_item->value->valuedouble) == NULL) {
|
||||
ogs_error("OpenAPI_patch_item_convertToJSON() failed [value]");
|
||||
goto end;
|
||||
}
|
||||
} else if (OpenAPI_IsBool(patch_item->value)) {
|
||||
if (cJSON_AddBoolToObject(
|
||||
item, "value", OpenAPI_IsTrue(patch_item->value)) == NULL) {
|
||||
ogs_error("OpenAPI_patch_item_convertToJSON() failed [value]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
cJSON *value_object = OpenAPI_any_type_convertToJSON(patch_item->value);
|
||||
if (value_object == NULL) {
|
||||
ogs_error("OpenAPI_patch_item_convertToJSON() failed [value]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToObject(item, "value", value_object);
|
||||
if (item->child == NULL) {
|
||||
ogs_error("OpenAPI_patch_item_convertToJSON() failed [value]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -96,8 +87,7 @@ OpenAPI_patch_item_t *OpenAPI_patch_item_parseFromJSON(cJSON *patch_itemJSON)
|
|||
goto end;
|
||||
}
|
||||
|
||||
OpenAPI_patch_operation_e opVariable;
|
||||
|
||||
OpenAPI_patch_operation_e opVariable = 0;
|
||||
if (!cJSON_IsString(op)) {
|
||||
ogs_error("OpenAPI_patch_item_parseFromJSON() failed [op]");
|
||||
goto end;
|
||||
|
@ -110,7 +100,6 @@ OpenAPI_patch_item_t *OpenAPI_patch_item_parseFromJSON(cJSON *patch_itemJSON)
|
|||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (!cJSON_IsString(path)) {
|
||||
ogs_error("OpenAPI_patch_item_parseFromJSON() failed [path]");
|
||||
goto end;
|
||||
|
@ -118,7 +107,7 @@ OpenAPI_patch_item_t *OpenAPI_patch_item_parseFromJSON(cJSON *patch_itemJSON)
|
|||
|
||||
cJSON *from = cJSON_GetObjectItemCaseSensitive(patch_itemJSON, "from");
|
||||
|
||||
if (from) {
|
||||
if (from) {
|
||||
if (!cJSON_IsString(from)) {
|
||||
ogs_error("OpenAPI_patch_item_parseFromJSON() failed [from]");
|
||||
goto end;
|
||||
|
@ -126,24 +115,17 @@ OpenAPI_patch_item_t *OpenAPI_patch_item_parseFromJSON(cJSON *patch_itemJSON)
|
|||
}
|
||||
|
||||
cJSON *value = cJSON_GetObjectItemCaseSensitive(patch_itemJSON, "value");
|
||||
OpenAPI_any_type_t *any_type_value = NULL;
|
||||
|
||||
if (value) {
|
||||
if (cJSON_IsString(value))
|
||||
any_type_value = OpenAPI_any_type_create_string(value->valuestring);
|
||||
if (cJSON_IsNumber(value))
|
||||
any_type_value = OpenAPI_any_type_create_number(value->valuedouble);
|
||||
if (cJSON_IsTrue(value))
|
||||
any_type_value = OpenAPI_any_type_create_true();
|
||||
if (cJSON_IsFalse(value))
|
||||
any_type_value = OpenAPI_any_type_create_false();
|
||||
OpenAPI_any_type_t *value_local_object = NULL;
|
||||
if (value) {
|
||||
value_local_object = OpenAPI_any_type_parseFromJSON(value);
|
||||
}
|
||||
|
||||
patch_item_local_var = OpenAPI_patch_item_create (
|
||||
opVariable,
|
||||
ogs_strdup(path->valuestring),
|
||||
from ? ogs_strdup(from->valuestring) : NULL,
|
||||
any_type_value
|
||||
value ? value_local_object : NULL
|
||||
);
|
||||
|
||||
return patch_item_local_var;
|
|
@ -8,11 +8,12 @@
|
|||
#define _OpenAPI_patch_item_H_
|
||||
|
||||
#include <string.h>
|
||||
#include "../openapi/external/cJSON.h"
|
||||
#include "../openapi/include/list.h"
|
||||
#include "../openapi/model/patch_operation.h"
|
||||
|
||||
#include "../openapi/model/any_type.h"
|
||||
#include "../external/cJSON.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/keyValuePair.h"
|
||||
#include "../include/binary.h"
|
||||
#include "any_type.h"
|
||||
#include "patch_operation.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
|
@ -321,9 +321,7 @@ components:
|
|||
type: string
|
||||
from:
|
||||
type: string
|
||||
# value: {}
|
||||
value:
|
||||
type: string
|
||||
value: {}
|
||||
required:
|
||||
- op
|
||||
- path
|
||||
|
|
|
@ -2,63 +2,88 @@
|
|||
|
||||
bool OpenAPI_IsInvalid(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Invalid;
|
||||
return item && cJSON_IsInvalid(item->json);
|
||||
}
|
||||
bool OpenAPI_IsFalse(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_False;
|
||||
return item && cJSON_IsFalse(item->json);
|
||||
}
|
||||
bool OpenAPI_IsTrue(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xff) == OpenAPI_True;
|
||||
return item && cJSON_IsTrue(item->json);
|
||||
}
|
||||
bool OpenAPI_IsBool(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & (OpenAPI_True | OpenAPI_False)) != 0;
|
||||
return item && cJSON_IsBool(item->json);
|
||||
}
|
||||
bool OpenAPI_IsNull(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_NULL;
|
||||
return item && cJSON_IsNull(item->json);
|
||||
}
|
||||
bool OpenAPI_IsNumber(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Number;
|
||||
return item && cJSON_IsNumber(item->json);
|
||||
}
|
||||
bool OpenAPI_IsString(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_String;
|
||||
return item && cJSON_IsString(item->json);
|
||||
}
|
||||
bool OpenAPI_IsArray(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Array;
|
||||
return item && cJSON_IsArray(item->json);
|
||||
}
|
||||
bool OpenAPI_IsObject(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Object;
|
||||
return item && cJSON_IsObject(item->json);
|
||||
}
|
||||
bool OpenAPI_IsRaw(const OpenAPI_any_type_t * const item)
|
||||
{
|
||||
if (item == NULL) return false;
|
||||
return item && cJSON_IsRaw(item->json);
|
||||
}
|
||||
|
||||
return (item->type & 0xFF) == OpenAPI_Raw;
|
||||
static OpenAPI_any_type_t *any_create(cJSON *json) {
|
||||
OpenAPI_any_type_t *any_type = NULL;
|
||||
|
||||
if (!json) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
any_type = ogs_calloc(1, sizeof(*any_type));
|
||||
if (!any_type) {
|
||||
cJSON_Delete(json);
|
||||
}
|
||||
any_type->json = json;
|
||||
|
||||
return any_type;
|
||||
}
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create(cJSON *json) {
|
||||
OpenAPI_any_type_t *any_type_local_var =
|
||||
any_create(cJSON_Duplicate(json, true));
|
||||
ogs_assert(any_type_local_var);
|
||||
|
||||
return any_type_local_var;
|
||||
}
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_parseFromJSON(cJSON *json) {
|
||||
return OpenAPI_any_type_create(json);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_any_type_convertToJSON(OpenAPI_any_type_t *any_type) {
|
||||
cJSON *item = NULL;
|
||||
|
||||
if (any_type == NULL) {
|
||||
ogs_error("OpenAPI_any_type_convertToJSON() failed [AnyType]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = cJSON_Duplicate(any_type->json, true);
|
||||
if (item == NULL) {
|
||||
ogs_error("OpenAPI_any_type_convertToJSON() failed [AnyType]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_true(void)
|
||||
|
@ -73,48 +98,24 @@ OpenAPI_any_type_t *OpenAPI_any_type_create_false(void)
|
|||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_bool(bool boolean)
|
||||
{
|
||||
OpenAPI_any_type_t *any_type = NULL;
|
||||
|
||||
any_type = ogs_calloc(1, sizeof(*any_type));
|
||||
if (any_type) {
|
||||
any_type->type = boolean ? OpenAPI_True : OpenAPI_False;
|
||||
}
|
||||
|
||||
return any_type;
|
||||
return any_create(boolean ? cJSON_CreateTrue() : cJSON_CreateFalse());
|
||||
}
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_number(double num)
|
||||
{
|
||||
OpenAPI_any_type_t *any_type = NULL;
|
||||
|
||||
any_type = ogs_calloc(1, sizeof(*any_type));
|
||||
if (any_type) {
|
||||
any_type->type = OpenAPI_Number;
|
||||
any_type->valuedouble = num;
|
||||
}
|
||||
|
||||
return any_type;
|
||||
return any_create(cJSON_CreateNumber(num));
|
||||
}
|
||||
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_string(const char *string)
|
||||
{
|
||||
OpenAPI_any_type_t *any_type = NULL;
|
||||
|
||||
any_type = ogs_calloc(1, sizeof(*any_type));
|
||||
if (any_type) {
|
||||
any_type->type = OpenAPI_String;
|
||||
any_type->valuestring = ogs_strdup(string);
|
||||
}
|
||||
|
||||
return any_type;
|
||||
return any_create(cJSON_CreateString(string));
|
||||
}
|
||||
|
||||
void OpenAPI_any_type_free(OpenAPI_any_type_t *any_type)
|
||||
{
|
||||
if (any_type) {
|
||||
if (any_type->type == OpenAPI_String) {
|
||||
ogs_free(any_type->valuestring);
|
||||
}
|
||||
cJSON_Delete(any_type->json);
|
||||
ogs_free(any_type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef OGS_SBI_ANY_TYPE_H
|
||||
#define OGS_SBI_ANY_TYPE_H
|
||||
|
||||
#include "../external/cJSON.h"
|
||||
#include "ogs-core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -22,10 +23,7 @@ extern "C" {
|
|||
|
||||
typedef struct OpenAPI_any_type_s OpenAPI_any_type_t;
|
||||
typedef struct OpenAPI_any_type_s {
|
||||
int type;
|
||||
|
||||
char *valuestring;
|
||||
double valuedouble;
|
||||
cJSON *json;
|
||||
} OpenAPI_any_type_t;
|
||||
|
||||
bool OpenAPI_IsInvalid(const OpenAPI_any_type_t * const item);
|
||||
|
@ -39,6 +37,10 @@ bool OpenAPI_IsArray(const OpenAPI_any_type_t * const item);
|
|||
bool OpenAPI_IsObject(const OpenAPI_any_type_t * const item);
|
||||
bool OpenAPI_IsRaw(const OpenAPI_any_type_t * const item);
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create(cJSON *json);
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_parseFromJSON(cJSON *json);
|
||||
cJSON *OpenAPI_any_type_convertToJSON(OpenAPI_any_type_t *any_type);
|
||||
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_true(void);
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_false(void);
|
||||
OpenAPI_any_type_t *OpenAPI_any_type_create_bool(bool boolean);
|
||||
|
|
|
@ -81,6 +81,9 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_create(
|
|||
{{#isFreeFormObject}}
|
||||
OpenAPI_{{datatype}}_t *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isFreeFormObject}}
|
||||
{{#isAnyType}}
|
||||
OpenAPI_{{datatype}}_t *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isAnyType}}
|
||||
{{/isEnum}}
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
|
@ -174,8 +177,11 @@ void OpenAPI_{{classname}}_free(OpenAPI_{{classname}}_t *{{classname}})
|
|||
ogs_free({{{classname}}}->{{{name}}});
|
||||
{{/isEmail}}
|
||||
{{#isFreeFormObject}}
|
||||
OpenAPI_object_free({{{classname}}}->{{{name}}});
|
||||
OpenAPI_{{{datatype}}}_free({{{classname}}}->{{{name}}});
|
||||
{{/isFreeFormObject}}
|
||||
{{#isAnyType}}
|
||||
OpenAPI_{{{datatype}}}_free({{{classname}}}->{{{name}}});
|
||||
{{/isAnyType}}
|
||||
{{/isEnum}}
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
|
@ -388,6 +394,21 @@ cJSON *OpenAPI_{{classname}}_convertToJSON(OpenAPI_{{classname}}_t *{{classname}
|
|||
goto end;
|
||||
}
|
||||
{{/isFreeFormObject}}
|
||||
{{#isAnyType}}
|
||||
{{^required}}
|
||||
if ({{{classname}}}->{{{name}}}) {
|
||||
{{/required}}
|
||||
cJSON *{{{name}}}_object = OpenAPI_any_type_convertToJSON({{{classname}}}->{{{name}}});
|
||||
if ({{{name}}}_object == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
cJSON_AddItemToObject(item, "{{{baseName}}}", {{{name}}}_object);
|
||||
if (item->child == NULL) {
|
||||
ogs_error("OpenAPI_{{classname}}_convertToJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{/isAnyType}}
|
||||
{{/isEnum}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
|
@ -669,8 +690,19 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
{{^required}}
|
||||
if ({{{name}}}) {
|
||||
{{/required}}
|
||||
if (!cJSON_IsObject({{{name}}})) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
{{{name}}}_local_object = OpenAPI_object_parseFromJSON({{{name}}});
|
||||
{{/isFreeFormObject}}
|
||||
{{#isAnyType}}
|
||||
OpenAPI_any_type_t *{{name}}_local_object = NULL;
|
||||
{{^required}}
|
||||
if ({{{name}}}) {
|
||||
{{/required}}
|
||||
{{{name}}}_local_object = OpenAPI_any_type_parseFromJSON({{{name}}});
|
||||
{{/isAnyType}}
|
||||
{{/isEnum}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
|
@ -849,6 +881,9 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
{{#isFreeFormObject}}
|
||||
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_object{{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
||||
{{/isFreeFormObject}}
|
||||
{{#isAnyType}}
|
||||
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_object{{^required}} : NULL{{/required}}{{^-last}},{{/-last}}
|
||||
{{/isAnyType}}
|
||||
{{/isEnum}}
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
|
|
|
@ -66,6 +66,9 @@ typedef struct OpenAPI_{{classname}}_s {
|
|||
{{#isFreeFormObject}}
|
||||
OpenAPI_{{datatype}}_t *{{name}};
|
||||
{{/isFreeFormObject}}
|
||||
{{#isAnyType}}
|
||||
OpenAPI_{{datatype}}_t *{{name}};
|
||||
{{/isAnyType}}
|
||||
{{/isEnum}}
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
|
@ -134,6 +137,9 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_create(
|
|||
{{#isFreeFormObject}}
|
||||
OpenAPI_{{datatype}}_t *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isFreeFormObject}}
|
||||
{{#isAnyType}}
|
||||
OpenAPI_{{datatype}}_t *{{name}}{{^-last}},{{/-last}}
|
||||
{{/isAnyType}}
|
||||
{{/isEnum}}
|
||||
{{/isPrimitiveType}}
|
||||
{{#isPrimitiveType}}
|
||||
|
|
|
@ -136,10 +136,9 @@ bool udr_nudr_dr_handle_subscription_authentication(
|
|||
if (node->data) {
|
||||
OpenAPI_patch_item_t *patch_item = node->data;
|
||||
if (OpenAPI_IsString(patch_item->value))
|
||||
sqn_string = patch_item->value->valuestring;
|
||||
sqn_string = cJSON_GetStringValue(patch_item->value->json);
|
||||
else
|
||||
ogs_error("Invalid any-type [%d]",
|
||||
patch_item->value->type);
|
||||
ogs_error("Non-string value in patch not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue