Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
{{/infoUrl}}

## Installation
You'll need the `curl 7.58.0` package in order to build the API. To have code formatted nicely, you also need to have uncrustify version 0.67 or later.
You'll need the `curl 7.61.1` package in order to build the API. To have code formatted nicely, you also need to have uncrustify version 0.67 or later.

# Prerequisites

## Install the `curl 7.58.0` package with the following command on Linux.
## Install the `curl 7.61.1` package with the following command on Linux.
```bash
sudo apt remove curl
wget http://curl.haxx.se/download/curl-7.58.0.tar.gz
tar -xvf curl-7.58.0.tar.gz
cd curl-7.58.0/
wget http://curl.haxx.se/download/curl-7.61.1.tar.gz
tar -xvf curl-7.61.1.tar.gz
cd curl-7.61.1/
./configure
make
sudo make install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ apiClient_t *apiClient_create() {
apiClient_t *apiClient = malloc(sizeof(apiClient_t));
apiClient->basePath = strdup("{{{basePath}}}");
apiClient->sslConfig = NULL;
apiClient->curlConfig = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -60,6 +61,12 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
apiClient->sslConfig = NULL;
}

apiClient->curlConfig = malloc(sizeof(curlConfig_t));
apiClient->curlConfig->verbose = 0;
apiClient->curlConfig->keepalive = 0;
apiClient->curlConfig->keepidle = 120;
apiClient->curlConfig->keepintvl = 60;

apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -142,6 +149,12 @@ void apiClient_free(apiClient_t *apiClient) {
{{/isApiKey}}
{{/authMethods}}
{{/hasAuthMethods}}

if(apiClient->curlConfig) {
free(apiClient->curlConfig);
apiClient->curlConfig = NULL;
}

free(apiClient);
}

Expand Down Expand Up @@ -498,7 +511,6 @@ void apiClient_invoke(apiClient_t *apiClient,
CURLOPT_WRITEDATA,
apiClient);
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(handle, CURLOPT_VERBOSE, 0); // to get curl debug msg 0: to disable, 1L:to enable

{{#hasAuthMethods}}
{{#authMethods}}
Expand Down Expand Up @@ -543,6 +555,15 @@ void apiClient_invoke(apiClient_t *apiClient,
postData(handle, bodyParameters, bodyParametersLength);
}

if(apiClient->curlConfig != NULL) {
if(apiClient->curlConfig->keepalive == 1) {
curl_easy_setopt(handle, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(handle, CURLOPT_TCP_KEEPIDLE, apiClient->curlConfig->keepidle);
curl_easy_setopt(handle, CURLOPT_TCP_KEEPINTVL, apiClient->curlConfig->keepintvl);
}
curl_easy_setopt(handle, CURLOPT_VERBOSE, apiClient->curlConfig->verbose);
}

res = curl_easy_perform(handle);

curl_slist_free_all(headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ typedef struct sslConfig_t {
/* 1 -- skip ssl verify for server certificate */
} sslConfig_t;

typedef struct curlConfig_t {
long verbose; /* 0 -- disable verbose (default) */
/* 1 -- enable verbose */
int keepalive; /* 0 -- disable keepalive (default) */
/* 1 -- enable keepalive */
long keepidle; /* keep-alive idle time: default to 120 seconds */
long keepintvl; /* interval time between keep-alive probes: default to 60 seconds */
} curlConfig_t;

typedef struct apiClient_t {
char *basePath;
sslConfig_t *sslConfig;
curlConfig_t *curlConfig;
void *dataReceived;
long dataReceivedLen;
void (*data_callback_func)(void **, long *);
Expand Down
10 changes: 5 additions & 5 deletions samples/client/others/c/bearerAuth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
- Build package: org.openapitools.codegen.languages.CLibcurlClientCodegen

## Installation
You'll need the `curl 7.58.0` package in order to build the API. To have code formatted nicely, you also need to have uncrustify version 0.67 or later.
You'll need the `curl 7.61.1` package in order to build the API. To have code formatted nicely, you also need to have uncrustify version 0.67 or later.

# Prerequisites

## Install the `curl 7.58.0` package with the following command on Linux.
## Install the `curl 7.61.1` package with the following command on Linux.
```bash
sudo apt remove curl
wget http://curl.haxx.se/download/curl-7.58.0.tar.gz
tar -xvf curl-7.58.0.tar.gz
cd curl-7.58.0/
wget http://curl.haxx.se/download/curl-7.61.1.tar.gz
tar -xvf curl-7.61.1.tar.gz
cd curl-7.61.1/
./configure
make
sudo make install
Expand Down
10 changes: 10 additions & 0 deletions samples/client/others/c/bearerAuth/include/apiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ typedef struct sslConfig_t {
/* 1 -- skip ssl verify for server certificate */
} sslConfig_t;

typedef struct curlConfig_t {
long verbose; /* 0 -- disable verbose (default) */
/* 1 -- enable verbose */
int keepalive; /* 0 -- disable keepalive (default) */
/* 1 -- enable keepalive */
long keepidle; /* keep-alive idle time: default to 120 seconds */
long keepintvl; /* interval time between keep-alive probes: default to 60 seconds */
} curlConfig_t;

typedef struct apiClient_t {
char *basePath;
sslConfig_t *sslConfig;
curlConfig_t *curlConfig;
void *dataReceived;
long dataReceivedLen;
void (*data_callback_func)(void **, long *);
Expand Down
23 changes: 22 additions & 1 deletion samples/client/others/c/bearerAuth/src/apiClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ apiClient_t *apiClient_create() {
apiClient_t *apiClient = malloc(sizeof(apiClient_t));
apiClient->basePath = strdup("http://api.example.com/v1");
apiClient->sslConfig = NULL;
apiClient->curlConfig = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -37,6 +38,12 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
apiClient->sslConfig = NULL;
}

apiClient->curlConfig = malloc(sizeof(curlConfig_t));
apiClient->curlConfig->verbose = 0;
apiClient->curlConfig->keepalive = 0;
apiClient->curlConfig->keepidle = 120;
apiClient->curlConfig->keepintvl = 60;

apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand All @@ -58,6 +65,12 @@ void apiClient_free(apiClient_t *apiClient) {
if(apiClient->accessToken) {
free(apiClient->accessToken);
}

if(apiClient->curlConfig) {
free(apiClient->curlConfig);
apiClient->curlConfig = NULL;
}

free(apiClient);
}

Expand Down Expand Up @@ -391,13 +404,21 @@ void apiClient_invoke(apiClient_t *apiClient,
CURLOPT_WRITEDATA,
apiClient);
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(handle, CURLOPT_VERBOSE, 0); // to get curl debug msg 0: to disable, 1L:to enable


if(bodyParameters != NULL) {
postData(handle, bodyParameters, bodyParametersLength);
}

if(apiClient->curlConfig != NULL) {
if(apiClient->curlConfig->keepalive == 1) {
curl_easy_setopt(handle, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(handle, CURLOPT_TCP_KEEPIDLE, apiClient->curlConfig->keepidle);
curl_easy_setopt(handle, CURLOPT_TCP_KEEPINTVL, apiClient->curlConfig->keepintvl);
}
curl_easy_setopt(handle, CURLOPT_VERBOSE, apiClient->curlConfig->verbose);
}

res = curl_easy_perform(handle);

curl_slist_free_all(headers);
Expand Down
10 changes: 5 additions & 5 deletions samples/client/petstore/c-useJsonUnformatted/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
- Build package: org.openapitools.codegen.languages.CLibcurlClientCodegen

## Installation
You'll need the `curl 7.58.0` package in order to build the API. To have code formatted nicely, you also need to have uncrustify version 0.67 or later.
You'll need the `curl 7.61.1` package in order to build the API. To have code formatted nicely, you also need to have uncrustify version 0.67 or later.

# Prerequisites

## Install the `curl 7.58.0` package with the following command on Linux.
## Install the `curl 7.61.1` package with the following command on Linux.
```bash
sudo apt remove curl
wget http://curl.haxx.se/download/curl-7.58.0.tar.gz
tar -xvf curl-7.58.0.tar.gz
cd curl-7.58.0/
wget http://curl.haxx.se/download/curl-7.61.1.tar.gz
tar -xvf curl-7.61.1.tar.gz
cd curl-7.61.1/
./configure
make
sudo make install
Expand Down
10 changes: 10 additions & 0 deletions samples/client/petstore/c-useJsonUnformatted/include/apiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ typedef struct sslConfig_t {
/* 1 -- skip ssl verify for server certificate */
} sslConfig_t;

typedef struct curlConfig_t {
long verbose; /* 0 -- disable verbose (default) */
/* 1 -- enable verbose */
int keepalive; /* 0 -- disable keepalive (default) */
/* 1 -- enable keepalive */
long keepidle; /* keep-alive idle time: default to 120 seconds */
long keepintvl; /* interval time between keep-alive probes: default to 60 seconds */
} curlConfig_t;

typedef struct apiClient_t {
char *basePath;
sslConfig_t *sslConfig;
curlConfig_t *curlConfig;
void *dataReceived;
long dataReceivedLen;
void (*data_callback_func)(void **, long *);
Expand Down
23 changes: 22 additions & 1 deletion samples/client/petstore/c-useJsonUnformatted/src/apiClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ apiClient_t *apiClient_create() {
apiClient_t *apiClient = malloc(sizeof(apiClient_t));
apiClient->basePath = strdup("http://petstore.swagger.io/v2");
apiClient->sslConfig = NULL;
apiClient->curlConfig = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -39,6 +40,12 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
apiClient->sslConfig = NULL;
}

apiClient->curlConfig = malloc(sizeof(curlConfig_t));
apiClient->curlConfig->verbose = 0;
apiClient->curlConfig->keepalive = 0;
apiClient->curlConfig->keepidle = 120;
apiClient->curlConfig->keepintvl = 60;

apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -85,6 +92,12 @@ void apiClient_free(apiClient_t *apiClient) {
}
list_freeList(apiClient->apiKeys_api_key);
}

if(apiClient->curlConfig) {
free(apiClient->curlConfig);
apiClient->curlConfig = NULL;
}

free(apiClient);
}

Expand Down Expand Up @@ -421,7 +434,6 @@ void apiClient_invoke(apiClient_t *apiClient,
CURLOPT_WRITEDATA,
apiClient);
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(handle, CURLOPT_VERBOSE, 0); // to get curl debug msg 0: to disable, 1L:to enable

// this would only be generated for OAuth2 authentication
if(apiClient->accessToken != NULL) {
Expand All @@ -435,6 +447,15 @@ void apiClient_invoke(apiClient_t *apiClient,
postData(handle, bodyParameters, bodyParametersLength);
}

if(apiClient->curlConfig != NULL) {
if(apiClient->curlConfig->keepalive == 1) {
curl_easy_setopt(handle, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(handle, CURLOPT_TCP_KEEPIDLE, apiClient->curlConfig->keepidle);
curl_easy_setopt(handle, CURLOPT_TCP_KEEPINTVL, apiClient->curlConfig->keepintvl);
}
curl_easy_setopt(handle, CURLOPT_VERBOSE, apiClient->curlConfig->verbose);
}

res = curl_easy_perform(handle);

curl_slist_free_all(headers);
Expand Down
10 changes: 5 additions & 5 deletions samples/client/petstore/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
- Build package: org.openapitools.codegen.languages.CLibcurlClientCodegen

## Installation
You'll need the `curl 7.58.0` package in order to build the API. To have code formatted nicely, you also need to have uncrustify version 0.67 or later.
You'll need the `curl 7.61.1` package in order to build the API. To have code formatted nicely, you also need to have uncrustify version 0.67 or later.

# Prerequisites

## Install the `curl 7.58.0` package with the following command on Linux.
## Install the `curl 7.61.1` package with the following command on Linux.
```bash
sudo apt remove curl
wget http://curl.haxx.se/download/curl-7.58.0.tar.gz
tar -xvf curl-7.58.0.tar.gz
cd curl-7.58.0/
wget http://curl.haxx.se/download/curl-7.61.1.tar.gz
tar -xvf curl-7.61.1.tar.gz
cd curl-7.61.1/
./configure
make
sudo make install
Expand Down
11 changes: 7 additions & 4 deletions samples/client/petstore/c/build-and-test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

set -e

# project
mkdir -p build
cd build

#install latest curl
wget https://curl.haxx.se/download/curl-7.61.1.zip
unzip curl-7.61.1.zip
Expand All @@ -11,10 +15,9 @@ make
sudo make install
cd ..

# project
cmake .

make
# build project
cmake ..
make

if [ -f unit-manual-PetAPI ]; then ./unit-manual-PetAPI; fi
if [ -f unit-manual-UserAPI ]; then ./unit-manual-UserAPI; fi
Expand Down
10 changes: 10 additions & 0 deletions samples/client/petstore/c/include/apiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ typedef struct sslConfig_t {
/* 1 -- skip ssl verify for server certificate */
} sslConfig_t;

typedef struct curlConfig_t {
long verbose; /* 0 -- disable verbose (default) */
/* 1 -- enable verbose */
int keepalive; /* 0 -- disable keepalive (default) */
/* 1 -- enable keepalive */
long keepidle; /* keep-alive idle time: default to 120 seconds */
long keepintvl; /* interval time between keep-alive probes: default to 60 seconds */
} curlConfig_t;

typedef struct apiClient_t {
char *basePath;
sslConfig_t *sslConfig;
curlConfig_t *curlConfig;
void *dataReceived;
long dataReceivedLen;
void (*data_callback_func)(void **, long *);
Expand Down
Loading
Loading