basyskom-dege cb1a620628
[C++][Qt5] added Authentication Support (#8004)
* first commit of api Key feature.

* added multi key and URL query key support

* fixed error in mustache files, updated samples and tests

* added Basic Auth with Base64 encoding.

* updated Readme, added bearer token

* added check that authentication credentials are set. fixed typo in README
2020-11-28 15:02:09 +08:00
..
2019-08-08 23:59:50 +08:00
2019-08-08 23:59:50 +08:00

OpenAPI Petstore

  • API version: 1.0.0

This is a sample server Petstore server. For this sample, you can use the api key special-key to test the authorization filters.

Automatically generated by the OpenAPI Generator

Licence

Apache-2.0

for more information visit Apache-2.0

Requirements

Building the API client library requires:

  1. Java 1.7+
  2. Maven/Gradle

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Generate manually

At first generate the JAR by executing:

mvn clean package

Use the Jar file to generate the Qt5 Client:

java -jar target/openapi-generator-cli.jar generate -i <yourOpenApiFile> -g cpp-qt5-client -o <outputDir>

Getting Started

Please follow the installation instruction and execute the following Java code:

example.h:


#include <iostream>
#include "../client/PFXPetApi.h"

using namespace test_namespace;

class Example : public QObject {
    Q_OBJECT
    PFXPet create();
public slots:
   void exampleFunction1();
};

example.cpp:


#include "../client/PFXPetApi.h"
#include "example.h"
#include <QTimer>
#include <QEventLoop> 

PFXPet Example::create(){
    PFXPet obj;
 return obj;
}

void Example::exampleFunction1(){
     PFXPetApi apiInstance;
     
      //OAuth Authentication supported right now
        
      QEventLoop loop;
      connect(&apiInstance, &PFXPetApi::addPetSignal, [&]() {
          loop.quit();
      });
      connect(&apiInstance, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
          qDebug() << "Error happened while issuing request : " << error_str;
          loop.quit();
      });

      PFXPet body = create(); // PFXPet | Pet object that needs to be added to the store
      apiInstance.addPet(body);
      QTimer::singleShot(5000, &loop, &QEventLoop::quit);
      loop.exec();
  }

Documentation for API Endpoints

All URIs are relative to http://petstore.swagger.io/v2

Class Method HTTP request Description
PFXPetApi addPet POST /pet Add a new pet to the store
PFXPetApi deletePet DELETE /pet/{petId} Deletes a pet
PFXPetApi findPetsByStatus GET /pet/findByStatus Finds Pets by status
PFXPetApi findPetsByTags GET /pet/findByTags Finds Pets by tags
PFXPetApi getPetById GET /pet/{petId} Find pet by ID
PFXPetApi updatePet PUT /pet Update an existing pet
PFXPetApi updatePetWithForm POST /pet/{petId} Updates a pet in the store with form data
PFXPetApi uploadFile POST /pet/{petId}/uploadImage uploads an image
PFXStoreApi deleteOrder DELETE /store/order/{orderId} Delete purchase order by ID
PFXStoreApi getInventory GET /store/inventory Returns pet inventories by status
PFXStoreApi getOrderById GET /store/order/{orderId} Find purchase order by ID
PFXStoreApi placeOrder POST /store/order Place an order for a pet
PFXUserApi createUser POST /user Create user
PFXUserApi createUsersWithArrayInput POST /user/createWithArray Creates list of users with given input array
PFXUserApi createUsersWithListInput POST /user/createWithList Creates list of users with given input array
PFXUserApi deleteUser DELETE /user/{username} Delete user
PFXUserApi getUserByName GET /user/{username} Get user by user name
PFXUserApi loginUser GET /user/login Logs user into the system
PFXUserApi logoutUser GET /user/logout Logs out current logged in user session
PFXUserApi updateUser PUT /user/{username} Updated user

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

api_key

  • Type: API key
  • API key parameter name: api_key
  • Location: HTTP header

petstore_auth

Author