Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,6 @@ end:

localVarPath = strReplace(localVarPath, localVarToReplace_{{paramName}}, {{^isEnum}}{{paramName}}{{/isEnum}}{{#isEnum}}{{{operationId}}}_{{enumName}}_ToString({{paramName}}){{/isEnum}});
{{/isString}}
{{#isUuid}}
if({{paramName}} == NULL) {
goto end;
}
char* localVarToReplace_{{paramName}} = malloc(sizeOfPathParams_{{paramName}});
sprintf(localVarToReplace_{{paramName}}, "{%s}", "{{baseName}}");

localVarPath = strReplace(localVarPath, localVarToReplace_{{paramName}}, {{paramName}});
{{/isUuid}}
{{/pathParams}}


Expand Down
28 changes: 28 additions & 0 deletions modules/openapi-generator/src/test/resources/2_0/c/petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,34 @@ paths:
- petstore_auth:
- 'write:pets'
- 'read:pets'
'/pet/byUuid/{uuid}':
get:
tags:
- pet
summary: Find pet by UUID
description: Returns a single pet identified by UUID
operationId: getPetByUuid
produces:
- application/xml
- application/json
parameters:
- name: uuid
in: path
description: UUID of pet to return
required: true
type: string
format: uuid
responses:
'200':
description: successful operation
schema:
$ref: '#/definitions/Pet'
'400':
description: Invalid UUID supplied
'404':
description: Pet not found
security:
- api_key: []
/pet/picture:
get:
tags:
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/c-useJsonUnformatted/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Category | Method | HTTP request | Description
*PetAPI* | [**PetAPI_findPetsByTags**](docs/PetAPI.md#PetAPI_findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
*PetAPI* | [**PetAPI_getDaysWithoutIncident**](docs/PetAPI.md#PetAPI_getDaysWithoutIncident) | **GET** /store/daysWithoutIncident | Number of days since the last time a pet maimed someone at the store
*PetAPI* | [**PetAPI_getPetById**](docs/PetAPI.md#PetAPI_getPetById) | **GET** /pet/{petId} | Find pet by ID
*PetAPI* | [**PetAPI_getPetByUuid**](docs/PetAPI.md#PetAPI_getPetByUuid) | **GET** /pet/byUuid/{uuid} | Find pet by UUID
*PetAPI* | [**PetAPI_getPicture**](docs/PetAPI.md#PetAPI_getPicture) | **GET** /pet/picture | Get a random picture of someone else's pet
*PetAPI* | [**PetAPI_isPetAvailable**](docs/PetAPI.md#PetAPI_isPetAvailable) | **POST** /pet/{petId}/isAvailable | Is this pet still available?
*PetAPI* | [**PetAPI_sharePicture**](docs/PetAPI.md#PetAPI_sharePicture) | **POST** /pet/picture | Send a picture of your happy pet
Expand Down
92 changes: 92 additions & 0 deletions samples/client/petstore/c-useJsonUnformatted/api/PetAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,98 @@ PetAPI_getPetById(apiClient_t *apiClient, long petId)

}

// Find pet by UUID
//
// Returns a single pet identified by UUID
//
pet_t*
PetAPI_getPetByUuid(apiClient_t *apiClient, char *uuid)
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
list_t *localVarFormParameters = NULL;
list_t *localVarHeaderType = list_createList();
list_t *localVarContentType = NULL;
char *localVarBodyParameters = NULL;
size_t localVarBodyLength = 0;

// clear the error code from the previous api call
apiClient->response_code = 0;

// create the path
char *localVarPath = strdup("/pet/byUuid/{uuid}");

if(!uuid)
goto end;


// Path Params
long sizeOfPathParams_uuid = strlen(uuid)+3 + sizeof("{ uuid }") - 1;
if(uuid == NULL) {
goto end;
}
char* localVarToReplace_uuid = malloc(sizeOfPathParams_uuid);
sprintf(localVarToReplace_uuid, "{%s}", "uuid");

localVarPath = strReplace(localVarPath, localVarToReplace_uuid, uuid);


list_addElement(localVarHeaderType,"application/xml"); //produces
list_addElement(localVarHeaderType,"application/json"); //produces
apiClient_invoke(apiClient,
localVarPath,
localVarQueryParameters,
localVarHeaderParameters,
localVarFormParameters,
localVarHeaderType,
localVarContentType,
localVarBodyParameters,
localVarBodyLength,
"GET");

// 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 UUID supplied");
//}
// uncomment below to debug the error response
//if (apiClient->response_code == 404) {
// printf("%s\n","Pet not found");
//}
//nonprimitive not container
pet_t *elementToReturn = NULL;
if(apiClient->response_code >= 200 && apiClient->response_code < 300) {
cJSON *PetAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
elementToReturn = pet_parseFromJSON(PetAPIlocalVarJSON);
cJSON_Delete(PetAPIlocalVarJSON);
if(elementToReturn == NULL) {
// return 0;
}
}

//return type
if (apiClient->dataReceived) {
free(apiClient->dataReceived);
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
}



list_freeList(localVarHeaderType);

free(localVarPath);
free(localVarToReplace_uuid);
return elementToReturn;
end:
free(localVarPath);
return NULL;

}

// Get a random picture of someone else's pet
//
binary_t*
Expand Down
8 changes: 8 additions & 0 deletions samples/client/petstore/c-useJsonUnformatted/api/PetAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ pet_t*
PetAPI_getPetById(apiClient_t *apiClient, long petId);


// Find pet by UUID
//
// Returns a single pet identified by UUID
//
pet_t*
PetAPI_getPetByUuid(apiClient_t *apiClient, char *uuid);


// Get a random picture of someone else's pet
//
binary_t*
Expand Down
32 changes: 32 additions & 0 deletions samples/client/petstore/c-useJsonUnformatted/docs/PetAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Method | HTTP request | Description
[**PetAPI_findPetsByTags**](PetAPI.md#PetAPI_findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
[**PetAPI_getDaysWithoutIncident**](PetAPI.md#PetAPI_getDaysWithoutIncident) | **GET** /store/daysWithoutIncident | Number of days since the last time a pet maimed someone at the store
[**PetAPI_getPetById**](PetAPI.md#PetAPI_getPetById) | **GET** /pet/{petId} | Find pet by ID
[**PetAPI_getPetByUuid**](PetAPI.md#PetAPI_getPetByUuid) | **GET** /pet/byUuid/{uuid} | Find pet by UUID
[**PetAPI_getPicture**](PetAPI.md#PetAPI_getPicture) | **GET** /pet/picture | Get a random picture of someone else&#39;s pet
[**PetAPI_isPetAvailable**](PetAPI.md#PetAPI_isPetAvailable) | **POST** /pet/{petId}/isAvailable | Is this pet still available?
[**PetAPI_sharePicture**](PetAPI.md#PetAPI_sharePicture) | **POST** /pet/picture | Send a picture of your happy pet
Expand Down Expand Up @@ -187,6 +188,37 @@ Name | Type | Description | Notes
[pet_t](pet.md) *


### Authorization

[api_key](../README.md#api_key)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/xml, application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **PetAPI_getPetByUuid**
```c
// Find pet by UUID
//
// Returns a single pet identified by UUID
//
pet_t* PetAPI_getPetByUuid(apiClient_t *apiClient, char *uuid);
```

### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**apiClient** | **apiClient_t \*** | context containing the client configuration |
**uuid** | **char \*** | UUID of pet to return |

### Return type

[pet_t](pet.md) *


### Authorization

[api_key](../README.md#api_key)
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Category | Method | HTTP request | Description
*PetAPI* | [**PetAPI_findPetsByTags**](docs/PetAPI.md#PetAPI_findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
*PetAPI* | [**PetAPI_getDaysWithoutIncident**](docs/PetAPI.md#PetAPI_getDaysWithoutIncident) | **GET** /store/daysWithoutIncident | Number of days since the last time a pet maimed someone at the store
*PetAPI* | [**PetAPI_getPetById**](docs/PetAPI.md#PetAPI_getPetById) | **GET** /pet/{petId} | Find pet by ID
*PetAPI* | [**PetAPI_getPetByUuid**](docs/PetAPI.md#PetAPI_getPetByUuid) | **GET** /pet/byUuid/{uuid} | Find pet by UUID
*PetAPI* | [**PetAPI_getPicture**](docs/PetAPI.md#PetAPI_getPicture) | **GET** /pet/picture | Get a random picture of someone else's pet
*PetAPI* | [**PetAPI_isPetAvailable**](docs/PetAPI.md#PetAPI_isPetAvailable) | **POST** /pet/{petId}/isAvailable | Is this pet still available?
*PetAPI* | [**PetAPI_sharePicture**](docs/PetAPI.md#PetAPI_sharePicture) | **POST** /pet/picture | Send a picture of your happy pet
Expand Down
92 changes: 92 additions & 0 deletions samples/client/petstore/c/api/PetAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,98 @@ PetAPI_getPetById(apiClient_t *apiClient, long petId)

}

// Find pet by UUID
//
// Returns a single pet identified by UUID
//
pet_t*
PetAPI_getPetByUuid(apiClient_t *apiClient, char *uuid)
{
list_t *localVarQueryParameters = NULL;
list_t *localVarHeaderParameters = NULL;
list_t *localVarFormParameters = NULL;
list_t *localVarHeaderType = list_createList();
list_t *localVarContentType = NULL;
char *localVarBodyParameters = NULL;
size_t localVarBodyLength = 0;

// clear the error code from the previous api call
apiClient->response_code = 0;

// create the path
char *localVarPath = strdup("/pet/byUuid/{uuid}");

if(!uuid)
goto end;


// Path Params
long sizeOfPathParams_uuid = strlen(uuid)+3 + sizeof("{ uuid }") - 1;
if(uuid == NULL) {
goto end;
}
char* localVarToReplace_uuid = malloc(sizeOfPathParams_uuid);
sprintf(localVarToReplace_uuid, "{%s}", "uuid");

localVarPath = strReplace(localVarPath, localVarToReplace_uuid, uuid);


list_addElement(localVarHeaderType,"application/xml"); //produces
list_addElement(localVarHeaderType,"application/json"); //produces
apiClient_invoke(apiClient,
localVarPath,
localVarQueryParameters,
localVarHeaderParameters,
localVarFormParameters,
localVarHeaderType,
localVarContentType,
localVarBodyParameters,
localVarBodyLength,
"GET");

// 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 UUID supplied");
//}
// uncomment below to debug the error response
//if (apiClient->response_code == 404) {
// printf("%s\n","Pet not found");
//}
//nonprimitive not container
pet_t *elementToReturn = NULL;
if(apiClient->response_code >= 200 && apiClient->response_code < 300) {
cJSON *PetAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
elementToReturn = pet_parseFromJSON(PetAPIlocalVarJSON);
cJSON_Delete(PetAPIlocalVarJSON);
if(elementToReturn == NULL) {
// return 0;
}
}

//return type
if (apiClient->dataReceived) {
free(apiClient->dataReceived);
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
}



list_freeList(localVarHeaderType);

free(localVarPath);
free(localVarToReplace_uuid);
return elementToReturn;
end:
free(localVarPath);
return NULL;

}

// Get a random picture of someone else's pet
//
binary_t*
Expand Down
8 changes: 8 additions & 0 deletions samples/client/petstore/c/api/PetAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ pet_t*
PetAPI_getPetById(apiClient_t *apiClient, long petId);


// Find pet by UUID
//
// Returns a single pet identified by UUID
//
pet_t*
PetAPI_getPetByUuid(apiClient_t *apiClient, char *uuid);


// Get a random picture of someone else's pet
//
binary_t*
Expand Down
32 changes: 32 additions & 0 deletions samples/client/petstore/c/docs/PetAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Method | HTTP request | Description
[**PetAPI_findPetsByTags**](PetAPI.md#PetAPI_findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
[**PetAPI_getDaysWithoutIncident**](PetAPI.md#PetAPI_getDaysWithoutIncident) | **GET** /store/daysWithoutIncident | Number of days since the last time a pet maimed someone at the store
[**PetAPI_getPetById**](PetAPI.md#PetAPI_getPetById) | **GET** /pet/{petId} | Find pet by ID
[**PetAPI_getPetByUuid**](PetAPI.md#PetAPI_getPetByUuid) | **GET** /pet/byUuid/{uuid} | Find pet by UUID
[**PetAPI_getPicture**](PetAPI.md#PetAPI_getPicture) | **GET** /pet/picture | Get a random picture of someone else&#39;s pet
[**PetAPI_isPetAvailable**](PetAPI.md#PetAPI_isPetAvailable) | **POST** /pet/{petId}/isAvailable | Is this pet still available?
[**PetAPI_sharePicture**](PetAPI.md#PetAPI_sharePicture) | **POST** /pet/picture | Send a picture of your happy pet
Expand Down Expand Up @@ -187,6 +188,37 @@ Name | Type | Description | Notes
[pet_t](pet.md) *


### Authorization

[api_key](../README.md#api_key)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/xml, application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **PetAPI_getPetByUuid**
```c
// Find pet by UUID
//
// Returns a single pet identified by UUID
//
pet_t* PetAPI_getPetByUuid(apiClient_t *apiClient, char *uuid);
```

### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**apiClient** | **apiClient_t \*** | context containing the client configuration |
**uuid** | **char \*** | UUID of pet to return |

### Return type

[pet_t](pet.md) *


### Authorization

[api_key](../README.md#api_key)
Expand Down
Loading