mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 12:07:07 +00:00
* [C-Curl] Client generator does not handle float properly (#21092) - Change function signature to float* - Change generator to convert float to string - Similar change for double and long * [C-Curl] Client generator does not handle float properly (#21092) - Generate samples - Fix generator for headers and path params * Revert "[C-Curl] Client generator does not handle float properly (#21092)" This reverts commitba044a65d5. * Revert "[C-Curl] Client generator does not handle float properly (#21092)" This reverts commitf99c5b0382. * [C-Curl] Client generator does not handle float properly (#21092) - Convert float, double and long to string - Generate samples * [C-Curl] Client generator does not handle float properly (#21092) - Add missing yaml example file * [C-Curl] Client generator does not handle float properly (#21092) - Transfer float and double in scientific notation with resp. 7 and 16 decimals - Adapt string size to number of required characters * [C-Curl] Client generator does not handle float properly (#21092) - Fix unused variable. - Fix snprintf string * * [C-Curl] Client generator does not handle float properly (#21092) - Generating samples * * [C-Curl] Client generator does not handle float properly (#21092) - Always allocate the exact string size
223 lines
6.2 KiB
C
223 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
|
|
#define MAX_NUMBER_LENGTH_LONG 21
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|