/src/open5gs/lib/sbi/openapi/model/problem_details.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "problem_details.h" |
6 | | |
7 | | OpenAPI_problem_details_t *OpenAPI_problem_details_create( |
8 | | char *type, |
9 | | char *title, |
10 | | bool is_status, |
11 | | int status, |
12 | | char *detail, |
13 | | char *instance, |
14 | | char *cause, |
15 | | OpenAPI_list_t *invalid_params, |
16 | | char *supported_features, |
17 | | OpenAPI_access_token_err_t *access_token_error, |
18 | | OpenAPI_access_token_req_t *access_token_request, |
19 | | char *nrf_id, |
20 | | OpenAPI_list_t *supported_api_versions, |
21 | | OpenAPI_no_profile_match_info_t *no_profile_match_info |
22 | | ) |
23 | 0 | { |
24 | 0 | OpenAPI_problem_details_t *problem_details_local_var = ogs_malloc(sizeof(OpenAPI_problem_details_t)); |
25 | 0 | ogs_assert(problem_details_local_var); |
26 | | |
27 | 0 | problem_details_local_var->type = type; |
28 | 0 | problem_details_local_var->title = title; |
29 | 0 | problem_details_local_var->is_status = is_status; |
30 | 0 | problem_details_local_var->status = status; |
31 | 0 | problem_details_local_var->detail = detail; |
32 | 0 | problem_details_local_var->instance = instance; |
33 | 0 | problem_details_local_var->cause = cause; |
34 | 0 | problem_details_local_var->invalid_params = invalid_params; |
35 | 0 | problem_details_local_var->supported_features = supported_features; |
36 | 0 | problem_details_local_var->access_token_error = access_token_error; |
37 | 0 | problem_details_local_var->access_token_request = access_token_request; |
38 | 0 | problem_details_local_var->nrf_id = nrf_id; |
39 | 0 | problem_details_local_var->supported_api_versions = supported_api_versions; |
40 | 0 | problem_details_local_var->no_profile_match_info = no_profile_match_info; |
41 | |
|
42 | 0 | return problem_details_local_var; |
43 | 0 | } |
44 | | |
45 | | void OpenAPI_problem_details_free(OpenAPI_problem_details_t *problem_details) |
46 | 0 | { |
47 | 0 | OpenAPI_lnode_t *node = NULL; |
48 | |
|
49 | 0 | if (NULL == problem_details) { |
50 | 0 | return; |
51 | 0 | } |
52 | 0 | if (problem_details->type) { |
53 | 0 | ogs_free(problem_details->type); |
54 | 0 | problem_details->type = NULL; |
55 | 0 | } |
56 | 0 | if (problem_details->title) { |
57 | 0 | ogs_free(problem_details->title); |
58 | 0 | problem_details->title = NULL; |
59 | 0 | } |
60 | 0 | if (problem_details->detail) { |
61 | 0 | ogs_free(problem_details->detail); |
62 | 0 | problem_details->detail = NULL; |
63 | 0 | } |
64 | 0 | if (problem_details->instance) { |
65 | 0 | ogs_free(problem_details->instance); |
66 | 0 | problem_details->instance = NULL; |
67 | 0 | } |
68 | 0 | if (problem_details->cause) { |
69 | 0 | ogs_free(problem_details->cause); |
70 | 0 | problem_details->cause = NULL; |
71 | 0 | } |
72 | 0 | if (problem_details->invalid_params) { |
73 | 0 | OpenAPI_list_for_each(problem_details->invalid_params, node) { |
74 | 0 | OpenAPI_invalid_param_free(node->data); |
75 | 0 | } |
76 | 0 | OpenAPI_list_free(problem_details->invalid_params); |
77 | 0 | problem_details->invalid_params = NULL; |
78 | 0 | } |
79 | 0 | if (problem_details->supported_features) { |
80 | 0 | ogs_free(problem_details->supported_features); |
81 | 0 | problem_details->supported_features = NULL; |
82 | 0 | } |
83 | 0 | if (problem_details->access_token_error) { |
84 | 0 | OpenAPI_access_token_err_free(problem_details->access_token_error); |
85 | 0 | problem_details->access_token_error = NULL; |
86 | 0 | } |
87 | 0 | if (problem_details->access_token_request) { |
88 | 0 | OpenAPI_access_token_req_free(problem_details->access_token_request); |
89 | 0 | problem_details->access_token_request = NULL; |
90 | 0 | } |
91 | 0 | if (problem_details->nrf_id) { |
92 | 0 | ogs_free(problem_details->nrf_id); |
93 | 0 | problem_details->nrf_id = NULL; |
94 | 0 | } |
95 | 0 | if (problem_details->supported_api_versions) { |
96 | 0 | OpenAPI_list_for_each(problem_details->supported_api_versions, node) { |
97 | 0 | ogs_free(node->data); |
98 | 0 | } |
99 | 0 | OpenAPI_list_free(problem_details->supported_api_versions); |
100 | 0 | problem_details->supported_api_versions = NULL; |
101 | 0 | } |
102 | 0 | if (problem_details->no_profile_match_info) { |
103 | 0 | OpenAPI_no_profile_match_info_free(problem_details->no_profile_match_info); |
104 | 0 | problem_details->no_profile_match_info = NULL; |
105 | 0 | } |
106 | 0 | ogs_free(problem_details); |
107 | 0 | } |
108 | | |
109 | | cJSON *OpenAPI_problem_details_convertToJSON(OpenAPI_problem_details_t *problem_details) |
110 | 0 | { |
111 | 0 | cJSON *item = NULL; |
112 | 0 | OpenAPI_lnode_t *node = NULL; |
113 | |
|
114 | 0 | if (problem_details == NULL) { |
115 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [ProblemDetails]"); |
116 | 0 | return NULL; |
117 | 0 | } |
118 | | |
119 | 0 | item = cJSON_CreateObject(); |
120 | 0 | if (problem_details->type) { |
121 | 0 | if (cJSON_AddStringToObject(item, "type", problem_details->type) == NULL) { |
122 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [type]"); |
123 | 0 | goto end; |
124 | 0 | } |
125 | 0 | } |
126 | | |
127 | 0 | if (problem_details->title) { |
128 | 0 | if (cJSON_AddStringToObject(item, "title", problem_details->title) == NULL) { |
129 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [title]"); |
130 | 0 | goto end; |
131 | 0 | } |
132 | 0 | } |
133 | | |
134 | 0 | if (problem_details->is_status) { |
135 | 0 | if (cJSON_AddNumberToObject(item, "status", problem_details->status) == NULL) { |
136 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [status]"); |
137 | 0 | goto end; |
138 | 0 | } |
139 | 0 | } |
140 | | |
141 | 0 | if (problem_details->detail) { |
142 | 0 | if (cJSON_AddStringToObject(item, "detail", problem_details->detail) == NULL) { |
143 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [detail]"); |
144 | 0 | goto end; |
145 | 0 | } |
146 | 0 | } |
147 | | |
148 | 0 | if (problem_details->instance) { |
149 | 0 | if (cJSON_AddStringToObject(item, "instance", problem_details->instance) == NULL) { |
150 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [instance]"); |
151 | 0 | goto end; |
152 | 0 | } |
153 | 0 | } |
154 | | |
155 | 0 | if (problem_details->cause) { |
156 | 0 | if (cJSON_AddStringToObject(item, "cause", problem_details->cause) == NULL) { |
157 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [cause]"); |
158 | 0 | goto end; |
159 | 0 | } |
160 | 0 | } |
161 | | |
162 | 0 | if (problem_details->invalid_params) { |
163 | 0 | cJSON *invalid_paramsList = cJSON_AddArrayToObject(item, "invalidParams"); |
164 | 0 | if (invalid_paramsList == NULL) { |
165 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [invalid_params]"); |
166 | 0 | goto end; |
167 | 0 | } |
168 | 0 | OpenAPI_list_for_each(problem_details->invalid_params, node) { |
169 | 0 | cJSON *itemLocal = OpenAPI_invalid_param_convertToJSON(node->data); |
170 | 0 | if (itemLocal == NULL) { |
171 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [invalid_params]"); |
172 | 0 | goto end; |
173 | 0 | } |
174 | 0 | cJSON_AddItemToArray(invalid_paramsList, itemLocal); |
175 | 0 | } |
176 | 0 | } |
177 | | |
178 | 0 | if (problem_details->supported_features) { |
179 | 0 | if (cJSON_AddStringToObject(item, "supportedFeatures", problem_details->supported_features) == NULL) { |
180 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [supported_features]"); |
181 | 0 | goto end; |
182 | 0 | } |
183 | 0 | } |
184 | | |
185 | 0 | if (problem_details->access_token_error) { |
186 | 0 | cJSON *access_token_error_local_JSON = OpenAPI_access_token_err_convertToJSON(problem_details->access_token_error); |
187 | 0 | if (access_token_error_local_JSON == NULL) { |
188 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [access_token_error]"); |
189 | 0 | goto end; |
190 | 0 | } |
191 | 0 | cJSON_AddItemToObject(item, "accessTokenError", access_token_error_local_JSON); |
192 | 0 | if (item->child == NULL) { |
193 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [access_token_error]"); |
194 | 0 | goto end; |
195 | 0 | } |
196 | 0 | } |
197 | | |
198 | 0 | if (problem_details->access_token_request) { |
199 | 0 | cJSON *access_token_request_local_JSON = OpenAPI_access_token_req_convertToJSON(problem_details->access_token_request); |
200 | 0 | if (access_token_request_local_JSON == NULL) { |
201 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [access_token_request]"); |
202 | 0 | goto end; |
203 | 0 | } |
204 | 0 | cJSON_AddItemToObject(item, "accessTokenRequest", access_token_request_local_JSON); |
205 | 0 | if (item->child == NULL) { |
206 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [access_token_request]"); |
207 | 0 | goto end; |
208 | 0 | } |
209 | 0 | } |
210 | | |
211 | 0 | if (problem_details->nrf_id) { |
212 | 0 | if (cJSON_AddStringToObject(item, "nrfId", problem_details->nrf_id) == NULL) { |
213 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [nrf_id]"); |
214 | 0 | goto end; |
215 | 0 | } |
216 | 0 | } |
217 | | |
218 | 0 | if (problem_details->supported_api_versions) { |
219 | 0 | cJSON *supported_api_versionsList = cJSON_AddArrayToObject(item, "supportedApiVersions"); |
220 | 0 | if (supported_api_versionsList == NULL) { |
221 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [supported_api_versions]"); |
222 | 0 | goto end; |
223 | 0 | } |
224 | 0 | OpenAPI_list_for_each(problem_details->supported_api_versions, node) { |
225 | 0 | if (cJSON_AddStringToObject(supported_api_versionsList, "", (char*)node->data) == NULL) { |
226 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [supported_api_versions]"); |
227 | 0 | goto end; |
228 | 0 | } |
229 | 0 | } |
230 | 0 | } |
231 | | |
232 | 0 | if (problem_details->no_profile_match_info) { |
233 | 0 | cJSON *no_profile_match_info_local_JSON = OpenAPI_no_profile_match_info_convertToJSON(problem_details->no_profile_match_info); |
234 | 0 | if (no_profile_match_info_local_JSON == NULL) { |
235 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [no_profile_match_info]"); |
236 | 0 | goto end; |
237 | 0 | } |
238 | 0 | cJSON_AddItemToObject(item, "noProfileMatchInfo", no_profile_match_info_local_JSON); |
239 | 0 | if (item->child == NULL) { |
240 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed [no_profile_match_info]"); |
241 | 0 | goto end; |
242 | 0 | } |
243 | 0 | } |
244 | | |
245 | 0 | end: |
246 | 0 | return item; |
247 | 0 | } |
248 | | |
249 | | OpenAPI_problem_details_t *OpenAPI_problem_details_parseFromJSON(cJSON *problem_detailsJSON) |
250 | 0 | { |
251 | 0 | OpenAPI_problem_details_t *problem_details_local_var = NULL; |
252 | 0 | OpenAPI_lnode_t *node = NULL; |
253 | 0 | cJSON *type = NULL; |
254 | 0 | cJSON *title = NULL; |
255 | 0 | cJSON *status = NULL; |
256 | 0 | cJSON *detail = NULL; |
257 | 0 | cJSON *instance = NULL; |
258 | 0 | cJSON *cause = NULL; |
259 | 0 | cJSON *invalid_params = NULL; |
260 | 0 | OpenAPI_list_t *invalid_paramsList = NULL; |
261 | 0 | cJSON *supported_features = NULL; |
262 | 0 | cJSON *access_token_error = NULL; |
263 | 0 | OpenAPI_access_token_err_t *access_token_error_local_nonprim = NULL; |
264 | 0 | cJSON *access_token_request = NULL; |
265 | 0 | OpenAPI_access_token_req_t *access_token_request_local_nonprim = NULL; |
266 | 0 | cJSON *nrf_id = NULL; |
267 | 0 | cJSON *supported_api_versions = NULL; |
268 | 0 | OpenAPI_list_t *supported_api_versionsList = NULL; |
269 | 0 | cJSON *no_profile_match_info = NULL; |
270 | 0 | OpenAPI_no_profile_match_info_t *no_profile_match_info_local_nonprim = NULL; |
271 | 0 | type = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "type"); |
272 | 0 | if (type) { |
273 | 0 | if (!cJSON_IsString(type) && !cJSON_IsNull(type)) { |
274 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [type]"); |
275 | 0 | goto end; |
276 | 0 | } |
277 | 0 | } |
278 | | |
279 | 0 | title = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "title"); |
280 | 0 | if (title) { |
281 | 0 | if (!cJSON_IsString(title) && !cJSON_IsNull(title)) { |
282 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [title]"); |
283 | 0 | goto end; |
284 | 0 | } |
285 | 0 | } |
286 | | |
287 | 0 | status = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "status"); |
288 | 0 | if (status) { |
289 | 0 | if (!cJSON_IsNumber(status)) { |
290 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [status]"); |
291 | 0 | goto end; |
292 | 0 | } |
293 | 0 | } |
294 | | |
295 | 0 | detail = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "detail"); |
296 | 0 | if (detail) { |
297 | 0 | if (!cJSON_IsString(detail) && !cJSON_IsNull(detail)) { |
298 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [detail]"); |
299 | 0 | goto end; |
300 | 0 | } |
301 | 0 | } |
302 | | |
303 | 0 | instance = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "instance"); |
304 | 0 | if (instance) { |
305 | 0 | if (!cJSON_IsString(instance) && !cJSON_IsNull(instance)) { |
306 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [instance]"); |
307 | 0 | goto end; |
308 | 0 | } |
309 | 0 | } |
310 | | |
311 | 0 | cause = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "cause"); |
312 | 0 | if (cause) { |
313 | 0 | if (!cJSON_IsString(cause) && !cJSON_IsNull(cause)) { |
314 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [cause]"); |
315 | 0 | goto end; |
316 | 0 | } |
317 | 0 | } |
318 | | |
319 | 0 | invalid_params = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "invalidParams"); |
320 | 0 | if (invalid_params) { |
321 | 0 | cJSON *invalid_params_local = NULL; |
322 | 0 | if (!cJSON_IsArray(invalid_params)) { |
323 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [invalid_params]"); |
324 | 0 | goto end; |
325 | 0 | } |
326 | | |
327 | 0 | invalid_paramsList = OpenAPI_list_create(); |
328 | |
|
329 | 0 | cJSON_ArrayForEach(invalid_params_local, invalid_params) { |
330 | 0 | if (!cJSON_IsObject(invalid_params_local)) { |
331 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [invalid_params]"); |
332 | 0 | goto end; |
333 | 0 | } |
334 | 0 | OpenAPI_invalid_param_t *invalid_paramsItem = OpenAPI_invalid_param_parseFromJSON(invalid_params_local); |
335 | 0 | if (!invalid_paramsItem) { |
336 | 0 | ogs_error("No invalid_paramsItem"); |
337 | 0 | goto end; |
338 | 0 | } |
339 | 0 | OpenAPI_list_add(invalid_paramsList, invalid_paramsItem); |
340 | 0 | } |
341 | 0 | } |
342 | | |
343 | 0 | supported_features = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "supportedFeatures"); |
344 | 0 | if (supported_features) { |
345 | 0 | if (!cJSON_IsString(supported_features) && !cJSON_IsNull(supported_features)) { |
346 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [supported_features]"); |
347 | 0 | goto end; |
348 | 0 | } |
349 | 0 | } |
350 | | |
351 | 0 | access_token_error = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "accessTokenError"); |
352 | 0 | if (access_token_error) { |
353 | 0 | access_token_error_local_nonprim = OpenAPI_access_token_err_parseFromJSON(access_token_error); |
354 | 0 | if (!access_token_error_local_nonprim) { |
355 | 0 | ogs_error("OpenAPI_access_token_err_parseFromJSON failed [access_token_error]"); |
356 | 0 | goto end; |
357 | 0 | } |
358 | 0 | } |
359 | | |
360 | 0 | access_token_request = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "accessTokenRequest"); |
361 | 0 | if (access_token_request) { |
362 | 0 | access_token_request_local_nonprim = OpenAPI_access_token_req_parseFromJSON(access_token_request); |
363 | 0 | if (!access_token_request_local_nonprim) { |
364 | 0 | ogs_error("OpenAPI_access_token_req_parseFromJSON failed [access_token_request]"); |
365 | 0 | goto end; |
366 | 0 | } |
367 | 0 | } |
368 | | |
369 | 0 | nrf_id = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "nrfId"); |
370 | 0 | if (nrf_id) { |
371 | 0 | if (!cJSON_IsString(nrf_id) && !cJSON_IsNull(nrf_id)) { |
372 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [nrf_id]"); |
373 | 0 | goto end; |
374 | 0 | } |
375 | 0 | } |
376 | | |
377 | 0 | supported_api_versions = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "supportedApiVersions"); |
378 | 0 | if (supported_api_versions) { |
379 | 0 | cJSON *supported_api_versions_local = NULL; |
380 | 0 | if (!cJSON_IsArray(supported_api_versions)) { |
381 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [supported_api_versions]"); |
382 | 0 | goto end; |
383 | 0 | } |
384 | | |
385 | 0 | supported_api_versionsList = OpenAPI_list_create(); |
386 | |
|
387 | 0 | cJSON_ArrayForEach(supported_api_versions_local, supported_api_versions) { |
388 | 0 | double *localDouble = NULL; |
389 | 0 | int *localInt = NULL; |
390 | 0 | if (!cJSON_IsString(supported_api_versions_local)) { |
391 | 0 | ogs_error("OpenAPI_problem_details_parseFromJSON() failed [supported_api_versions]"); |
392 | 0 | goto end; |
393 | 0 | } |
394 | 0 | OpenAPI_list_add(supported_api_versionsList, ogs_strdup(supported_api_versions_local->valuestring)); |
395 | 0 | } |
396 | 0 | } |
397 | | |
398 | 0 | no_profile_match_info = cJSON_GetObjectItemCaseSensitive(problem_detailsJSON, "noProfileMatchInfo"); |
399 | 0 | if (no_profile_match_info) { |
400 | 0 | no_profile_match_info_local_nonprim = OpenAPI_no_profile_match_info_parseFromJSON(no_profile_match_info); |
401 | 0 | if (!no_profile_match_info_local_nonprim) { |
402 | 0 | ogs_error("OpenAPI_no_profile_match_info_parseFromJSON failed [no_profile_match_info]"); |
403 | 0 | goto end; |
404 | 0 | } |
405 | 0 | } |
406 | | |
407 | 0 | problem_details_local_var = OpenAPI_problem_details_create ( |
408 | 0 | type && !cJSON_IsNull(type) ? ogs_strdup(type->valuestring) : NULL, |
409 | 0 | title && !cJSON_IsNull(title) ? ogs_strdup(title->valuestring) : NULL, |
410 | 0 | status ? true : false, |
411 | 0 | status ? status->valuedouble : 0, |
412 | 0 | detail && !cJSON_IsNull(detail) ? ogs_strdup(detail->valuestring) : NULL, |
413 | 0 | instance && !cJSON_IsNull(instance) ? ogs_strdup(instance->valuestring) : NULL, |
414 | 0 | cause && !cJSON_IsNull(cause) ? ogs_strdup(cause->valuestring) : NULL, |
415 | 0 | invalid_params ? invalid_paramsList : NULL, |
416 | 0 | supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL, |
417 | 0 | access_token_error ? access_token_error_local_nonprim : NULL, |
418 | 0 | access_token_request ? access_token_request_local_nonprim : NULL, |
419 | 0 | nrf_id && !cJSON_IsNull(nrf_id) ? ogs_strdup(nrf_id->valuestring) : NULL, |
420 | 0 | supported_api_versions ? supported_api_versionsList : NULL, |
421 | 0 | no_profile_match_info ? no_profile_match_info_local_nonprim : NULL |
422 | 0 | ); |
423 | |
|
424 | 0 | return problem_details_local_var; |
425 | 0 | end: |
426 | 0 | if (invalid_paramsList) { |
427 | 0 | OpenAPI_list_for_each(invalid_paramsList, node) { |
428 | 0 | OpenAPI_invalid_param_free(node->data); |
429 | 0 | } |
430 | 0 | OpenAPI_list_free(invalid_paramsList); |
431 | 0 | invalid_paramsList = NULL; |
432 | 0 | } |
433 | 0 | if (access_token_error_local_nonprim) { |
434 | 0 | OpenAPI_access_token_err_free(access_token_error_local_nonprim); |
435 | 0 | access_token_error_local_nonprim = NULL; |
436 | 0 | } |
437 | 0 | if (access_token_request_local_nonprim) { |
438 | 0 | OpenAPI_access_token_req_free(access_token_request_local_nonprim); |
439 | 0 | access_token_request_local_nonprim = NULL; |
440 | 0 | } |
441 | 0 | if (supported_api_versionsList) { |
442 | 0 | OpenAPI_list_for_each(supported_api_versionsList, node) { |
443 | 0 | ogs_free(node->data); |
444 | 0 | } |
445 | 0 | OpenAPI_list_free(supported_api_versionsList); |
446 | 0 | supported_api_versionsList = NULL; |
447 | 0 | } |
448 | 0 | if (no_profile_match_info_local_nonprim) { |
449 | 0 | OpenAPI_no_profile_match_info_free(no_profile_match_info_local_nonprim); |
450 | 0 | no_profile_match_info_local_nonprim = NULL; |
451 | 0 | } |
452 | 0 | return NULL; |
453 | 0 | } |
454 | | |
455 | | OpenAPI_problem_details_t *OpenAPI_problem_details_copy(OpenAPI_problem_details_t *dst, OpenAPI_problem_details_t *src) |
456 | 0 | { |
457 | 0 | cJSON *item = NULL; |
458 | 0 | char *content = NULL; |
459 | |
|
460 | 0 | ogs_assert(src); |
461 | 0 | item = OpenAPI_problem_details_convertToJSON(src); |
462 | 0 | if (!item) { |
463 | 0 | ogs_error("OpenAPI_problem_details_convertToJSON() failed"); |
464 | 0 | return NULL; |
465 | 0 | } |
466 | | |
467 | 0 | content = cJSON_Print(item); |
468 | 0 | cJSON_Delete(item); |
469 | |
|
470 | 0 | if (!content) { |
471 | 0 | ogs_error("cJSON_Print() failed"); |
472 | 0 | return NULL; |
473 | 0 | } |
474 | | |
475 | 0 | item = cJSON_Parse(content); |
476 | 0 | ogs_free(content); |
477 | 0 | if (!item) { |
478 | 0 | ogs_error("cJSON_Parse() failed"); |
479 | 0 | return NULL; |
480 | 0 | } |
481 | | |
482 | 0 | OpenAPI_problem_details_free(dst); |
483 | 0 | dst = OpenAPI_problem_details_parseFromJSON(item); |
484 | 0 | cJSON_Delete(item); |
485 | |
|
486 | 0 | return dst; |
487 | 0 | } |
488 | | |