Use ServerConfiguration::url() in the operations
This function substitutes the server variables, so it should be
used instead of the serverUrl().
The test revealed the fact that s URL template with variables in
curly braces (e.g. "http://127.0.0.1:{port}/{basePath}") cannot
be stored in QUrl, because parsing of such URL fails, and as a
result conversion to QString results in an empty string.
This means that url() was always returning an empty QUrl.
To fix it, store the URL template as a QString, and convert to
QUrl only after the variable substitution.
Update all the relevant APIs that were taking QUrl to take
QString instead + adjust the variable name to show that this is
a url template.
This patch also removes the serverUrl() function and introduces
a new urlTempalte() function instead.
Now we have:
* urlTemplate() that returns a QString representing the url
template as specified in the yaml file
* url() which returns an actual QUrl with all server variables
replaced with the actual values.
Task-number: QTBUG-141948
Change-Id: Ia38641187a6f37dddaf39427caa938f74f0a1e13
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Rym Bouabid <rym.bouabid@qt.io>
| commit | ba2d1b4be76b49ea7e2861180cb3d3e7f1affeb5 |
| parent | ec9dda617af5505a4905d92a31461d06dd556975 |
| author | Ivan Solovev <ivan.solovev@qt.io> |
| committer | Ivan Solovev <ivan.solovev@qt.io> |
| commit time | Wed, 26 Nov 2025 18:27:27 +0100 |
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/api-body.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/ServerConfiguration.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-body.mustache
- M src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/api-base-header.mustache
- M tests/auto/CMakeLists.txt
- A tests/auto/server_configuration/CMakeLists.txt
- A tests/auto/server_configuration/client/CMakeLists.txt
- A tests/auto/server_configuration/client/tst_server_configuration/CMakeLists.txt
- A tests/auto/server_configuration/client/tst_server_configuration/server_configuration.yaml
- A tests/auto/server_configuration/client/tst_server_configuration/tst_server_configuration.cpp
- A tests/auto/server_configuration/server/CMakeLists.txt
- A tests/auto/server_configuration/server/go.mod
- A tests/auto/server_configuration/server/go.sum
- A tests/auto/server_configuration/server/go/api_test_.go
- A tests/auto/server_configuration/server/go/routers.go
- A tests/auto/server_configuration/server/main.go