From edc984a07a2543427592e609eba7441a9079b122 Mon Sep 17 00:00:00 2001 From: Miklos Marton Date: Sun, 15 Feb 2026 08:10:27 +0100 Subject: [PATCH 1/3] [cpp-qt-client]Fix variable redeclarations in the api-body.mustache --- .../resources/cpp-qt-client/api-body.mustache | 48 ++++----- .../client/PFXPetApi.cpp | 98 +++++++++---------- .../petstore/cpp-qt/client/PFXPetApi.cpp | 98 +++++++++---------- 3 files changed, 122 insertions(+), 122 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache index 38172b270edb..0a88f9f7eae7 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache @@ -702,13 +702,13 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} _credentialFlow.unlink(); _passwordFlow.unlink(); _authFlow.link(); - QStringList scope; + QStringList scope2; {{#scopes}} - scope.append("{{scope}}"); + scope2.append("{{scope}}"); {{/scopes}} - auto token = _authFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + auto token2 = _authFlow.getToken(scope2.join(" ")); + if(token2.isValid()) + input.headers.insert("Authorization", "Bearer " + token2.getToken()); _latestWorker = new {{prefix}}HttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -725,20 +725,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope;{{/isCode}} + _latestScope = scope2;{{/isCode}} {{#isImplicit}} _OauthMethod = 1; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; + QStringList scope1; {{#scopes}} - scope.append("{{scope}}"); + scope1.append("{{scope}}"); {{/scopes}} - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new {{prefix}}HttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -755,20 +755,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope;{{/isImplicit}} + _latestScope = scope1;{{/isImplicit}} {{#isApplication}} _OauthMethod = 3; _authFlow.unlink(); _implicitFlow.unlink(); _passwordFlow.unlink(); _credentialFlow.link(); - QStringList scope; + QStringList scope3; {{#scopes}} - scope.append("{{scope}}"); + scope3.append("{{scope}}"); {{/scopes}} - auto token = _credentialFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + auto token3 = _credentialFlow.getToken(scope3.join(" ")); + if(token3.isValid()) + input.headers.insert("Authorization", "Bearer " + token3.getToken()); _latestWorker = new {{prefix}}HttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -785,20 +785,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope;{{/isApplication}} + _latestScope = scope3;{{/isApplication}} {{#isPassword}} _OauthMethod = 4; _passwordFlow.link(); _authFlow.unlink(); _implicitFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; + QStringList scope4; {{#scopes}} - scope.append("{{scope}}"); + scope4.append("{{scope}}"); {{/scopes}} - auto token = _passwordFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + auto token4 = _passwordFlow.getToken(scope4.join(" ")); + if(token4.isValid()) + input.headers.insert("Authorization", "Bearer " + token4.getToken()); _latestWorker = new {{prefix}}HttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -815,7 +815,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope; + _latestScope = scope4; {{/isPassword}}{{/isOAuth}}{{/authMethods}} worker->execute(&input); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp index b414998f9c24..37c2a109fe64 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp @@ -269,12 +269,12 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -289,7 +289,7 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -477,12 +477,12 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -497,7 +497,7 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -672,12 +672,12 @@ void PFXPetApi::findPetsByStatus(const QList &status) { _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -692,7 +692,7 @@ void PFXPetApi::findPetsByStatus(const QList &status) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -877,12 +877,12 @@ void PFXPetApi::findPetsByTags(const QList &tags) { _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -897,7 +897,7 @@ void PFXPetApi::findPetsByTags(const QList &tags) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -1089,12 +1089,12 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1109,7 +1109,7 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -1220,12 +1220,12 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1240,7 +1240,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -1351,12 +1351,12 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1371,7 +1371,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; diff --git a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp index cb07b0b4718b..13529d2d3b45 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp @@ -269,12 +269,12 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -289,7 +289,7 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -477,12 +477,12 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -497,7 +497,7 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -672,12 +672,12 @@ void PFXPetApi::findPetsByStatus(const QList &status) { _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -692,7 +692,7 @@ void PFXPetApi::findPetsByStatus(const QList &status) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -877,12 +877,12 @@ void PFXPetApi::findPetsByTags(const QList &tags) { _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -897,7 +897,7 @@ void PFXPetApi::findPetsByTags(const QList &tags) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -1089,12 +1089,12 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1109,7 +1109,7 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -1220,12 +1220,12 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1240,7 +1240,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; @@ -1351,12 +1351,12 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; - scope.append("write:pets"); - scope.append("read:pets"); - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.getToken()); + QStringList scope1; + scope1.append("write:pets"); + scope1.append("read:pets"); + auto token1 = _implicitFlow.getToken(scope1.join(" ")); + if(token1.isValid()) + input.headers.insert("Authorization", "Bearer " + token1.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1371,7 +1371,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona }); _latestInput = input; - _latestScope = scope; + _latestScope = scope1; From dd4166dd115cf70ac742ba92308637b100df7236 Mon Sep 17 00:00:00 2001 From: Miklos Marton Date: Tue, 24 Feb 2026 20:15:57 +0100 Subject: [PATCH 2/3] [cpp-qt-client]Utilize enum for OauthMethod flow --- .../resources/cpp-qt-client/api-body.mustache | 50 +++++----- .../cpp-qt-client/api-header.mustache | 9 +- .../client/PFXFakeApi.cpp | 10 +- .../client/PFXFakeApi.h | 9 +- .../client/PFXPetApi.cpp | 94 +++++++++---------- .../client/PFXPetApi.h | 9 +- .../client/PFXPrimitivesApi.cpp | 10 +- .../client/PFXPrimitivesApi.h | 9 +- .../client/PFXStoreApi.cpp | 10 +- .../client/PFXStoreApi.h | 9 +- .../client/PFXUserApi.cpp | 10 +- .../client/PFXUserApi.h | 9 +- .../petstore/cpp-qt/client/PFXFakeApi.cpp | 10 +- .../petstore/cpp-qt/client/PFXFakeApi.h | 9 +- .../petstore/cpp-qt/client/PFXPetApi.cpp | 94 +++++++++---------- .../client/petstore/cpp-qt/client/PFXPetApi.h | 9 +- .../cpp-qt/client/PFXPrimitivesApi.cpp | 10 +- .../petstore/cpp-qt/client/PFXPrimitivesApi.h | 9 +- .../petstore/cpp-qt/client/PFXStoreApi.cpp | 10 +- .../petstore/cpp-qt/client/PFXStoreApi.h | 9 +- .../petstore/cpp-qt/client/PFXUserApi.cpp | 10 +- .../petstore/cpp-qt/client/PFXUserApi.h | 9 +- 22 files changed, 247 insertions(+), 170 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache index 0a88f9f7eae7..d3ea4010cf88 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache @@ -697,16 +697,16 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} Q_EMIT allPendingRequestsCompleted(); } });{{#authMethods}}{{#isOAuth}}{{#isCode}} - _OauthMethod = 2; + _OauthMethod = OauthMethod::AuthorizationFlow; _implicitFlow.unlink(); _credentialFlow.unlink(); _passwordFlow.unlink(); _authFlow.link(); - QStringList scope2; + QStringList scopeAuthorizationFlow; {{#scopes}} - scope2.append("{{scope}}"); + scopeAuthorizationFlow.append("{{scope}}"); {{/scopes}} - auto token2 = _authFlow.getToken(scope2.join(" ")); + auto token2 = _authFlow.getToken(scopeAuthorizationFlow.join(" ")); if(token2.isValid()) input.headers.insert("Authorization", "Bearer " + token2.getToken()); @@ -725,18 +725,18 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope2;{{/isCode}} + _latestScope = scopeAuthorizationFlow;{{/isCode}} {{#isImplicit}} - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; + QStringList scopeImplicitFlow; {{#scopes}} - scope1.append("{{scope}}"); + scopeImplicitFlow.append("{{scope}}"); {{/scopes}} - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -755,18 +755,18 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope1;{{/isImplicit}} + _latestScope = scopeImplicitFlow;{{/isImplicit}} {{#isApplication}} - _OauthMethod = 3; + _OauthMethod = OauthMethod::ClientCredentialsFlow; _authFlow.unlink(); _implicitFlow.unlink(); _passwordFlow.unlink(); _credentialFlow.link(); - QStringList scope3; + QStringList scopeClientCredentialsFlow; {{#scopes}} - scope3.append("{{scope}}"); + scopeClientCredentialsFlow.append("{{scope}}"); {{/scopes}} - auto token3 = _credentialFlow.getToken(scope3.join(" ")); + auto token3 = _credentialFlow.getToken(scopeClientCredentialsFlow.join(" ")); if(token3.isValid()) input.headers.insert("Authorization", "Bearer " + token3.getToken()); @@ -785,18 +785,18 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope3;{{/isApplication}} + _latestScope = scopeClientCredentialsFlow;{{/isApplication}} {{#isPassword}} - _OauthMethod = 4; + _OauthMethod = OauthMethod::ResourceOwnerPasswordFlow; _passwordFlow.link(); _authFlow.unlink(); _implicitFlow.unlink(); _credentialFlow.unlink(); - QStringList scope4; + QStringList scopeResourceOwnerPasswordFlow; {{#scopes}} - scope4.append("{{scope}}"); + scopeResourceOwnerPasswordFlow.append("{{scope}}"); {{/scopes}} - auto token4 = _passwordFlow.getToken(scope4.join(" ")); + auto token4 = _passwordFlow.getToken(scopeResourceOwnerPasswordFlow.join(" ")); if(token4.isValid()) input.headers.insert("Authorization", "Bearer " + token4.getToken()); @@ -815,7 +815,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope4; + _latestScope = scopeResourceOwnerPasswordFlow; {{/isPassword}}{{/isOAuth}}{{/authMethods}} worker->execute(&input); @@ -960,11 +960,11 @@ void {{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker *worker) { {{/operation}} {{/operations}} -void {{classname}}::tokenAvailable(){ +void {{classname}}::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -974,7 +974,7 @@ void {{classname}}::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -984,7 +984,7 @@ void {{classname}}::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -994,7 +994,7 @@ void {{classname}}::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-header.mustache index 888589643701..35952058cc71 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-header.mustache @@ -63,6 +63,13 @@ public: {{/operation}}{{/operations}} private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -82,7 +89,7 @@ private: OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; {{#operations}}{{#operation}} void {{nickname}}Callback({{prefix}}HttpRequestWorker *worker);{{/operation}}{{/operations}} diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXFakeApi.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXFakeApi.cpp index 19516440f05c..904663598966 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXFakeApi.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXFakeApi.cpp @@ -326,11 +326,11 @@ void PFXFakeApi::getEnumInlineOrRefCallback(PFXHttpRequestWorker *worker) { } } -void PFXFakeApi::tokenAvailable(){ +void PFXFakeApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -340,7 +340,7 @@ void PFXFakeApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -350,7 +350,7 @@ void PFXFakeApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -360,7 +360,7 @@ void PFXFakeApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXFakeApi.h b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXFakeApi.h index cba16795183b..ea161cdcefa3 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXFakeApi.h +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXFakeApi.h @@ -65,6 +65,13 @@ class PFXFakeApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -84,7 +91,7 @@ class PFXFakeApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void getEnumInlineOrRefCallback(PFXHttpRequestWorker *worker); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp index 37c2a109fe64..e43791cceca1 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp @@ -264,15 +264,15 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -289,7 +289,7 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -472,15 +472,15 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -497,7 +497,7 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -667,15 +667,15 @@ void PFXPetApi::findPetsByStatus(const QList &status) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -692,7 +692,7 @@ void PFXPetApi::findPetsByStatus(const QList &status) { }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -872,15 +872,15 @@ void PFXPetApi::findPetsByTags(const QList &tags) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -897,7 +897,7 @@ void PFXPetApi::findPetsByTags(const QList &tags) { }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -1084,15 +1084,15 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -1109,7 +1109,7 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -1215,15 +1215,15 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -1240,7 +1240,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -1346,15 +1346,15 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -1371,7 +1371,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -1435,11 +1435,11 @@ void PFXPetApi::uploadFileCallback(PFXHttpRequestWorker *worker) { } } -void PFXPetApi::tokenAvailable(){ +void PFXPetApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -1449,7 +1449,7 @@ void PFXPetApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -1459,7 +1459,7 @@ void PFXPetApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -1469,7 +1469,7 @@ void PFXPetApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.h b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.h index 265237f4e555..3a3139d96068 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.h +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.h @@ -110,6 +110,13 @@ class PFXPetApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -129,7 +136,7 @@ class PFXPetApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void addPetCallback(PFXHttpRequestWorker *worker); void allPetsCallback(PFXHttpRequestWorker *worker); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPrimitivesApi.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPrimitivesApi.cpp index 5fbd9a44fd04..643d55f4a764 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPrimitivesApi.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPrimitivesApi.cpp @@ -370,11 +370,11 @@ void PFXPrimitivesApi::primitivesNumberPutCallback(PFXHttpRequestWorker *worker) } } -void PFXPrimitivesApi::tokenAvailable(){ +void PFXPrimitivesApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -384,7 +384,7 @@ void PFXPrimitivesApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -394,7 +394,7 @@ void PFXPrimitivesApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -404,7 +404,7 @@ void PFXPrimitivesApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPrimitivesApi.h b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPrimitivesApi.h index b13e83173984..bd4c936a4290 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPrimitivesApi.h +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPrimitivesApi.h @@ -68,6 +68,13 @@ class PFXPrimitivesApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -87,7 +94,7 @@ class PFXPrimitivesApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void primitivesIntegerPostCallback(PFXHttpRequestWorker *worker); void primitivesNumberPutCallback(PFXHttpRequestWorker *worker); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXStoreApi.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXStoreApi.cpp index fa51b30651cf..406410db7e1c 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXStoreApi.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXStoreApi.cpp @@ -553,11 +553,11 @@ void PFXStoreApi::placeOrderCallback(PFXHttpRequestWorker *worker) { } } -void PFXStoreApi::tokenAvailable(){ +void PFXStoreApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -567,7 +567,7 @@ void PFXStoreApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -577,7 +577,7 @@ void PFXStoreApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -587,7 +587,7 @@ void PFXStoreApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXStoreApi.h b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXStoreApi.h index c46b31250a15..11ea171a2695 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXStoreApi.h +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXStoreApi.h @@ -78,6 +78,13 @@ class PFXStoreApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -97,7 +104,7 @@ class PFXStoreApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void deleteOrderCallback(PFXHttpRequestWorker *worker); void getInventoryCallback(PFXHttpRequestWorker *worker); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUserApi.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUserApi.cpp index 03de0d24022f..c06b664c560a 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUserApi.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUserApi.cpp @@ -889,11 +889,11 @@ void PFXUserApi::updateUserCallback(PFXHttpRequestWorker *worker) { } } -void PFXUserApi::tokenAvailable(){ +void PFXUserApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -903,7 +903,7 @@ void PFXUserApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -913,7 +913,7 @@ void PFXUserApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -923,7 +923,7 @@ void PFXUserApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUserApi.h b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUserApi.h index cce2728f3114..f0ebf9885109 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUserApi.h +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUserApi.h @@ -99,6 +99,13 @@ class PFXUserApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -118,7 +125,7 @@ class PFXUserApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void createUserCallback(PFXHttpRequestWorker *worker); void createUsersWithArrayInputCallback(PFXHttpRequestWorker *worker); diff --git a/samples/client/petstore/cpp-qt/client/PFXFakeApi.cpp b/samples/client/petstore/cpp-qt/client/PFXFakeApi.cpp index 6bbd634658c6..3c84753b5e4f 100644 --- a/samples/client/petstore/cpp-qt/client/PFXFakeApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXFakeApi.cpp @@ -326,11 +326,11 @@ void PFXFakeApi::getEnumInlineOrRefCallback(PFXHttpRequestWorker *worker) { } } -void PFXFakeApi::tokenAvailable(){ +void PFXFakeApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -340,7 +340,7 @@ void PFXFakeApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -350,7 +350,7 @@ void PFXFakeApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -360,7 +360,7 @@ void PFXFakeApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt/client/PFXFakeApi.h b/samples/client/petstore/cpp-qt/client/PFXFakeApi.h index f81543a99463..962b10da10bd 100644 --- a/samples/client/petstore/cpp-qt/client/PFXFakeApi.h +++ b/samples/client/petstore/cpp-qt/client/PFXFakeApi.h @@ -65,6 +65,13 @@ class PFXFakeApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -84,7 +91,7 @@ class PFXFakeApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void getEnumInlineOrRefCallback(PFXHttpRequestWorker *worker); diff --git a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp index 13529d2d3b45..14ec97b28c2c 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp @@ -264,15 +264,15 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -289,7 +289,7 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -472,15 +472,15 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -497,7 +497,7 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -667,15 +667,15 @@ void PFXPetApi::findPetsByStatus(const QList &status) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -692,7 +692,7 @@ void PFXPetApi::findPetsByStatus(const QList &status) { }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -872,15 +872,15 @@ void PFXPetApi::findPetsByTags(const QList &tags) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -897,7 +897,7 @@ void PFXPetApi::findPetsByTags(const QList &tags) { }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -1084,15 +1084,15 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -1109,7 +1109,7 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -1215,15 +1215,15 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -1240,7 +1240,7 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -1346,15 +1346,15 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope1; - scope1.append("write:pets"); - scope1.append("read:pets"); - auto token1 = _implicitFlow.getToken(scope1.join(" ")); + QStringList scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); if(token1.isValid()) input.headers.insert("Authorization", "Bearer " + token1.getToken()); @@ -1371,7 +1371,7 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona }); _latestInput = input; - _latestScope = scope1; + _latestScope = scopeImplicitFlow; @@ -1435,11 +1435,11 @@ void PFXPetApi::uploadFileCallback(PFXHttpRequestWorker *worker) { } } -void PFXPetApi::tokenAvailable(){ +void PFXPetApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -1449,7 +1449,7 @@ void PFXPetApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -1459,7 +1459,7 @@ void PFXPetApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -1469,7 +1469,7 @@ void PFXPetApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt/client/PFXPetApi.h b/samples/client/petstore/cpp-qt/client/PFXPetApi.h index be4917756d21..649dad2c2ddc 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPetApi.h +++ b/samples/client/petstore/cpp-qt/client/PFXPetApi.h @@ -110,6 +110,13 @@ class PFXPetApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -129,7 +136,7 @@ class PFXPetApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void addPetCallback(PFXHttpRequestWorker *worker); void allPetsCallback(PFXHttpRequestWorker *worker); diff --git a/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp b/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp index 017a8af18239..b851cdfec408 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.cpp @@ -370,11 +370,11 @@ void PFXPrimitivesApi::primitivesNumberPutCallback(PFXHttpRequestWorker *worker) } } -void PFXPrimitivesApi::tokenAvailable(){ +void PFXPrimitivesApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -384,7 +384,7 @@ void PFXPrimitivesApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -394,7 +394,7 @@ void PFXPrimitivesApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -404,7 +404,7 @@ void PFXPrimitivesApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h b/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h index a5bdfeeabb1e..37af3a5c953f 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h +++ b/samples/client/petstore/cpp-qt/client/PFXPrimitivesApi.h @@ -68,6 +68,13 @@ class PFXPrimitivesApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -87,7 +94,7 @@ class PFXPrimitivesApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void primitivesIntegerPostCallback(PFXHttpRequestWorker *worker); void primitivesNumberPutCallback(PFXHttpRequestWorker *worker); diff --git a/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp b/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp index bf4a5924bf38..bf9c616d4186 100644 --- a/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXStoreApi.cpp @@ -553,11 +553,11 @@ void PFXStoreApi::placeOrderCallback(PFXHttpRequestWorker *worker) { } } -void PFXStoreApi::tokenAvailable(){ +void PFXStoreApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -567,7 +567,7 @@ void PFXStoreApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -577,7 +577,7 @@ void PFXStoreApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -587,7 +587,7 @@ void PFXStoreApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt/client/PFXStoreApi.h b/samples/client/petstore/cpp-qt/client/PFXStoreApi.h index d16fbe9502d5..762b5497516d 100644 --- a/samples/client/petstore/cpp-qt/client/PFXStoreApi.h +++ b/samples/client/petstore/cpp-qt/client/PFXStoreApi.h @@ -78,6 +78,13 @@ class PFXStoreApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -97,7 +104,7 @@ class PFXStoreApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void deleteOrderCallback(PFXHttpRequestWorker *worker); void getInventoryCallback(PFXHttpRequestWorker *worker); diff --git a/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp b/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp index a37550d24653..78d636663866 100644 --- a/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp @@ -889,11 +889,11 @@ void PFXUserApi::updateUserCallback(PFXHttpRequestWorker *worker) { } } -void PFXUserApi::tokenAvailable(){ +void PFXUserApi::tokenAvailable() { oauthToken token; switch (_OauthMethod) { - case 1: //implicit flow + case OauthMethod::ImplicitFlow: token = _implicitFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -903,7 +903,7 @@ void PFXUserApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 2: //authorization flow + case OauthMethod::AuthorizationFlow: token = _authFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -913,7 +913,7 @@ void PFXUserApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 3: //client credentials flow + case OauthMethod::ClientCredentialsFlow: token = _credentialFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); @@ -923,7 +923,7 @@ void PFXUserApi::tokenAvailable(){ qDebug() << "Could not retrieve a valid token"; } break; - case 4: //resource owner password flow + case OauthMethod::ResourceOwnerPasswordFlow: token = _passwordFlow.getToken(_latestScope.join(" ")); if(token.isValid()){ _latestInput.headers.insert("Authorization", "Bearer " + token.getToken()); diff --git a/samples/client/petstore/cpp-qt/client/PFXUserApi.h b/samples/client/petstore/cpp-qt/client/PFXUserApi.h index 15bc9510433f..85f21189d949 100644 --- a/samples/client/petstore/cpp-qt/client/PFXUserApi.h +++ b/samples/client/petstore/cpp-qt/client/PFXUserApi.h @@ -99,6 +99,13 @@ class PFXUserApi : public QObject { private: + enum class OauthMethod : int { + INVALID_VALUE_OPENAPI_GENERATED = 0, + ImplicitFlow = 1, + AuthorizationFlow = 2, + ClientCredentialsFlow = 3, + ResourceOwnerPasswordFlow = 4 + }; QMap _serverIndices; QMap> _serverConfigs; QMap _apiKeys; @@ -118,7 +125,7 @@ class PFXUserApi : public QObject { OauthImplicit _implicitFlow; OauthCredentials _credentialFlow; OauthPassword _passwordFlow; - int _OauthMethod = 0; + OauthMethod _OauthMethod = OauthMethod::INVALID_VALUE_OPENAPI_GENERATED; void createUserCallback(PFXHttpRequestWorker *worker); void createUsersWithArrayInputCallback(PFXHttpRequestWorker *worker); From fef1373374c076e0d390abaf69025b398b171fdc Mon Sep 17 00:00:00 2001 From: Miklos Marton Date: Mon, 2 Mar 2026 17:33:23 +0100 Subject: [PATCH 3/3] [cpp-qt-clien]Suffix token variables in OAuth with meaningful state names instead of numeric indexes --- .../resources/cpp-qt-client/api-body.mustache | 24 +++++------ .../client/PFXPetApi.cpp | 42 +++++++++---------- .../petstore/cpp-qt/client/PFXPetApi.cpp | 42 +++++++++---------- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache index d3ea4010cf88..d5a62bb0def0 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache @@ -706,9 +706,9 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} {{#scopes}} scopeAuthorizationFlow.append("{{scope}}"); {{/scopes}} - auto token2 = _authFlow.getToken(scopeAuthorizationFlow.join(" ")); - if(token2.isValid()) - input.headers.insert("Authorization", "Bearer " + token2.getToken()); + auto tokenAuthorizationFlow = _authFlow.getToken(scopeAuthorizationFlow.join(" ")); + if(tokenAuthorizationFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenAuthorizationFlow.getToken()); _latestWorker = new {{prefix}}HttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -736,9 +736,9 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} {{#scopes}} scopeImplicitFlow.append("{{scope}}"); {{/scopes}} - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new {{prefix}}HttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -766,9 +766,9 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} {{#scopes}} scopeClientCredentialsFlow.append("{{scope}}"); {{/scopes}} - auto token3 = _credentialFlow.getToken(scopeClientCredentialsFlow.join(" ")); - if(token3.isValid()) - input.headers.insert("Authorization", "Bearer " + token3.getToken()); + auto tokenClientCredentialsFlow = _credentialFlow.getToken(scopeClientCredentialsFlow.join(" ")); + if(tokenClientCredentialsFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenClientCredentialsFlow.getToken()); _latestWorker = new {{prefix}}HttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -796,9 +796,9 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} {{#scopes}} scopeResourceOwnerPasswordFlow.append("{{scope}}"); {{/scopes}} - auto token4 = _passwordFlow.getToken(scopeResourceOwnerPasswordFlow.join(" ")); - if(token4.isValid()) - input.headers.insert("Authorization", "Bearer " + token4.getToken()); + auto tokenResourceOwnerPasswordFlow = _passwordFlow.getToken(scopeResourceOwnerPasswordFlow.join(" ")); + if(tokenResourceOwnerPasswordFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenResourceOwnerPasswordFlow.getToken()); _latestWorker = new {{prefix}}HttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp index e43791cceca1..03c84ce6e6a1 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp @@ -272,9 +272,9 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -480,9 +480,9 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -675,9 +675,9 @@ void PFXPetApi::findPetsByStatus(const QList &status) { QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -880,9 +880,9 @@ void PFXPetApi::findPetsByTags(const QList &tags) { QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1092,9 +1092,9 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1223,9 +1223,9 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1354,9 +1354,9 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); diff --git a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp index 14ec97b28c2c..ba4326156edd 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp @@ -272,9 +272,9 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -480,9 +480,9 @@ void PFXPetApi::deletePet(const qint64 &pet_id, const ::test_namespace::Optional QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -675,9 +675,9 @@ void PFXPetApi::findPetsByStatus(const QList &status) { QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -880,9 +880,9 @@ void PFXPetApi::findPetsByTags(const QList &tags) { QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1092,9 +1092,9 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1223,9 +1223,9 @@ void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const ::test_namespace:: QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -1354,9 +1354,9 @@ void PFXPetApi::uploadFile(const qint64 &pet_id, const ::test_namespace::Optiona QStringList scopeImplicitFlow; scopeImplicitFlow.append("write:pets"); scopeImplicitFlow.append("read:pets"); - auto token1 = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); - if(token1.isValid()) - input.headers.insert("Authorization", "Bearer " + token1.getToken()); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut);