Revision control

# C++ Qt6API client
OpenAPI Petstore
- API version: 1.0.0
- Generator version: 7.15.0
This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
## Requirements
Building the API client library requires:
1. CMake 3.16+
2. Qt 6.8+
3. C++17 Compiler
## Getting Started
# Documentation for OpenAPI Petstore 1.0.0 Qt6 Client Cpp
### OAIPetApi
|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.|
### OAIStoreApi
|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.|
### OAIUserApi
|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|
|------------- | -------------|
|*OAIApiResponse* | Describes the result of uploading an image resource|
|*OAICategory* | A category for a pet|
|*OAIOrder* | An order for a pets from the pet store|
|*OAIPet* | A pet for sale in the pet store|
+ |*OAIPetStatus* | |
|*OAITag* | A tag for a pet|
|*OAIUser* | A User who is purchasing from the pet store|
main.cpp:
```
#include "../client/OAIPetApi.h"
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
OAIPet oAIPet;
OAIPetApi 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(oAIPet, nullptr, [&](QRestReply &reply, OAIPet 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, &OAIPetApi::addPetFinished, [&](OAIPet summary) {
// handling the user logic
});
connect(&apiInstance, &OAIPetApi::addPetErrorOccurred, [&](QNetworkReply::NetworkError errorType, const QString &errorStr) {
qWarning() << "There is an error occurred: " << errorType << errorStr;
});
apiInstance.addPet(oAIPet);
return a.exec();
}
```main.qml:
```qml
import QtQuick
import client
Item {
id: root
property dataOAIPet oAIPet;
OAIPetApi {
id: apiInstance
Component.onCompleted: {
// Configure HTTP basic authorization: http_basic_test
apiInstance.setUsername("YOUR USERNAME");
apiInstance.setPassword("YOUR PASSWORD");
}
}
Button {
onClicked:
apiInstance.addPet(oAIPet);
}
Connections {
target: apiInstance
function onAddPetFinished(summary) {
// do user logic
}
function onAddPetErrorOccurred(errorCode, errorString) {
console.log("The error occured. Code:" + errorCode + " error string is " + errorString)
}
}
}
```
## Documentation for Servers
Parameterized Servers are supported. Define a server in the API for each endpoint with arbitrary numbers of variables:
```
*.yaml:
servers:
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:
```
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val);
```
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 -1 when the variable does not exists, -2 if value is not defined in the variable enum and -3 if the operation is not found.
If your endpoint has multiple server objects in the servers array, you can set the server that will be used with this function:
```
void setServerIndex(const QString &operation, int 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:
description: Description of the Server
variables:
server:
enum:
- 'main-server'
- 'qa-server'
- 'dev-server'
default: 'main-server'
```
## 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
Apache-2.0 for more information visit [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.html)