# C++ Qt6API client

OpenAPI Generated Petstore Client

- API version: 1.0.0
- Generator version: 7.18.0

This is a sample of Petstore application.


*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*


## Requirements

Building the API client library requires:

1. CMake 3.22+
2. Qt 6.11+
3. C++17 Compiler

## Getting Started

# Documentation for OpenAPI Generated Petstore Client 1.0.0 Qt6 Client Cpp
All URIs are relative to:
http://127.0.0.1:19080/v2

## PetApi
|Method | HTTP request | Description|
|------------- | ------------- | -------------|
|*addPet* | *POST* /pet | Add a new pet to the store.|
|*deletePet* | *DELETE* /pet/{petId} | Deletes a pet.|
|*findPetsByAgeAndPatience* | *GET* /pet/findPetsByAgeAndPatience/{petData} | get a pet by age and patience.|
|*findPetsByStatus* | *GET* /pet/findByStatus | Finds Pets by status.|
|*findPetsByTags* | *GET* /pet/findByTags | Finds Pets by tags.|
|*findPetsImageById* | *GET* /pet/findPetsImageById | get a pet png image.|
|*getJsonFile* | *GET* /pet/{petId}/uploadImage | get a pet json information file.|
|*getPetById* | *GET* /pet/{petId} | Find pet by ID.|
|*updatePet* | *PUT* /pet | Update an existing pet.|
|*updatePetWithForm* | *POST* /pet/{petId} | Updates a pet in the store with form data.|
|*uploadFile* | *POST* /pet/{petId}/uploadImage | uploads an image.|

## StoreApi
|Method | HTTP request | Description|
|------------- | ------------- | -------------|
|*deleteOrder* | *DELETE* /store/order/{orderId} | Delete purchase order by ID.|
|*getInventory* | *GET* /store/inventory | Returns pet inventories by status.|
|*getOrderById* | *GET* /store/order/{orderId} | Find purchase order by ID.|
|*placeOrder* | *POST* /store/order | Place an order for a pet.|

## UserApi
|Method | HTTP request | Description|
|------------- | ------------- | -------------|
|*createInQueryMap* | *POST* /user/createInQueryMap | Testing map query operation parameter.|
|*createUser* | *POST* /user | Create user.|
|*createUsersWithArrayInput* | *POST* /user/createWithArray | Creates list of users with given input array.|
|*createUsersWithListInput* | *POST* /user/createWithList | Creates list of users with given input array.|
|*deleteUser* | *DELETE* /user/{username} | Delete user.|
|*getUserByName* | *GET* /user/{username} | Get user by user name.|
|*loginUser* | *GET* /user/login | Logs user into the system.|
|*logoutUser* | *GET* /user/logout | Logs out current logged in user session.|
|*updateUser* | *PUT* /user/{username} | Updated user.|


## What are the Model files for the data structures/objects?
|Class | Description|
|------------- | -------------|
|*ApiResponse* | Describes the result of uploading an image resource|
|*Category* | A category for a pet|
|*Order* | An order for a pets from the pet store|
|*Pet* | A pet for sale in the pet store|
|*PetStatus* | |
|*Tag* | A tag for a pet|
|*User* | A User who is purchasing from the pet store|


main.cpp:
```

#include "../client/petapi.h"

int main(int argc, char *argv[]) {
    QCoreApplication a(argc, argv);
    Pet pet;
    PetApi apiInstance;

    /* Configure HTTP basic authorization: http_basic_test */
    apiInstance.setUsername("YOUR USERNAME");
    apiInstance.setPassword("YOUR PASSWORD");

    /*
        Handle the 'addPet()' operation response directly in the callback.
        Note, the callback should always have the 'QRestReply &reply' as first parameter.
        The second and subsequent parameters are defined by the 'response' field of operation in your yaml specification.
    */
    apiInstance.addPet(pet, nullptr, [&](QRestReply &reply, Pet summary) {
        if (reply.isSuccess())
            qDebug() << "The server response is: " << summary.asJson();
            // Proceed with handling the user logic.
        else
            qWarning() << "There is an error occurred: " << reply.error();
    });

    /*
        Or connect to the operation response 'addPetFinished()/addPetErrorOccurred()' signals
        And call the operation 'addPet()'
    */
    connect(&apiInstance, &PetApi::addPetFinished, [&](Pet summary) {
               // handling the user logic
           });
    connect(&apiInstance, &PetApi::addPetErrorOccurred, [&](QNetworkReply::NetworkError errorType, const QString &errorStr) {
               qWarning() << "There is an error occurred: " << errorType << errorStr;
           });
    apiInstance.addPet(pet);
    return a.exec();
}

```

## Documentation for Servers

Parameterized Servers are supported. Define a server in the API for each endpoint with arbitrary numbers of variables:

```
*.yaml:

servers:
- url: http://{server}:{port}/{basePath}
  description: Description of the Server
  variables:
    server:
        enum:
          - 'main-server'
          - 'qa-server'
          - 'dev-server'
        default: 'main-server'
    port:
      enum:
        - '3000'
        - '1000'
      default: '3000'
    basePath:
      default: v1
```
To change the default variable, use this function in each Api:
```
ServerError setServerVariable(const QString &operation, qsizetype serverIndex, const QString &variable, const QString &value);
```
The parameter "serverIndex" will choose a server from the server list for each endpoint.
There is always at least one server with index 0. The Parameter "operation" should be the desired endpoint operationid.
Variable is the name of the variable you wish to change and the value is the new default Value.
The function will return ServerError::ServerVariableNotFound when the variable does not exists,
ServerError::EnumValueNotFound if value is not defined in the variable enum,
ServerError::OperationNotFound if the operation is not found, and ServerError::ServerIndexNotFound
if there is no server with such serverIndex.

If your endpoint has multiple server objects in the servers array, you can set the server that will be used with this function:
```
void setServer(const QString &operation, qsizetype serverIndex);
```
Parameter "operation" should be your operationid. "serverIndex" is the index you want to set as your default server. The function will check if there is a server with your index.
Here is an example of multiple servers in the servers array. The first server will have index 0 and the second will have index 1.
```
*.yaml:

servers:
- url: http://{server}:8080/
  description: Description of the Server
  variables:
    server:
        enum:
          - 'main-server'
          - 'qa-server'
          - 'dev-server'
        default: 'main-server'
- url: https://localhost:8080/v1
```

## Documentation for Authorization

Authentication schemes defined for the API:
### api_key


- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header

### http_basic_test


- **Type**: HTTP basic authentication

### bearer_test


- **Type**: HTTP Bearer Token authentication (JWT)

### api_key_query


- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string

### http_signature_test


- **Type**: HTTP signature authentication


## Author




## License

 for more information visit []()
