Skip to content

Commit b04331c

Browse files
[cpp-libcurl] Fix Sonar issues with API keys
1 parent 26a7f35 commit b04331c

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

modules/openapi-generator/src/main/resources/cpp-libcurl/apiclient-source.mustache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,7 @@ ApiResponse ApiClient::callApi(
315315
{{#authMethods}}
316316
{{#isApiKey}}
317317
// this would only be generated for apiKey authentication
318-
const auto &apiKeys = m_Configuration->getApiKeys();
319-
if (apiKeys.size() > 0) {
318+
if (const auto &apiKeys = m_Configuration->getApiKeys(); !apiKeys.empty()) {
320319
for (const auto &[key, value] : apiKeys) {
321320
std::string apiKey = key + ": " + value;
322321

samples/client/petstore/cpp/libcurl/src/ApiClient.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ ApiResponse ApiClient::callApi(
320320
}
321321

322322
// this would only be generated for apiKey authentication
323-
const auto &apiKeys = m_Configuration->getApiKeys();
324-
if (apiKeys.size() > 0) {
323+
if (const auto &apiKeys = m_Configuration->getApiKeys(); !apiKeys.empty()) {
325324
for (const auto &[key, value] : apiKeys) {
326325
std::string apiKey = key + ": " + value;
327326

0 commit comments

Comments
 (0)