* New modified model header and body mustache for c client generator * remove uncrustify from cmake as it is used during code generation, also remove valgrind as it is not used * add function to encode and decode binary data * update model mustache * update api body and header mustache for handling all types of parameters * update model mustache with variable names and address few more issues to generate working codes * updated api body and header mustaches with support for various new parameters and fix some issues as per new changes in code flow structure * update apiClient header and body mustache as per new modifications for handling binary data and few more stuff * updated samples generated by new modified mustache * update handling of file and binary data type to binary_t * update samples with recent commit on master regarding c-generator * update cmakelist which was ignored by .openapi-generator-ignore, cleanup external folder * update CMakeList mustache to show how to use compiled libary to compile source files * update samples with new cmake * Add comments explaining what each command is doing inshort * remove freeing of base path as it is not memory allocated * update samples to free apiclient object when the requirement is over * add missing cJSON delete to fix memory not freed bugs * use uncrustify to beautify manual written test code
C API client for openapi_petstore
Overview
This API client was generated by the OpenAPI Generator project. By using the OpenAPI spec from a remote server, you can easily generate an API client.
- API version: 1.0.0
- Package version:
- 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.
Prerequisites
Install the curl 7.58.0
package with the following command on Linux.
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/
./configure
make
sudo make install
Install the uncrustify 0.67
package with the following command on Linux.
git clone https://github.com/uncrustify/uncrustify.git
cd uncrustify
mkdir build
cd build
cmake ..
make
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.
mkdir build
cd build
// To install library to specific location use following command
cmake -DCMAKE_INSTALL_PREFIX=/pathtolocaiton ..
// for normal install use following command
cmake ..
make
sudo make install
How to use compiled library
Considering the test/source code which uses the API is written in main.c(respective api include is written and all objects necessary are defined and created)
To compile main.c(considering the file is present in build folder) use following command -L - locaiton of the library(not required if cmake with normal installation is performed) -l library name
gcc main.c -L. -lpetstore -o main
once compile, 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.