mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
* [C] Deprecate *_create() to avoid *_free() confusion The behaviour of *_free() doesn't match *_create(), so the user should avoid using them together. But they still need *_free() to clean up library-allocated objects, so add a _library_owned flag to each struct as an attempt to tell them apart. This isn't perfect though, because the user may neglect to zero the field, but they would still see a warning once in a while so it serves its purpose. To prevent the new deprecation warnings (intended for the user) from showing up during the library build itself, define a new family of *_create_internal() functions, and turn *_create() into simple wrappers. * Update samples * add eafer to c technical committee --------- Co-authored-by: William Cheng <wing328hk@gmail.com>
59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
/*
|
|
* user.h
|
|
*
|
|
* A User who is purchasing from the pet store
|
|
*/
|
|
|
|
#ifndef _user_H_
|
|
#define _user_H_
|
|
|
|
#include <string.h>
|
|
#include "../external/cJSON.h"
|
|
#include "../include/list.h"
|
|
#include "../include/keyValuePair.h"
|
|
#include "../include/binary.h"
|
|
|
|
typedef struct user_t user_t;
|
|
|
|
#include "any_type.h"
|
|
#include "preference.h"
|
|
|
|
|
|
|
|
typedef struct user_t {
|
|
long id; //numeric
|
|
char *username; // string
|
|
char *first_name; // string
|
|
char *last_name; // string
|
|
char *email; // string
|
|
char *password; // string
|
|
char *phone; // string
|
|
int user_status; //numeric
|
|
list_t* extra; //map
|
|
openapi_petstore_preference__e preference; //referenced enum
|
|
|
|
int _library_owned; // Is the library responsible for freeing this object?
|
|
} user_t;
|
|
|
|
__attribute__((deprecated)) user_t *user_create(
|
|
long id,
|
|
char *username,
|
|
char *first_name,
|
|
char *last_name,
|
|
char *email,
|
|
char *password,
|
|
char *phone,
|
|
int user_status,
|
|
list_t* extra,
|
|
openapi_petstore_preference__e preference
|
|
);
|
|
|
|
void user_free(user_t *user);
|
|
|
|
user_t *user_parseFromJSON(cJSON *userJSON);
|
|
|
|
cJSON *user_convertToJSON(user_t *user);
|
|
|
|
#endif /* _user_H_ */
|
|
|