Jazzco 1214ad7492
Update HttpRequest.cpp.mustache - use stable 4-parameter connect (#18893)
* Update HttpRequest.cpp.mustache

Use stable 4-parameter connect

* add generated files

* Revert "add generated files"

This reverts commit 1d4e78aa0d42208b576354276c274000c29863f9.

* changed from 3- to 4-parameter connect for api-body for stable connection (see warning [clazy-connect-3arg-lambda])

* ran step 3 from Linux

* fixed missing braces and additional 3par issues

* add step 3 generated file

* activate trace for more info about link issue

* Update .github/workflows/samples-cpp-qt-client.yaml

Co-authored-by: Martin Delille <martin@delille.org>

* Update .github/workflows/samples-cpp-qt-client.yaml

Co-authored-by: Martin Delille <martin@delille.org>

* Update samples/client/petstore/cpp-qt/client/PFXPetApi.cpp

Co-authored-by: Martin Delille <martin@delille.org>

* Update modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.cpp.mustache

Co-authored-by: Martin Delille <martin@delille.org>

* Update modules/openapi-generator/src/main/resources/cpp-qt-client/HttpRequest.cpp.mustache

Co-authored-by: Martin Delille <martin@delille.org>

* Update modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache

Co-authored-by: Martin Delille <martin@delille.org>

* Update modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache

Co-authored-by: Martin Delille <martin@delille.org>

* Update modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache

Co-authored-by: Martin Delille <martin@delille.org>

* Update samples/client/petstore/cpp-qt/client/PFXPetApi.cpp

Co-authored-by: Martin Delille <martin@delille.org>

* Update samples/client/petstore/cpp-qt/client/PFXPetApi.cpp

Co-authored-by: Martin Delille <martin@delille.org>

* Update samples/client/petstore/cpp-qt/client/PFXPetApi.cpp

Co-authored-by: Martin Delille <martin@delille.org>

* Update samples/client/petstore/cpp-qt/client/PFXPetApi.cpp

Co-authored-by: Martin Delille <martin@delille.org>

* rebuild examples

* Update modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache

Co-authored-by: Martin Delille <martin@delille.org>

* removed braces and updated examples

* rebuild samples

* remove false generated changes

---------

Co-authored-by: Martin Delille <martin@delille.org>
2024-10-16 00:08:40 +08:00
..
2024-10-08 11:21:54 +08:00

C++ Qt API client

OpenAPI Petstore

  • API version: 1.0.0
  • Generator version: 7.10.0-SNAPSHOT

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

Requirements

Building the API client library requires:

  1. CMake 3.2+
  2. Qt
  3. C++ Compiler

Getting Started

example.h:


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

using namespace test_namespace;

class Example : public QObject {
    Q_OBJECT
    PFXPet create();
public Q_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 pfx_pet = create(); // PFXPet | Pet object that needs to be added to the store
      apiInstance.addPet(pfx_pet);
      QTimer::singleShot(5000, &loop, &QEventLoop::quit);
      loop.exec();
  }

Documentation for Servers

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

servers:
- url: http://{server}:{port}/{basePath}
  description: Description of the Server
  variables:
    server:
        enum:
          - 'petstore'
          - 'qa-petstore'
          - 'dev-petstore'
        default: 'petstore'
    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.

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

Documentation for Authorization

Authentication schemes defined for the API:

petstore_auth

api_key

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

Author

License

Apache-2.0 for more information visit Apache-2.0