Skip to content

Commit 543952e

Browse files
committed
Update samples
1 parent 84c9b24 commit 543952e

31 files changed

+736
-39
lines changed

samples/client/others/c/bearerAuth/.openapi-generator/FILES

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CMakeLists.txt
2+
Config.cmake.in
23
Packing.cmake
34
README.md
45
api/DefaultAPI.c

samples/client/others/c/bearerAuth/CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
cmake_minimum_required (VERSION 2.6...3.10.2)
2-
project (CGenerator)
2+
project (CGenerator C)
33

44
cmake_policy(SET CMP0063 NEW)
55

66
set(CMAKE_C_VISIBILITY_PRESET default)
7-
set(CMAKE_CXX_VISIBILITY_PRESET default)
87
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
98
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
109

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)
4+
5+
check_required_components("@PROJECT_NAME@")

samples/client/others/c/bearerAuth/api/DefaultAPI.c

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ DefaultAPI_privateGet(apiClient_t *apiClient)
2525
list_t *localVarHeaderType = list_createList();
2626
list_t *localVarContentType = NULL;
2727
char *localVarBodyParameters = NULL;
28+
size_t localVarBodyLength = 0;
2829

2930
// clear the error code from the previous api call
3031
apiClient->response_code = 0;
@@ -46,6 +47,7 @@ DefaultAPI_privateGet(apiClient_t *apiClient)
4647
localVarHeaderType,
4748
localVarContentType,
4849
localVarBodyParameters,
50+
localVarBodyLength,
4951
"GET");
5052

5153
// uncomment below to debug the error response
@@ -95,6 +97,7 @@ DefaultAPI_publicGet(apiClient_t *apiClient)
9597
list_t *localVarHeaderType = list_createList();
9698
list_t *localVarContentType = NULL;
9799
char *localVarBodyParameters = NULL;
100+
size_t localVarBodyLength = 0;
98101

99102
// clear the error code from the previous api call
100103
apiClient->response_code = 0;
@@ -116,6 +119,7 @@ DefaultAPI_publicGet(apiClient_t *apiClient)
116119
localVarHeaderType,
117120
localVarContentType,
118121
localVarBodyParameters,
122+
localVarBodyLength,
119123
"GET");
120124

121125
// uncomment below to debug the error response
@@ -165,6 +169,7 @@ DefaultAPI_usersGet(apiClient_t *apiClient)
165169
list_t *localVarHeaderType = list_createList();
166170
list_t *localVarContentType = NULL;
167171
char *localVarBodyParameters = NULL;
172+
size_t localVarBodyLength = 0;
168173

169174
// clear the error code from the previous api call
170175
apiClient->response_code = 0;
@@ -186,6 +191,7 @@ DefaultAPI_usersGet(apiClient_t *apiClient)
186191
localVarHeaderType,
187192
localVarContentType,
188193
localVarBodyParameters,
194+
localVarBodyLength,
189195
"GET");
190196

191197
// uncomment below to debug the error response

samples/client/others/c/bearerAuth/include/apiClient.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ apiClient_t* apiClient_create_with_base_path(const char *basePath
3939

4040
void apiClient_free(apiClient_t *apiClient);
4141

42-
void apiClient_invoke(apiClient_t *apiClient,const char* operationParameter, list_t *queryParameters, list_t *headerParameters, list_t *formParameters,list_t *headerType,list_t *contentType, const char *bodyParameters, const char *requestType);
42+
void apiClient_invoke(apiClient_t *apiClient,const char* operationParameter, list_t *queryParameters, list_t *headerParameters, list_t *formParameters,list_t *headerType,list_t *contentType, const char *bodyParameters, size_t bodyParametersLength, const char *requestType);
4343

4444
sslConfig_t *sslConfig_create(const char *clientCertFile, const char *clientKeyFile, const char *CACertFile, int insecureSkipTlsVerify);
4545

samples/client/others/c/bearerAuth/src/apiClient.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ char *assembleHeaderField(char *key, char *value) {
160160
return header;
161161
}
162162

163-
void postData(CURL *handle, const char *bodyParameters) {
163+
void postData(CURL *handle, const char *bodyParameters, size_t bodyParametersLength) {
164164
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, bodyParameters);
165165
curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE_LARGE,
166-
(curl_off_t)strlen(bodyParameters));
166+
(curl_off_t)bodyParametersLength);
167167
}
168168

169169
int lengthOfKeyPair(keyValuePair_t *keyPair) {
@@ -186,7 +186,8 @@ void apiClient_invoke(apiClient_t *apiClient,
186186
list_t *headerType,
187187
list_t *contentType,
188188
const char *bodyParameters,
189-
const char *requestType) {
189+
size_t bodyParametersLength,
190+
const char *requestType) {
190191
CURL *handle = curl_easy_init();
191192
CURLcode res;
192193

@@ -405,7 +406,7 @@ void apiClient_invoke(apiClient_t *apiClient,
405406

406407

407408
if(bodyParameters != NULL) {
408-
postData(handle, bodyParameters);
409+
postData(handle, bodyParameters, bodyParametersLength);
409410
}
410411

411412
res = curl_easy_perform(handle);

samples/client/petstore/c-useJsonUnformatted/.openapi-generator/FILES

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CMakeLists.txt
2+
Config.cmake.in
23
Packing.cmake
34
README.md
45
api/PetAPI.c

samples/client/petstore/c-useJsonUnformatted/CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
cmake_minimum_required (VERSION 2.6...3.10.2)
2-
project (CGenerator)
2+
project (CGenerator C)
33

44
cmake_policy(SET CMP0063 NEW)
55

66
set(CMAKE_C_VISIBILITY_PRESET default)
7-
set(CMAKE_CXX_VISIBILITY_PRESET default)
87
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
98
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
109

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)
4+
5+
check_required_components("@PROJECT_NAME@")

samples/client/petstore/c-useJsonUnformatted/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ Category | Method | HTTP request | Description
8282
*StoreAPI* | [**StoreAPI_getInventory**](docs/StoreAPI.md#StoreAPI_getInventory) | **GET** /store/inventory | Returns pet inventories by status
8383
*StoreAPI* | [**StoreAPI_getOrderById**](docs/StoreAPI.md#StoreAPI_getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
8484
*StoreAPI* | [**StoreAPI_placeOrder**](docs/StoreAPI.md#StoreAPI_placeOrder) | **POST** /store/order | Place an order for a pet
85+
*StoreAPI* | [**StoreAPI_sendFeedback**](docs/StoreAPI.md#StoreAPI_sendFeedback) | **POST** /store/feedback | Send us a feedback message
86+
*StoreAPI* | [**StoreAPI_sendRating**](docs/StoreAPI.md#StoreAPI_sendRating) | **POST** /store/rating/{rating} | How would you rate our service?
8587
*UserAPI* | [**UserAPI_createUser**](docs/UserAPI.md#UserAPI_createUser) | **POST** /user | Create user
8688
*UserAPI* | [**UserAPI_createUsersWithArrayInput**](docs/UserAPI.md#UserAPI_createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
8789
*UserAPI* | [**UserAPI_createUsersWithListInput**](docs/UserAPI.md#UserAPI_createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array

samples/client/petstore/c-useJsonUnformatted/api/PetAPI.c

+34-4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ PetAPI_addPet(apiClient_t *apiClient, pet_t *body)
6666
list_t *localVarHeaderType = NULL;
6767
list_t *localVarContentType = list_createList();
6868
char *localVarBodyParameters = NULL;
69+
size_t localVarBodyLength = 0;
6970

7071
// clear the error code from the previous api call
7172
apiClient->response_code = 0;
@@ -83,9 +84,10 @@ PetAPI_addPet(apiClient_t *apiClient, pet_t *body)
8384
cJSON *localVarSingleItemJSON_body = NULL;
8485
if (body != NULL)
8586
{
86-
//string
87+
//not string, not binary
8788
localVarSingleItemJSON_body = pet_convertToJSON(body);
8889
localVarBodyParameters = cJSON_PrintUnformatted(localVarSingleItemJSON_body);
90+
localVarBodyLength = strlen(localVarBodyParameters);
8991
}
9092
list_addElement(localVarContentType,"application/json"); //consumes
9193
list_addElement(localVarContentType,"application/xml"); //consumes
@@ -97,6 +99,7 @@ PetAPI_addPet(apiClient_t *apiClient, pet_t *body)
9799
localVarHeaderType,
98100
localVarContentType,
99101
localVarBodyParameters,
102+
localVarBodyLength,
100103
"POST");
101104

102105
// uncomment below to debug the error response
@@ -135,6 +138,7 @@ PetAPI_deletePet(apiClient_t *apiClient, long petId, char *api_key)
135138
list_t *localVarHeaderType = NULL;
136139
list_t *localVarContentType = NULL;
137140
char *localVarBodyParameters = NULL;
141+
size_t localVarBodyLength = 0;
138142

139143
// clear the error code from the previous api call
140144
apiClient->response_code = 0;
@@ -181,6 +185,7 @@ PetAPI_deletePet(apiClient_t *apiClient, long petId, char *api_key)
181185
localVarHeaderType,
182186
localVarContentType,
183187
localVarBodyParameters,
188+
localVarBodyLength,
184189
"DELETE");
185190

186191
// uncomment below to debug the error response
@@ -226,6 +231,7 @@ PetAPI_findPetsByStatus(apiClient_t *apiClient, list_t *status)
226231
list_t *localVarHeaderType = list_createList();
227232
list_t *localVarContentType = NULL;
228233
char *localVarBodyParameters = NULL;
234+
size_t localVarBodyLength = 0;
229235

230236
// clear the error code from the previous api call
231237
apiClient->response_code = 0;
@@ -254,6 +260,7 @@ PetAPI_findPetsByStatus(apiClient_t *apiClient, list_t *status)
254260
localVarHeaderType,
255261
localVarContentType,
256262
localVarBodyParameters,
263+
localVarBodyLength,
257264
"GET");
258265

259266
// uncomment below to debug the error response
@@ -317,6 +324,7 @@ PetAPI_findPetsByTags(apiClient_t *apiClient, list_t *tags)
317324
list_t *localVarHeaderType = list_createList();
318325
list_t *localVarContentType = NULL;
319326
char *localVarBodyParameters = NULL;
327+
size_t localVarBodyLength = 0;
320328

321329
// clear the error code from the previous api call
322330
apiClient->response_code = 0;
@@ -345,6 +353,7 @@ PetAPI_findPetsByTags(apiClient_t *apiClient, list_t *tags)
345353
localVarHeaderType,
346354
localVarContentType,
347355
localVarBodyParameters,
356+
localVarBodyLength,
348357
"GET");
349358

350359
// uncomment below to debug the error response
@@ -406,6 +415,7 @@ PetAPI_getDaysWithoutIncident(apiClient_t *apiClient)
406415
list_t *localVarHeaderType = list_createList();
407416
list_t *localVarContentType = NULL;
408417
char *localVarBodyParameters = NULL;
418+
size_t localVarBodyLength = 0;
409419

410420
// clear the error code from the previous api call
411421
apiClient->response_code = 0;
@@ -427,6 +437,7 @@ PetAPI_getDaysWithoutIncident(apiClient_t *apiClient)
427437
localVarHeaderType,
428438
localVarContentType,
429439
localVarBodyParameters,
440+
localVarBodyLength,
430441
"GET");
431442

432443
// uncomment below to debug the error response
@@ -469,6 +480,7 @@ PetAPI_getPetById(apiClient_t *apiClient, long petId)
469480
list_t *localVarHeaderType = list_createList();
470481
list_t *localVarContentType = NULL;
471482
char *localVarBodyParameters = NULL;
483+
size_t localVarBodyLength = 0;
472484

473485
// clear the error code from the previous api call
474486
apiClient->response_code = 0;
@@ -505,6 +517,7 @@ PetAPI_getPetById(apiClient_t *apiClient, long petId)
505517
localVarHeaderType,
506518
localVarContentType,
507519
localVarBodyParameters,
520+
localVarBodyLength,
508521
"GET");
509522

510523
// uncomment below to debug the error response
@@ -561,6 +574,7 @@ PetAPI_getPicture(apiClient_t *apiClient)
561574
list_t *localVarHeaderType = list_createList();
562575
list_t *localVarContentType = NULL;
563576
char *localVarBodyParameters = NULL;
577+
size_t localVarBodyLength = 0;
564578

565579
// clear the error code from the previous api call
566580
apiClient->response_code = 0;
@@ -582,6 +596,7 @@ PetAPI_getPicture(apiClient_t *apiClient)
582596
localVarHeaderType,
583597
localVarContentType,
584598
localVarBodyParameters,
599+
localVarBodyLength,
585600
"GET");
586601

587602
// uncomment below to debug the error response
@@ -622,6 +637,7 @@ PetAPI_isPetAvailable(apiClient_t *apiClient, long petId)
622637
list_t *localVarHeaderType = list_createList();
623638
list_t *localVarContentType = NULL;
624639
char *localVarBodyParameters = NULL;
640+
size_t localVarBodyLength = 0;
625641

626642
// clear the error code from the previous api call
627643
apiClient->response_code = 0;
@@ -657,6 +673,7 @@ PetAPI_isPetAvailable(apiClient_t *apiClient, long petId)
657673
localVarHeaderType,
658674
localVarContentType,
659675
localVarBodyParameters,
676+
localVarBodyLength,
660677
"POST");
661678

662679
// uncomment below to debug the error response
@@ -697,14 +714,15 @@ PetAPI_isPetAvailable(apiClient_t *apiClient, long petId)
697714
// Send a picture of your happy pet
698715
//
699716
char*
700-
PetAPI_sharePicture(apiClient_t *apiClient, char *picture)
717+
PetAPI_sharePicture(apiClient_t *apiClient, binary_t* picture)
701718
{
702719
list_t *localVarQueryParameters = NULL;
703720
list_t *localVarHeaderParameters = NULL;
704721
list_t *localVarFormParameters = NULL;
705722
list_t *localVarHeaderType = list_createList();
706723
list_t *localVarContentType = NULL;
707724
char *localVarBodyParameters = NULL;
725+
size_t localVarBodyLength = 0;
708726

709727
// clear the error code from the previous api call
710728
apiClient->response_code = 0;
@@ -719,7 +737,9 @@ PetAPI_sharePicture(apiClient_t *apiClient, char *picture)
719737

720738

721739
// Body Param
722-
localVarBodyParameters = strdup(picture);
740+
localVarBodyParameters = malloc(picture->len);
741+
memcpy(localVarBodyParameters, picture->data, picture->len);
742+
localVarBodyLength = picture->len;
723743
list_addElement(localVarHeaderType,"*/*"); //produces
724744
apiClient_invoke(apiClient,
725745
localVarPath,
@@ -729,6 +749,7 @@ PetAPI_sharePicture(apiClient_t *apiClient, char *picture)
729749
localVarHeaderType,
730750
localVarContentType,
731751
localVarBodyParameters,
752+
localVarBodyLength,
732753
"POST");
733754

734755
// uncomment below to debug the error response
@@ -772,6 +793,7 @@ PetAPI_specialtyPet(apiClient_t *apiClient)
772793
list_t *localVarHeaderType = list_createList();
773794
list_t *localVarContentType = NULL;
774795
char *localVarBodyParameters = NULL;
796+
size_t localVarBodyLength = 0;
775797

776798
// clear the error code from the previous api call
777799
apiClient->response_code = 0;
@@ -794,6 +816,7 @@ PetAPI_specialtyPet(apiClient_t *apiClient)
794816
localVarHeaderType,
795817
localVarContentType,
796818
localVarBodyParameters,
819+
localVarBodyLength,
797820
"GET");
798821

799822
// uncomment below to debug the error response
@@ -841,6 +864,7 @@ PetAPI_updatePet(apiClient_t *apiClient, pet_t *body)
841864
list_t *localVarHeaderType = NULL;
842865
list_t *localVarContentType = list_createList();
843866
char *localVarBodyParameters = NULL;
867+
size_t localVarBodyLength = 0;
844868

845869
// clear the error code from the previous api call
846870
apiClient->response_code = 0;
@@ -858,9 +882,10 @@ PetAPI_updatePet(apiClient_t *apiClient, pet_t *body)
858882
cJSON *localVarSingleItemJSON_body = NULL;
859883
if (body != NULL)
860884
{
861-
//string
885+
//not string, not binary
862886
localVarSingleItemJSON_body = pet_convertToJSON(body);
863887
localVarBodyParameters = cJSON_PrintUnformatted(localVarSingleItemJSON_body);
888+
localVarBodyLength = strlen(localVarBodyParameters);
864889
}
865890
list_addElement(localVarContentType,"application/json"); //consumes
866891
list_addElement(localVarContentType,"application/xml"); //consumes
@@ -872,6 +897,7 @@ PetAPI_updatePet(apiClient_t *apiClient, pet_t *body)
872897
localVarHeaderType,
873898
localVarContentType,
874899
localVarBodyParameters,
900+
localVarBodyLength,
875901
"PUT");
876902

877903
// uncomment below to debug the error response
@@ -918,6 +944,7 @@ PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId, char *name, char *s
918944
list_t *localVarHeaderType = NULL;
919945
list_t *localVarContentType = list_createList();
920946
char *localVarBodyParameters = NULL;
947+
size_t localVarBodyLength = 0;
921948

922949
// clear the error code from the previous api call
923950
apiClient->response_code = 0;
@@ -977,6 +1004,7 @@ PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId, char *name, char *s
9771004
localVarHeaderType,
9781005
localVarContentType,
9791006
localVarBodyParameters,
1007+
localVarBodyLength,
9801008
"POST");
9811009

9821010
// uncomment below to debug the error response
@@ -1029,6 +1057,7 @@ PetAPI_uploadFile(apiClient_t *apiClient, long petId, char *additionalMetadata,
10291057
list_t *localVarHeaderType = list_createList();
10301058
list_t *localVarContentType = list_createList();
10311059
char *localVarBodyParameters = NULL;
1060+
size_t localVarBodyLength = 0;
10321061

10331062
// clear the error code from the previous api call
10341063
apiClient->response_code = 0;
@@ -1089,6 +1118,7 @@ PetAPI_uploadFile(apiClient_t *apiClient, long petId, char *additionalMetadata,
10891118
localVarHeaderType,
10901119
localVarContentType,
10911120
localVarBodyParameters,
1121+
localVarBodyLength,
10921122
"POST");
10931123

10941124
// uncomment below to debug the error response

0 commit comments

Comments
 (0)