diff --git a/lib/sbi/custom/patch_item.h b/lib/sbi/custom/patch_item.h index ed7777695..50b24c851 100644 --- a/lib/sbi/custom/patch_item.h +++ b/lib/sbi/custom/patch_item.h @@ -12,7 +12,7 @@ #include "../openapi/include/list.h" #include "../openapi/model/patch_operation.h" -#include "../custom/any_type.h" +#include "../openapi/model/any_type.h" #ifdef __cplusplus extern "C" { diff --git a/lib/sbi/meson.build b/lib/sbi/meson.build index bbebc0f25..d943d61d1 100644 --- a/lib/sbi/meson.build +++ b/lib/sbi/meson.build @@ -20,8 +20,6 @@ subdir('openapi') libsbi_sources = files(''' contrib/multipart_parser.c - custom/any_type.c - custom/links.c custom/ue_authentication_ctx.c custom/patch_item.c diff --git a/lib/sbi/openapi/meson.build b/lib/sbi/openapi/meson.build index 6b02d32ce..9313ecbf0 100644 --- a/lib/sbi/openapi/meson.build +++ b/lib/sbi/openapi/meson.build @@ -86,6 +86,7 @@ libsbi_openapi_sources = files(''' model/am_policy_data.c model/an_gw_address.c model/an_node_type.c + model/any_type.c model/apn_rate_status.c model/app_descriptor.c model/app_detection_info.c diff --git a/lib/sbi/custom/any_type.c b/lib/sbi/openapi/model/any_type.c similarity index 100% rename from lib/sbi/custom/any_type.c rename to lib/sbi/openapi/model/any_type.c diff --git a/lib/sbi/custom/any_type.h b/lib/sbi/openapi/model/any_type.h similarity index 100% rename from lib/sbi/custom/any_type.h rename to lib/sbi/openapi/model/any_type.h diff --git a/lib/sbi/support/20210629/openapi-generator/config.yaml b/lib/sbi/support/20210629/openapi-generator/config.yaml index 8f7b22df0..8e60fe8d0 100644 --- a/lib/sbi/support/20210629/openapi-generator/config.yaml +++ b/lib/sbi/support/20210629/openapi-generator/config.yaml @@ -6,3 +6,8 @@ reservedWordMappings: 5G_AKA: "5G_AKA" 5G_HE_AKA: "5G_HE_AKA" 5GMM: "5GMM" +files: + any_type.h: + folder: model + any_type.c: + folder: model diff --git a/lib/sbi/support/20210629/openapi-generator/templates/any_type.c b/lib/sbi/support/20210629/openapi-generator/templates/any_type.c new file mode 100644 index 000000000..175dbf10f --- /dev/null +++ b/lib/sbi/support/20210629/openapi-generator/templates/any_type.c @@ -0,0 +1,120 @@ +#include "any_type.h" + +bool OpenAPI_IsInvalid(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & 0xFF) == OpenAPI_Invalid; +} +bool OpenAPI_IsFalse(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & 0xFF) == OpenAPI_False; +} +bool OpenAPI_IsTrue(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & 0xff) == OpenAPI_True; +} +bool OpenAPI_IsBool(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & (OpenAPI_True | OpenAPI_False)) != 0; +} +bool OpenAPI_IsNull(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & 0xFF) == OpenAPI_NULL; +} +bool OpenAPI_IsNumber(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & 0xFF) == OpenAPI_Number; +} +bool OpenAPI_IsString(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & 0xFF) == OpenAPI_String; +} +bool OpenAPI_IsArray(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & 0xFF) == OpenAPI_Array; +} +bool OpenAPI_IsObject(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & 0xFF) == OpenAPI_Object; +} +bool OpenAPI_IsRaw(const OpenAPI_any_type_t * const item) +{ + if (item == NULL) return false; + + return (item->type & 0xFF) == OpenAPI_Raw; +} + +OpenAPI_any_type_t *OpenAPI_any_type_create_true(void) +{ + return OpenAPI_any_type_create_bool(true); +} + +OpenAPI_any_type_t *OpenAPI_any_type_create_false(void) +{ + return OpenAPI_any_type_create_bool(false); +} + +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; +} + +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; +} + +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; +} + +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); + } + ogs_free(any_type); + } +} diff --git a/lib/sbi/support/20210629/openapi-generator/templates/any_type.h b/lib/sbi/support/20210629/openapi-generator/templates/any_type.h new file mode 100644 index 000000000..eeb00197e --- /dev/null +++ b/lib/sbi/support/20210629/openapi-generator/templates/any_type.h @@ -0,0 +1,53 @@ +#ifndef OGS_SBI_ANY_TYPE_H +#define OGS_SBI_ANY_TYPE_H + +#include "ogs-core.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define OpenAPI_Invalid (0) +#define OpenAPI_False (1 << 0) +#define OpenAPI_True (1 << 1) +#define OpenAPI_NULL (1 << 2) +#define OpenAPI_Number (1 << 3) +#define OpenAPI_String (1 << 4) +#define OpenAPI_Array (1 << 5) +#define OpenAPI_Object (1 << 6) +#define OpenAPI_Raw (1 << 7) /* raw json */ + +#define OpenAPI_IsReference 256 +#define OpenAPI_StringIsConst 512 + +typedef struct OpenAPI_any_type_s OpenAPI_any_type_t; +typedef struct OpenAPI_any_type_s { + int type; + + char *valuestring; + double valuedouble; +} OpenAPI_any_type_t; + +bool OpenAPI_IsInvalid(const OpenAPI_any_type_t * const item); +bool OpenAPI_IsFalse(const OpenAPI_any_type_t * const item); +bool OpenAPI_IsTrue(const OpenAPI_any_type_t * const item); +bool OpenAPI_IsBool(const OpenAPI_any_type_t * const item); +bool OpenAPI_IsNull(const OpenAPI_any_type_t * const item); +bool OpenAPI_IsNumber(const OpenAPI_any_type_t * const item); +bool OpenAPI_IsString(const OpenAPI_any_type_t * const item); +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_true(void); +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 *OpenAPI_any_type_create_number(double num); +OpenAPI_any_type_t *OpenAPI_any_type_create_string(const char *string); +void OpenAPI_any_type_free(OpenAPI_any_type_t *any_type); + +#ifdef __cplusplus +} +#endif + +#endif /* OGS_SBI_ANY_TYPE_H */