Add setting of input.m_headers into the request
- Use all headers from `input.m_headers`, not only ContentType.
We have to use `request.setRawHeader()` in a loop, because the
request might already contain other headers that we want to keep,
and the `request.setHeaders()` call will simply overwrite them.
- Delete from the HttpRequest.cpp.mustache the if() condition,
that now never happens, since we set input.m_headers.
Note: The Openapi generator fails all *.yaml files without a media type,
e.g:
requestBody:
content: {}
- Move setting of ContentType header for {{bodyParams}} block upper
inside the api-body.mustache, because even if the operation doesn't add
empty optional parameters into the resulting message, the operation's
message still should have a ContentType.
- Add tests for ContentType header into the operation-parameters
and mediatypes.
NOTE: ContentType header should always be set for POST operations.
Even operation parameters, that don't use requestBody, need to have
a ContentType header, NOT because Openapi SPEC requires it,
but because Qt Network libs require it.
See qt5/qtbase/src/network/access/qhttpnetworkrequest.cpp
QHttpNetworkRequestPrivate::header() for details.
- Revert alignments to the default ones in
the operation-parameters/server/api_test_.go
Change-Id: I9a5efe44dc01435bc15fa860d0b592d77f54d6dc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
| commit | 87cb0e3aa88c964d6f32989b211539acb333747c |
| parent | f0b24ac6b6bb804c00374ba7197d42215858ab76 |
| author | Tatiana Borisova <tatiana.borisova@qt.io> |
| committer | Tatiana Borisova <tatiana.borisova@qt.io> |
| commit time | Wed, 10 Sep 2025 05:55:20 +0000 |
- M src/main/resources/cpp-qt6-client/HttpRequest.cpp.mustache
- M src/main/resources/cpp-qt6-client/api-body.mustache
- M tests/auto/colorpalette/client/client/QtOAIColorsApi.cpp
- M tests/auto/colorpalette/client/client/QtOAIDefaultApi.cpp
- M tests/auto/colorpalette/client/client/QtOAIHttpRequest.cpp
- M tests/auto/colorpalette/client/client/QtOAIRegisterApi.cpp
- M tests/auto/colorpalette/client/client/QtOAIUsersApi.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIColorsApi.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIDefaultApi.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIHttpRequest.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIRegisterApi.cpp
- M tests/auto/colorpalette/qmlclient/client/OAIUsersApi.cpp
- M tests/auto/mediatype/client/client/QtOAIHttpRequest.cpp
- M tests/auto/mediatype/client/client/QtOAITestApi.cpp
- M tests/auto/mediatype/client/mediatype/MediaType.cpp
- M tests/auto/mediatype/server/go/api_test_.go
- M tests/auto/openapi2.0/client/client/QtOAIHttpRequest.cpp
- M tests/auto/operation-parameters/client/OperationParameters/OperationParameters.cpp
- M tests/auto/operation-parameters/client/client/QtOAIHttpRequest.cpp
- M tests/auto/operation-parameters/server/go/api_test_.go
- M tests/auto/petstore/client/client/QtOAIHttpRequest.cpp
- M tests/auto/petstore/client/client/QtOAIPetApi.cpp
- M tests/auto/petstore/client/client/QtOAIStoreApi.cpp
- M tests/auto/petstore/client/client/QtOAIUserApi.cpp
- M tests/auto/petstore/qmlclient/client/OAIHttpRequest.cpp
- M tests/auto/petstore/qmlclient/client/OAIPetApi.cpp
- M tests/auto/petstore/qmlclient/client/OAIStoreApi.cpp
- M tests/auto/petstore/qmlclient/client/OAIUserApi.cpp