forked from loafle/openapi-generator-original
minor enhancement to c client generaotr (#4457)
This commit is contained in:
parent
440e3f301d
commit
fa1e003a3b
@ -73,11 +73,14 @@ set(HDRS "")
|
||||
## This section shows how to use the above compiled libary to compile the source files
|
||||
## set source files
|
||||
#set(SRCS
|
||||
# unit-tests/manual-PetAPI.c
|
||||
# unit-tests/manual-StoreAPI.c
|
||||
# unit-tests/manual-UserAPI.c
|
||||
# unit-tests/manual-order.c
|
||||
# unit-tests/manual-user.c)
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
# unit-tests/manual-{{classname}}.c
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
#)
|
||||
|
||||
##set header files
|
||||
#set(HDRS
|
||||
|
@ -14,7 +14,7 @@ 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.
|
||||
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.
|
||||
|
||||
# Prerequisites
|
||||
|
||||
@ -40,11 +40,11 @@ sudo make install
|
||||
```
|
||||
|
||||
## Compile the sample:
|
||||
This will compile the generated code and create a library in build folder which has to be linked to the codes where API will be used.
|
||||
This will compile the generated code and create a library in the build folder which has to be linked to the codes where API will be used.
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
// To install library to specific location use following command
|
||||
// To install library to specific location, use following commands
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/pathtolocaiton ..
|
||||
// for normal install use following command
|
||||
cmake ..
|
||||
@ -58,11 +58,11 @@ To compile main.c(considering the file is present in build folder) use following
|
||||
-L - locaiton of the library(not required if cmake with normal installation is performed)
|
||||
-l library name
|
||||
```bash
|
||||
gcc main.c -L. -lpetstore -o main
|
||||
gcc main.c -L. -l{{projectName}} -o main
|
||||
```
|
||||
once compile, you can run it with ``` ./main ```
|
||||
Once compiled, you can run it with ``` ./main ```
|
||||
|
||||
Note: You dont need to specify includes for models and include folder seperately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
|
||||
Note: You don't need to specify includes for models and include folder seperately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
|
||||
|
||||
## Author
|
||||
|
||||
|
@ -21,3 +21,4 @@
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
CMakeLists.txt
|
||||
|
@ -1 +1 @@
|
||||
4.0.0-SNAPSHOT
|
||||
4.2.1-SNAPSHOT
|
@ -52,10 +52,14 @@ set(HDRS
|
||||
|
||||
)
|
||||
|
||||
# Add library with project file with projectname as library name
|
||||
add_library(${pkgName} SHARED ${SRCS} ${HDRS})
|
||||
# Link dependent libraries
|
||||
target_link_libraries(${pkgName} ${CURL_LIBRARIES} )
|
||||
#install library to destination
|
||||
install(TARGETS ${pkgName} DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
# Setting file variables to null
|
||||
set(SRCS "")
|
||||
set(HDRS "")
|
||||
|
||||
|
@ -8,7 +8,7 @@ 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.
|
||||
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.
|
||||
|
||||
# Prerequisites
|
||||
|
||||
@ -34,11 +34,11 @@ sudo make install
|
||||
```
|
||||
|
||||
## Compile the sample:
|
||||
This will compile the generated code and create a library in build folder which has to be linked to the codes where API will be used.
|
||||
This will compile the generated code and create a library in the build folder which has to be linked to the codes where API will be used.
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
// To install library to specific location use following command
|
||||
// To install library to specific location, use following commands
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/pathtolocaiton ..
|
||||
// for normal install use following command
|
||||
cmake ..
|
||||
@ -52,11 +52,11 @@ To compile main.c(considering the file is present in build folder) use following
|
||||
-L - locaiton of the library(not required if cmake with normal installation is performed)
|
||||
-l library name
|
||||
```bash
|
||||
gcc main.c -L. -lpetstore -o main
|
||||
gcc main.c -L. -lopenapi_petstore -o main
|
||||
```
|
||||
once compile, you can run it with ``` ./main ```
|
||||
Once compiled, you can run it with ``` ./main ```
|
||||
|
||||
Note: You dont need to specify includes for models and include folder seperately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
|
||||
Note: You don't need to specify includes for models and include folder seperately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
|
||||
|
||||
## Author
|
||||
|
||||
|
@ -351,7 +351,7 @@ pet_t *PetAPI_getPetById(apiClient_t *apiClient, long petId) {
|
||||
// nonprimitive not container
|
||||
cJSON *PetAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
|
||||
pet_t *elementToReturn = pet_parseFromJSON(PetAPIlocalVarJSON);
|
||||
cJSON_Delete(PetAPIlocalVarJSON);
|
||||
cJSON_Delete(PetAPIlocalVarJSON);
|
||||
if(elementToReturn == NULL) {
|
||||
// return 0;
|
||||
}
|
||||
@ -606,7 +606,7 @@ api_response_t *PetAPI_uploadFile(apiClient_t *apiClient, long petId,
|
||||
cJSON *PetAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
|
||||
api_response_t *elementToReturn = api_response_parseFromJSON(
|
||||
PetAPIlocalVarJSON);
|
||||
cJSON_Delete(PetAPIlocalVarJSON);
|
||||
cJSON_Delete(PetAPIlocalVarJSON);
|
||||
if(elementToReturn == NULL) {
|
||||
// return 0;
|
||||
}
|
||||
|
@ -111,7 +111,8 @@ list_t *StoreAPI_getInventory(apiClient_t *apiClient) {
|
||||
list_t *elementToReturn = list_create();
|
||||
cJSON_ArrayForEach(VarJSON, localVarJSON) {
|
||||
keyValuePair_t *keyPair =
|
||||
keyValuePair_create(strdup(VarJSON->string), cJSON_Print(
|
||||
keyValuePair_create(strdup(
|
||||
VarJSON->string), cJSON_Print(
|
||||
VarJSON));
|
||||
list_addElement(elementToReturn, keyPair);
|
||||
}
|
||||
@ -191,7 +192,7 @@ order_t *StoreAPI_getOrderById(apiClient_t *apiClient, long orderId) {
|
||||
// nonprimitive not container
|
||||
cJSON *StoreAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
|
||||
order_t *elementToReturn = order_parseFromJSON(StoreAPIlocalVarJSON);
|
||||
cJSON_Delete(StoreAPIlocalVarJSON);
|
||||
cJSON_Delete(StoreAPIlocalVarJSON);
|
||||
if(elementToReturn == NULL) {
|
||||
// return 0;
|
||||
}
|
||||
@ -259,7 +260,7 @@ order_t *StoreAPI_placeOrder(apiClient_t *apiClient, order_t *body) {
|
||||
// nonprimitive not container
|
||||
cJSON *StoreAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
|
||||
order_t *elementToReturn = order_parseFromJSON(StoreAPIlocalVarJSON);
|
||||
cJSON_Delete(StoreAPIlocalVarJSON);
|
||||
cJSON_Delete(StoreAPIlocalVarJSON);
|
||||
if(elementToReturn == NULL) {
|
||||
// return 0;
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ user_t *UserAPI_getUserByName(apiClient_t *apiClient, char *username) {
|
||||
// nonprimitive not container
|
||||
cJSON *UserAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
|
||||
user_t *elementToReturn = user_parseFromJSON(UserAPIlocalVarJSON);
|
||||
cJSON_Delete(UserAPIlocalVarJSON);
|
||||
cJSON_Delete(UserAPIlocalVarJSON);
|
||||
if(elementToReturn == NULL) {
|
||||
// return 0;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ apiClient_t *apiClient_create() {
|
||||
}
|
||||
|
||||
void apiClient_free(apiClient_t *apiClient) {
|
||||
if(apiClient->apiKeys) {
|
||||
if(apiClient->accessToken) {
|
||||
list_free(apiClient->apiKeys);
|
||||
}
|
||||
if(apiClient->accessToken) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user