From 4038eddb8ab0513d0776e7de333e41e5dac38734 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 6 Apr 2022 08:52:16 +0800 Subject: [PATCH] comment out error message debug --- .../resources/C-libcurl/api-body.mustache | 7 +- samples/client/petstore/c/api/PetAPI.c | 98 +++++++++++-------- samples/client/petstore/c/api/StoreAPI.c | 56 ++++++----- samples/client/petstore/c/api/UserAPI.c | 91 +++++++++-------- 4 files changed, 144 insertions(+), 108 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache b/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache index 7ee11c71fbcd..4a0c6c116b95 100644 --- a/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache +++ b/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache @@ -326,9 +326,10 @@ end: "{{{httpMethod}}}"); {{#responses}} - if (apiClient->response_code == {{code}}) { - printf("%s\n","{{message}}"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == {{code}}) { + // printf("%s\n","{{message}}"); + //} {{/responses}} {{#returnType}} {{#returnTypeIsPrimitive}} diff --git a/samples/client/petstore/c/api/PetAPI.c b/samples/client/petstore/c/api/PetAPI.c index b5d6f2d61806..515146a12ba2 100644 --- a/samples/client/petstore/c/api/PetAPI.c +++ b/samples/client/petstore/c/api/PetAPI.c @@ -95,9 +95,10 @@ PetAPI_addPet(apiClient_t *apiClient, pet_t * body ) localVarBodyParameters, "POST"); - if (apiClient->response_code == 405) { - printf("%s\n","Invalid input"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 405) { + // printf("%s\n","Invalid input"); + //} //No return type end: if (apiClient->dataReceived) { @@ -174,9 +175,10 @@ PetAPI_deletePet(apiClient_t *apiClient, long petId , char * api_key ) localVarBodyParameters, "DELETE"); - if (apiClient->response_code == 400) { - printf("%s\n","Invalid pet value"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid pet value"); + //} //No return type end: if (apiClient->dataReceived) { @@ -242,12 +244,14 @@ PetAPI_findPetsByStatus(apiClient_t *apiClient, list_t * status ) localVarBodyParameters, "GET"); - if (apiClient->response_code == 200) { - printf("%s\n","successful operation"); - } - if (apiClient->response_code == 400) { - printf("%s\n","Invalid status value"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 200) { + // printf("%s\n","successful operation"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid status value"); + //} cJSON *PetAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived); if(!cJSON_IsArray(PetAPIlocalVarJSON)) { return 0;//nonprimitive container @@ -324,12 +328,14 @@ PetAPI_findPetsByTags(apiClient_t *apiClient, list_t * tags ) localVarBodyParameters, "GET"); - if (apiClient->response_code == 200) { - printf("%s\n","successful operation"); - } - if (apiClient->response_code == 400) { - printf("%s\n","Invalid tag value"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 200) { + // printf("%s\n","successful operation"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid tag value"); + //} cJSON *PetAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived); if(!cJSON_IsArray(PetAPIlocalVarJSON)) { return 0;//nonprimitive container @@ -414,15 +420,18 @@ PetAPI_getPetById(apiClient_t *apiClient, long petId ) localVarBodyParameters, "GET"); - if (apiClient->response_code == 200) { - printf("%s\n","successful operation"); - } - if (apiClient->response_code == 400) { - printf("%s\n","Invalid ID supplied"); - } - if (apiClient->response_code == 404) { - printf("%s\n","Pet not found"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 200) { + // printf("%s\n","successful operation"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid ID supplied"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 404) { + // printf("%s\n","Pet not found"); + //} //nonprimitive not container cJSON *PetAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived); pet_t *elementToReturn = pet_parseFromJSON(PetAPIlocalVarJSON); @@ -491,15 +500,18 @@ PetAPI_updatePet(apiClient_t *apiClient, pet_t * body ) localVarBodyParameters, "PUT"); - if (apiClient->response_code == 400) { - printf("%s\n","Invalid ID supplied"); - } - if (apiClient->response_code == 404) { - printf("%s\n","Pet not found"); - } - if (apiClient->response_code == 405) { - printf("%s\n","Validation exception"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid ID supplied"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 404) { + // printf("%s\n","Pet not found"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 405) { + // printf("%s\n","Validation exception"); + //} //No return type end: if (apiClient->dataReceived) { @@ -589,9 +601,10 @@ PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId , char * name , char localVarBodyParameters, "POST"); - if (apiClient->response_code == 405) { - printf("%s\n","Invalid input"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 405) { + // printf("%s\n","Invalid input"); + //} //No return type end: if (apiClient->dataReceived) { @@ -696,9 +709,10 @@ PetAPI_uploadFile(apiClient_t *apiClient, long petId , char * additionalMetadata localVarBodyParameters, "POST"); - if (apiClient->response_code == 200) { - printf("%s\n","successful operation"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 200) { + // printf("%s\n","successful operation"); + //} //nonprimitive not container cJSON *PetAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived); api_response_t *elementToReturn = api_response_parseFromJSON(PetAPIlocalVarJSON); diff --git a/samples/client/petstore/c/api/StoreAPI.c b/samples/client/petstore/c/api/StoreAPI.c index 8086a57a64c2..3208b8ae53a2 100644 --- a/samples/client/petstore/c/api/StoreAPI.c +++ b/samples/client/petstore/c/api/StoreAPI.c @@ -53,12 +53,14 @@ StoreAPI_deleteOrder(apiClient_t *apiClient, char * orderId ) localVarBodyParameters, "DELETE"); - if (apiClient->response_code == 400) { - printf("%s\n","Invalid ID supplied"); - } - if (apiClient->response_code == 404) { - printf("%s\n","Order not found"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid ID supplied"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 404) { + // printf("%s\n","Order not found"); + //} //No return type end: if (apiClient->dataReceived) { @@ -108,9 +110,10 @@ StoreAPI_getInventory(apiClient_t *apiClient) localVarBodyParameters, "GET"); - if (apiClient->response_code == 200) { - printf("%s\n","successful operation"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 200) { + // printf("%s\n","successful operation"); + //} //primitive return type not simple cJSON *localVarJSON = cJSON_Parse(apiClient->dataReceived); cJSON *VarJSON; @@ -186,15 +189,18 @@ StoreAPI_getOrderById(apiClient_t *apiClient, long orderId ) localVarBodyParameters, "GET"); - if (apiClient->response_code == 200) { - printf("%s\n","successful operation"); - } - if (apiClient->response_code == 400) { - printf("%s\n","Invalid ID supplied"); - } - if (apiClient->response_code == 404) { - printf("%s\n","Order not found"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 200) { + // printf("%s\n","successful operation"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid ID supplied"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 404) { + // printf("%s\n","Order not found"); + //} //nonprimitive not container cJSON *StoreAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived); order_t *elementToReturn = order_parseFromJSON(StoreAPIlocalVarJSON); @@ -263,12 +269,14 @@ StoreAPI_placeOrder(apiClient_t *apiClient, order_t * body ) localVarBodyParameters, "POST"); - if (apiClient->response_code == 200) { - printf("%s\n","successful operation"); - } - if (apiClient->response_code == 400) { - printf("%s\n","Invalid Order"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 200) { + // printf("%s\n","successful operation"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid Order"); + //} //nonprimitive not container cJSON *StoreAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived); order_t *elementToReturn = order_parseFromJSON(StoreAPIlocalVarJSON); diff --git a/samples/client/petstore/c/api/UserAPI.c b/samples/client/petstore/c/api/UserAPI.c index de32d2eef0d6..dff8c0934250 100644 --- a/samples/client/petstore/c/api/UserAPI.c +++ b/samples/client/petstore/c/api/UserAPI.c @@ -52,9 +52,10 @@ UserAPI_createUser(apiClient_t *apiClient, user_t * body ) localVarBodyParameters, "POST"); - if (apiClient->response_code == 0) { - printf("%s\n","successful operation"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 0) { + // printf("%s\n","successful operation"); + //} //No return type end: if (apiClient->dataReceived) { @@ -134,9 +135,10 @@ UserAPI_createUsersWithArrayInput(apiClient_t *apiClient, list_t * body ) localVarBodyParameters, "POST"); - if (apiClient->response_code == 0) { - printf("%s\n","successful operation"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 0) { + // printf("%s\n","successful operation"); + //} //No return type end: if (apiClient->dataReceived) { @@ -224,9 +226,10 @@ UserAPI_createUsersWithListInput(apiClient_t *apiClient, list_t * body ) localVarBodyParameters, "POST"); - if (apiClient->response_code == 0) { - printf("%s\n","successful operation"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 0) { + // printf("%s\n","successful operation"); + //} //No return type end: if (apiClient->dataReceived) { @@ -297,12 +300,14 @@ UserAPI_deleteUser(apiClient_t *apiClient, char * username ) localVarBodyParameters, "DELETE"); - if (apiClient->response_code == 400) { - printf("%s\n","Invalid username supplied"); - } - if (apiClient->response_code == 404) { - printf("%s\n","User not found"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid username supplied"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 404) { + // printf("%s\n","User not found"); + //} //No return type end: if (apiClient->dataReceived) { @@ -361,15 +366,18 @@ UserAPI_getUserByName(apiClient_t *apiClient, char * username ) localVarBodyParameters, "GET"); - if (apiClient->response_code == 200) { - printf("%s\n","successful operation"); - } - if (apiClient->response_code == 400) { - printf("%s\n","Invalid username supplied"); - } - if (apiClient->response_code == 404) { - printf("%s\n","User not found"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 200) { + // printf("%s\n","successful operation"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid username supplied"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 404) { + // printf("%s\n","User not found"); + //} //nonprimitive not container cJSON *UserAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived); user_t *elementToReturn = user_parseFromJSON(UserAPIlocalVarJSON); @@ -453,12 +461,14 @@ UserAPI_loginUser(apiClient_t *apiClient, char * username , char * password ) localVarBodyParameters, "GET"); - if (apiClient->response_code == 200) { - printf("%s\n","successful operation"); - } - if (apiClient->response_code == 400) { - printf("%s\n","Invalid username/password supplied"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 200) { + // printf("%s\n","successful operation"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid username/password supplied"); + //} //primitive return type simple char* elementToReturn = strdup((char*)apiClient->dataReceived); @@ -533,9 +543,10 @@ UserAPI_logoutUser(apiClient_t *apiClient) localVarBodyParameters, "GET"); - if (apiClient->response_code == 0) { - printf("%s\n","successful operation"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 0) { + // printf("%s\n","successful operation"); + //} //No return type end: if (apiClient->dataReceived) { @@ -602,12 +613,14 @@ UserAPI_updateUser(apiClient_t *apiClient, char * username , user_t * body ) localVarBodyParameters, "PUT"); - if (apiClient->response_code == 400) { - printf("%s\n","Invalid user supplied"); - } - if (apiClient->response_code == 404) { - printf("%s\n","User not found"); - } + // uncomment below to debug the error response + //if (apiClient->response_code == 400) { + // printf("%s\n","Invalid user supplied"); + //} + // uncomment below to debug the error response + //if (apiClient->response_code == 404) { + // printf("%s\n","User not found"); + //} //No return type end: if (apiClient->dataReceived) {