summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2025-12-10 12:27:27 +0100
committerIvan Solovev <ivan.solovev@qt.io>2025-12-12 19:00:28 +0100
commit4b42f900ab1f7dd19021632ec0fc9caa672156b3 (patch)
tree477d7f6db32a94277329c67eb06fcf27e8619940
parentebd85f9cadae26d82331f5e922af332f015540b2 (diff)
BaseApi: remove the methods that add new server configurationsHEADdev
The available server configurations are determined by the yaml file, so there is no need to provide the possibility to add new server configurations. These methods can be removed in order to make the API cleaner. Found in API review. Task-number: QTBUG-142269 Pick-to: 6.11 Change-Id: I6bb89808eaa0ab55716a80047b524baa9bd794e8 Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
-rw-r--r--src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-body.mustache57
-rw-r--r--src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-header.mustache4
2 files changed, 1 insertions, 60 deletions
diff --git a/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-body.mustache b/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-body.mustache
index 96277e0..47e6de0 100644
--- a/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-body.mustache
+++ b/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-body.mustache
@@ -153,63 +153,6 @@ void {{prefix}}BaseApi::setNetworkRequestFactory(std::shared_ptr<QNetworkRequest
m_networkFactory = factory;
}
-/**
- * Appends a new ServerConfiguration to the config map for a specific operation.
- * @param operation The id to the target operation.
- * @param urlTemplate A string that contains the URL template of the server
- * @param description A String that describes the server
- * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
- * returns the index of the new server config on success and std::nullopt if the operation is not found
- */
-std::optional<int> {{prefix}}BaseApi::addServerConfiguration(const QString &operation, const QString &urlTemplate, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables)
-{
- if (m_serverConfigs.contains(operation)) {
- m_serverConfigs[operation].append({{prefix}}ServerConfiguration(
- urlTemplate,
- description,
- variables));
- return m_serverConfigs[operation].size()-1;
- }
-
- return std::nullopt; // ServerError::OperationNotFound
-}
-
-/**
- * Appends a new ServerConfiguration to the config map for all operations and sets the index to that server.
- * @param urlTemplate A string that contains the URL template of the server
- * @param description A String that describes the server
- * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
- */
-{{prefix}}BaseApi::ServerError {{prefix}}BaseApi::setNewServerForAllOperations(const QString &urlTemplate, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables)
-{
- {{prefix}}BaseApi::ServerError err = ServerError::ServerIndexNotFound;
-
- for (auto keyIt = m_serverIndices.keyBegin(); keyIt != m_serverIndices.keyEnd(); keyIt++) {
- err = setNewServer(*keyIt, urlTemplate, description, variables);
- if (err != ServerError::NoError) // Mark failure but continue with other operations
- qWarning() <<"Failed to set server configuration for " << *keyIt << " operation. Error:" << errorString(err);
- }
-
- return err;
-}
-
-/**
- * Appends a new ServerConfiguration to the config map for an operation and sets the index to that server.
- * @param operation A name of user operation
- * @param urlTemplate A string that contains the URL template of the server
- * @param description A String that describes the server
- * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
- */
-{{prefix}}BaseApi::ServerError {{prefix}}BaseApi::setNewServer(const QString &operation, const QString &urlTemplate, const QString &description, const QMap<QString, {{prefix}}ServerVariable> &variables)
-{
- std::optional<int> serverIndex = addServerConfiguration(operation, urlTemplate, description, variables);
-
- if (!serverIndex.has_value()) // operation was not found in m_serverConfigs
- return ServerError::OperationNotFound;
-
- return setServer(operation, serverIndex.value());
-}
-
void {{prefix}}BaseApi::setHeader(QHttpHeaders::WellKnownHeader key, QAnyStringView value)
{
if (m_networkFactory->commonHeaders().values(key).contains(value))
diff --git a/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-header.mustache b/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-header.mustache
index 333e99f..31266ee 100644
--- a/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-header.mustache
+++ b/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-header.mustache
@@ -192,9 +192,7 @@ public Q_SLOTS:
void setWorkingDirectory(const QString &path);
void setNetworkAccessResources(std::shared_ptr<QNetworkAccessManager> manager, std::shared_ptr<QRestAccessManager> ram);
void setNetworkRequestFactory(std::shared_ptr<QNetworkRequestFactory> factory);
- std::optional<int> addServerConfiguration(const QString &operation, const QString &urlTemplate, const QString &description = QString(), const QMap<QString, {{prefix}}ServerVariable> &variables = QMap<QString, {{prefix}}ServerVariable>());
- ServerError setNewServerForAllOperations(const QString &urlTemplate, const QString &description = QString(), const QMap<QString, {{prefix}}ServerVariable> &variables = QMap<QString, {{prefix}}ServerVariable>());
- ServerError setNewServer(const QString &operation, const QString &urlTemplate, const QString &description = QString(), const QMap<QString, {{prefix}}ServerVariable> &variables = QMap<QString, {{prefix}}ServerVariable>());
+
void setHeader(QHttpHeaders::WellKnownHeader key, QAnyStringView value);
void setHeader(QAnyStringView key, QAnyStringView value);
void enableRequestCompression();