Coverage Report

Created: 2026-06-30 06:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/nwdaf_info.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "nwdaf_info.h"
6
7
OpenAPI_nwdaf_info_t *OpenAPI_nwdaf_info_create(
8
    OpenAPI_list_t *event_ids,
9
    OpenAPI_list_t *nwdaf_events,
10
    OpenAPI_list_t *tai_list,
11
    OpenAPI_list_t *tai_range_list,
12
    OpenAPI_list_t *tai_weight_list,
13
    OpenAPI_nwdaf_capability_t *nwdaf_capability,
14
    bool is_analytics_delay,
15
    int analytics_delay,
16
    OpenAPI_list_t *serving_nf_set_id_list,
17
    OpenAPI_list_t *serving_nf_type_list,
18
    OpenAPI_list_t *ml_analytics_list,
19
    OpenAPI_list_t *pos_cases
20
)
21
4.45k
{
22
4.45k
    OpenAPI_nwdaf_info_t *nwdaf_info_local_var = ogs_malloc(sizeof(OpenAPI_nwdaf_info_t));
23
4.45k
    ogs_assert(nwdaf_info_local_var);
24
25
4.45k
    nwdaf_info_local_var->event_ids = event_ids;
26
4.45k
    nwdaf_info_local_var->nwdaf_events = nwdaf_events;
27
4.45k
    nwdaf_info_local_var->tai_list = tai_list;
28
4.45k
    nwdaf_info_local_var->tai_range_list = tai_range_list;
29
4.45k
    nwdaf_info_local_var->tai_weight_list = tai_weight_list;
30
4.45k
    nwdaf_info_local_var->nwdaf_capability = nwdaf_capability;
31
4.45k
    nwdaf_info_local_var->is_analytics_delay = is_analytics_delay;
32
4.45k
    nwdaf_info_local_var->analytics_delay = analytics_delay;
33
4.45k
    nwdaf_info_local_var->serving_nf_set_id_list = serving_nf_set_id_list;
34
4.45k
    nwdaf_info_local_var->serving_nf_type_list = serving_nf_type_list;
35
4.45k
    nwdaf_info_local_var->ml_analytics_list = ml_analytics_list;
36
4.45k
    nwdaf_info_local_var->pos_cases = pos_cases;
37
38
4.45k
    return nwdaf_info_local_var;
39
4.45k
}
40
41
void OpenAPI_nwdaf_info_free(OpenAPI_nwdaf_info_t *nwdaf_info)
42
7.64k
{
43
7.64k
    OpenAPI_lnode_t *node = NULL;
44
45
7.64k
    if (NULL == nwdaf_info) {
46
3.18k
        return;
47
3.18k
    }
48
4.45k
    if (nwdaf_info->event_ids) {
49
0
        OpenAPI_list_free(nwdaf_info->event_ids);
50
0
        nwdaf_info->event_ids = NULL;
51
0
    }
52
4.45k
    if (nwdaf_info->nwdaf_events) {
53
0
        OpenAPI_list_free(nwdaf_info->nwdaf_events);
54
0
        nwdaf_info->nwdaf_events = NULL;
55
0
    }
56
4.45k
    if (nwdaf_info->tai_list) {
57
14
        OpenAPI_list_for_each(nwdaf_info->tai_list, node) {
58
0
            OpenAPI_tai_free(node->data);
59
0
        }
60
14
        OpenAPI_list_free(nwdaf_info->tai_list);
61
14
        nwdaf_info->tai_list = NULL;
62
14
    }
63
4.45k
    if (nwdaf_info->tai_range_list) {
64
22
        OpenAPI_list_for_each(nwdaf_info->tai_range_list, node) {
65
0
            OpenAPI_tai_range_free(node->data);
66
0
        }
67
22
        OpenAPI_list_free(nwdaf_info->tai_range_list);
68
22
        nwdaf_info->tai_range_list = NULL;
69
22
    }
70
4.45k
    if (nwdaf_info->tai_weight_list) {
71
1
        OpenAPI_list_for_each(nwdaf_info->tai_weight_list, node) {
72
0
            OpenAPI_tai_weight_info_free(node->data);
73
0
        }
74
1
        OpenAPI_list_free(nwdaf_info->tai_weight_list);
75
1
        nwdaf_info->tai_weight_list = NULL;
76
1
    }
77
4.45k
    if (nwdaf_info->nwdaf_capability) {
78
67
        OpenAPI_nwdaf_capability_free(nwdaf_info->nwdaf_capability);
79
67
        nwdaf_info->nwdaf_capability = NULL;
80
67
    }
81
4.45k
    if (nwdaf_info->serving_nf_set_id_list) {
82
18
        OpenAPI_list_for_each(nwdaf_info->serving_nf_set_id_list, node) {
83
0
            ogs_free(node->data);
84
0
        }
85
18
        OpenAPI_list_free(nwdaf_info->serving_nf_set_id_list);
86
18
        nwdaf_info->serving_nf_set_id_list = NULL;
87
18
    }
88
4.45k
    if (nwdaf_info->serving_nf_type_list) {
89
0
        OpenAPI_list_free(nwdaf_info->serving_nf_type_list);
90
0
        nwdaf_info->serving_nf_type_list = NULL;
91
0
    }
92
4.45k
    if (nwdaf_info->ml_analytics_list) {
93
19
        OpenAPI_list_for_each(nwdaf_info->ml_analytics_list, node) {
94
0
            OpenAPI_ml_analytics_info_free(node->data);
95
0
        }
96
19
        OpenAPI_list_free(nwdaf_info->ml_analytics_list);
97
19
        nwdaf_info->ml_analytics_list = NULL;
98
19
    }
99
4.45k
    if (nwdaf_info->pos_cases) {
100
0
        OpenAPI_list_free(nwdaf_info->pos_cases);
101
0
        nwdaf_info->pos_cases = NULL;
102
0
    }
103
4.45k
    ogs_free(nwdaf_info);
104
4.45k
}
105
106
cJSON *OpenAPI_nwdaf_info_convertToJSON(OpenAPI_nwdaf_info_t *nwdaf_info)
107
0
{
108
0
    cJSON *item = NULL;
109
0
    OpenAPI_lnode_t *node = NULL;
110
111
0
    if (nwdaf_info == NULL) {
112
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [NwdafInfo]");
113
0
        return NULL;
114
0
    }
115
116
0
    item = cJSON_CreateObject();
117
0
    if (nwdaf_info->event_ids != OpenAPI_event_id_NULL) {
118
0
    cJSON *event_idsList = cJSON_AddArrayToObject(item, "eventIds");
119
0
    if (event_idsList == NULL) {
120
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [event_ids]");
121
0
        goto end;
122
0
    }
123
0
    OpenAPI_list_for_each(nwdaf_info->event_ids, node) {
124
0
        if (cJSON_AddStringToObject(event_idsList, "", OpenAPI_event_id_ToString((intptr_t)node->data)) == NULL) {
125
0
            ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [event_ids]");
126
0
            goto end;
127
0
        }
128
0
    }
129
0
    }
130
131
0
    if (nwdaf_info->nwdaf_events != OpenAPI_nwdaf_event_NULL) {
132
0
    cJSON *nwdaf_eventsList = cJSON_AddArrayToObject(item, "nwdafEvents");
133
0
    if (nwdaf_eventsList == NULL) {
134
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [nwdaf_events]");
135
0
        goto end;
136
0
    }
137
0
    OpenAPI_list_for_each(nwdaf_info->nwdaf_events, node) {
138
0
        if (cJSON_AddStringToObject(nwdaf_eventsList, "", OpenAPI_nwdaf_event_ToString((intptr_t)node->data)) == NULL) {
139
0
            ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [nwdaf_events]");
140
0
            goto end;
141
0
        }
142
0
    }
143
0
    }
144
145
0
    if (nwdaf_info->tai_list) {
146
0
    cJSON *tai_listList = cJSON_AddArrayToObject(item, "taiList");
147
0
    if (tai_listList == NULL) {
148
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [tai_list]");
149
0
        goto end;
150
0
    }
151
0
    OpenAPI_list_for_each(nwdaf_info->tai_list, node) {
152
0
        cJSON *itemLocal = OpenAPI_tai_convertToJSON(node->data);
153
0
        if (itemLocal == NULL) {
154
0
            ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [tai_list]");
155
0
            goto end;
156
0
        }
157
0
        cJSON_AddItemToArray(tai_listList, itemLocal);
158
0
    }
159
0
    }
160
161
0
    if (nwdaf_info->tai_range_list) {
162
0
    cJSON *tai_range_listList = cJSON_AddArrayToObject(item, "taiRangeList");
163
0
    if (tai_range_listList == NULL) {
164
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [tai_range_list]");
165
0
        goto end;
166
0
    }
167
0
    OpenAPI_list_for_each(nwdaf_info->tai_range_list, node) {
168
0
        cJSON *itemLocal = OpenAPI_tai_range_convertToJSON(node->data);
169
0
        if (itemLocal == NULL) {
170
0
            ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [tai_range_list]");
171
0
            goto end;
172
0
        }
173
0
        cJSON_AddItemToArray(tai_range_listList, itemLocal);
174
0
    }
175
0
    }
176
177
0
    if (nwdaf_info->tai_weight_list) {
178
0
    cJSON *tai_weight_listList = cJSON_AddArrayToObject(item, "taiWeightList");
179
0
    if (tai_weight_listList == NULL) {
180
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [tai_weight_list]");
181
0
        goto end;
182
0
    }
183
0
    OpenAPI_list_for_each(nwdaf_info->tai_weight_list, node) {
184
0
        cJSON *itemLocal = OpenAPI_tai_weight_info_convertToJSON(node->data);
185
0
        if (itemLocal == NULL) {
186
0
            ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [tai_weight_list]");
187
0
            goto end;
188
0
        }
189
0
        cJSON_AddItemToArray(tai_weight_listList, itemLocal);
190
0
    }
191
0
    }
192
193
0
    if (nwdaf_info->nwdaf_capability) {
194
0
    cJSON *nwdaf_capability_local_JSON = OpenAPI_nwdaf_capability_convertToJSON(nwdaf_info->nwdaf_capability);
195
0
    if (nwdaf_capability_local_JSON == NULL) {
196
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [nwdaf_capability]");
197
0
        goto end;
198
0
    }
199
0
    cJSON_AddItemToObject(item, "nwdafCapability", nwdaf_capability_local_JSON);
200
0
    if (item->child == NULL) {
201
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [nwdaf_capability]");
202
0
        goto end;
203
0
    }
204
0
    }
205
206
0
    if (nwdaf_info->is_analytics_delay) {
207
0
    if (cJSON_AddNumberToObject(item, "analyticsDelay", nwdaf_info->analytics_delay) == NULL) {
208
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [analytics_delay]");
209
0
        goto end;
210
0
    }
211
0
    }
212
213
0
    if (nwdaf_info->serving_nf_set_id_list) {
214
0
    cJSON *serving_nf_set_id_listList = cJSON_AddArrayToObject(item, "servingNfSetIdList");
215
0
    if (serving_nf_set_id_listList == NULL) {
216
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [serving_nf_set_id_list]");
217
0
        goto end;
218
0
    }
219
0
    OpenAPI_list_for_each(nwdaf_info->serving_nf_set_id_list, node) {
220
0
        if (cJSON_AddStringToObject(serving_nf_set_id_listList, "", (char*)node->data) == NULL) {
221
0
            ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [serving_nf_set_id_list]");
222
0
            goto end;
223
0
        }
224
0
    }
225
0
    }
226
227
0
    if (nwdaf_info->serving_nf_type_list != OpenAPI_nf_type_NULL) {
228
0
    cJSON *serving_nf_type_listList = cJSON_AddArrayToObject(item, "servingNfTypeList");
229
0
    if (serving_nf_type_listList == NULL) {
230
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [serving_nf_type_list]");
231
0
        goto end;
232
0
    }
233
0
    OpenAPI_list_for_each(nwdaf_info->serving_nf_type_list, node) {
234
0
        if (cJSON_AddStringToObject(serving_nf_type_listList, "", OpenAPI_nf_type_ToString((intptr_t)node->data)) == NULL) {
235
0
            ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [serving_nf_type_list]");
236
0
            goto end;
237
0
        }
238
0
    }
239
0
    }
240
241
0
    if (nwdaf_info->ml_analytics_list) {
242
0
    cJSON *ml_analytics_listList = cJSON_AddArrayToObject(item, "mlAnalyticsList");
243
0
    if (ml_analytics_listList == NULL) {
244
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [ml_analytics_list]");
245
0
        goto end;
246
0
    }
247
0
    OpenAPI_list_for_each(nwdaf_info->ml_analytics_list, node) {
248
0
        cJSON *itemLocal = OpenAPI_ml_analytics_info_convertToJSON(node->data);
249
0
        if (itemLocal == NULL) {
250
0
            ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [ml_analytics_list]");
251
0
            goto end;
252
0
        }
253
0
        cJSON_AddItemToArray(ml_analytics_listList, itemLocal);
254
0
    }
255
0
    }
256
257
0
    if (nwdaf_info->pos_cases != OpenAPI_positioning_case_NULL) {
258
0
    cJSON *pos_casesList = cJSON_AddArrayToObject(item, "posCases");
259
0
    if (pos_casesList == NULL) {
260
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [pos_cases]");
261
0
        goto end;
262
0
    }
263
0
    OpenAPI_list_for_each(nwdaf_info->pos_cases, node) {
264
0
        if (cJSON_AddStringToObject(pos_casesList, "", OpenAPI_positioning_case_ToString((intptr_t)node->data)) == NULL) {
265
0
            ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed [pos_cases]");
266
0
            goto end;
267
0
        }
268
0
    }
269
0
    }
270
271
0
end:
272
0
    return item;
273
0
}
274
275
OpenAPI_nwdaf_info_t *OpenAPI_nwdaf_info_parseFromJSON(cJSON *nwdaf_infoJSON)
276
6.53k
{
277
6.53k
    OpenAPI_nwdaf_info_t *nwdaf_info_local_var = NULL;
278
6.53k
    OpenAPI_lnode_t *node = NULL;
279
6.53k
    cJSON *event_ids = NULL;
280
6.53k
    OpenAPI_list_t *event_idsList = NULL;
281
6.53k
    cJSON *nwdaf_events = NULL;
282
6.53k
    OpenAPI_list_t *nwdaf_eventsList = NULL;
283
6.53k
    cJSON *tai_list = NULL;
284
6.53k
    OpenAPI_list_t *tai_listList = NULL;
285
6.53k
    cJSON *tai_range_list = NULL;
286
6.53k
    OpenAPI_list_t *tai_range_listList = NULL;
287
6.53k
    cJSON *tai_weight_list = NULL;
288
6.53k
    OpenAPI_list_t *tai_weight_listList = NULL;
289
6.53k
    cJSON *nwdaf_capability = NULL;
290
6.53k
    OpenAPI_nwdaf_capability_t *nwdaf_capability_local_nonprim = NULL;
291
6.53k
    cJSON *analytics_delay = NULL;
292
6.53k
    cJSON *serving_nf_set_id_list = NULL;
293
6.53k
    OpenAPI_list_t *serving_nf_set_id_listList = NULL;
294
6.53k
    cJSON *serving_nf_type_list = NULL;
295
6.53k
    OpenAPI_list_t *serving_nf_type_listList = NULL;
296
6.53k
    cJSON *ml_analytics_list = NULL;
297
6.53k
    OpenAPI_list_t *ml_analytics_listList = NULL;
298
6.53k
    cJSON *pos_cases = NULL;
299
6.53k
    OpenAPI_list_t *pos_casesList = NULL;
300
6.53k
    event_ids = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "eventIds");
301
6.53k
    if (event_ids) {
302
157
        cJSON *event_ids_local = NULL;
303
157
        if (!cJSON_IsArray(event_ids)) {
304
122
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [event_ids]");
305
122
            goto end;
306
122
        }
307
308
35
        event_idsList = OpenAPI_list_create();
309
310
35
        cJSON_ArrayForEach(event_ids_local, event_ids) {
311
0
            OpenAPI_event_id_e localEnum = OpenAPI_event_id_NULL;
312
0
            if (!cJSON_IsString(event_ids_local)) {
313
0
                ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [event_ids]");
314
0
                goto end;
315
0
            }
316
0
            localEnum = OpenAPI_event_id_FromString(event_ids_local->valuestring);
317
0
            if (!localEnum) {
318
0
                ogs_info("Enum value \"%s\" for field \"event_ids\" is not supported. Ignoring it ...",
319
0
                         event_ids_local->valuestring);
320
0
            } else {
321
0
                OpenAPI_list_add(event_idsList, (void *)localEnum);
322
0
            }
323
0
        }
324
35
        if (event_idsList->count == 0) {
325
35
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed: Expected event_idsList to not be empty (after ignoring unsupported enum values).");
326
35
            goto end;
327
35
        }
328
35
    }
329
330
6.37k
    nwdaf_events = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "nwdafEvents");
331
6.37k
    if (nwdaf_events) {
332
0
        cJSON *nwdaf_events_local = NULL;
333
0
        if (!cJSON_IsArray(nwdaf_events)) {
334
0
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [nwdaf_events]");
335
0
            goto end;
336
0
        }
337
338
0
        nwdaf_eventsList = OpenAPI_list_create();
339
340
0
        cJSON_ArrayForEach(nwdaf_events_local, nwdaf_events) {
341
0
            OpenAPI_nwdaf_event_e localEnum = OpenAPI_nwdaf_event_NULL;
342
0
            if (!cJSON_IsString(nwdaf_events_local)) {
343
0
                ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [nwdaf_events]");
344
0
                goto end;
345
0
            }
346
0
            localEnum = OpenAPI_nwdaf_event_FromString(nwdaf_events_local->valuestring);
347
0
            if (!localEnum) {
348
0
                ogs_info("Enum value \"%s\" for field \"nwdaf_events\" is not supported. Ignoring it ...",
349
0
                         nwdaf_events_local->valuestring);
350
0
            } else {
351
0
                OpenAPI_list_add(nwdaf_eventsList, (void *)localEnum);
352
0
            }
353
0
        }
354
0
        if (nwdaf_eventsList->count == 0) {
355
0
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed: Expected nwdaf_eventsList to not be empty (after ignoring unsupported enum values).");
356
0
            goto end;
357
0
        }
358
0
    }
359
360
6.37k
    tai_list = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "taiList");
361
6.37k
    if (tai_list) {
362
98
        cJSON *tai_list_local = NULL;
363
98
        if (!cJSON_IsArray(tai_list)) {
364
80
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [tai_list]");
365
80
            goto end;
366
80
        }
367
368
18
        tai_listList = OpenAPI_list_create();
369
370
18
        cJSON_ArrayForEach(tai_list_local, tai_list) {
371
4
            if (!cJSON_IsObject(tai_list_local)) {
372
3
                ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [tai_list]");
373
3
                goto end;
374
3
            }
375
1
            OpenAPI_tai_t *tai_listItem = OpenAPI_tai_parseFromJSON(tai_list_local);
376
1
            if (!tai_listItem) {
377
1
                ogs_error("No tai_listItem");
378
1
                goto end;
379
1
            }
380
0
            OpenAPI_list_add(tai_listList, tai_listItem);
381
0
        }
382
18
    }
383
384
6.29k
    tai_range_list = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "taiRangeList");
385
6.29k
    if (tai_range_list) {
386
124
        cJSON *tai_range_list_local = NULL;
387
124
        if (!cJSON_IsArray(tai_range_list)) {
388
84
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [tai_range_list]");
389
84
            goto end;
390
84
        }
391
392
40
        tai_range_listList = OpenAPI_list_create();
393
394
40
        cJSON_ArrayForEach(tai_range_list_local, tai_range_list) {
395
10
            if (!cJSON_IsObject(tai_range_list_local)) {
396
10
                ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [tai_range_list]");
397
10
                goto end;
398
10
            }
399
0
            OpenAPI_tai_range_t *tai_range_listItem = OpenAPI_tai_range_parseFromJSON(tai_range_list_local);
400
0
            if (!tai_range_listItem) {
401
0
                ogs_error("No tai_range_listItem");
402
0
                goto end;
403
0
            }
404
0
            OpenAPI_list_add(tai_range_listList, tai_range_listItem);
405
0
        }
406
40
    }
407
408
6.19k
    tai_weight_list = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "taiWeightList");
409
6.19k
    if (tai_weight_list) {
410
142
        cJSON *tai_weight_list_local = NULL;
411
142
        if (!cJSON_IsArray(tai_weight_list)) {
412
141
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [tai_weight_list]");
413
141
            goto end;
414
141
        }
415
416
1
        tai_weight_listList = OpenAPI_list_create();
417
418
1
        cJSON_ArrayForEach(tai_weight_list_local, tai_weight_list) {
419
0
            if (!cJSON_IsObject(tai_weight_list_local)) {
420
0
                ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [tai_weight_list]");
421
0
                goto end;
422
0
            }
423
0
            OpenAPI_tai_weight_info_t *tai_weight_listItem = OpenAPI_tai_weight_info_parseFromJSON(tai_weight_list_local);
424
0
            if (!tai_weight_listItem) {
425
0
                ogs_error("No tai_weight_listItem");
426
0
                goto end;
427
0
            }
428
0
            OpenAPI_list_add(tai_weight_listList, tai_weight_listItem);
429
0
        }
430
1
    }
431
432
6.05k
    nwdaf_capability = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "nwdafCapability");
433
6.05k
    if (nwdaf_capability) {
434
68
    nwdaf_capability_local_nonprim = OpenAPI_nwdaf_capability_parseFromJSON(nwdaf_capability);
435
68
    if (!nwdaf_capability_local_nonprim) {
436
0
        ogs_error("OpenAPI_nwdaf_capability_parseFromJSON failed [nwdaf_capability]");
437
0
        goto end;
438
0
    }
439
68
    }
440
441
6.05k
    analytics_delay = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "analyticsDelay");
442
6.05k
    if (analytics_delay) {
443
19
    if (!cJSON_IsNumber(analytics_delay)) {
444
19
        ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [analytics_delay]");
445
19
        goto end;
446
19
    }
447
19
    }
448
449
6.03k
    serving_nf_set_id_list = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "servingNfSetIdList");
450
6.03k
    if (serving_nf_set_id_list) {
451
920
        cJSON *serving_nf_set_id_list_local = NULL;
452
920
        if (!cJSON_IsArray(serving_nf_set_id_list)) {
453
855
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [serving_nf_set_id_list]");
454
855
            goto end;
455
855
        }
456
457
65
        serving_nf_set_id_listList = OpenAPI_list_create();
458
459
65
        cJSON_ArrayForEach(serving_nf_set_id_list_local, serving_nf_set_id_list) {
460
47
            double *localDouble = NULL;
461
47
            int *localInt = NULL;
462
47
            if (!cJSON_IsString(serving_nf_set_id_list_local)) {
463
47
                ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [serving_nf_set_id_list]");
464
47
                goto end;
465
47
            }
466
0
            OpenAPI_list_add(serving_nf_set_id_listList, ogs_strdup(serving_nf_set_id_list_local->valuestring));
467
0
        }
468
65
    }
469
470
5.13k
    serving_nf_type_list = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "servingNfTypeList");
471
5.13k
    if (serving_nf_type_list) {
472
217
        cJSON *serving_nf_type_list_local = NULL;
473
217
        if (!cJSON_IsArray(serving_nf_type_list)) {
474
146
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [serving_nf_type_list]");
475
146
            goto end;
476
146
        }
477
478
71
        serving_nf_type_listList = OpenAPI_list_create();
479
480
71
        cJSON_ArrayForEach(serving_nf_type_list_local, serving_nf_type_list) {
481
70
            OpenAPI_nf_type_e localEnum = OpenAPI_nf_type_NULL;
482
70
            if (!cJSON_IsString(serving_nf_type_list_local)) {
483
70
                ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [serving_nf_type_list]");
484
70
                goto end;
485
70
            }
486
0
            localEnum = OpenAPI_nf_type_FromString(serving_nf_type_list_local->valuestring);
487
0
            if (!localEnum) {
488
0
                ogs_info("Enum value \"%s\" for field \"serving_nf_type_list\" is not supported. Ignoring it ...",
489
0
                         serving_nf_type_list_local->valuestring);
490
0
            } else {
491
0
                OpenAPI_list_add(serving_nf_type_listList, (void *)localEnum);
492
0
            }
493
0
        }
494
1
        if (serving_nf_type_listList->count == 0) {
495
1
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed: Expected serving_nf_type_listList to not be empty (after ignoring unsupported enum values).");
496
1
            goto end;
497
1
        }
498
1
    }
499
500
4.91k
    ml_analytics_list = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "mlAnalyticsList");
501
4.91k
    if (ml_analytics_list) {
502
94
        cJSON *ml_analytics_list_local = NULL;
503
94
        if (!cJSON_IsArray(ml_analytics_list)) {
504
71
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [ml_analytics_list]");
505
71
            goto end;
506
71
        }
507
508
23
        ml_analytics_listList = OpenAPI_list_create();
509
510
23
        cJSON_ArrayForEach(ml_analytics_list_local, ml_analytics_list) {
511
4
            if (!cJSON_IsObject(ml_analytics_list_local)) {
512
4
                ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [ml_analytics_list]");
513
4
                goto end;
514
4
            }
515
0
            OpenAPI_ml_analytics_info_t *ml_analytics_listItem = OpenAPI_ml_analytics_info_parseFromJSON(ml_analytics_list_local);
516
0
            if (!ml_analytics_listItem) {
517
0
                ogs_error("No ml_analytics_listItem");
518
0
                goto end;
519
0
            }
520
0
            OpenAPI_list_add(ml_analytics_listList, ml_analytics_listItem);
521
0
        }
522
23
    }
523
524
4.84k
    pos_cases = cJSON_GetObjectItemCaseSensitive(nwdaf_infoJSON, "posCases");
525
4.84k
    if (pos_cases) {
526
388
        cJSON *pos_cases_local = NULL;
527
388
        if (!cJSON_IsArray(pos_cases)) {
528
361
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [pos_cases]");
529
361
            goto end;
530
361
        }
531
532
27
        pos_casesList = OpenAPI_list_create();
533
534
27
        cJSON_ArrayForEach(pos_cases_local, pos_cases) {
535
5
            OpenAPI_positioning_case_e localEnum = OpenAPI_positioning_case_NULL;
536
5
            if (!cJSON_IsString(pos_cases_local)) {
537
3
                ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed [pos_cases]");
538
3
                goto end;
539
3
            }
540
2
            localEnum = OpenAPI_positioning_case_FromString(pos_cases_local->valuestring);
541
2
            if (!localEnum) {
542
2
                ogs_info("Enum value \"%s\" for field \"pos_cases\" is not supported. Ignoring it ...",
543
2
                         pos_cases_local->valuestring);
544
2
            } else {
545
0
                OpenAPI_list_add(pos_casesList, (void *)localEnum);
546
0
            }
547
2
        }
548
24
        if (pos_casesList->count == 0) {
549
24
            ogs_error("OpenAPI_nwdaf_info_parseFromJSON() failed: Expected pos_casesList to not be empty (after ignoring unsupported enum values).");
550
24
            goto end;
551
24
        }
552
24
    }
553
554
4.45k
    nwdaf_info_local_var = OpenAPI_nwdaf_info_create (
555
4.45k
        event_ids ? event_idsList : NULL,
556
4.45k
        nwdaf_events ? nwdaf_eventsList : NULL,
557
4.45k
        tai_list ? tai_listList : NULL,
558
4.45k
        tai_range_list ? tai_range_listList : NULL,
559
4.45k
        tai_weight_list ? tai_weight_listList : NULL,
560
4.45k
        nwdaf_capability ? nwdaf_capability_local_nonprim : NULL,
561
4.45k
        analytics_delay ? true : false,
562
4.45k
        analytics_delay ? analytics_delay->valuedouble : 0,
563
4.45k
        serving_nf_set_id_list ? serving_nf_set_id_listList : NULL,
564
4.45k
        serving_nf_type_list ? serving_nf_type_listList : NULL,
565
4.45k
        ml_analytics_list ? ml_analytics_listList : NULL,
566
4.45k
        pos_cases ? pos_casesList : NULL
567
4.45k
    );
568
569
4.45k
    return nwdaf_info_local_var;
570
2.07k
end:
571
2.07k
    if (event_idsList) {
572
35
        OpenAPI_list_free(event_idsList);
573
35
        event_idsList = NULL;
574
35
    }
575
2.07k
    if (nwdaf_eventsList) {
576
0
        OpenAPI_list_free(nwdaf_eventsList);
577
0
        nwdaf_eventsList = NULL;
578
0
    }
579
2.07k
    if (tai_listList) {
580
4
        OpenAPI_list_for_each(tai_listList, node) {
581
0
            OpenAPI_tai_free(node->data);
582
0
        }
583
4
        OpenAPI_list_free(tai_listList);
584
4
        tai_listList = NULL;
585
4
    }
586
2.07k
    if (tai_range_listList) {
587
18
        OpenAPI_list_for_each(tai_range_listList, node) {
588
0
            OpenAPI_tai_range_free(node->data);
589
0
        }
590
18
        OpenAPI_list_free(tai_range_listList);
591
18
        tai_range_listList = NULL;
592
18
    }
593
2.07k
    if (tai_weight_listList) {
594
0
        OpenAPI_list_for_each(tai_weight_listList, node) {
595
0
            OpenAPI_tai_weight_info_free(node->data);
596
0
        }
597
0
        OpenAPI_list_free(tai_weight_listList);
598
0
        tai_weight_listList = NULL;
599
0
    }
600
2.07k
    if (nwdaf_capability_local_nonprim) {
601
1
        OpenAPI_nwdaf_capability_free(nwdaf_capability_local_nonprim);
602
1
        nwdaf_capability_local_nonprim = NULL;
603
1
    }
604
2.07k
    if (serving_nf_set_id_listList) {
605
47
        OpenAPI_list_for_each(serving_nf_set_id_listList, node) {
606
0
            ogs_free(node->data);
607
0
        }
608
47
        OpenAPI_list_free(serving_nf_set_id_listList);
609
47
        serving_nf_set_id_listList = NULL;
610
47
    }
611
2.07k
    if (serving_nf_type_listList) {
612
71
        OpenAPI_list_free(serving_nf_type_listList);
613
71
        serving_nf_type_listList = NULL;
614
71
    }
615
2.07k
    if (ml_analytics_listList) {
616
4
        OpenAPI_list_for_each(ml_analytics_listList, node) {
617
0
            OpenAPI_ml_analytics_info_free(node->data);
618
0
        }
619
4
        OpenAPI_list_free(ml_analytics_listList);
620
4
        ml_analytics_listList = NULL;
621
4
    }
622
2.07k
    if (pos_casesList) {
623
27
        OpenAPI_list_free(pos_casesList);
624
27
        pos_casesList = NULL;
625
27
    }
626
2.07k
    return NULL;
627
4.84k
}
628
629
OpenAPI_nwdaf_info_t *OpenAPI_nwdaf_info_copy(OpenAPI_nwdaf_info_t *dst, OpenAPI_nwdaf_info_t *src)
630
0
{
631
0
    cJSON *item = NULL;
632
0
    char *content = NULL;
633
634
0
    ogs_assert(src);
635
0
    item = OpenAPI_nwdaf_info_convertToJSON(src);
636
0
    if (!item) {
637
0
        ogs_error("OpenAPI_nwdaf_info_convertToJSON() failed");
638
0
        return NULL;
639
0
    }
640
641
0
    content = cJSON_Print(item);
642
0
    cJSON_Delete(item);
643
644
0
    if (!content) {
645
0
        ogs_error("cJSON_Print() failed");
646
0
        return NULL;
647
0
    }
648
649
0
    item = cJSON_Parse(content);
650
0
    ogs_free(content);
651
0
    if (!item) {
652
0
        ogs_error("cJSON_Parse() failed");
653
0
        return NULL;
654
0
    }
655
656
0
    OpenAPI_nwdaf_info_free(dst);
657
0
    dst = OpenAPI_nwdaf_info_parseFromJSON(item);
658
0
    cJSON_Delete(item);
659
660
0
    return dst;
661
0
}
662