Skip to content

Commit

Permalink
Change to C API mustache files to solve issue OpenAPITools#5623
Browse files Browse the repository at this point in the history
  • Loading branch information
michelealbano committed Mar 18, 2020
1 parent 806f206 commit ee01a9e
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ end:
//
{{/notes}}
{{#returnType}}{{#returnTypeIsPrimitive}}{{#returnSimpleType}}{{{.}}}*{{/returnSimpleType}}{{^returnSimpleType}}{{#isListContainer}}{{{.}}}_t*{{/isListContainer}}{{#isMapContainer}}{{{.}}}{{/isMapContainer}}{{/returnSimpleType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{{.}}}_t*{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void{{/returnType}}
{{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{^isListContainer}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isListContainer}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{#isContainer}}{{#isListContainer}}{{dataType}}_t *{{/isListContainer}}{{#isMapContainer}}{{dataType}}{{/isMapContainer}}{{/isContainer}} {{{paramName}}}{{/allParams}})
{{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isListContainer}}{{^isPrimitiveType}}
{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{/isListContainer}}{{#isContainer}}{{#isListContainer}}{{dataType}}_t *{{/isListContainer}}{{#isMapContainer}}{{dataType}}{{/isMapContainer}}{{/isContainer}} {{{paramName}}} {{/allParams}})
{
list_t *localVarQueryParameters = {{#hasQueryParams}}list_create();{{/hasQueryParams}}{{^hasQueryParams}}NULL;{{/hasQueryParams}}
list_t *localVarHeaderParameters = {{#hasHeaderParams}}list_create();{{/hasHeaderParams}}{{^hasHeaderParams}}NULL;{{/hasHeaderParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ typedef enum { {{projectName}}_{{operationId}}_{{enumName}}_NULL = 0{{#enumVars
//
{{/notes}}
{{#returnType}}{{#returnTypeIsPrimitive}}{{#returnSimpleType}}{{{.}}}*{{/returnSimpleType}}{{^returnSimpleType}}{{#isListContainer}}{{{.}}}_t*{{/isListContainer}}{{#isMapContainer}}{{{.}}}{{/isMapContainer}}{{/returnSimpleType}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{{.}}}_t*{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void{{/returnType}}
{{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}} ,{{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{^isListContainer}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isListContainer}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{#isContainer}}{{#isListContainer}}{{dataType}}_t *{{/isListContainer}}{{#isMapContainer}}{{dataType}}{{/isMapContainer}}{{/isContainer}} {{{paramName}}}{{/allParams}});
{{{classname}}}_{{{operationId}}}(apiClient_t *apiClient{{#allParams}}, {{#isPrimitiveType}}{{#isNumber}}{{{dataType}}}{{/isNumber}}{{#isLong}}{{{dataType}}}{{/isLong}}{{#isInteger}}{{{dataType}}}{{/isInteger}}{{#isDouble}}{{{dataType}}}{{/isDouble}}{{#isFloat}}{{{dataType}}}{{/isFloat}}{{#isBoolean}}{{dataType}}{{/isBoolean}}{{#isEnum}}{{#isString}}{{projectName}}_{{operationId}}_{{baseName}}_e{{/isString}}{{/isEnum}}{{^isEnum}}{{#isString}}{{{dataType}}} *{{/isString}}{{/isEnum}}{{#isByteArray}}{{{dataType}}}{{/isByteArray}}{{#isDate}}{{{dataType}}}{{/isDate}}{{#isDateTime}}{{{dataType}}}{{/isDateTime}}{{#isFile}}{{{dataType}}}{{/isFile}}{{#isFreeFormObject}}{{dataType}}_t *{{/isFreeFormObject}}{{/isPrimitiveType}}{{^isListContainer}}{{^isPrimitiveType}}
{{#isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{^isEnum}}{{{dataType}}}_t *{{/isEnum}}{{/isModel}}{{^isModel}}{{#isEnum}}{{datatypeWithEnum}}_e{{/isEnum}}{{/isModel}}{{#isUuid}}{{dataType}} *{{/isUuid}}{{#isEmail}}{{dataType}}{{/isEmail}}{{/isPrimitiveType}}{{/isListContainer}}{{#isContainer}}{{#isListContainer}}{{dataType}}_t *{{/isListContainer}}{{#isMapContainer}}{{dataType}}{{/isMapContainer}}{{/isContainer}} {{{paramName}}} {{/allParams}});


{{/operation}}
Expand Down
18 changes: 10 additions & 8 deletions samples/client/petstore/c/api/PetAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ static openapi_petstore_findPetsByStatus_status_e findPetsByStatus_STATUS_parseF
// Add a new pet to the store
//
void
PetAPI_addPet(apiClient_t *apiClient, pet_t * body)
PetAPI_addPet(apiClient_t *apiClient,
pet_t * body )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -117,7 +118,7 @@ PetAPI_addPet(apiClient_t *apiClient, pet_t * body)
// Deletes a pet
//
void
PetAPI_deletePet(apiClient_t *apiClient, long petId, char * api_key)
PetAPI_deletePet(apiClient_t *apiClient, long petId , char * api_key )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = list_create();
Expand Down Expand Up @@ -195,7 +196,7 @@ PetAPI_deletePet(apiClient_t *apiClient, long petId, char * api_key)
// Multiple status values can be provided with comma separated strings
//
list_t*
PetAPI_findPetsByStatus(apiClient_t *apiClient, list_t * status)
PetAPI_findPetsByStatus(apiClient_t *apiClient, list_t * status )
{
list_t *localVarQueryParameters = list_create();
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -274,7 +275,7 @@ PetAPI_findPetsByStatus(apiClient_t *apiClient, list_t * status)
// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
//
list_t*
PetAPI_findPetsByTags(apiClient_t *apiClient, list_t * tags)
PetAPI_findPetsByTags(apiClient_t *apiClient, list_t * tags )
{
list_t *localVarQueryParameters = list_create();
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -353,7 +354,7 @@ PetAPI_findPetsByTags(apiClient_t *apiClient, list_t * tags)
// Returns a single pet
//
pet_t*
PetAPI_getPetById(apiClient_t *apiClient, long petId)
PetAPI_getPetById(apiClient_t *apiClient, long petId )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -432,7 +433,8 @@ PetAPI_getPetById(apiClient_t *apiClient, long petId)
// Update an existing pet
//
void
PetAPI_updatePet(apiClient_t *apiClient, pet_t * body)
PetAPI_updatePet(apiClient_t *apiClient,
pet_t * body )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -497,7 +499,7 @@ PetAPI_updatePet(apiClient_t *apiClient, pet_t * body)
// Updates a pet in the store with form data
//
void
PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId, char * name, char * status)
PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId , char * name , char * status )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -589,7 +591,7 @@ PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId, char * name, char *
// uploads an image
//
api_response_t*
PetAPI_uploadFile(apiClient_t *apiClient, long petId, char * additionalMetadata, binary_t* file)
PetAPI_uploadFile(apiClient_t *apiClient, long petId , char * additionalMetadata , binary_t* file )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down
18 changes: 10 additions & 8 deletions samples/client/petstore/c/api/PetAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,56 @@ typedef enum { openapi_petstore_findPetsByStatus_STATUS_NULL = 0, openapi_petst
// Add a new pet to the store
//
void
PetAPI_addPet(apiClient_t *apiClient ,pet_t * body);
PetAPI_addPet(apiClient_t *apiClient,
pet_t * body );


// Deletes a pet
//
void
PetAPI_deletePet(apiClient_t *apiClient ,long petId ,char * api_key);
PetAPI_deletePet(apiClient_t *apiClient, long petId , char * api_key );


// Finds Pets by status
//
// Multiple status values can be provided with comma separated strings
//
list_t*
PetAPI_findPetsByStatus(apiClient_t *apiClient ,list_t * status);
PetAPI_findPetsByStatus(apiClient_t *apiClient, list_t * status );


// Finds Pets by tags
//
// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
//
list_t*
PetAPI_findPetsByTags(apiClient_t *apiClient ,list_t * tags);
PetAPI_findPetsByTags(apiClient_t *apiClient, list_t * tags );


// Find pet by ID
//
// Returns a single pet
//
pet_t*
PetAPI_getPetById(apiClient_t *apiClient ,long petId);
PetAPI_getPetById(apiClient_t *apiClient, long petId );


// Update an existing pet
//
void
PetAPI_updatePet(apiClient_t *apiClient ,pet_t * body);
PetAPI_updatePet(apiClient_t *apiClient,
pet_t * body );


// Updates a pet in the store with form data
//
void
PetAPI_updatePetWithForm(apiClient_t *apiClient ,long petId ,char * name ,char * status);
PetAPI_updatePetWithForm(apiClient_t *apiClient, long petId , char * name , char * status );


// uploads an image
//
api_response_t*
PetAPI_uploadFile(apiClient_t *apiClient ,long petId ,char * additionalMetadata ,binary_t* file);
PetAPI_uploadFile(apiClient_t *apiClient, long petId , char * additionalMetadata , binary_t* file );


7 changes: 4 additions & 3 deletions samples/client/petstore/c/api/StoreAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
//
void
StoreAPI_deleteOrder(apiClient_t *apiClient, char * orderId)
StoreAPI_deleteOrder(apiClient_t *apiClient, char * orderId )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -139,7 +139,7 @@ StoreAPI_getInventory(apiClient_t *apiClient)
// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
//
order_t*
StoreAPI_getOrderById(apiClient_t *apiClient, long orderId)
StoreAPI_getOrderById(apiClient_t *apiClient, long orderId )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -218,7 +218,8 @@ StoreAPI_getOrderById(apiClient_t *apiClient, long orderId)
// Place an order for a pet
//
order_t*
StoreAPI_placeOrder(apiClient_t *apiClient, order_t * body)
StoreAPI_placeOrder(apiClient_t *apiClient,
order_t * body )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down
7 changes: 4 additions & 3 deletions samples/client/petstore/c/api/StoreAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
//
void
StoreAPI_deleteOrder(apiClient_t *apiClient ,char * orderId);
StoreAPI_deleteOrder(apiClient_t *apiClient, char * orderId );


// Returns pet inventories by status
Expand All @@ -28,12 +28,13 @@ StoreAPI_getInventory(apiClient_t *apiClient);
// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
//
order_t*
StoreAPI_getOrderById(apiClient_t *apiClient ,long orderId);
StoreAPI_getOrderById(apiClient_t *apiClient, long orderId );


// Place an order for a pet
//
order_t*
StoreAPI_placeOrder(apiClient_t *apiClient ,order_t * body);
StoreAPI_placeOrder(apiClient_t *apiClient,
order_t * body );


16 changes: 9 additions & 7 deletions samples/client/petstore/c/api/UserAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
// This can only be done by the logged in user.
//
void
UserAPI_createUser(apiClient_t *apiClient, user_t * body)
UserAPI_createUser(apiClient_t *apiClient,
user_t * body )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -74,7 +75,7 @@ UserAPI_createUser(apiClient_t *apiClient, user_t * body)
// Creates list of users with given input array
//
void
UserAPI_createUsersWithArrayInput(apiClient_t *apiClient, list_t * body)
UserAPI_createUsersWithArrayInput(apiClient_t *apiClient, list_t * body )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -153,7 +154,7 @@ UserAPI_createUsersWithArrayInput(apiClient_t *apiClient, list_t * body)
// Creates list of users with given input array
//
void
UserAPI_createUsersWithListInput(apiClient_t *apiClient, list_t * body)
UserAPI_createUsersWithListInput(apiClient_t *apiClient, list_t * body )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -234,7 +235,7 @@ UserAPI_createUsersWithListInput(apiClient_t *apiClient, list_t * body)
// This can only be done by the logged in user.
//
void
UserAPI_deleteUser(apiClient_t *apiClient, char * username)
UserAPI_deleteUser(apiClient_t *apiClient, char * username )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -294,7 +295,7 @@ UserAPI_deleteUser(apiClient_t *apiClient, char * username)
// Get user by user name
//
user_t*
UserAPI_getUserByName(apiClient_t *apiClient, char * username)
UserAPI_getUserByName(apiClient_t *apiClient, char * username )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -369,7 +370,7 @@ UserAPI_getUserByName(apiClient_t *apiClient, char * username)
// Logs user into the system
//
char*
UserAPI_loginUser(apiClient_t *apiClient, char * username, char * password)
UserAPI_loginUser(apiClient_t *apiClient, char * username , char * password )
{
list_t *localVarQueryParameters = list_create();
list_t *localVarHeaderParameters = NULL;
Expand Down Expand Up @@ -520,7 +521,8 @@ UserAPI_logoutUser(apiClient_t *apiClient)
// This can only be done by the logged in user.
//
void
UserAPI_updateUser(apiClient_t *apiClient, char * username, user_t * body)
UserAPI_updateUser(apiClient_t *apiClient, char * username ,
user_t * body )
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
Expand Down
16 changes: 9 additions & 7 deletions samples/client/petstore/c/api/UserAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,40 @@
// This can only be done by the logged in user.
//
void
UserAPI_createUser(apiClient_t *apiClient ,user_t * body);
UserAPI_createUser(apiClient_t *apiClient,
user_t * body );


// Creates list of users with given input array
//
void
UserAPI_createUsersWithArrayInput(apiClient_t *apiClient ,list_t * body);
UserAPI_createUsersWithArrayInput(apiClient_t *apiClient, list_t * body );


// Creates list of users with given input array
//
void
UserAPI_createUsersWithListInput(apiClient_t *apiClient ,list_t * body);
UserAPI_createUsersWithListInput(apiClient_t *apiClient, list_t * body );


// Delete user
//
// This can only be done by the logged in user.
//
void
UserAPI_deleteUser(apiClient_t *apiClient ,char * username);
UserAPI_deleteUser(apiClient_t *apiClient, char * username );


// Get user by user name
//
user_t*
UserAPI_getUserByName(apiClient_t *apiClient ,char * username);
UserAPI_getUserByName(apiClient_t *apiClient, char * username );


// Logs user into the system
//
char*
UserAPI_loginUser(apiClient_t *apiClient ,char * username ,char * password);
UserAPI_loginUser(apiClient_t *apiClient, char * username , char * password );


// Logs out current logged in user session
Expand All @@ -58,6 +59,7 @@ UserAPI_logoutUser(apiClient_t *apiClient);
// This can only be done by the logged in user.
//
void
UserAPI_updateUser(apiClient_t *apiClient ,char * username ,user_t * body);
UserAPI_updateUser(apiClient_t *apiClient, char * username ,
user_t * body );


4 changes: 4 additions & 0 deletions samples/client/petstore/c/model/pet.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ cJSON *pet_convertToJSON(pet_t *pet) {
{
goto fail;
}
if(cJSON_AddNumberToObject(photo_urls, "", *(double *)photo_urlsListEntry->data) == NULL)
{
goto fail;
}
}


Expand Down

0 comments on commit ee01a9e

Please sign in to comment.