forked from loafle/openapi-generator-original
* [C][Client] Remove redundant casts Don't explicitly cast void pointers as it's unnecessary in C, but leave printf arguments untouched to avoid setting off -Wformat. * [C][Client] Cosmetic: remove unnecessary parens, align some lines * [C][Client] Reduce number of unnecessary strlen() calls
221 lines
6.2 KiB
C
221 lines
6.2 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include "DefaultAPI.h"
|
|
|
|
#define MAX_NUMBER_LENGTH 16
|
|
#define MAX_BUFFER_LENGTH 4096
|
|
|
|
|
|
// Returns private information.
|
|
//
|
|
// This endpoint requires global security settings.
|
|
//
|
|
object_t*
|
|
DefaultAPI_privateGet(apiClient_t *apiClient)
|
|
{
|
|
list_t *localVarQueryParameters = NULL;
|
|
list_t *localVarHeaderParameters = NULL;
|
|
list_t *localVarFormParameters = NULL;
|
|
list_t *localVarHeaderType = list_createList();
|
|
list_t *localVarContentType = NULL;
|
|
char *localVarBodyParameters = NULL;
|
|
size_t localVarBodyLength = 0;
|
|
|
|
// clear the error code from the previous api call
|
|
apiClient->response_code = 0;
|
|
|
|
// create the path
|
|
char *localVarPath = strdup("/private");
|
|
|
|
|
|
|
|
|
|
list_addElement(localVarHeaderType,"application/json"); //produces
|
|
apiClient_invoke(apiClient,
|
|
localVarPath,
|
|
localVarQueryParameters,
|
|
localVarHeaderParameters,
|
|
localVarFormParameters,
|
|
localVarHeaderType,
|
|
localVarContentType,
|
|
localVarBodyParameters,
|
|
localVarBodyLength,
|
|
"GET");
|
|
|
|
// uncomment below to debug the error response
|
|
//if (apiClient->response_code == 200) {
|
|
// printf("%s\n","A JSON object with private information");
|
|
//}
|
|
//nonprimitive not container
|
|
object_t *elementToReturn = NULL;
|
|
if(apiClient->response_code >= 200 && apiClient->response_code < 300) {
|
|
cJSON *DefaultAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
|
|
elementToReturn = object_parseFromJSON(DefaultAPIlocalVarJSON);
|
|
cJSON_Delete(DefaultAPIlocalVarJSON);
|
|
if(elementToReturn == NULL) {
|
|
// return 0;
|
|
}
|
|
}
|
|
|
|
//return type
|
|
if (apiClient->dataReceived) {
|
|
free(apiClient->dataReceived);
|
|
apiClient->dataReceived = NULL;
|
|
apiClient->dataReceivedLen = 0;
|
|
}
|
|
|
|
|
|
|
|
list_freeList(localVarHeaderType);
|
|
|
|
free(localVarPath);
|
|
return elementToReturn;
|
|
end:
|
|
free(localVarPath);
|
|
return NULL;
|
|
|
|
}
|
|
|
|
// Returns public information.
|
|
//
|
|
// This endpoint does not require authentication.
|
|
//
|
|
object_t*
|
|
DefaultAPI_publicGet(apiClient_t *apiClient)
|
|
{
|
|
list_t *localVarQueryParameters = NULL;
|
|
list_t *localVarHeaderParameters = NULL;
|
|
list_t *localVarFormParameters = NULL;
|
|
list_t *localVarHeaderType = list_createList();
|
|
list_t *localVarContentType = NULL;
|
|
char *localVarBodyParameters = NULL;
|
|
size_t localVarBodyLength = 0;
|
|
|
|
// clear the error code from the previous api call
|
|
apiClient->response_code = 0;
|
|
|
|
// create the path
|
|
char *localVarPath = strdup("/public");
|
|
|
|
|
|
|
|
|
|
list_addElement(localVarHeaderType,"application/json"); //produces
|
|
apiClient_invoke(apiClient,
|
|
localVarPath,
|
|
localVarQueryParameters,
|
|
localVarHeaderParameters,
|
|
localVarFormParameters,
|
|
localVarHeaderType,
|
|
localVarContentType,
|
|
localVarBodyParameters,
|
|
localVarBodyLength,
|
|
"GET");
|
|
|
|
// uncomment below to debug the error response
|
|
//if (apiClient->response_code == 200) {
|
|
// printf("%s\n","A JSON object with public information");
|
|
//}
|
|
//nonprimitive not container
|
|
object_t *elementToReturn = NULL;
|
|
if(apiClient->response_code >= 200 && apiClient->response_code < 300) {
|
|
cJSON *DefaultAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
|
|
elementToReturn = object_parseFromJSON(DefaultAPIlocalVarJSON);
|
|
cJSON_Delete(DefaultAPIlocalVarJSON);
|
|
if(elementToReturn == NULL) {
|
|
// return 0;
|
|
}
|
|
}
|
|
|
|
//return type
|
|
if (apiClient->dataReceived) {
|
|
free(apiClient->dataReceived);
|
|
apiClient->dataReceived = NULL;
|
|
apiClient->dataReceivedLen = 0;
|
|
}
|
|
|
|
|
|
|
|
list_freeList(localVarHeaderType);
|
|
|
|
free(localVarPath);
|
|
return elementToReturn;
|
|
end:
|
|
free(localVarPath);
|
|
return NULL;
|
|
|
|
}
|
|
|
|
// Returns a list of users.
|
|
//
|
|
// Optional extended description in CommonMark or HTML.
|
|
//
|
|
list_t*
|
|
DefaultAPI_usersGet(apiClient_t *apiClient)
|
|
{
|
|
list_t *localVarQueryParameters = NULL;
|
|
list_t *localVarHeaderParameters = NULL;
|
|
list_t *localVarFormParameters = NULL;
|
|
list_t *localVarHeaderType = list_createList();
|
|
list_t *localVarContentType = NULL;
|
|
char *localVarBodyParameters = NULL;
|
|
size_t localVarBodyLength = 0;
|
|
|
|
// clear the error code from the previous api call
|
|
apiClient->response_code = 0;
|
|
|
|
// create the path
|
|
char *localVarPath = strdup("/users");
|
|
|
|
|
|
|
|
|
|
list_addElement(localVarHeaderType,"application/json"); //produces
|
|
apiClient_invoke(apiClient,
|
|
localVarPath,
|
|
localVarQueryParameters,
|
|
localVarHeaderParameters,
|
|
localVarFormParameters,
|
|
localVarHeaderType,
|
|
localVarContentType,
|
|
localVarBodyParameters,
|
|
localVarBodyLength,
|
|
"GET");
|
|
|
|
// uncomment below to debug the error response
|
|
//if (apiClient->response_code == 200) {
|
|
// printf("%s\n","A JSON array of user names");
|
|
//}
|
|
//primitive return type not simple
|
|
list_t *elementToReturn = NULL;
|
|
if(apiClient->response_code >= 200 && apiClient->response_code < 300) {
|
|
cJSON *localVarJSON = cJSON_Parse(apiClient->dataReceived);
|
|
cJSON *VarJSON;
|
|
elementToReturn = list_createList();
|
|
cJSON_ArrayForEach(VarJSON, localVarJSON){
|
|
keyValuePair_t *keyPair = keyValuePair_create(strdup(VarJSON->string), cJSON_Print(VarJSON));
|
|
list_addElement(elementToReturn, keyPair);
|
|
}
|
|
cJSON_Delete(localVarJSON);
|
|
}
|
|
|
|
if (apiClient->dataReceived) {
|
|
free(apiClient->dataReceived);
|
|
apiClient->dataReceived = NULL;
|
|
apiClient->dataReceivedLen = 0;
|
|
}
|
|
|
|
|
|
|
|
list_freeList(localVarHeaderType);
|
|
|
|
free(localVarPath);
|
|
return elementToReturn;
|
|
end:
|
|
free(localVarPath);
|
|
return NULL;
|
|
|
|
}
|
|
|