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..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 @@ -697,18 +697,18 @@ 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 scope; + QStringList scopeAuthorizationFlow; {{#scopes}} - scope.append("{{scope}}"); + scopeAuthorizationFlow.append("{{scope}}"); {{/scopes}} - auto token = _authFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.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); @@ -725,20 +725,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope;{{/isCode}} + _latestScope = scopeAuthorizationFlow;{{/isCode}} {{#isImplicit}} - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _passwordFlow.unlink(); _authFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; + QStringList scopeImplicitFlow; {{#scopes}} - scope.append("{{scope}}"); + scopeImplicitFlow.append("{{scope}}"); {{/scopes}} - auto token = _implicitFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.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); @@ -755,20 +755,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope;{{/isImplicit}} + _latestScope = scopeImplicitFlow;{{/isImplicit}} {{#isApplication}} - _OauthMethod = 3; + _OauthMethod = OauthMethod::ClientCredentialsFlow; _authFlow.unlink(); _implicitFlow.unlink(); _passwordFlow.unlink(); _credentialFlow.link(); - QStringList scope; + QStringList scopeClientCredentialsFlow; {{#scopes}} - scope.append("{{scope}}"); + scopeClientCredentialsFlow.append("{{scope}}"); {{/scopes}} - auto token = _credentialFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.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); @@ -785,20 +785,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope;{{/isApplication}} + _latestScope = scopeClientCredentialsFlow;{{/isApplication}} {{#isPassword}} - _OauthMethod = 4; + _OauthMethod = OauthMethod::ResourceOwnerPasswordFlow; _passwordFlow.link(); _authFlow.unlink(); _implicitFlow.unlink(); _credentialFlow.unlink(); - QStringList scope; + QStringList scopeResourceOwnerPasswordFlow; {{#scopes}} - scope.append("{{scope}}"); + scopeResourceOwnerPasswordFlow.append("{{scope}}"); {{/scopes}} - auto token = _passwordFlow.getToken(scope.join(" ")); - if(token.isValid()) - input.headers.insert("Authorization", "Bearer " + token.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); @@ -815,7 +815,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} }); _latestInput = input; - _latestScope = scope; + _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 b414998f9c24..03c84ce6e6a1 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPetApi.cpp @@ -264,17 +264,17 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = scopeImplicitFlow; @@ -472,17 +472,17 @@ 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 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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = scopeImplicitFlow; @@ -667,17 +667,17 @@ void PFXPetApi::findPetsByStatus(const QList &status) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -692,7 +692,7 @@ void PFXPetApi::findPetsByStatus(const QList &status) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scopeImplicitFlow; @@ -872,17 +872,17 @@ void PFXPetApi::findPetsByTags(const QList &tags) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -897,7 +897,7 @@ void PFXPetApi::findPetsByTags(const QList &tags) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scopeImplicitFlow; @@ -1084,17 +1084,17 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = scopeImplicitFlow; @@ -1215,17 +1215,17 @@ 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 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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = scopeImplicitFlow; @@ -1346,17 +1346,17 @@ 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 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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = 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 cb07b0b4718b..ba4326156edd 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp @@ -264,17 +264,17 @@ void PFXPetApi::addPet(const PFXPet &pfx_pet) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = scopeImplicitFlow; @@ -472,17 +472,17 @@ 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 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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = scopeImplicitFlow; @@ -667,17 +667,17 @@ void PFXPetApi::findPetsByStatus(const QList &status) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -692,7 +692,7 @@ void PFXPetApi::findPetsByStatus(const QList &status) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scopeImplicitFlow; @@ -872,17 +872,17 @@ void PFXPetApi::findPetsByTags(const QList &tags) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.getToken()); _latestWorker = new PFXHttpRequestWorker(this, _manager); _latestWorker->setTimeOut(_timeOut); @@ -897,7 +897,7 @@ void PFXPetApi::findPetsByTags(const QList &tags) { }); _latestInput = input; - _latestScope = scope; + _latestScope = scopeImplicitFlow; @@ -1084,17 +1084,17 @@ void PFXPetApi::updatePet(const PFXPet &pfx_pet) { Q_EMIT allPendingRequestsCompleted(); } }); - _OauthMethod = 1; + _OauthMethod = OauthMethod::ImplicitFlow; _implicitFlow.link(); _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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = scopeImplicitFlow; @@ -1215,17 +1215,17 @@ 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 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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = scopeImplicitFlow; @@ -1346,17 +1346,17 @@ 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 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 scopeImplicitFlow; + scopeImplicitFlow.append("write:pets"); + scopeImplicitFlow.append("read:pets"); + auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow.join(" ")); + if(tokenImplicitFlow.isValid()) + input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow.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 = 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);