├── .tag
├── coin
├── openapi-generator-cli
│ └── debian
│ │ ├── source
│ │ └── format
│ │ ├── install
│ │ ├── rules
│ │ ├── changelog
│ │ └── control
├── make_openapi_generator_cli_as_debian.sh
├── axivion
│ └── ci_config_linux.json
└── module_config.yaml
├── tests
├── auto
│ ├── mediatype
│ │ ├── client
│ │ │ ├── mediatype
│ │ │ │ ├── file-for-uploading.txt
│ │ │ │ ├── usericon.png
│ │ │ │ └── CMakeLists.txt
│ │ │ └── CMakeLists.txt
│ │ ├── CMakeLists.txt
│ │ └── server
│ │ │ ├── go
│ │ │ ├── model_post_application_json_several_objects_request.go
│ │ │ ├── model_post_multi_part_data_request_form_object.go
│ │ │ ├── model_user.go
│ │ │ └── routers.go
│ │ │ ├── main.go
│ │ │ ├── CMakeLists.txt
│ │ │ └── go.mod
│ ├── petstore
│ │ ├── client
│ │ │ ├── petapitest
│ │ │ │ ├── file-for-uploading.txt
│ │ │ │ └── CMakeLists.txt
│ │ │ ├── CMakeLists.txt
│ │ │ ├── userapitest
│ │ │ │ └── CMakeLists.txt
│ │ │ └── storeapitest
│ │ │ │ └── CMakeLists.txt
│ │ ├── server
│ │ │ ├── qt-logo.png
│ │ │ ├── response.json
│ │ │ ├── go
│ │ │ │ ├── model_tag.go
│ │ │ │ ├── model_pet_status.go
│ │ │ │ ├── model_category.go
│ │ │ │ ├── model_api_response.go
│ │ │ │ ├── model_order.go
│ │ │ │ ├── model_user.go
│ │ │ │ ├── model_pet.go
│ │ │ │ └── api_store.go
│ │ │ ├── main.go
│ │ │ ├── go.mod
│ │ │ └── CMakeLists.txt
│ │ └── CMakeLists.txt
│ ├── responses
│ │ ├── server
│ │ │ ├── test.bin
│ │ │ ├── test.pdf
│ │ │ ├── testImage.jpg
│ │ │ ├── testImage.png
│ │ │ ├── go
│ │ │ │ ├── model_user.go
│ │ │ │ ├── model_application_json_object_response_200_response.go
│ │ │ │ └── routers.go
│ │ │ ├── main.go
│ │ │ ├── go.mod
│ │ │ └── CMakeLists.txt
│ │ ├── client
│ │ │ ├── CMakeLists.txt
│ │ │ └── responses
│ │ │ │ └── CMakeLists.txt
│ │ └── CMakeLists.txt
│ ├── compression
│ │ ├── CMakeLists.txt
│ │ └── client
│ │ │ ├── CMakeLists.txt
│ │ │ └── tst_compression
│ │ │ ├── compression.yaml
│ │ │ ├── tst_compression.cpp
│ │ │ └── CMakeLists.txt
│ ├── openapi2.0
│ │ ├── client
│ │ │ ├── CMakeLists.txt
│ │ │ └── openapi2.0
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── openapi2.0.yaml
│ │ │ │ └── tst_openapi2_0.cpp
│ │ ├── CMakeLists.txt
│ │ └── server
│ │ │ ├── main.go
│ │ │ ├── go
│ │ │ ├── api_fake.go
│ │ │ └── routers.go
│ │ │ ├── CMakeLists.txt
│ │ │ └── go.mod
│ ├── linking_several_clients
│ │ ├── CMakeLists.txt
│ │ └── application
│ │ │ ├── linking_several_clients
│ │ │ ├── client1.yaml
│ │ │ └── client2.yaml
│ │ │ ├── CMakeLists.txt
│ │ │ └── TestConfiguration1.cpp
│ ├── operation-parameters
│ │ ├── client
│ │ │ ├── CMakeLists.txt
│ │ │ └── operationparameters
│ │ │ │ └── CMakeLists.txt
│ │ ├── CMakeLists.txt
│ │ └── server
│ │ │ ├── go
│ │ │ ├── model_double_response.go
│ │ │ ├── model_float_response.go
│ │ │ └── model_test_object.go
│ │ │ ├── main.go
│ │ │ ├── CMakeLists.txt
│ │ │ └── go.mod
│ ├── server_configuration
│ │ ├── CMakeLists.txt
│ │ ├── client
│ │ │ ├── CMakeLists.txt
│ │ │ └── tst_server_configuration
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ └── server_configuration.yaml
│ │ └── server
│ │ │ ├── go
│ │ │ ├── api_test_.go
│ │ │ └── routers.go
│ │ │ ├── main.go
│ │ │ ├── CMakeLists.txt
│ │ │ └── go.mod
│ ├── cmake
│ │ ├── RunCMake
│ │ │ ├── CMakeLists.txt
│ │ │ └── LibraryInstallation
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── find_openapi_deps.cmake
│ │ │ │ ├── src
│ │ │ │ ├── compression.yaml
│ │ │ │ └── tst_compression.cpp
│ │ │ │ ├── consume_installed_lib.cmake
│ │ │ │ ├── build_and_install_lib.cmake
│ │ │ │ └── RunCMakeTest.cmake
│ │ └── CMakeLists.txt
│ ├── common
│ │ └── BuildGoExecutable.cmake
│ └── CMakeLists.txt
└── CMakeLists.txt
├── examples
├── openapi
│ ├── colorpalette
│ │ ├── icons
│ │ │ ├── qt.png
│ │ │ ├── userMask.svg
│ │ │ ├── plus.svg
│ │ │ ├── logout.svg
│ │ │ ├── login.svg
│ │ │ ├── delete.svg
│ │ │ ├── edit.svg
│ │ │ ├── qt_attribution.json
│ │ │ ├── REUSE.toml
│ │ │ ├── update.svg
│ │ │ └── user.svg
│ │ ├── ColorPalette
│ │ │ ├── Main.qml
│ │ │ ├── ColorDialogDelete.qml
│ │ │ └── ColorDialogEditor.qml
│ │ ├── main.cpp
│ │ ├── QtOpenApiExampleStyle
│ │ │ ├── UIStyle.qml
│ │ │ ├── Button.qml
│ │ │ └── CMakeLists.txt
│ │ ├── CMakeLists.txt
│ │ └── ApiBridges.h
│ └── CMakeLists.txt
└── CMakeLists.txt
├── qt_cmdline.cmake
├── src
├── tools
│ ├── qtopenapi-generator
│ │ ├── src
│ │ │ ├── main
│ │ │ │ └── resources
│ │ │ │ │ ├── META-INF
│ │ │ │ │ └── services
│ │ │ │ │ │ └── org.openapitools.codegen.CodegenConfig
│ │ │ │ │ └── cpp-qt6-client
│ │ │ │ │ ├── CMakeConfig.mustache
│ │ │ │ │ ├── common
│ │ │ │ │ ├── CMakeConfig.mustache
│ │ │ │ │ ├── enum-body.mustache
│ │ │ │ │ ├── object-body.mustache
│ │ │ │ │ ├── common-exports.mustache
│ │ │ │ │ ├── enum-header.mustache
│ │ │ │ │ ├── object-header.mustache
│ │ │ │ │ ├── servervariable.cpp.mustache
│ │ │ │ │ ├── CMakeLists.txt.mustache
│ │ │ │ │ ├── servervariable.h.mustache
│ │ │ │ │ ├── serverconfiguration.h.mustache
│ │ │ │ │ ├── httpfileelement.h.mustache
│ │ │ │ │ ├── serverconfiguration.cpp.mustache
│ │ │ │ │ └── httprequest.h.mustache
│ │ │ │ │ ├── licenseInfo.mustache
│ │ │ │ │ ├── exports.mustache
│ │ │ │ │ ├── model-header.mustache
│ │ │ │ │ ├── api-header.mustache
│ │ │ │ │ └── CMakeLists.txt.mustache
│ │ │ └── test
│ │ │ │ └── java
│ │ │ │ └── org
│ │ │ │ └── qtproject
│ │ │ │ └── qt
│ │ │ │ └── codegen
│ │ │ │ └── CppQt6ClientGeneratorTest.java
│ │ ├── logback.xml
│ │ └── CMakeLists.txt
│ └── CMakeLists.txt
├── global
│ ├── qt_cmdline.cmake
│ └── CMakeLists.txt
├── openapi
│ ├── doc
│ │ ├── CMakeLists.txt
│ │ ├── qtopenapi.qdocconf
│ │ └── src
│ │ │ └── qtopenapi-index.qdoc
│ ├── Qt6OpenApiToolsConfigExtras.cmake.in
│ ├── Qt6OpenApiToolsExtraTargets.cmake
│ ├── Qt6OpenApiConfigureDoxygenScript.cmake
│ ├── Qt6OpenApiToolsCopyHeadersScript.cmake
│ └── CMakeLists.txt
├── openapicommon
│ ├── REUSE.toml
│ ├── qtopenapi-common.yaml
│ └── CMakeLists.txt
└── CMakeLists.txt
├── dependencies.yaml
├── .cmake.conf
├── LICENSES
├── LicenseRef-Qt-Commercial.txt
└── BSD-3-Clause.txt
├── cmake
├── FindWrapOpenAPIJava.cmake
└── FindWrapOpenAPIGenerator.cmake
├── CMakeLists.txt
├── REUSE.toml
└── licenseRule.json
/.tag:
--------------------------------------------------------------------------------
1 | 25e1c3c937996bc65031e8b1dc3be58d8ec1173b
2 |
--------------------------------------------------------------------------------
/coin/openapi-generator-cli/debian/source/format:
--------------------------------------------------------------------------------
1 | 3.0 (native)
2 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/client/mediatype/file-for-uploading.txt:
--------------------------------------------------------------------------------
1 | Hello world!
2 |
--------------------------------------------------------------------------------
/tests/auto/petstore/client/petapitest/file-for-uploading.txt:
--------------------------------------------------------------------------------
1 | Hello world!
2 |
--------------------------------------------------------------------------------
/coin/openapi-generator-cli/debian/install:
--------------------------------------------------------------------------------
1 | openapi-generator-cli.jar usr/bin/
2 |
--------------------------------------------------------------------------------
/coin/openapi-generator-cli/debian/rules:
--------------------------------------------------------------------------------
1 | #!/usr/bin/make -f
2 | #export DH_VERBOSE = 1
3 |
4 | %:
5 | dh $@
6 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/qt-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qt/qtopenapi/dev/tests/auto/petstore/server/qt-logo.png
--------------------------------------------------------------------------------
/tests/auto/petstore/server/response.json:
--------------------------------------------------------------------------------
1 | {
2 | "file-name" : "Hi, I am a response!",
3 | "value" : 81
4 | }
5 |
--------------------------------------------------------------------------------
/tests/auto/responses/server/test.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qt/qtopenapi/dev/tests/auto/responses/server/test.bin
--------------------------------------------------------------------------------
/tests/auto/responses/server/test.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qt/qtopenapi/dev/tests/auto/responses/server/test.pdf
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/qt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qt/qtopenapi/dev/examples/openapi/colorpalette/icons/qt.png
--------------------------------------------------------------------------------
/tests/auto/responses/server/testImage.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qt/qtopenapi/dev/tests/auto/responses/server/testImage.jpg
--------------------------------------------------------------------------------
/tests/auto/responses/server/testImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qt/qtopenapi/dev/tests/auto/responses/server/testImage.png
--------------------------------------------------------------------------------
/qt_cmdline.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | qt_commandline_subconfig(src)
5 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/client/mediatype/usericon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qt/qtopenapi/dev/tests/auto/mediatype/client/mediatype/usericon.png
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig:
--------------------------------------------------------------------------------
1 | org.qtproject.qt.codegen.CppQt6ClientGenerator
2 |
3 |
--------------------------------------------------------------------------------
/tests/auto/compression/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(client)
5 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(mediatype)
5 |
--------------------------------------------------------------------------------
/tests/auto/responses/client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(responses)
5 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(openapi2.0)
5 |
--------------------------------------------------------------------------------
/tests/auto/compression/client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(tst_compression)
5 |
--------------------------------------------------------------------------------
/tests/auto/linking_several_clients/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(application)
5 |
--------------------------------------------------------------------------------
/src/global/qt_cmdline.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | qt_commandline_option(openapi_generator TYPE boolean)
5 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(server)
5 | add_subdirectory(client)
6 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(server)
5 | add_subdirectory(client)
6 |
--------------------------------------------------------------------------------
/tests/auto/petstore/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(server)
5 | add_subdirectory(client)
6 |
--------------------------------------------------------------------------------
/tests/auto/responses/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(server)
5 | add_subdirectory(client)
6 |
--------------------------------------------------------------------------------
/tests/auto/operation-parameters/client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(operationparameters)
5 |
--------------------------------------------------------------------------------
/tests/auto/operation-parameters/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(server)
5 | add_subdirectory(client)
6 |
--------------------------------------------------------------------------------
/tests/auto/server_configuration/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(server)
5 | add_subdirectory(client)
6 |
--------------------------------------------------------------------------------
/tests/auto/server_configuration/client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_subdirectory(tst_server_configuration)
5 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/userMask.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
--------------------------------------------------------------------------------
/src/tools/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(QT_FEATURE_openapi_generator)
5 | add_subdirectory(qtopenapi-generator)
6 | endif()
7 |
--------------------------------------------------------------------------------
/coin/openapi-generator-cli/debian/changelog:
--------------------------------------------------------------------------------
1 |
2 | openapi-generator-cli (CLI_VERSION) unstable; urgency=medium
3 |
4 | * Initial release.
5 |
6 | -- The Qt Company Fri, 12 Dec 2025 08:00:00 +0200
7 |
--------------------------------------------------------------------------------
/src/openapi/doc/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | add_library(OpenApiDoc INTERFACE)
5 |
6 | qt_internal_add_docs(OpenApiDoc qtopenapi.qdocconf)
7 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/CMakeConfig.mustache:
--------------------------------------------------------------------------------
1 | @PACKAGE_INIT@
2 |
3 | include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)
4 |
5 | check_required_components("@PROJECT_NAME@")
6 |
--------------------------------------------------------------------------------
/dependencies.yaml:
--------------------------------------------------------------------------------
1 | dependencies:
2 | ../qtbase:
3 | ref: df1292e2b96aab02ad6df778d8336e7958ad5d1c
4 | required: true
5 | ../qtdeclarative:
6 | ref: 7ef1d06ce70fa360613dca0b5ff03365ebbc9883
7 | required: false
8 |
--------------------------------------------------------------------------------
/examples/openapi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | if(TARGET Qt::Quick)
5 | qt_internal_add_example(colorpalette)
6 | endif()
7 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/plus.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/tests/auto/cmake/RunCMake/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | set(extra_run_cmake_args "")
5 | qt_internal_add_RunCMake_test(LibraryInstallation ${extra_run_cmake_args})
6 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/CMakeConfig.mustache:
--------------------------------------------------------------------------------
1 | @PACKAGE_INIT@
2 |
3 | include(${CMAKE_CURRENT_LIST_DIR}/{{{commonLibraryName}}}Targets.cmake)
4 |
5 | check_required_components("{{{commonLibraryName}}}")
6 |
--------------------------------------------------------------------------------
/src/openapi/Qt6OpenApiToolsConfigExtras.cmake.in:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | set(QT_OPENAPI_GENERATOR_VERSION "@QT_OPENAPI_GENERATOR_VERSION@")
5 | set(QT_OPENAPI_GENERATOR_NAME "@QT_OPENAPI_GENERATOR_NAME@")
6 |
--------------------------------------------------------------------------------
/tests/auto/cmake/RunCMake/LibraryInstallation/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 | project(${RunCMake_TEST} LANGUAGES CXX VERSION "1.0.0")
6 | include(${RunCMake_TEST}.cmake)
7 |
--------------------------------------------------------------------------------
/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | qt_examples_build_begin(EXTERNAL_BUILD)
5 |
6 | if(TARGET Qt::OpenApi)
7 | add_subdirectory(openapi)
8 | endif()
9 |
10 | qt_examples_build_end()
11 |
--------------------------------------------------------------------------------
/tests/auto/cmake/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 | project(qtopenapi_cmake_tests)
6 | enable_testing()
7 |
8 | # Add all tests using CMake's RunCMake test module
9 | add_subdirectory(RunCMake)
10 |
--------------------------------------------------------------------------------
/tests/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(QT_BUILD_STANDALONE_TESTS)
5 | # Gui is need to build and run tests on Android Platforms.
6 | find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Gui)
7 | endif()
8 | qt_build_tests()
9 |
--------------------------------------------------------------------------------
/src/global/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | qt_feature_module_begin(NO_MODULE
5 | PUBLIC_FILE fake_openapi_config.h
6 | PRIVATE_FILE fake_openapi_config_p.h
7 | )
8 | include("${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
9 | qt_feature_module_end(NO_MODULE)
10 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/licenseInfo.mustache:
--------------------------------------------------------------------------------
1 | /**
2 | * {{{appName}}}
3 | *
4 | * {{appDescription}}
5 | * {{{licenseName}}}
6 | *
7 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
8 | * https://openapi-generator.tech
9 | * Do not edit the class manually.
10 | */
11 |
--------------------------------------------------------------------------------
/src/openapicommon/REUSE.toml:
--------------------------------------------------------------------------------
1 | version = 1
2 | [[annotations]]
3 | path = ["qtopenapi-common.yaml"]
4 | precedence = "override"
5 | comment = "spec file has a license literl inside of it that confuses reuse"
6 | SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
7 | SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only"
8 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/logout.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/login.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/tests/auto/responses/server/go/model_user.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Responses Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates various response media types.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | type User struct {
13 |
14 | Name string `json:"name,omitempty"`
15 |
16 | Id int32 `json:"id,omitempty"`
17 | }
18 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/delete.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/enum-body.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | #include "{{prefixLowerCase}}enum.h"
3 |
4 | {{#cppCommonNamespaceDeclarations}}
5 | namespace {{this}} {
6 | {{/cppCommonNamespaceDeclarations}}
7 |
8 | {{prefix}}Enum::{{prefix}}Enum() = default;
9 |
10 | {{prefix}}Enum::~{{prefix}}Enum() = default;
11 |
12 | {{#cppCommonNamespaceDeclarations}}
13 | } // namespace {{this}}
14 | {{/cppCommonNamespaceDeclarations}}
15 |
--------------------------------------------------------------------------------
/coin/openapi-generator-cli/debian/control:
--------------------------------------------------------------------------------
1 |
2 | Source: openapi-generator-cli
3 | Section: java
4 | Priority: optional
5 | Maintainer: QtCompany
6 | Build-Depends: debhelper-compat (= 13)
7 | Standards-Version: 4.7.0
8 | Rules-Requires-Root: no
9 |
10 | Package: openapi-generator-cli
11 | Architecture: all
12 | Depends: ${misc:Depends}, default-jre | java-runtime
13 | Description: openapi-generator-cli.jar packaged as a .deb
14 | openapi-generator-cli.jar packaged as a .deb
15 |
16 |
--------------------------------------------------------------------------------
/tests/auto/petstore/client/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | qt_add_library(PetStoreClient)
5 | qt6_add_openapi_client(PetStoreClient
6 | SPEC_FILE
7 | ${CMAKE_CURRENT_SOURCE_DIR}/petstore.yaml
8 | )
9 | qt_autogen_tools_initial_setup(PetStoreClient)
10 |
11 | if(TARGET Qt::Gui)
12 | add_subdirectory(petapitest)
13 | endif()
14 | add_subdirectory(storeapitest)
15 | add_subdirectory(userapitest)
16 |
--------------------------------------------------------------------------------
/.cmake.conf:
--------------------------------------------------------------------------------
1 | set(QT_REPO_MODULE_VERSION "6.12.0")
2 | set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
3 | set(QT_OPENAPI_GENERATOR_VERSION "1.0.0")
4 | set(QT_OPENAPI_GENERATOR_NAME "cpp-qt6-client")
5 |
6 | set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_LEAN_HEADERS=1")
7 | list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1")
8 | list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_FOREACH=1")
9 | list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_CONTEXTLESS_CONNECT=1")
10 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/object-body.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | #include "{{prefixLowerCase}}object.h"
3 |
4 | {{#cppCommonNamespaceDeclarations}}
5 | namespace {{this}} {
6 | {{/cppCommonNamespaceDeclarations}}
7 |
8 | {{prefix}}Object::{{prefix}}Object() = default;
9 |
10 | {{prefix}}Object::~{{prefix}}Object() = default;
11 |
12 | {{#cppCommonNamespaceDeclarations}}
13 | } // namespace {{this}}
14 | {{/cppCommonNamespaceDeclarations}}
15 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/go/model_tag.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI Petstore
3 | *
4 | * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | // Tag - A tag for a pet
13 | type Tag struct {
14 |
15 | Id int64 `json:"id,omitempty"`
16 |
17 | Name string `json:"name,omitempty"`
18 | }
19 |
--------------------------------------------------------------------------------
/LICENSES/LicenseRef-Qt-Commercial.txt:
--------------------------------------------------------------------------------
1 | Licensees holding valid commercial Qt licenses may use this software in
2 | accordance with the the terms contained in a written agreement between
3 | you and The Qt Company. Alternatively, the terms and conditions that were
4 | accepted by the licensee when buying and/or downloading the
5 | software do apply.
6 |
7 | For the latest licensing terms and conditions, see https://www.qt.io/terms-conditions.
8 | For further information use the contact form at https://www.qt.io/contact-us.
9 |
--------------------------------------------------------------------------------
/tests/auto/responses/server/go/model_application_json_object_response_200_response.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Responses Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates various response media types.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | type ApplicationJsonObjectResponse200Response struct {
13 | Status string `json:"status,omitempty"`
14 |
15 | Value int64 `json:"value,omitempty"`
16 | }
17 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/edit.svg:
--------------------------------------------------------------------------------
1 |
4 |
5 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/go/model_pet_status.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI Petstore
3 | *
4 | * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | type PetStatus string
13 |
14 | // List of PetStatus
15 | const (
16 | AVAILABLE PetStatus = "available"
17 | PENDING PetStatus = "pending"
18 | SOLD PetStatus = "sold"
19 | )
20 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/qt_attribution.json:
--------------------------------------------------------------------------------
1 | {
2 | "Id": "colorpaletteapp",
3 | "Name": "Selected Material Icons",
4 | "QDocModule": "qtopenapi",
5 | "QtUsage": "Used in Color Palette Client example in QtOpenAPI",
6 | "QtParts": [
7 | "examples"
8 | ],
9 | "Files": "login.svg logout.svg user.svg delete.svg edit.svg update.svg",
10 | "Homepage": "https://fonts.google.com/icons",
11 | "License": "Apache License Version 2.0",
12 | "LicenseId": "Apache-2.0",
13 | "Copyright": "Copyright 2018 Google, Inc. All Rights Reserved."
14 | }
15 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/go/model_category.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI Petstore
3 | *
4 | * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | // Category - A category for a pet
13 | type Category struct {
14 |
15 | Id int64 `json:"id,omitempty"`
16 |
17 | Name string `json:"name,omitempty" validate:"regexp=^[a-zA-Z0-9]+[a-zA-Z0-9\\\\.\\\\-_]*[a-zA-Z0-9]+$"`
18 | }
19 |
--------------------------------------------------------------------------------
/tests/auto/cmake/RunCMake/LibraryInstallation/find_openapi_deps.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | set(deps_available TRUE)
5 |
6 | # Try to find the openapi deps. If they are missing, we will skip the test, because
7 | # not all CI platforms have them installed.
8 | find_package(Qt6 COMPONENTS OpenApi OpenApiCommon)
9 |
10 | if(NOT TARGET Qt6::OpenApi OR NOT TARGET Qt6::OpenApiCommon)
11 | set(deps_available FALSE)
12 | endif()
13 |
14 | file(WRITE "${DEPS_AVAILABLE_INCLUDE_PATH}" "set(DEPS_AVAILABLE \"${deps_available}\")\n")
15 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/server/go/model_post_application_json_several_objects_request.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Operation Parameters Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates a wide range of content types for requestBody. The goal is to verify correct url for each case.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | type PostApplicationJsonSeveralObjectsRequest struct {
13 |
14 | Uuid string `json:"uuid,omitempty"`
15 |
16 | User User `json:"user,omitempty"`
17 | }
18 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/server/go/model_post_multi_part_data_request_form_object.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Operation Parameters Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates a wide range of content types for requestBody. The goal is to verify correct url for each case.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | type PostMultiPartDataRequestFormObject struct {
13 |
14 | ObjectId int32 `json:"objectId,omitempty"`
15 |
16 | ObjectName string `json:"objectName,omitempty"`
17 | }
18 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/go/model_api_response.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI Petstore
3 | *
4 | * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | // ApiResponse - Describes the result of uploading an image resource
13 | type ApiResponse struct {
14 |
15 | Code int32 `json:"code,omitempty"`
16 |
17 | Type string `json:"type,omitempty"`
18 |
19 | Message string `json:"message,omitempty"`
20 | }
21 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/server/go/model_user.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Operation Parameters Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates a wide range of content types for requestBody. The goal is to verify correct url for each case.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | type User struct {
13 |
14 | // User name
15 | Name string `json:"name,omitempty"`
16 |
17 | // User status
18 | Status string `json:"status,omitempty"`
19 |
20 | // User age
21 | Age int32 `json:"age,omitempty"`
22 | }
23 |
--------------------------------------------------------------------------------
/src/openapicommon/qtopenapi-common.yaml:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3 |
4 | openapi: 3.1.0
5 | info:
6 | description: >
7 | The Qt6 Common library is auto-generated and available to users under the same
8 | license as the Qt which it is used with or built with. See available licenses below.
9 | version: 1.0.0
10 | title: Qt6 Common library
11 | license:
12 | name: 'SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only'
13 | url: 'https:'
14 | paths: {}
15 |
--------------------------------------------------------------------------------
/coin/make_openapi_generator_cli_as_debian.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Copyright (C) 2025 The Qt Company Ltd.
3 | # SPDX-License-Identifier: BSD-3-Clause
4 |
5 | cd coin/openapi-generator-cli || exit
6 | # The dir is set in provisioning script..
7 | cp /opt/qt-openapi/openapi-generator-cli.jar .
8 | version=$(java -jar ./openapi-generator-cli.jar version)
9 | sed -i "s/CLI_VERSION/$version/g" debian/changelog
10 | dpkg-buildpackage -us -uc
11 | cd ..
12 | mkdir -p /home/qt/work/output/debian_packages/
13 | # To build qtopenapi
14 | cp ./*.deb /home/qt/work/debian_packages/
15 | # For artifacts
16 | mv ./*.deb /home/qt/work/output/debian_packages/
17 |
--------------------------------------------------------------------------------
/src/openapi/Qt6OpenApiToolsExtraTargets.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT TARGET "${QT_CMAKE_EXPORT_NAMESPACE}::QtOpenAPIGeneratorJar")
5 | add_executable("${QT_CMAKE_EXPORT_NAMESPACE}::QtOpenAPIGeneratorJar" IMPORTED GLOBAL)
6 |
7 | set(_qt_openapi_generator_path
8 | "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_LIBEXECS}/cpp-qt6-client-openapi-generator-${QT_OPENAPI_GENERATOR_VERSION}.jar")
9 |
10 | set_target_properties("${QT_CMAKE_EXPORT_NAMESPACE}::QtOpenAPIGeneratorJar"
11 | PROPERTIES IMPORTED_LOCATION "${_qt_openapi_generator_path}")
12 | endif()
13 |
--------------------------------------------------------------------------------
/tests/auto/server_configuration/server/go/api_test_.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Server Configuration Test
3 | *
4 | * This specification is needed to check how various server configurations are handled.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | import (
13 | "github.com/gin-gonic/gin"
14 | )
15 |
16 | type TestAPI struct {
17 | }
18 |
19 | // Post /v1/operations/dummy
20 | // not used for now
21 | func (api *TestAPI) DummyOperation(c *gin.Context) {
22 | // Your handler implementation
23 | c.JSON(200, gin.H{"status": c.Request.RequestURI});
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/server/main.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI 2.0 test
3 | *
4 | * This spec is mainly for testing Openapi 2.0
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package main
11 |
12 | import (
13 | "log"
14 |
15 | // WARNING!
16 | // Pass --git-repo-id and --git-user-id properties when generating the code
17 | //
18 | sw "github.com/GIT_USER_ID/GIT_REPO_ID/go"
19 | )
20 |
21 | func main() {
22 | routes := sw.ApiHandleFunctions{}
23 |
24 | log.Printf("Server started")
25 |
26 | router := sw.NewRouter(routes)
27 |
28 | log.Fatal(router.Run(":10300"))
29 | }
30 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/exports.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | #ifndef {{packageNameUpperCase}}_EXPORTS_H
3 | #define {{packageNameUpperCase}}_EXPORTS_H
4 |
5 | #include
6 |
7 | #if defined({{packageNameUpperCase}}_LIB_SHARED) || !defined({{packageNameUpperCase}}_LIB_STATIC)
8 | # if defined({{packageNameUpperCase}}_BUILD_LIB)
9 | # define {{packageNameUpperCase}}_EXPORT Q_DECL_EXPORT
10 | # else
11 | # define {{packageNameUpperCase}}_EXPORT Q_DECL_IMPORT
12 | # endif
13 | #else
14 | # define {{packageNameUpperCase}}_EXPORT
15 | #endif
16 |
17 | #endif // {{packageNameUpperCase}}_EXPORTS_H
18 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/REUSE.toml:
--------------------------------------------------------------------------------
1 | version = 1
2 |
3 | [[annotations]]
4 | path = ["login.svg", "logout.svg", "user.svg", "delete.svg",
5 | "edit.svg", "update.svg"]
6 | comment = "files listed in the qt_attribution.json file"
7 | precedence = "closest"
8 | SPDX-FileCopyrightText = "Copyright 2018 Google, Inc. All Rights Reserved."
9 | SPDX-License-Identifier = "Apache-2.0"
10 |
11 | [[annotations]]
12 | path = ["plus.svg", "qt.png", "userMask.svg"]
13 | comment = "files not listed in the qt_attribution.json"
14 | precedence = "closest"
15 | SPDX-FileCopyrightText = "Copyright 2018 Google, Inc. All Rights Reserved."
16 | SPDX-License-Identifier = "Apache-2.0"
17 |
--------------------------------------------------------------------------------
/tests/auto/operation-parameters/server/go/model_double_response.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Operation Parameters Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates a wide range of combinations of the `style` and `explode` attributes for parameters in various locations: query, path, header, and cookie. The goal is to verify correct path and parameter generation for each case.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | type DoubleResponse struct {
13 |
14 | StringValue string `json:"stringValue,omitempty"`
15 |
16 | Value float64 `json:"value,omitempty"`
17 | }
18 |
--------------------------------------------------------------------------------
/tests/auto/operation-parameters/server/go/model_float_response.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Operation Parameters Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates a wide range of combinations of the `style` and `explode` attributes for parameters in various locations: query, path, header, and cookie. The goal is to verify correct path and parameter generation for each case.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | type FloatResponse struct {
13 |
14 | StringValue string `json:"stringValue,omitempty"`
15 |
16 | Value float32 `json:"value,omitempty"`
17 | }
18 |
--------------------------------------------------------------------------------
/tests/auto/responses/server/main.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Responses Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates various response media types.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package main
11 |
12 | import (
13 | "log"
14 |
15 | // WARNING!
16 | // Pass --git-repo-id and --git-user-id properties when generating the code
17 | //
18 | sw "github.com/GIT_USER_ID/GIT_REPO_ID/go"
19 | )
20 |
21 | func main() {
22 | routes := sw.ApiHandleFunctions{}
23 |
24 | log.Printf("Server started")
25 |
26 | router := sw.NewRouter(routes)
27 |
28 | log.Fatal(router.Run(":20202"))
29 | }
30 |
--------------------------------------------------------------------------------
/tests/auto/server_configuration/server/main.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Server Configuration Test
3 | *
4 | * This specification is needed to check how various server configurations are handled.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package main
11 |
12 | import (
13 | "log"
14 |
15 | // WARNING!
16 | // Pass --git-repo-id and --git-user-id properties when generating the code
17 | //
18 | sw "github.com/GIT_USER_ID/GIT_REPO_ID/go"
19 | )
20 |
21 | func main() {
22 | routes := sw.ApiHandleFunctions{}
23 |
24 | log.Printf("Server started")
25 |
26 | router := sw.NewRouter(routes)
27 |
28 | log.Fatal(router.Run(":20303"))
29 | }
30 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/ColorPalette/Main.qml:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | import QtQuick
5 |
6 | Window {
7 | width: 640
8 | height: 480
9 | visible: true
10 | title: qsTr("Color Palette")
11 |
12 | ServerSelection {
13 | id: serverview
14 | anchors.fill: parent
15 | onServerSelected: {colorview.visible = true; serverview.visible = false}
16 | }
17 |
18 | ColorView {
19 | id: colorview
20 | anchors.fill: parent
21 | visible: false // initially invisible
22 | onErrorOccurred: {colorview.visible = false; serverview.visible = true}
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/cmake/FindWrapOpenAPIJava.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(TARGET WrapOpenAPIJava::WrapOpenAPIJava)
5 | set(WrapOpenAPIJava_FOUND TRUE)
6 | return()
7 | endif()
8 |
9 | find_package(Java COMPONENTS Runtime)
10 |
11 | include(FindPackageHandleStandardArgs)
12 | find_package_handle_standard_args(WrapOpenAPIJava
13 | REQUIRED_VARS
14 | Java_JAVA_EXECUTABLE
15 | )
16 |
17 | if(WrapOpenAPIJava_FOUND)
18 | add_library(WrapOpenAPIJava::WrapOpenAPIJava INTERFACE IMPORTED)
19 | set_target_properties(WrapOpenAPIJava::WrapOpenAPIJava PROPERTIES
20 | INTERFACE_OPENAPI_JAVA_RUNTIME_PATH "${Java_JAVA_EXECUTABLE}"
21 | )
22 | endif()
23 |
24 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/main.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI Petstore
3 | *
4 | * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package main
11 |
12 | import (
13 | "log"
14 |
15 | // WARNING!
16 | // Pass --git-repo-id and --git-user-id properties when generating the code
17 | //
18 | sw "github.com/GIT_USER_ID/GIT_REPO_ID/go"
19 | )
20 |
21 | func main() {
22 | routes := sw.ApiHandleFunctions{}
23 |
24 | log.Printf("Server started")
25 |
26 | router := sw.NewRouter(routes)
27 |
28 | log.Fatal(router.Run(":19080"))
29 | }
30 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/common-exports.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | #ifndef {{packageNameUpperCase}}_COMMON_EXPORTS_H
3 | #define {{packageNameUpperCase}}_COMMON_EXPORTS_H
4 |
5 | #include
6 |
7 | #if defined({{packageNameUpperCase}}_COMMON_LIB_SHARED) || !defined({{packageNameUpperCase}}_COMMON_LIB_STATIC)
8 | # if defined({{packageNameUpperCase}}_BUILD_COMMON_LIB)
9 | # define {{packageNameUpperCase}}_COMMON_EXPORT Q_DECL_EXPORT
10 | # else
11 | # define {{packageNameUpperCase}}_COMMON_EXPORT Q_DECL_IMPORT
12 | # endif
13 | #else
14 | # define {{packageNameUpperCase}}_COMMON_EXPORT
15 | #endif
16 |
17 | #endif // {{packageNameUpperCase}}_COMMON_EXPORTS_H
18 |
--------------------------------------------------------------------------------
/tests/auto/operation-parameters/server/go/model_test_object.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Operation Parameters Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates a wide range of combinations of the `style` and `explode` attributes for parameters in various locations: query, path, header, and cookie. The goal is to verify correct path and parameter generation for each case.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | type TestObject struct {
13 |
14 | // Updated name
15 | Name string `json:"name,omitempty"`
16 |
17 | // Updated status
18 | Status string `json:"status,omitempty"`
19 |
20 | // age number
21 | Age int32 `json:"age,omitempty"`
22 | }
23 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/update.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/server/main.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Operation Parameters Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates a wide range of content types for requestBody. The goal is to verify correct url for each case.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package main
11 |
12 | import (
13 | "log"
14 |
15 | // WARNING!
16 | // Pass --git-repo-id and --git-user-id properties when generating the code
17 | //
18 | sw "github.com/GIT_USER_ID/GIT_REPO_ID/go"
19 | )
20 |
21 | func main() {
22 | routes := sw.ApiHandleFunctions{}
23 |
24 | log.Printf("Server started")
25 |
26 | router := sw.NewRouter(routes)
27 |
28 | log.Fatal(router.Run(":10209"))
29 | }
30 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/server/go/api_fake.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI 2.0 test
3 | *
4 | * This spec is mainly for testing Openapi 2.0
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | import (
13 | "github.com/gin-gonic/gin"
14 | )
15 |
16 | type FakeAPI struct {
17 | }
18 |
19 | // Post /v2/fake/test-path-parameters/:pipeId/:ioutilId/:httpId/:urlId/:multiContextId
20 | func (api *FakeAPI) TestPathParameterCollectionFormat(c *gin.Context) {
21 | c.JSON(200, gin.H{"status": c.Request.RequestURI})
22 | }
23 |
24 | // Post /v2/fake/test-query-parameters
25 | func (api *FakeAPI) TestQueryParameterCollectionFormat(c *gin.Context) {
26 | c.JSON(200, gin.H{"status": c.Request.RequestURI})
27 | }
28 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/go/model_order.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI Petstore
3 | *
4 | * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | import (
13 | "time"
14 | )
15 |
16 | // Order - An order for a pets from the pet store
17 | type Order struct {
18 |
19 | Id int64 `json:"id,omitempty"`
20 |
21 | PetId int64 `json:"petId,omitempty"`
22 |
23 | Quantity int32 `json:"quantity,omitempty"`
24 |
25 | ShipDate time.Time `json:"shipDate,omitempty"`
26 |
27 | // Order Status
28 | Status string `json:"status,omitempty"`
29 |
30 | Complete bool `json:"complete,omitempty"`
31 | }
32 |
--------------------------------------------------------------------------------
/src/openapi/doc/qtopenapi.qdocconf:
--------------------------------------------------------------------------------
1 | include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
2 |
3 | project = QtOpenAPI
4 | description = Qt OpenAPI Reference Documentation
5 | version = $QT_VERSION
6 |
7 | qhp.projects = QtOpenAPI
8 |
9 | qhp.QtOpenAPI.file = qtopenapi.qhp
10 | qhp.QtOpenAPI.namespace = org.qt-project.qtopenapi.$QT_VERSION_TAG
11 | qhp.QtOpenAPI.virtualFolder = qtopenapi
12 | qhp.QtOpenAPI.indexTitle = Qt OpenAPI
13 | qhp.QtOpenAPI.indexRoot =
14 |
15 | moduleheader =
16 |
17 | sourcedirs += ..
18 |
19 | depends += qtdoc qtcmake qtcore qtnetwork
20 |
21 | navigation.landingpage = "Qt OpenAPI"
22 |
23 | # Fail the documentation build if there are more warnings than the limit
24 | warninglimit = 10
25 |
--------------------------------------------------------------------------------
/tests/auto/compression/client/tst_compression/compression.yaml:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | openapi: 3.1.1
5 | servers:
6 | - url: 'http://127.0.0.1:20203/v2'
7 | info:
8 | title: Compression Test
9 | description: >
10 | This specification is needed to check how the compression is implemented.
11 | version: 1.0.0
12 | tags:
13 | - name: test
14 | description: test operations
15 |
16 | paths:
17 | /compression/dummy:
18 | post:
19 | tags: [test]
20 | operationId: dummyOperation
21 | summary: "not used for now"
22 | responses:
23 | '200':
24 | description: OK
25 | content:
26 | application/json:
27 | schema:
28 | type: string
29 |
--------------------------------------------------------------------------------
/tests/auto/cmake/RunCMake/LibraryInstallation/src/compression.yaml:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | openapi: 3.1.1
5 | servers:
6 | - url: 'http://127.0.0.1:20203/v2'
7 | info:
8 | title: Compression Test
9 | description: >
10 | This specification is needed to check how the compression is implemented.
11 | version: 1.0.0
12 | tags:
13 | - name: test
14 | description: test operations
15 |
16 | paths:
17 | /compression/dummy:
18 | post:
19 | tags: [test]
20 | operationId: dummyOperation
21 | summary: "not used for now"
22 | responses:
23 | '200':
24 | description: OK
25 | content:
26 | application/json:
27 | schema:
28 | type: string
29 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/icons/user.svg:
--------------------------------------------------------------------------------
1 |
5 |
6 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/go/model_user.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI Petstore
3 | *
4 | * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | // User - A User who is purchasing from the pet store
13 | type User struct {
14 |
15 | Id int64 `json:"id,omitempty"`
16 |
17 | Username string `json:"username,omitempty"`
18 |
19 | FirstName string `json:"firstName,omitempty"`
20 |
21 | LastName string `json:"lastName,omitempty"`
22 |
23 | Email string `json:"email,omitempty"`
24 |
25 | Password string `json:"password,omitempty"`
26 |
27 | Phone string `json:"phone,omitempty"`
28 |
29 | // User Status
30 | UserStatus int32 `json:"userStatus,omitempty"`
31 | }
32 |
--------------------------------------------------------------------------------
/tests/auto/operation-parameters/server/main.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Operation Parameters Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates a wide range of combinations of the `style` and `explode` attributes for parameters in various locations: query, path, header, and cookie. The goal is to verify correct path and parameter generation for each case.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package main
11 |
12 | import (
13 | "log"
14 |
15 | // WARNING!
16 | // Pass --git-repo-id and --git-user-id properties when generating the code
17 | //
18 | sw "github.com/GIT_USER_ID/GIT_REPO_ID/go"
19 | )
20 |
21 | func main() {
22 | routes := sw.ApiHandleFunctions{}
23 |
24 | log.Printf("Server started")
25 |
26 | router := sw.NewRouter(routes)
27 |
28 | log.Fatal(router.Run(":10203"))
29 | }
30 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/go/model_pet.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI Petstore
3 | *
4 | * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | // Pet - A pet for sale in the pet store
13 | type Pet struct {
14 |
15 | Id int64 `json:"id,omitempty"`
16 |
17 | Category Category `json:"category,omitempty"`
18 |
19 | Name string `json:"name"`
20 |
21 | PhotoUrls []string `json:"photoUrls"`
22 |
23 | Tags []Tag `json:"tags,omitempty"`
24 |
25 | // pet status in the store
26 | // Deprecated
27 | Status PetStatus `json:"status,omitempty"`
28 |
29 | Age int32 `json:"age,omitempty"`
30 |
31 | // Do not use omitempty, because we use 0 as a valid value in tests
32 | Patience int32 `json:"patience"`
33 | }
34 |
--------------------------------------------------------------------------------
/src/openapi/Qt6OpenApiConfigureDoxygenScript.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.21)
5 |
6 | if(NOT DOXYGEN_IN_FILE_PATH)
7 | message(FATAL_ERROR "Doxyfile input file is not set")
8 | endif()
9 |
10 | if(NOT DOXYGEN_OUT_FILE_PATH)
11 | message(FATAL_ERROR "Doxyfile output file is not set")
12 | endif()
13 |
14 | if(NOT INPUT_DIR)
15 | message(FATAL_ERROR "INPUT_DIR is not set")
16 | endif()
17 |
18 | if(NOT OUTPUT_DIR)
19 | message(FATAL_ERROR "OUTPUT_DIR is not set")
20 | endif()
21 |
22 | if(NOT EXCLUDE_FILE)
23 | message(FATAL_ERROR "EXCLUDE_FILE is not set")
24 | endif()
25 |
26 | set(DOXY_OUT_DIR "${OUTPUT_DIR}")
27 | set(DOXY_IN_DIR "${INPUT_DIR}")
28 | set(DOXY_EXCLUDE_FILE "${EXCLUDE_FILE}")
29 |
30 | configure_file(
31 | "${DOXYGEN_IN_FILE_PATH}"
32 | "${DOXYGEN_OUT_FILE_PATH}"
33 | @ONLY
34 | )
35 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/main.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "ApiBridges.h"
9 |
10 | int main(int argc, char *argv[])
11 | {
12 | QGuiApplication app(argc, argv);
13 |
14 | QtOpenAPI::ColorsApi colorsApiInstance;
15 | ForeignColorsAPI::s_singletonInstance = &colorsApiInstance;
16 |
17 | QtOpenAPI::UsersApi usersApiInstance;
18 | ForeignUsersAPI::s_singletonInstance = &usersApiInstance;
19 |
20 | QQmlApplicationEngine engine;
21 |
22 | QObject::connect(
23 | &engine, &QQmlApplicationEngine::objectCreationFailed, &app,
24 | []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);
25 |
26 | engine.loadFromModule("ColorPalette", "Main");
27 |
28 | return app.exec();
29 | }
30 |
--------------------------------------------------------------------------------
/tests/auto/operation-parameters/server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 |
6 | find_program(OPENAPI_GO_EXECUTABLE NAMES go)
7 |
8 | if (NOT OPENAPI_GO_EXECUTABLE)
9 | message(WARNING "Go (golang) is not installed or not in the PATH.")
10 | return()
11 | endif()
12 |
13 | include(../../common/BuildGoExecutable.cmake)
14 |
15 | set(GO_BINARY op-server-app)
16 | set(GO_SOURCE main.go)
17 |
18 | build_go_executable(${GO_BINARY} ${GO_SOURCE})
19 |
20 | # Custom target that depends on the output binary
21 | add_custom_target(op-server-build ALL
22 | DEPENDS ${GO_BINARY}
23 | )
24 |
25 | add_executable(op-server-go IMPORTED)
26 | add_dependencies(op-server-go op-server-build)
27 | set_target_properties(op-server-go PROPERTIES
28 | IMPORTED_LOCATION
29 | "${CMAKE_CURRENT_BINARY_DIR}/op-server-app"
30 | IMPORTED_GLOBAL TRUE
31 | )
32 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/QtOpenApiExampleStyle/UIStyle.qml:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2023 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | pragma Singleton
5 |
6 | import QtQuick
7 |
8 | QtObject {
9 | id: uiStyle
10 |
11 | // Font Sizes
12 | readonly property int fontSizeXXS: 10
13 | readonly property int fontSizeXS: 15
14 | readonly property int fontSizeS: 20
15 | readonly property int fontSizeM: 25
16 | readonly property int fontSizeL: 30
17 | readonly property int fontSizeXL: 35
18 | readonly property int fontSizeXXL: 40
19 |
20 | // Color Scheme
21 | // Green
22 | readonly property color colorQtPrimGreen: "#41cd52"
23 | readonly property color colorQtAuxGreen1: "#21be2b"
24 | readonly property color colorQtAuxGreen2: "#17a81a"
25 |
26 | function iconPath(baseImagePath) {
27 | return `qrc:/qt/qml/ColorPalette/icons/${baseImagePath}.svg`
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | # We need to evaluate the features early, to decide whether to build and install the
5 | # OpenAPI module at all. Otherwise if not all dependencies are met and the generator is not built
6 | # in the tools subdir, we still end up installing the macros and extra targets files, which is
7 | # undesirable.
8 | add_subdirectory(global)
9 |
10 | # First build the generator tool, before the common library is created.
11 | add_subdirectory(tools)
12 |
13 | if(QT_FEATURE_openapi_generator)
14 | if(QT_FEATURE_openapi_common_library)
15 | add_subdirectory(openapicommon)
16 | endif()
17 |
18 | # We create the openapi module last, because we want to add a dependency on the common library
19 | # on the CMake package level.
20 | add_subdirectory(openapi)
21 | else()
22 | # Enable documentation build only
23 | add_subdirectory(openapi/doc)
24 | endif()
25 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 |
6 | find_program(OPENAPI_GO_EXECUTABLE NAMES go)
7 |
8 | if (NOT OPENAPI_GO_EXECUTABLE)
9 | message(WARNING "Go (golang) is not installed or not in the PATH.")
10 | return()
11 | endif()
12 |
13 | include(../../common/BuildGoExecutable.cmake)
14 |
15 | set(GO_BINARY backport-server-app)
16 | set(GO_SOURCE main.go)
17 |
18 | build_go_executable(${GO_BINARY} ${GO_SOURCE})
19 |
20 | # Custom target that depends on the output binary
21 | add_custom_target(backport-server-build ALL
22 | DEPENDS ${GO_BINARY}
23 | )
24 |
25 | add_executable(backport-server-go IMPORTED)
26 | add_dependencies(backport-server-go backport-server-build)
27 | set_target_properties(backport-server-go PROPERTIES
28 | IMPORTED_LOCATION
29 | "${CMAKE_CURRENT_BINARY_DIR}/backport-server-app"
30 | IMPORTED_GLOBAL TRUE
31 | )
32 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 |
6 | find_program(OPENAPI_GO_EXECUTABLE NAMES go)
7 |
8 | if (NOT OPENAPI_GO_EXECUTABLE)
9 | message(WARNING "Go (golang) is not installed or not in the PATH.")
10 | return()
11 | endif()
12 |
13 | include(../../common/BuildGoExecutable.cmake)
14 |
15 | set(GO_BINARY mediatype-server-app)
16 | set(GO_SOURCE main.go)
17 |
18 | build_go_executable(${GO_BINARY} ${GO_SOURCE})
19 |
20 | # Custom target that depends on the output binary
21 | add_custom_target(mediatype-server-build ALL
22 | DEPENDS ${GO_BINARY}
23 | )
24 |
25 | add_executable(mediatype-server-go IMPORTED)
26 | add_dependencies(mediatype-server-go mediatype-server-build)
27 | set_target_properties(mediatype-server-go PROPERTIES
28 | IMPORTED_LOCATION
29 | "${CMAKE_CURRENT_BINARY_DIR}/mediatype-server-app"
30 | IMPORTED_GLOBAL TRUE
31 | )
32 |
--------------------------------------------------------------------------------
/tests/auto/server_configuration/server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 |
6 | find_program(OPENAPI_GO_EXECUTABLE NAMES go)
7 |
8 | if (NOT OPENAPI_GO_EXECUTABLE)
9 | message(WARNING "Go (golang) is not installed or not in the PATH.")
10 | return()
11 | endif()
12 |
13 | include(../../common/BuildGoExecutable.cmake)
14 |
15 | set(GO_BINARY serverconfiguration-server-app)
16 | set(GO_SOURCE main.go)
17 |
18 | build_go_executable(${GO_BINARY} ${GO_SOURCE})
19 |
20 | # Custom target that depends on the output binary
21 | add_custom_target(serverconfiguration-server-build ALL
22 | DEPENDS ${GO_BINARY}
23 | )
24 |
25 | add_executable(serverconfiguration-server-go IMPORTED)
26 | add_dependencies(serverconfiguration-server-go serverconfiguration-server-build)
27 | set_target_properties(serverconfiguration-server-go PROPERTIES
28 | IMPORTED_LOCATION
29 | "${CMAKE_CURRENT_BINARY_DIR}/serverconfiguration-server-app"
30 | IMPORTED_GLOBAL TRUE
31 | )
32 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | [%thread] %highlight(%-5level) %logger - %msg%n
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 |
6 | include(.cmake.conf)
7 | project(QtOpenAPI
8 | VERSION "${QT_REPO_MODULE_VERSION}"
9 | DESCRIPTION "Qt6 OpenAPI Client generator and bindings."
10 | HOMEPAGE_URL "https://qt.io"
11 | LANGUAGES CXX C
12 | )
13 |
14 | find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals)
15 |
16 | # This should be called as early as possible, just after find_package(BuildInternals) where it is
17 | # defined.
18 | qt_internal_project_setup()
19 |
20 | find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED Core)
21 | find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS
22 | Network Gui Widgets Quick
23 | QmlNetwork QuickControls2
24 | TestInternalsPrivate
25 | )
26 |
27 | if(NOT TARGET Qt::Network)
28 | message(NOTICE "Skipping the build as the condition \"TARGET Qt::Network\" is not met.")
29 | return()
30 | endif()
31 |
32 | include("${CMAKE_CURRENT_LIST_DIR}/src/openapi/Qt6OpenApiToolsGeneratorMacros.cmake")
33 |
34 | qt_build_repo()
35 |
--------------------------------------------------------------------------------
/cmake/FindWrapOpenAPIGenerator.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(TARGET WrapOpenAPIGenerator::WrapOpenAPIGenerator)
5 | set(WrapOpenAPIGenerator_FOUND TRUE)
6 | return()
7 | endif()
8 |
9 | # We don't use find_jar, because that passes NO_DEFAULT_PATH to find_path, and we want to search
10 | # inside PATH env.
11 | find_file(OPENAPI_GENERATOR_CLI_JAR
12 | NAMES
13 | openapi-generator-cli.jar
14 | PATHS
15 | # These are the paths that find_jar would search by default
16 | /usr/share/java
17 | /usr/local/share/java
18 | ${Java_JAR_PATHS}
19 | )
20 |
21 | include(FindPackageHandleStandardArgs)
22 | find_package_handle_standard_args(WrapOpenAPIGenerator
23 | REQUIRED_VARS
24 | OPENAPI_GENERATOR_CLI_JAR
25 | )
26 |
27 | if(WrapOpenAPIGenerator_FOUND)
28 | add_library(WrapOpenAPIGenerator::WrapOpenAPIGenerator INTERFACE IMPORTED)
29 | set_target_properties(WrapOpenAPIGenerator::WrapOpenAPIGenerator PROPERTIES
30 | INTERFACE_OPENAPI_GENERATOR_CLI_JAR "${OPENAPI_GENERATOR_CLI_JAR}"
31 | )
32 | endif()
33 |
34 |
--------------------------------------------------------------------------------
/coin/axivion/ci_config_linux.json:
--------------------------------------------------------------------------------
1 | {
2 | "Project": {
3 | "BuildSystemIntegration": {
4 | "child_order": [
5 | "GCCSetup",
6 | "CMake",
7 | "LinkLibraries"
8 | ]
9 | },
10 | "CMake": {
11 | "_active": true,
12 | "_copy_from": "CMakeIntegration",
13 | "build_environment": {},
14 | "build_options": "-j4",
15 | "generate_options": "--fresh",
16 | "generator": "Ninja"
17 | },
18 | "GCCSetup": {
19 | "_active": true,
20 | "_copy_from": "Command",
21 | "build_command": "gccsetup --cc gcc --cxx g++ --config ../../../axivion/"
22 | },
23 | "LinkLibraries": {
24 | "_active": true,
25 | "_copy_from": "AxivionLinker",
26 | "input_files": [
27 | "build/lib/lib*.so*.ir"
28 | ],
29 | "ir": "build/$(env:TESTED_MODULE_COIN).ir"
30 | }
31 | },
32 | "_Format": "1.0",
33 | "_Version": "7.6.2",
34 | "_VersionNum": [
35 | 7,
36 | 6,
37 | 2,
38 | 12725
39 | ]
40 | }
41 |
--------------------------------------------------------------------------------
/tests/auto/linking_several_clients/application/linking_several_clients/client1.yaml:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | openapi: 3.1.1
5 | servers:
6 | - url: 'http://127.0.0.1:10205/v2'
7 | info:
8 | title: Client with 'QtOpenAPICommon' option Test
9 | description: >
10 | This specification is intended for testing purposes.
11 | version: 1.0.0
12 | tags:
13 | - name: client1Test
14 | description: test client 1. It will be generated with 'QtOpenAPICommon' option.
15 |
16 | paths:
17 | /path/string/simple-explode/{stringParameter}:
18 | get:
19 | tags: [client1Test]
20 | operationId: simpleExplodeString
21 | summary: Simple style with explode set to true for string path parameter.
22 | parameters:
23 | - name: stringParameter
24 | in: path
25 | required: true
26 | style: simple
27 | explode: true
28 | schema:
29 | type: string
30 | responses:
31 | '200':
32 | description: OK
33 | content:
34 | application/json:
35 | schema:
36 | type: string
37 |
--------------------------------------------------------------------------------
/tests/auto/linking_several_clients/application/linking_several_clients/client2.yaml:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | openapi: 3.1.1
5 | servers:
6 | - url: 'http://127.0.0.1:10205/v2'
7 | info:
8 | title: Client with 'Skip-All' option Test
9 | description: >
10 | This specification is intended for testing purposes.
11 | version: 1.0.0
12 | tags:
13 | - name: client2Test
14 | description: Test client 2. It will be generated with 'Skip-All' option.
15 |
16 | paths:
17 | /path/int/simple-explode/{intParameter}:
18 | get:
19 | tags: [client2Test]
20 | operationId: simpleExplodeInt
21 | summary: Simple style with explode set to true for integer path parameter.
22 | parameters:
23 | - name: intParameter
24 | in: path
25 | required: true
26 | style: simple
27 | explode: true
28 | schema:
29 | type: integer
30 | format: int64
31 | responses:
32 | '200':
33 | description: OK
34 | content:
35 | application/json:
36 | schema:
37 | type: string
38 |
--------------------------------------------------------------------------------
/src/openapicommon/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | qt_internal_add_module(OpenApiCommon
5 | NO_PRIVATE_MODULE
6 | DEFINES
7 | #TODO: Fix this to work without commenting it out
8 | #QT_NO_CAST_FROM_ASCII
9 | QT_NO_CONTEXTLESS_CONNECT
10 | QT_NO_USING_NAMESPACE
11 | QT_USE_NODISCARD_FILE_OPEN
12 | LIBRARIES
13 | Qt::CorePrivate
14 | Qt::NetworkPrivate
15 | PUBLIC_LIBRARIES
16 | Qt::Core
17 | Qt::Network
18 | )
19 |
20 | # Handle the conditional finding of either system zlib or qt zlib.
21 | if(NOT QT_FEATURE_system_zlib)
22 | find_package(Qt6 COMPONENTS ZlibPrivate)
23 | qt_internal_extend_target(OpenApiCommon LIBRARIES Qt::ZlibPrivate)
24 | elseif(NOT TARGET WrapZLIB::WrapZLIB)
25 | qt_find_package(WrapZLIB PROVIDED_TARGETS WrapZLIB::WrapZLIB)
26 | endif()
27 |
28 | if(TARGET WrapZLIB::WrapZLIB)
29 | qt_internal_extend_target(OpenApiCommon LIBRARIES WrapZLIB::WrapZLIB)
30 | endif()
31 |
32 | qt6_add_openapi_client(OpenApiCommon
33 | SPEC_FILE
34 | ${CMAKE_CURRENT_SOURCE_DIR}/qtopenapi-common.yaml
35 | __QT_INTERNAL_GENERATE_COMMON_LIBRARY_TARGET
36 | )
37 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/QtOpenApiExampleStyle/Button.qml:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2023 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | import QtQuick
5 | import QtQuick.Controls.impl
6 | import QtQuick.Templates as T
7 |
8 | T.Button {
9 | id: control
10 |
11 | property alias buttonColor: rect.color
12 | property alias textColor: label.color
13 |
14 | implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
15 | implicitContentWidth + leftPadding + rightPadding)
16 | implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
17 | implicitContentHeight + topPadding + bottomPadding)
18 |
19 | leftPadding: 15
20 | rightPadding: 15
21 | topPadding: 10
22 | bottomPadding: 10
23 |
24 | background: Rectangle {
25 | id: rect
26 | radius: 8
27 | border.color: "#E0E2E7"
28 | border.width: 1
29 | color: "#FFFFFF"
30 | }
31 |
32 | icon.width: 24
33 | icon.height: 24
34 | icon.color: control.palette.buttonText
35 |
36 | contentItem: IconLabel {
37 | id: label
38 | spacing: control.spacing
39 | mirrored: control.mirrored
40 | display: control.display
41 |
42 | icon: control.icon
43 | text: control.text
44 | font.pixelSize: 14
45 | color: "#667085"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/tests/auto/cmake/RunCMake/LibraryInstallation/consume_installed_lib.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | # This project builds an executable that links against the previously installed client
5 | # library and runs the executable test.
6 |
7 | find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core Network Test OpenApiCommon)
8 |
9 | # Avoid erorrs in CI about unsupported SDK and Xcode versions on older CI macOS versions.
10 | if(APPLE)
11 | set(QT_NO_APPLE_SDK_AND_XCODE_CHECK ON)
12 | endif()
13 |
14 | # Needed for qt_internal_add_test to work
15 | qt_build_internals_set_up_private_api()
16 |
17 | # This is passed to the project from outside, to include the previously installed libraries.
18 | include("${CMAKE_TARGETS_INCLUDE_PATH}")
19 |
20 | qt_standard_project_setup(REQUIRES 6.10)
21 |
22 | qt_internal_add_test(cpp-qt-compression
23 | SOURCES
24 | src/tst_compression.cpp
25 | LIBRARIES
26 | Qt::Core
27 | Qt::Network
28 | Qt::Test
29 | )
30 |
31 | target_link_libraries(cpp-qt-compression PRIVATE
32 | CompressionClient::CompressionClient
33 | )
34 |
35 | if(WIN32)
36 | add_custom_command(TARGET cpp-qt-compression POST_BUILD
37 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
38 | $
39 | ${CMAKE_CURRENT_BINARY_DIR}
40 | VERBATIM)
41 | endif()
42 |
43 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/QtOpenApiExampleStyle/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 | project(qtopenapi_examplestyle LANGUAGES CXX)
6 |
7 | set(CMAKE_AUTOMOC ON)
8 |
9 | find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick QuickControls2)
10 |
11 | set_source_files_properties(UIStyle.qml
12 | PROPERTIES
13 | QT_QML_SINGLETON_TYPE TRUE
14 | )
15 |
16 | qt_policy(SET QTP0001 NEW)
17 | qt_add_qml_module(qtopenapi_examplestyle
18 | URI QtOpenApiExampleStyle
19 | PLUGIN_TARGET qtopenapi_examplestyle
20 | QML_FILES
21 | Button.qml
22 | UIStyle.qml
23 | )
24 |
25 | target_link_libraries(qtopenapi_examplestyle PUBLIC
26 | Qt6::Core
27 | Qt6::Gui
28 | Qt6::Quick
29 | Qt6::QuickControls2
30 | )
31 |
32 | if(UNIX AND NOT APPLE AND CMAKE_CROSSCOMPILING)
33 | find_package(Qt6 REQUIRED COMPONENTS QuickTemplates2)
34 |
35 | # Work around QTBUG-86533
36 | target_link_libraries(qtopenapi_examplestyle PRIVATE Qt6::QuickTemplates2)
37 | endif()
38 |
39 | install(TARGETS qtopenapi_examplestyle
40 | RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/QtOpenApiExampleStyle"
41 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/QtOpenApiExampleStyle"
42 | )
43 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
44 | DESTINATION "${CMAKE_INSTALL_BINDIR}/QtOpenApiExampleStyle"
45 | )
46 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/server/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/GIT_USER_ID/GIT_REPO_ID
2 |
3 | go 1.19
4 |
5 | require github.com/gin-gonic/gin v1.9.1
6 |
7 | require (
8 | github.com/bytedance/sonic v1.9.1 // indirect
9 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
10 | github.com/gabriel-vasile/mimetype v1.4.2 // indirect
11 | github.com/gin-contrib/sse v0.1.0 // indirect
12 | github.com/go-playground/locales v0.14.1 // indirect
13 | github.com/go-playground/universal-translator v0.18.1 // indirect
14 | github.com/go-playground/validator/v10 v10.14.0 // indirect
15 | github.com/goccy/go-json v0.10.2 // indirect
16 | github.com/json-iterator/go v1.1.12 // indirect
17 | github.com/klauspost/cpuid/v2 v2.2.4 // indirect
18 | github.com/leodido/go-urn v1.2.4 // indirect
19 | github.com/mattn/go-isatty v0.0.19 // indirect
20 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
21 | github.com/modern-go/reflect2 v1.0.2 // indirect
22 | github.com/pelletier/go-toml/v2 v2.0.8 // indirect
23 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
24 | github.com/ugorji/go/codec v1.2.11 // indirect
25 | golang.org/x/arch v0.3.0 // indirect
26 | golang.org/x/crypto v0.31.0 // indirect
27 | golang.org/x/net v0.23.0 // indirect
28 | golang.org/x/sys v0.28.0 // indirect
29 | golang.org/x/text v0.21.0 // indirect
30 | google.golang.org/protobuf v1.33.0 // indirect
31 | gopkg.in/yaml.v3 v3.0.1 // indirect
32 | )
33 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/server/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/GIT_USER_ID/GIT_REPO_ID
2 |
3 | go 1.19
4 |
5 | require github.com/gin-gonic/gin v1.9.1
6 |
7 | require (
8 | github.com/bytedance/sonic v1.9.1 // indirect
9 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
10 | github.com/gabriel-vasile/mimetype v1.4.2 // indirect
11 | github.com/gin-contrib/sse v0.1.0 // indirect
12 | github.com/go-playground/locales v0.14.1 // indirect
13 | github.com/go-playground/universal-translator v0.18.1 // indirect
14 | github.com/go-playground/validator/v10 v10.14.0 // indirect
15 | github.com/goccy/go-json v0.10.2 // indirect
16 | github.com/json-iterator/go v1.1.12 // indirect
17 | github.com/klauspost/cpuid/v2 v2.2.4 // indirect
18 | github.com/leodido/go-urn v1.2.4 // indirect
19 | github.com/mattn/go-isatty v0.0.19 // indirect
20 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
21 | github.com/modern-go/reflect2 v1.0.2 // indirect
22 | github.com/pelletier/go-toml/v2 v2.0.8 // indirect
23 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
24 | github.com/ugorji/go/codec v1.2.11 // indirect
25 | golang.org/x/arch v0.3.0 // indirect
26 | golang.org/x/crypto v0.31.0 // indirect
27 | golang.org/x/net v0.23.0 // indirect
28 | golang.org/x/sys v0.28.0 // indirect
29 | golang.org/x/text v0.21.0 // indirect
30 | google.golang.org/protobuf v1.33.0 // indirect
31 | gopkg.in/yaml.v3 v3.0.1 // indirect
32 | )
33 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/GIT_USER_ID/GIT_REPO_ID
2 |
3 | go 1.19
4 |
5 | require github.com/gin-gonic/gin v1.9.1
6 |
7 | require (
8 | github.com/bytedance/sonic v1.9.1 // indirect
9 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
10 | github.com/gabriel-vasile/mimetype v1.4.2 // indirect
11 | github.com/gin-contrib/sse v0.1.0 // indirect
12 | github.com/go-playground/locales v0.14.1 // indirect
13 | github.com/go-playground/universal-translator v0.18.1 // indirect
14 | github.com/go-playground/validator/v10 v10.14.0 // indirect
15 | github.com/goccy/go-json v0.10.2 // indirect
16 | github.com/json-iterator/go v1.1.12 // indirect
17 | github.com/klauspost/cpuid/v2 v2.2.4 // indirect
18 | github.com/leodido/go-urn v1.2.4 // indirect
19 | github.com/mattn/go-isatty v0.0.19 // indirect
20 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
21 | github.com/modern-go/reflect2 v1.0.2 // indirect
22 | github.com/pelletier/go-toml/v2 v2.0.8 // indirect
23 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
24 | github.com/ugorji/go/codec v1.2.11 // indirect
25 | golang.org/x/arch v0.3.0 // indirect
26 | golang.org/x/crypto v0.31.0 // indirect
27 | golang.org/x/net v0.23.0 // indirect
28 | golang.org/x/sys v0.28.0 // indirect
29 | golang.org/x/text v0.21.0 // indirect
30 | google.golang.org/protobuf v1.33.0 // indirect
31 | gopkg.in/yaml.v3 v3.0.1 // indirect
32 | )
33 |
--------------------------------------------------------------------------------
/tests/auto/responses/server/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/GIT_USER_ID/GIT_REPO_ID
2 |
3 | go 1.19
4 |
5 | require github.com/gin-gonic/gin v1.9.1
6 |
7 | require (
8 | github.com/bytedance/sonic v1.9.1 // indirect
9 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
10 | github.com/gabriel-vasile/mimetype v1.4.2 // indirect
11 | github.com/gin-contrib/sse v0.1.0 // indirect
12 | github.com/go-playground/locales v0.14.1 // indirect
13 | github.com/go-playground/universal-translator v0.18.1 // indirect
14 | github.com/go-playground/validator/v10 v10.14.0 // indirect
15 | github.com/goccy/go-json v0.10.2 // indirect
16 | github.com/json-iterator/go v1.1.12 // indirect
17 | github.com/klauspost/cpuid/v2 v2.2.4 // indirect
18 | github.com/leodido/go-urn v1.2.4 // indirect
19 | github.com/mattn/go-isatty v0.0.19 // indirect
20 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
21 | github.com/modern-go/reflect2 v1.0.2 // indirect
22 | github.com/pelletier/go-toml/v2 v2.0.8 // indirect
23 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
24 | github.com/ugorji/go/codec v1.2.11 // indirect
25 | golang.org/x/arch v0.3.0 // indirect
26 | golang.org/x/crypto v0.31.0 // indirect
27 | golang.org/x/net v0.23.0 // indirect
28 | golang.org/x/sys v0.28.0 // indirect
29 | golang.org/x/text v0.21.0 // indirect
30 | google.golang.org/protobuf v1.33.0 // indirect
31 | gopkg.in/yaml.v3 v3.0.1 // indirect
32 | )
33 |
--------------------------------------------------------------------------------
/tests/auto/operation-parameters/server/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/GIT_USER_ID/GIT_REPO_ID
2 |
3 | go 1.19
4 |
5 | require github.com/gin-gonic/gin v1.9.1
6 |
7 | require (
8 | github.com/bytedance/sonic v1.9.1 // indirect
9 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
10 | github.com/gabriel-vasile/mimetype v1.4.2 // indirect
11 | github.com/gin-contrib/sse v0.1.0 // indirect
12 | github.com/go-playground/locales v0.14.1 // indirect
13 | github.com/go-playground/universal-translator v0.18.1 // indirect
14 | github.com/go-playground/validator/v10 v10.14.0 // indirect
15 | github.com/goccy/go-json v0.10.2 // indirect
16 | github.com/json-iterator/go v1.1.12 // indirect
17 | github.com/klauspost/cpuid/v2 v2.2.4 // indirect
18 | github.com/leodido/go-urn v1.2.4 // indirect
19 | github.com/mattn/go-isatty v0.0.19 // indirect
20 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
21 | github.com/modern-go/reflect2 v1.0.2 // indirect
22 | github.com/pelletier/go-toml/v2 v2.0.8 // indirect
23 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
24 | github.com/ugorji/go/codec v1.2.11 // indirect
25 | golang.org/x/arch v0.3.0 // indirect
26 | golang.org/x/crypto v0.31.0 // indirect
27 | golang.org/x/net v0.23.0 // indirect
28 | golang.org/x/sys v0.28.0 // indirect
29 | golang.org/x/text v0.21.0 // indirect
30 | google.golang.org/protobuf v1.33.0 // indirect
31 | gopkg.in/yaml.v3 v3.0.1 // indirect
32 | )
33 |
--------------------------------------------------------------------------------
/tests/auto/server_configuration/server/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/GIT_USER_ID/GIT_REPO_ID
2 |
3 | go 1.19
4 |
5 | require github.com/gin-gonic/gin v1.9.1
6 |
7 | require (
8 | github.com/bytedance/sonic v1.9.1 // indirect
9 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
10 | github.com/gabriel-vasile/mimetype v1.4.2 // indirect
11 | github.com/gin-contrib/sse v0.1.0 // indirect
12 | github.com/go-playground/locales v0.14.1 // indirect
13 | github.com/go-playground/universal-translator v0.18.1 // indirect
14 | github.com/go-playground/validator/v10 v10.14.0 // indirect
15 | github.com/goccy/go-json v0.10.2 // indirect
16 | github.com/json-iterator/go v1.1.12 // indirect
17 | github.com/klauspost/cpuid/v2 v2.2.4 // indirect
18 | github.com/leodido/go-urn v1.2.4 // indirect
19 | github.com/mattn/go-isatty v0.0.19 // indirect
20 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
21 | github.com/modern-go/reflect2 v1.0.2 // indirect
22 | github.com/pelletier/go-toml/v2 v2.0.8 // indirect
23 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
24 | github.com/ugorji/go/codec v1.2.11 // indirect
25 | golang.org/x/arch v0.3.0 // indirect
26 | golang.org/x/crypto v0.31.0 // indirect
27 | golang.org/x/net v0.23.0 // indirect
28 | golang.org/x/sys v0.28.0 // indirect
29 | golang.org/x/text v0.21.0 // indirect
30 | google.golang.org/protobuf v1.33.0 // indirect
31 | gopkg.in/yaml.v3 v3.0.1 // indirect
32 | )
33 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 |
6 | find_program(OPENAPI_GO_EXECUTABLE NAMES go)
7 |
8 | if (NOT OPENAPI_GO_EXECUTABLE)
9 | message(WARNING "Go (golang) is not installed or not in the PATH.")
10 | return()
11 | endif()
12 |
13 | include(../../common/BuildGoExecutable.cmake)
14 |
15 | set(GO_BINARY petstore-server-app)
16 | set(GO_SOURCE main.go)
17 |
18 | build_go_executable(${GO_BINARY} ${GO_SOURCE})
19 |
20 | # Custom target that depends on the output binary
21 | add_custom_target(petstore-server-build ALL
22 | DEPENDS ${GO_BINARY}
23 | )
24 |
25 | add_executable(petstore-server-go IMPORTED)
26 | add_dependencies(petstore-server-go petstore-server-build)
27 | set_target_properties(petstore-server-go PROPERTIES
28 | IMPORTED_LOCATION
29 | "${CMAKE_CURRENT_BINARY_DIR}/petstore-server-app"
30 | IMPORTED_GLOBAL TRUE
31 | )
32 |
33 | add_custom_command(
34 | TARGET petstore-server-build
35 | POST_BUILD
36 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
37 | ${CMAKE_CURRENT_SOURCE_DIR}/qt-logo.png
38 | ${CMAKE_CURRENT_BINARY_DIR}/qt-logo.png
39 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
40 | ${CMAKE_CURRENT_SOURCE_DIR}/response.json
41 | ${CMAKE_CURRENT_BINARY_DIR}/response.json
42 | COMMENT "Copying test files to ${CMAKE_CURRENT_BINARY_DIR}"
43 | )
44 |
--------------------------------------------------------------------------------
/LICENSES/BSD-3-Clause.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .
2 |
3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4 |
5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
8 |
9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10 |
--------------------------------------------------------------------------------
/tests/auto/common/BuildGoExecutable.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | function(build_go_executable target sources)
5 | set(OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
6 | if(CMAKE_HOST_APPLE AND ("${CMAKE_OSX_ARCHITECTURES}" MATCHES "(x86_64;arm64|arm64;x64_64)"))
7 | add_custom_command(
8 | OUTPUT ${target}
9 | COMMAND go mod tidy
10 | COMMAND GOOS=darwin GOARCH=arm64 go build -o "${OUTPUT_DIR}/${target}_arm64" ${sources}
11 | COMMAND GOOS=darwin GOARCH=amd64 go build -o "${OUTPUT_DIR}/${target}_amd64" ${sources}
12 | COMMAND lipo -create -output "${OUTPUT_DIR}/${target}" "${OUTPUT_DIR}/${target}_arm64"
13 | "${OUTPUT_DIR}/${target}_amd64"
14 | COMMAND rm -f "${OUTPUT_DIR}/${target}_arm64" "${OUTPUT_DIR}/${target}_amd64"
15 | DEPENDS ${sources}
16 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
17 | COMMENT "Generating the golang server: ${target}"
18 | VERBATIM
19 | )
20 | else()
21 | add_custom_command(
22 | OUTPUT ${target}
23 | COMMAND go mod tidy
24 | COMMAND go build -o "${OUTPUT_DIR}/${target}" ${sources}
25 | DEPENDS ${sources}
26 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
27 | COMMENT "Generating the golang server: ${target}"
28 | VERBATIM
29 | )
30 | endif()
31 | endfunction()
32 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/enum-header.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | #ifndef {{prefix}}_ENUM_H
3 | #define {{prefix}}_ENUM_H
4 |
5 | #include "{{packageNameLowerCase}}commonexports.h"
6 |
7 | #include
8 | #include
9 |
10 | {{#cppCommonNamespaceDeclarations}}
11 | namespace {{this}} {
12 | {{/cppCommonNamespaceDeclarations}}
13 |
14 | class {{packageNameUpperCase}}_COMMON_EXPORT {{prefix}}Enum {
15 | public:
16 | {{prefix}}Enum();
17 | virtual ~{{prefix}}Enum();
18 |
19 | virtual QJsonValue asJsonValue() const = 0;
20 | virtual QString asJson() const = 0;
21 | virtual void fromJson(const QString &jsonString) = 0;
22 | virtual void fromJsonValue(const QJsonValue &jval) = 0;
23 | virtual bool isSet() const = 0;
24 | virtual bool isValid() const = 0;
25 |
26 | private:
27 | friend bool operator==(const {{prefix}}Enum &lhs, const {{prefix}}Enum &rhs)
28 | { return lhs.asJsonValue() == rhs.asJsonValue(); }
29 | friend bool operator!=(const {{prefix}}Enum &lhs, const {{prefix}}Enum &rhs)
30 | { return !operator==(lhs, rhs); }
31 |
32 | friend size_t qHash(const {{prefix}}Enum &val, size_t seed)
33 | { return qHash(val.asJsonValue(), seed); }
34 | friend size_t qHash(const {{prefix}}Enum &val)
35 | { return qHash(val, 0); }
36 | };
37 |
38 | {{#cppCommonNamespaceDeclarations}}
39 | } // namespace {{this}}
40 | {{/cppCommonNamespaceDeclarations}}
41 |
42 | #endif // {{prefix}}_ENUM_H
43 |
--------------------------------------------------------------------------------
/tests/auto/petstore/client/userapitest/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-petstore-userapi LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | if(NOT TARGET petstore-server-go)
11 | message(WARNING "No petstore-server-go server in the build.")
12 | return()
13 | endif()
14 |
15 | if(MSVC)
16 | add_compile_options(/W4 /WX)
17 | else()
18 | add_compile_options(-Wall -Wextra)
19 | if(WARNINGS_ARE_ERRORS)
20 | add_compile_options(-Werror=deprecated-declarations)
21 | endif()
22 | endif()
23 |
24 | qt_internal_add_test(cpp-qt-petstore-userapi
25 | SOURCES
26 | tst_userapitests.cpp
27 | LIBRARIES
28 | Qt::Core
29 | Qt::Network
30 | Qt::Test
31 | )
32 |
33 | target_compile_definitions(cpp-qt-petstore-userapi
34 | PRIVATE
35 | SERVER_PATH="$"
36 | )
37 |
38 | target_link_libraries(cpp-qt-petstore-userapi PRIVATE PetStoreClient)
39 | add_dependencies(cpp-qt-petstore-userapi petstore-server-go)
40 |
41 | if(WIN32)
42 | add_custom_command(TARGET cpp-qt-petstore-userapi POST_BUILD
43 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
44 | $
45 | ${CMAKE_CURRENT_BINARY_DIR}
46 | VERBATIM)
47 | endif()
48 |
--------------------------------------------------------------------------------
/tests/auto/petstore/client/storeapitest/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-petstore-storeapi LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | if(NOT TARGET petstore-server-go)
11 | message(WARNING "No petstore-server-go server in the build.")
12 | return()
13 | endif()
14 |
15 | if(MSVC)
16 | add_compile_options(/W4 /WX)
17 | else()
18 | add_compile_options(-Wall -Wextra)
19 | if(WARNINGS_ARE_ERRORS)
20 | add_compile_options(-Werror=deprecated-declarations)
21 | endif()
22 | endif()
23 |
24 | qt_internal_add_test(cpp-qt-petstore-storeapi
25 | SOURCES
26 | tst_storeapitests.cpp
27 | LIBRARIES
28 | Qt::Core
29 | Qt::Network
30 | Qt::Test
31 | )
32 |
33 | target_compile_definitions(cpp-qt-petstore-storeapi
34 | PRIVATE
35 | SERVER_PATH="$"
36 | )
37 |
38 | target_link_libraries(cpp-qt-petstore-storeapi PRIVATE PetStoreClient)
39 | add_dependencies(cpp-qt-petstore-storeapi petstore-server-go)
40 |
41 | if(WIN32)
42 | add_custom_command(TARGET cpp-qt-petstore-storeapi POST_BUILD
43 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
44 | $
45 | ${CMAKE_CURRENT_BINARY_DIR}
46 | VERBATIM)
47 | endif()
48 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/object-header.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | #ifndef {{prefix}}_OBJECT_H
3 | #define {{prefix}}_OBJECT_H
4 |
5 | #include "{{packageNameLowerCase}}commonexports.h"
6 |
7 | #include
8 | #include
9 |
10 | {{#cppCommonNamespaceDeclarations}}
11 | namespace {{this}} {
12 | {{/cppCommonNamespaceDeclarations}}
13 |
14 | class {{packageNameUpperCase}}_COMMON_EXPORT {{prefix}}Object {
15 | public:
16 | {{prefix}}Object();
17 | virtual ~{{prefix}}Object();
18 |
19 | virtual QJsonObject asJsonObject() const = 0;
20 | virtual QString asJson() const = 0;
21 | virtual void fromJson(const QString &jsonString) = 0;
22 | virtual void fromJsonObject(const QJsonObject &json) = 0;
23 | virtual bool isSet() const = 0;
24 | virtual bool isValid() const = 0;
25 |
26 | private:
27 | friend bool operator==(const {{prefix}}Object &lhs, const {{prefix}}Object &rhs)
28 | { return lhs.asJsonObject() == rhs.asJsonObject(); }
29 | friend bool operator!=(const {{prefix}}Object &lhs, const {{prefix}}Object &rhs)
30 | { return !operator==(lhs, rhs); }
31 |
32 | friend size_t qHash(const {{prefix}}Object &obj, size_t seed)
33 | { return qHash(obj.asJsonObject(), seed); }
34 | friend size_t qHash(const {{prefix}}Object &obj)
35 | { return qHash(obj, 0); }
36 | };
37 |
38 | {{#cppCommonNamespaceDeclarations}}
39 | } // namespace {{this}}
40 | {{/cppCommonNamespaceDeclarations}}
41 |
42 | #endif // {{prefix}}_OBJECT_H
43 |
--------------------------------------------------------------------------------
/tests/auto/operation-parameters/client/operationparameters/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-operation-parameters LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | if(NOT TARGET op-server-go)
11 | message(WARNING "No op-server-go server in the build.")
12 | return()
13 | endif()
14 |
15 | qt_internal_add_test(cpp-qt-operation-parameters
16 | SOURCES
17 | tst_operationparameters.cpp
18 | LIBRARIES
19 | Qt::Core
20 | Qt::Network
21 | Qt::Test
22 | )
23 |
24 | qt_add_library(OperationParametersClient)
25 | qt6_add_openapi_client(OperationParametersClient
26 | SPEC_FILE
27 | ${CMAKE_CURRENT_SOURCE_DIR}/operation-parameters.yaml
28 | )
29 |
30 | target_compile_definitions(cpp-qt-operation-parameters
31 | PRIVATE
32 | SERVER_PATH="$"
33 | )
34 | qt_autogen_tools_initial_setup(OperationParametersClient)
35 | target_link_libraries(cpp-qt-operation-parameters PRIVATE
36 | OperationParametersClient)
37 | add_dependencies(cpp-qt-operation-parameters op-server-go)
38 |
39 | if(WIN32)
40 | add_custom_command(TARGET cpp-qt-operation-parameters POST_BUILD
41 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
42 | $
43 | ${CMAKE_CURRENT_BINARY_DIR}
44 | VERBATIM)
45 | endif()
46 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/client/openapi2.0/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-operations-parameters-backport LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | if(NOT TARGET backport-server-go)
11 | message(WARNING "No backport-server-go server in the build.")
12 | return()
13 | endif()
14 |
15 | qt_internal_add_test(cpp-qt-operations-parameters-backport
16 | SOURCES
17 | tst_openapi2_0.cpp
18 | LIBRARIES
19 | Qt::Core
20 | Qt::Network
21 | Qt::Test
22 | )
23 |
24 | qt_add_library(OpenapiBackportClient)
25 | qt6_add_openapi_client(OpenapiBackportClient
26 | SPEC_FILE
27 | ${CMAKE_CURRENT_SOURCE_DIR}/openapi2.0.yaml
28 | )
29 |
30 | target_compile_definitions(cpp-qt-operations-parameters-backport
31 | PRIVATE
32 | SERVER_PATH="$"
33 | )
34 |
35 | add_dependencies(cpp-qt-operations-parameters-backport backport-server-go)
36 | qt_autogen_tools_initial_setup(OpenapiBackportClient)
37 | target_link_libraries(cpp-qt-operations-parameters-backport
38 | PRIVATE
39 | OpenapiBackportClient
40 | )
41 |
42 | if(WIN32)
43 | add_custom_command(TARGET cpp-qt-operations-parameters-backport POST_BUILD
44 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
45 | $
46 | ${CMAKE_CURRENT_BINARY_DIR}
47 | VERBATIM)
48 | endif()
49 |
--------------------------------------------------------------------------------
/src/openapi/Qt6OpenApiToolsCopyHeadersScript.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.21)
5 |
6 | if(NOT CLIENT_DIR OR NOT EXISTS "${CLIENT_DIR}")
7 | message(FATAL_ERROR "Client dir '${CLIENT_DIR}' does not exist")
8 | endif()
9 |
10 | if(NOT OUTPUT_PUBLIC_HEADERS_DIR)
11 | message(FATAL_ERROR "OUTPUT_PUBLIC_HEADERS_DIR is not set")
12 | endif()
13 |
14 | if(NOT OUTPUT_PRIVATE_HEADERS_DIR)
15 | message(FATAL_ERROR "OUTPUT_PRIVATE_HEADERS_DIR is not set")
16 | endif()
17 |
18 | if(NOT TIMESTAMP_PATH)
19 | message(FATAL_ERROR "TIMESTAMP_PATH is not set")
20 | endif()
21 |
22 | set(public_globs "${CLIENT_DIR}/*.h")
23 | set(private_globs "${CLIENT_DIR}/*_p.h")
24 |
25 | file(GLOB_RECURSE public_header_files
26 | ${public_globs}
27 | )
28 |
29 | file(GLOB_RECURSE private_header_files
30 | ${private_globs}
31 | )
32 |
33 | file(MAKE_DIRECTORY "${OUTPUT_PUBLIC_HEADERS_DIR}")
34 | file(MAKE_DIRECTORY "${OUTPUT_PRIVATE_HEADERS_DIR}")
35 |
36 | foreach(header_file IN LISTS public_header_files)
37 | get_filename_component(header_name "${header_file}" NAME)
38 | set(destination_path "${OUTPUT_PUBLIC_HEADERS_DIR}/${header_name}")
39 | file(COPY_FILE "${header_file}" "${destination_path}" ONLY_IF_DIFFERENT)
40 | endforeach()
41 |
42 | foreach(header_file IN LISTS private_header_files)
43 | get_filename_component(header_name "${header_file}" NAME)
44 | set(destination_path "${OUTPUT_PRIVATE_HEADERS_DIR}/${header_name}")
45 | file(COPY_FILE "${header_file}" "${destination_path}" ONLY_IF_DIFFERENT)
46 | endforeach()
47 |
48 | file(TOUCH "${TIMESTAMP_PATH}")
49 |
--------------------------------------------------------------------------------
/src/openapi/doc/src/qtopenapi-index.qdoc:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3 |
4 | /*!
5 | \title Qt OpenAPI
6 | \page qtopenapi-index.html
7 | \brief Qt OpenAPI module provides functionality for generating Qt HTTP clients.
8 |
9 | The Qt6 OpenAPI generator is a plugin to the \l {https://openapi-generator.tech/}
10 | {OpenAPI generator} which allows you to generate clients, servers, and
11 | documentation from OpenAPI 2.0/3.x specifications using a variety of programming
12 | languages and frameworks.
13 |
14 | The Qt6 OpenAPI generator allows you to autogenerate Qt HTTP clients
15 | in C++ using \l{Qt Network} APIs such as \l QRestAccessManager.
16 |
17 | \section1 Using the module
18 | Installation of the following packages is necessary to use the Qt OpenAPI module:
19 | \list
20 | \li \l {https://openapi-generator.tech/}{OpenAPI generator}
21 | (requires OpenAPI 7.12.0 or above).
22 | \li \l {https://maven.apache.org/}{Maven plugin} (requires Maven 3.0 or above).
23 | \li \l {https://openjdk.org/projects/jdk/}{Java JDK} (requires JDK 17 or above).
24 | \endlist
25 | Once you have the required installations, the Qt OpenAPI generator
26 | is ready for use within your projects.
27 | To generate client code from an OpenAPI specification
28 | using the Qt OpenAPI Generator, you should call the
29 | \c qt6_add_openapi_client macro inside your project's
30 | CMakeLists.txt file. See \l {Building with CMake} for details.
31 |
32 | \section2 Building with CMake
33 |
34 | \section1 Examples
35 |
36 | \section1 Licenses and Attributions
37 | */
38 |
--------------------------------------------------------------------------------
/tests/auto/responses/client/responses/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-responses LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | if(NOT TARGET responses-server-go)
11 | message(WARNING "No responses-server-go server in the build.")
12 | return()
13 | endif()
14 |
15 | if(MSVC)
16 | add_compile_options(/W4 /WX)
17 | else()
18 | add_compile_options(-Wall -Wextra)
19 | if(WARNINGS_ARE_ERRORS)
20 | add_compile_options(-Werror=deprecated-declarations)
21 | endif()
22 | endif()
23 |
24 | qt_internal_add_test(cpp-qt-responses
25 | SOURCES
26 | tst_responses.cpp
27 | LIBRARIES
28 | Qt::Core
29 | Qt::Network
30 | Qt::Test
31 | )
32 |
33 | qt_add_library(ResponsesClient)
34 | qt6_add_openapi_client(ResponsesClient
35 | SPEC_FILE
36 | ${CMAKE_CURRENT_SOURCE_DIR}/responses.yaml
37 | )
38 |
39 | target_compile_definitions(cpp-qt-responses
40 | PRIVATE
41 | SERVER_PATH="$"
42 | SERVER_DIR="$"
43 | )
44 | qt_autogen_tools_initial_setup(ResponsesClient)
45 | target_link_libraries(cpp-qt-responses PRIVATE ResponsesClient)
46 | add_dependencies(cpp-qt-responses responses-server-go)
47 |
48 | if(WIN32)
49 | add_custom_command(TARGET cpp-qt-responses POST_BUILD
50 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
51 | $
52 | ${CMAKE_CURRENT_BINARY_DIR}
53 | VERBATIM)
54 | endif()
55 |
--------------------------------------------------------------------------------
/tests/auto/responses/server/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 |
6 | find_program(OPENAPI_GO_EXECUTABLE NAMES go)
7 |
8 | if (NOT OPENAPI_GO_EXECUTABLE)
9 | message(WARNING "Go (golang) is not installed or not in the PATH.")
10 | return()
11 | endif()
12 |
13 | include(../../common/BuildGoExecutable.cmake)
14 |
15 | set(GO_BINARY responses-server-app)
16 | set(GO_SOURCE main.go)
17 |
18 | build_go_executable(${GO_BINARY} ${GO_SOURCE})
19 |
20 | # Custom target that depends on the output binary
21 | add_custom_target(responses-server-build ALL
22 | DEPENDS ${GO_BINARY}
23 | )
24 |
25 | add_executable(responses-server-go IMPORTED)
26 | add_dependencies(responses-server-go responses-server-build)
27 | set_target_properties(responses-server-go PROPERTIES
28 | IMPORTED_LOCATION
29 | "${CMAKE_CURRENT_BINARY_DIR}/responses-server-app"
30 | IMPORTED_GLOBAL TRUE
31 | )
32 |
33 | add_custom_command(
34 | TARGET responses-server-build
35 | POST_BUILD
36 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
37 | ${CMAKE_CURRENT_SOURCE_DIR}/test.pdf
38 | ${CMAKE_CURRENT_BINARY_DIR}/test.pdf
39 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
40 | ${CMAKE_CURRENT_SOURCE_DIR}/testImage.jpg
41 | ${CMAKE_CURRENT_BINARY_DIR}/testImage.jpg
42 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
43 | ${CMAKE_CURRENT_SOURCE_DIR}/testImage.png
44 | ${CMAKE_CURRENT_BINARY_DIR}/testImage.png
45 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
46 | ${CMAKE_CURRENT_SOURCE_DIR}/test.bin
47 | ${CMAKE_CURRENT_BINARY_DIR}/test.bin
48 | COMMENT "Copying test files to ${CMAKE_CURRENT_BINARY_DIR}"
49 | )
50 |
--------------------------------------------------------------------------------
/tests/auto/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | # Check for both existence of the built Qt generator plugin and the
5 | # upstream generator.
6 | # It's possible to have java + maven available, so the qt plugin will be built,
7 | # but for the upstream generator to be missing, in which case we can't build the tests.
8 | if(TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::QtOpenAPIGeneratorJar
9 | AND TARGET WrapOpenAPIGenerator::WrapOpenAPIGenerator
10 | AND TARGET Qt::OpenApiCommon
11 | )
12 | add_subdirectory(compression)
13 | add_subdirectory(linking_several_clients)
14 | if(TARGET Qt::Gui)
15 | add_subdirectory(mediatype)
16 | endif()
17 | add_subdirectory(openapi2.0)
18 | add_subdirectory(operation-parameters)
19 | add_subdirectory(petstore)
20 | add_subdirectory(responses)
21 | add_subdirectory(cmake)
22 | add_subdirectory(server_configuration)
23 | else()
24 | set(missing_text "")
25 | if(NOT TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::QtOpenAPIGeneratorJar)
26 | set(missing_text "Qt OpenAPI generator plugin target is missing.")
27 | endif()
28 | if(NOT TARGET WrapOpenAPIGenerator::WrapOpenAPIGenerator)
29 | set(missing_text "Upstream OpenAPI generator target is missing.")
30 | endif()
31 | if(NOT TARGET Qt::OpenApiCommon)
32 | set(missing_text "Qt OpenAPI Common library target is missing.")
33 | endif()
34 | # Only show when building standalone tests.
35 | # Otherwise we already say when skip the tests when configuring
36 | # them in-tree with the repo in the configure summary section.
37 | if(NOT QT_SUPERBUILD AND QT_BUILD_STANDALONE_TESTS)
38 | message(STATUS "Skipping OpenAPI tests because ${missing_text}")
39 | endif()
40 | endif()
41 |
--------------------------------------------------------------------------------
/tests/auto/cmake/RunCMake/LibraryInstallation/src/tst_compression.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | #include "testapi.h"
5 |
6 | #include
7 | #include
8 |
9 | using namespace Qt::StringLiterals;
10 | using namespace QtCommonOpenAPI;
11 |
12 | namespace QtOpenAPI {
13 |
14 | class tst_Compression : public TestApi {
15 | Q_OBJECT
16 |
17 | private Q_SLOTS:
18 | void localCompressionRoundtrip_data();
19 | void localCompressionRoundtrip();
20 | };
21 |
22 | void tst_Compression::localCompressionRoundtrip_data()
23 | {
24 | using namespace QOAIHttpRequestWorker;
25 | QTest::addColumn("compressionType");
26 |
27 | QTest::newRow("gzip") << CompressionType::Gzip;
28 | QTest::newRow("deflate") << CompressionType::Deflate;
29 | }
30 |
31 | void tst_Compression::localCompressionRoundtrip()
32 | {
33 | // Generate the data to compress
34 | static constexpr int BlockSize = 1024;
35 | static constexpr size_t MaxUChar = std::numeric_limits::max();
36 |
37 | QByteArray originalData;
38 | originalData.reserve(MaxUChar * BlockSize);
39 | for (uchar c = 0; c < MaxUChar; ++c)
40 | originalData.append(BlockSize, c);
41 |
42 | using namespace QOAIHttpRequestWorker;
43 | QFETCH(const CompressionType, compressionType);
44 |
45 | const QByteArray compressed = compressData(originalData, 9, compressionType);
46 | QCOMPARE_LE(compressed.size(), originalData.size());
47 |
48 | const QByteArray decompressed = decompressData(compressed, compressionType);
49 |
50 | QCOMPARE(decompressed, originalData);
51 | }
52 |
53 | } // namespace QtOpenAPI
54 |
55 | QTEST_MAIN(QtOpenAPI::tst_Compression)
56 | #include "tst_compression.moc"
57 |
--------------------------------------------------------------------------------
/tests/auto/compression/client/tst_compression/tst_compression.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | #include "../client/testapi.h"
5 |
6 | #include
7 | #include
8 |
9 | using namespace Qt::StringLiterals;
10 | using namespace QtCommonOpenAPI;
11 |
12 | namespace QtOpenAPI {
13 |
14 | class tst_Compression : public TestApi {
15 | Q_OBJECT
16 |
17 | private Q_SLOTS:
18 | void localCompressionRoundtrip_data();
19 | void localCompressionRoundtrip();
20 | };
21 |
22 | void tst_Compression::localCompressionRoundtrip_data()
23 | {
24 | using namespace QOAIHttpRequestWorker;
25 | QTest::addColumn("compressionType");
26 |
27 | QTest::newRow("gzip") << CompressionType::Gzip;
28 | QTest::newRow("deflate") << CompressionType::Deflate;
29 | }
30 |
31 | void tst_Compression::localCompressionRoundtrip()
32 | {
33 | // Generate the data to compress
34 | static constexpr int BlockSize = 1024;
35 | static constexpr size_t MaxUChar = std::numeric_limits::max();
36 |
37 | QByteArray originalData;
38 | originalData.reserve(MaxUChar * BlockSize);
39 | for (uchar c = 0; c < MaxUChar; ++c)
40 | originalData.append(BlockSize, c);
41 |
42 | using namespace QOAIHttpRequestWorker;
43 | QFETCH(const CompressionType, compressionType);
44 |
45 | const QByteArray compressed = compressData(originalData, 9, compressionType);
46 | QCOMPARE_LE(compressed.size(), originalData.size());
47 |
48 | const QByteArray decompressed = decompressData(compressed, compressionType);
49 |
50 | QCOMPARE(decompressed, originalData);
51 | }
52 |
53 | } // namespace QtOpenAPI
54 |
55 | QTEST_MAIN(QtOpenAPI::tst_Compression)
56 | #include "tst_compression.moc"
57 |
--------------------------------------------------------------------------------
/tests/auto/compression/client/tst_compression/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-compression LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | # We do not need a server now
11 | # if(NOT TARGET compression-server-go)
12 | # message(WARNING "No compression-server-go server in the build.")
13 | # return()
14 | # endif()
15 |
16 | if(MSVC)
17 | add_compile_options(/W4 /WX)
18 | else()
19 | add_compile_options(-Wall -Wextra)
20 | if(WARNINGS_ARE_ERRORS)
21 | add_compile_options(-Werror=deprecated-declarations)
22 | endif()
23 | endif()
24 |
25 | find_package(Doxygen)
26 |
27 | qt_internal_add_test(cpp-qt-compression
28 | SOURCES
29 | tst_compression.cpp
30 | LIBRARIES
31 | Qt::Core
32 | Qt::Network
33 | Qt::Test
34 | )
35 |
36 | qt_add_library(CompressionClient)
37 | qt6_add_openapi_client(CompressionClient
38 | SPEC_FILE
39 | ${CMAKE_CURRENT_SOURCE_DIR}/compression.yaml
40 | GENERATE_DOCUMENTATION
41 | )
42 |
43 | # target_compile_definitions(cpp-qt-compression
44 | # PRIVATE
45 | # SERVER_PATH="$"
46 | # )
47 | qt_autogen_tools_initial_setup(CompressionClient)
48 | target_link_libraries(cpp-qt-compression PRIVATE CompressionClient)
49 | # add_dependencies(cpp-qt-compression compression-server-go)
50 |
51 | if(WIN32)
52 | add_custom_command(TARGET cpp-qt-compression POST_BUILD
53 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
54 | $
55 | ${CMAKE_CURRENT_BINARY_DIR}
56 | VERBATIM)
57 | endif()
58 |
--------------------------------------------------------------------------------
/tests/auto/petstore/client/petapitest/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-petstore-petapi LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | if(NOT TARGET petstore-server-go)
11 | message(WARNING "No petstore-server-go server in the build.")
12 | return()
13 | endif()
14 |
15 | if(MSVC)
16 | add_compile_options(/W4 /WX)
17 | else()
18 | add_compile_options(-Wall -Wextra)
19 | if(WARNINGS_ARE_ERRORS)
20 | add_compile_options(-Werror=deprecated-declarations)
21 | endif()
22 | endif()
23 |
24 | qt_internal_add_test(cpp-qt-petstore-petapi
25 | SOURCES
26 | tst_petapitests.cpp
27 | LIBRARIES
28 | Qt::Core
29 | Qt::Gui
30 | Qt::Network
31 | Qt::Test
32 | )
33 |
34 | target_compile_definitions(cpp-qt-petstore-petapi
35 | PRIVATE
36 | SERVER_PATH="$"
37 | SERVER_FOLDER="$"
38 | )
39 |
40 | # Resources:
41 | set(cpp_qt_petstore_resource_files
42 | "file-for-uploading.txt"
43 | )
44 |
45 | qt_add_resources(cpp-qt-petstore-petapi "cpp-qt-petstore-petapi"
46 | PREFIX
47 | "/"
48 | FILES
49 | ${cpp_qt_petstore_resource_files}
50 | )
51 |
52 | target_link_libraries(cpp-qt-petstore-petapi PRIVATE PetStoreClient)
53 | add_dependencies(cpp-qt-petstore-petapi petstore-server-go)
54 |
55 | if(WIN32)
56 | add_custom_command(TARGET cpp-qt-petstore-petapi POST_BUILD
57 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
58 | $
59 | ${CMAKE_CURRENT_BINARY_DIR}
60 | VERBATIM)
61 | endif()
62 |
--------------------------------------------------------------------------------
/tests/auto/server_configuration/client/tst_server_configuration/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-serverconfiguration LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | if(NOT TARGET serverconfiguration-server-go)
11 | message(WARNING "No serverconfiguration-server-go server in the build.")
12 | return()
13 | endif()
14 |
15 | if(MSVC)
16 | add_compile_options(/W4 /WX)
17 | else()
18 | add_compile_options(-Wall -Wextra)
19 | if(WARNINGS_ARE_ERRORS)
20 | add_compile_options(-Werror=deprecated-declarations)
21 | endif()
22 | endif()
23 |
24 | qt_internal_add_test(cpp-qt-serverconfiguration
25 | SOURCES
26 | tst_server_configuration.cpp
27 | LIBRARIES
28 | Qt::Core
29 | Qt::Network
30 | Qt::Test
31 | )
32 |
33 | qt_add_library(ServerConfigurationClient)
34 | qt6_add_openapi_client(ServerConfigurationClient
35 | SPEC_FILE
36 | ${CMAKE_CURRENT_SOURCE_DIR}/server_configuration.yaml
37 | )
38 |
39 | target_compile_definitions(cpp-qt-serverconfiguration
40 | PRIVATE
41 | SERVER_PATH="$"
42 | )
43 | qt_autogen_tools_initial_setup(ServerConfigurationClient)
44 | target_link_libraries(cpp-qt-serverconfiguration PRIVATE ServerConfigurationClient)
45 | add_dependencies(cpp-qt-serverconfiguration serverconfiguration-server-go)
46 |
47 | if(WIN32)
48 | add_custom_command(TARGET cpp-qt-serverconfiguration POST_BUILD
49 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
50 | $
51 | ${CMAKE_CURRENT_BINARY_DIR}
52 | VERBATIM)
53 | endif()
54 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | cmake_minimum_required(VERSION 3.16)
5 | project(colorpaletteApp LANGUAGES CXX)
6 |
7 | if(NOT DEFINED INSTALL_EXAMPLESDIR)
8 | set(INSTALL_EXAMPLESDIR "examples")
9 | endif()
10 |
11 | set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}")
12 |
13 | find_package(Qt6 REQUIRED COMPONENTS Core Network Gui Qml Quick OpenApi)
14 |
15 | qt_standard_project_setup(REQUIRES 6.10)
16 |
17 | qt_add_executable(colorpaletteApp
18 | main.cpp
19 | )
20 |
21 | add_subdirectory(QtOpenApiExampleStyle)
22 |
23 | qt_add_qml_module(colorpaletteApp
24 | URI ColorPalette
25 | VERSION 1.0
26 | QML_FILES
27 | ColorPalette/Main.qml
28 | ColorPalette/ColorView.qml
29 | ColorPalette/UserMenu.qml
30 | ColorPalette/ColorDialogDelete.qml
31 | ColorPalette/ColorDialogEditor.qml
32 | ColorPalette/ServerSelection.qml
33 | SOURCES
34 | ApiBridges.h
35 | RESOURCES
36 | icons/delete.svg
37 | icons/edit.svg
38 | icons/plus.svg
39 | icons/update.svg
40 | icons/userMask.svg
41 | icons/user.svg
42 | icons/qt.png
43 | icons/login.svg
44 | icons/logout.svg
45 | icons/qt_attribution.json
46 | )
47 |
48 | qt_add_library(ColorpaletteClientExample)
49 |
50 | qt6_add_openapi_client(ColorpaletteClientExample
51 | SPEC_FILE
52 | ${CMAKE_CURRENT_SOURCE_DIR}/colorpalette.yaml
53 | )
54 |
55 | target_link_libraries(colorpaletteApp PRIVATE
56 | Qt6::Core
57 | Qt6::Network
58 | Qt6::Gui
59 | Qt6::Qml
60 | Qt6::Quick
61 | ColorpaletteClientExample
62 | )
63 |
64 | install(TARGETS colorpaletteApp
65 | BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
66 | RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
67 | LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
68 | )
69 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/ColorPalette/ColorDialogDelete.qml:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | import QtQuick
5 | import QtQuick.Controls
6 | import QtQuick.Layouts
7 |
8 | import QtOpenApiExampleStyle
9 |
10 | Popup {
11 | id: colorDeleter
12 | padding: 10
13 | modal: true
14 | focus: true
15 | anchors.centerIn: parent
16 | closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
17 | signal deleteClicked(int cid)
18 |
19 | property int colorId: -1
20 |
21 | property string colorName: ""
22 |
23 | function maybeDelete(data) {
24 | colorName = data.name
25 | colorId = data.id
26 | open()
27 | }
28 |
29 | ColumnLayout {
30 | anchors.fill: parent
31 | spacing: 10
32 |
33 | Text {
34 | color: "#222222"
35 | text: qsTr("Delete Color?")
36 | font.pixelSize: 16
37 | font.bold: true
38 | }
39 |
40 | Text {
41 | color: "#222222"
42 | text: qsTr("Are you sure, you want to delete color") + " \"" + colorDeleter.colorName + "\"?"
43 | font.pixelSize: 12
44 | }
45 |
46 | RowLayout {
47 | Layout.fillWidth: true
48 | spacing: 10
49 |
50 | Button {
51 | Layout.fillWidth: true
52 | text: qsTr("Cancel")
53 | onClicked: colorDeleter.close()
54 | }
55 |
56 | Button {
57 | Layout.fillWidth: true
58 | text: qsTr("Delete")
59 |
60 | buttonColor: "#CC1414"
61 | textColor: "#FFFFFF"
62 |
63 | onClicked: {
64 | colorDeleter.deleteClicked(colorDeleter.colorId)
65 | colorDeleter.close()
66 | }
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/client/mediatype/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-mediatype LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | if(NOT TARGET mediatype-server-go)
11 | message(WARNING "No mediatype-server-go server in the build.")
12 | return()
13 | endif()
14 |
15 | if(MSVC)
16 | add_compile_options(/W4 /WX)
17 | else()
18 | add_compile_options(-Wall -Wextra)
19 | if(WARNINGS_ARE_ERRORS)
20 | add_compile_options(-Werror=deprecated-declarations)
21 | endif()
22 | endif()
23 |
24 | qt_internal_add_test(cpp-qt-mediatype
25 | SOURCES
26 | tst_mediatype.cpp
27 | LIBRARIES
28 | Qt::Core
29 | Qt::Gui
30 | Qt::Network
31 | Qt::Test
32 | )
33 |
34 | qt_add_library(MediaTypeClient)
35 | qt6_add_openapi_client(MediaTypeClient
36 | SPEC_FILE
37 | ${CMAKE_CURRENT_SOURCE_DIR}/mediatype.yaml
38 | )
39 |
40 | # Resources:
41 | set(cpp_qt_mediatype_resource_files
42 | "file-for-uploading.txt"
43 | "usericon.png"
44 | )
45 |
46 | qt_internal_add_resource(cpp-qt-mediatype "cpp-qt-mediatype"
47 | PREFIX
48 | "/"
49 | FILES
50 | ${cpp_qt_mediatype_resource_files}
51 | )
52 |
53 | target_compile_definitions(cpp-qt-mediatype
54 | PRIVATE
55 | SERVER_PATH="$"
56 | )
57 | qt_autogen_tools_initial_setup(MediaTypeClient)
58 | target_link_libraries(cpp-qt-mediatype PRIVATE MediaTypeClient)
59 | add_dependencies(cpp-qt-mediatype mediatype-server-go)
60 |
61 | if(WIN32)
62 | add_custom_command(TARGET cpp-qt-mediatype POST_BUILD
63 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
64 | $
65 | ${CMAKE_CURRENT_BINARY_DIR}
66 | VERBATIM)
67 | endif()
68 |
--------------------------------------------------------------------------------
/src/openapi/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | # This is just a placeholder module that in the future might ship public headers.
5 | qt_internal_add_module(OpenApi
6 | HEADER_MODULE
7 | NO_MODULE_HEADERS
8 | NO_PRIVATE_MODULE
9 | NO_GENERATE_CPP_EXPORTS
10 | NO_ADDITIONAL_TARGET_INFO
11 | NO_GENERATE_METATYPES
12 | NO_PACKAGE_CONFIG_FILE
13 | NO_MODULE_JSON_FILE
14 | NO_QMAKE_SUPPORT_FILES
15 | )
16 | set_target_properties(OpenApi PROPERTIES AUTOMOC OFF)
17 |
18 | # Make find_package(Qt6 COMPONENTS OpenApi) lookup the OpenApiCommon library as a dependency as
19 | # well.
20 | if(TARGET Qt::OpenApiCommon)
21 | qt_internal_register_target_dependencies(OpenApi PUBLIC Qt::OpenApiCommon)
22 | endif()
23 |
24 | qt_internal_add_docs(OpenApi
25 | doc/qtopenapi.qdocconf
26 | )
27 |
28 | # Add the standalone tool package that exposes the Qt openapi generator plugin.
29 | set(base_name "${QT_CMAKE_EXPORT_NAMESPACE}OpenApiTools")
30 | set(base_path "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}")
31 |
32 | qt_internal_add_tools_package(
33 | PACKAGE_BASE_NAME OpenApi
34 | EXTRA_CMAKE_FILES
35 | "${base_path}ExtraTargets.cmake"
36 | "${base_path}GeneratorMacros.cmake"
37 | "${base_path}CopyHeadersScript.cmake"
38 | EXTRA_CMAKE_INCLUDES
39 | "${base_name}ExtraTargets.cmake"
40 | "${base_name}GeneratorMacros.cmake"
41 | )
42 |
43 | # Make find_package(Qt6 COMPONENTS OpenApiTools) also find the java runtime and the upstream
44 | # generator.
45 | qt_internal_record_tools_package_extra_third_party_dependency(
46 | PACKAGE_BASE_NAME OpenApi
47 | DEPENDENCY_PACKAGE_NAME WrapOpenAPIJava)
48 | qt_internal_record_tools_package_extra_third_party_dependency(
49 | PACKAGE_BASE_NAME OpenApi
50 | DEPENDENCY_PACKAGE_NAME WrapOpenAPIGenerator)
51 |
52 | # Make find_package(Qt6 COMPONENTS OpenApi) also find the OpenApiTools package.
53 | qt_record_extra_qt_main_tools_package_dependency(OpenApi OpenApiTools "${PROJECT_VERSION}")
54 |
55 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/test/java/org/qtproject/qt/codegen/CppQt6ClientGeneratorTest.java:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: Apache-2.0
3 |
4 | package org.qtproject.qt.codegen;
5 |
6 | import org.junit.jupiter.api.Test;
7 | import org.openapitools.codegen.ClientOptInput;
8 | import org.openapitools.codegen.DefaultGenerator;
9 | import org.openapitools.codegen.config.CodegenConfigurator;
10 | import org.qtproject.qt.codegen.CppQt6ClientGenerator;
11 |
12 | /***
13 | * This test allows you to easily launch your code generation software under a debugger.
14 | * Then run this test under debug mode. You will be able to step through your java code
15 | * and then see the results in the out directory.
16 | *
17 | * To experiment with debugging your code generator:
18 | * 1) Set a break point in CppQt6ClientGenerator.java in the postProcessOperationsWithModels() method.
19 | * 2) To launch this test in Eclipse: right-click | Debug As | JUnit Test
20 | *
21 | */
22 | public class CppQt6ClientGeneratorTest {
23 |
24 | // use this test to launch you code generator in the debugger.
25 | // this allows you to easily set break points in CppQt6ClientGenerator.
26 | @Test
27 | public void launchCodeGenerator() {
28 | // to understand how the 'openapi-generator-cli' module is using 'CodegenConfigurator', have a look at the 'Generate' class:
29 | // https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java
30 | final CodegenConfigurator configurator = new CodegenConfigurator()
31 | .setGeneratorName("cpp-qt6-client") // use this codegen library
32 | .setInputSpec("yaml_files/petstore.yaml") // petstore test yaml file
33 | .setOutputDir("out/cpp-qt6-client"); // output directory
34 |
35 | final ClientOptInput clientOptInput = configurator.toClientOptInput();
36 | DefaultGenerator generator = new DefaultGenerator();
37 | generator.opts(clientOptInput).generate();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/coin/module_config.yaml:
--------------------------------------------------------------------------------
1 | version: 2
2 | accept_configuration:
3 | condition: property
4 | property: features
5 | not_contains_value: Disable
6 |
7 | create_debian_from_openapi-cli: &create_debian_from_openapi-cli
8 | type: Group
9 | instructions:
10 | - type: ExecuteCommand
11 | command: "coin/make_openapi_generator_cli_as_debian.sh"
12 | maxTimeInSeconds: 1400
13 | maxTimeBetweenOutput: 1200
14 | enable_if:
15 | condition: property
16 | property: features
17 | contains_value: DebianPackaging
18 | userMessageOnFailure: >
19 | Failed to build openapi-generator-cli.jar debian package
20 |
21 | instructions:
22 | Build:
23 | - type: EnvironmentVariable
24 | variableName: VERIFY_SOURCE_SBOM
25 | variableValue: "ON"
26 | - type: Group
27 | disable_if:
28 | condition: and
29 | conditions:
30 | # Disable Windows if it's not MSVC
31 | - condition: property
32 | property: target.os
33 | equals_value: Windows
34 | - condition: or
35 | conditions:
36 | - condition: property
37 | property: target.compiler
38 | contains_value: Mingw
39 | - condition: property
40 | property: target.compiler
41 | contains_value: Clang
42 | instructions:
43 | - *create_debian_from_openapi-cli
44 | - !include "{{qt/qtbase}}/coin_module_build_template_v2.yaml"
45 |
46 | Test:
47 | - type: Group
48 | disable_if:
49 | condition: and
50 | conditions:
51 | # Disable Windows if it's not MSVC
52 | - condition: property
53 | property: target.os
54 | equals_value: Windows
55 | - condition: or
56 | conditions:
57 | - condition: property
58 | property: target.compiler
59 | contains_value: Mingw
60 | - condition: property
61 | property: target.compiler
62 | contains_value: Clang
63 | instructions:
64 | - !include "{{qt/qtbase}}/coin_module_test_template_v3.yaml"
65 | - !include "{{qt/qtbase}}/coin_module_test_docs.yaml"
66 |
--------------------------------------------------------------------------------
/tests/auto/linking_several_clients/application/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
5 | cmake_minimum_required(VERSION 3.16)
6 | project(cpp-qt-test-config LANGUAGES CXX)
7 | find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
8 | endif()
9 |
10 | find_package(Qt6 REQUIRED COMPONENTS Core Network Test)
11 |
12 | if(MSVC)
13 | add_compile_options(/W4 /WX)
14 | else()
15 | add_compile_options(-Wall -Wextra)
16 | if(WARNINGS_ARE_ERRORS)
17 | add_compile_options(-Werror=deprecated-declarations)
18 | endif()
19 | endif()
20 |
21 | ## application 1:
22 | ## Client1 produces common-lib on generation.
23 | ## Client2 links common-lib for common files usage.
24 | qt_internal_add_test(cpp-qt-test-config1-app
25 | SOURCES
26 | TestConfiguration1.cpp
27 | LIBRARIES
28 | Qt::Core
29 | Qt::Network
30 | Qt::Test
31 | )
32 |
33 | # client1 generation
34 | qt_add_library(TestClient1)
35 | qt6_add_openapi_client(TestClient1
36 | SPEC_FILE
37 | ${CMAKE_CURRENT_SOURCE_DIR}/linking_several_clients/client1.yaml
38 | OUTPUT_DIRECTORY
39 | ${CMAKE_CURRENT_BINARY_DIR}/client1
40 | )
41 |
42 | # client2 generation
43 | qt_add_library(TestClient2)
44 | qt6_add_openapi_client(TestClient2
45 | SPEC_FILE
46 | ${CMAKE_CURRENT_SOURCE_DIR}/linking_several_clients/client2.yaml
47 | OUTPUT_DIRECTORY
48 | ${CMAKE_CURRENT_BINARY_DIR}/client2
49 | )
50 |
51 | target_include_directories(TestClient2
52 | PUBLIC
53 | $
54 | )
55 |
56 | qt_autogen_tools_initial_setup(TestClient1)
57 | qt_autogen_tools_initial_setup(TestClient2)
58 |
59 | target_link_libraries(cpp-qt-test-config1-app PRIVATE TestClient1 TestClient2)
60 |
61 | if(WIN32)
62 | add_custom_command(TARGET cpp-qt-test-config1-app POST_BUILD
63 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
64 | $
65 | ${CMAKE_CURRENT_BINARY_DIR}
66 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
67 | $
68 | ${CMAKE_CURRENT_BINARY_DIR}
69 | VERBATIM)
70 | endif()
71 |
--------------------------------------------------------------------------------
/tests/auto/server_configuration/client/tst_server_configuration/server_configuration.yaml:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | openapi: 3.1.1
5 | servers:
6 | - url: 'http://127.0.0.1:{port}/{basePath}'
7 | variables:
8 | port:
9 | default: '20303'
10 | basePath:
11 | enum:
12 | - v1
13 | - v2
14 | default: v1
15 | info:
16 | title: Server Configuration Test
17 | description: >
18 | This specification is needed to check how various server configurations are handled.
19 | version: 1.0.0
20 | tags:
21 | - name: test
22 | description: test operations
23 |
24 | paths:
25 | /operations/dummy:
26 | post:
27 | tags: [test]
28 | operationId: dummyOperation
29 | summary: "not used for now"
30 | responses:
31 | '200':
32 | description: OK
33 | content:
34 | application/json:
35 | schema:
36 | type: string
37 | /operations/customServers:
38 | servers:
39 | - url: 'http://{user}.some.server:{port}/api'
40 | variables:
41 | user:
42 | default: admin
43 | port:
44 | enum:
45 | - '80'
46 | - '443'
47 | default: '80'
48 | - url: 'http://other.server/api'
49 | get:
50 | tags: [test]
51 | operationId: customServersGet
52 | summary: "Uses the servers from the path"
53 | responses:
54 | '200':
55 | description: OK
56 | content:
57 | application/json:
58 | schema:
59 | type: string
60 | post:
61 | tags: [test]
62 | operationId: customServersPost
63 | summary: "The servers in the operation should override the servers from path"
64 | servers:
65 | - url: 'http://127.0.0.1:20303/{basePath}'
66 | variables:
67 | basePath:
68 | enum:
69 | - v1
70 | - v2
71 | default: v1
72 | - url: 'http://fake.server/api'
73 | responses:
74 | '200':
75 | description: OK
76 | content:
77 | application/json:
78 | schema:
79 | type: string
80 |
--------------------------------------------------------------------------------
/REUSE.toml:
--------------------------------------------------------------------------------
1 | version = 1
2 |
3 | [[annotations]]
4 | path = ["src/tools/qtopenapi-generator/**"]
5 | precedence = "closest"
6 | comment = "generator java files and templates"
7 | SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
8 | SPDX-License-Identifier = "Apache-2.0"
9 |
10 | [[annotations]]
11 | path = ["tests/auto/**.go", "tests/auto/**go.mod",
12 | "tests/auto/**go.sum", "tests/auto/**.jpg",
13 | "tests/auto/**.png", "tests/auto/**.txt",
14 | "tests/auto/**.json", "tests/auto/**.pdf",
15 | "tests/auto/**.bin"]
16 | precedence = "closest"
17 | comment = "test resource files"
18 | SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
19 | SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GPL-3.0-only"
20 |
21 | [[annotations]]
22 | path = ["**.in", "**.pro", "**CMakeLists.txt",
23 | ".cmake.conf", "dependencies.yaml",
24 | ".tag", "coin/**"]
25 | precedence = "closest"
26 | comment = "build system"
27 | SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
28 | SPDX-License-Identifier = "BSD-3-Clause"
29 |
30 | [[annotations]]
31 | path = ["**/.gitattributes", "**.gitignore", "**/.gitreview"]
32 | precedence = "closest"
33 | comment = "infrastructure"
34 | SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
35 | SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
36 |
37 | [[annotations]]
38 | path = ["**/doc/snippets/**"]
39 | comment = "this must be after the build system table because example and snippets take precedence over build system"
40 | precedence = "closest"
41 | SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
42 | SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
43 |
44 | [[annotations]]
45 | path = ["**.qdocconf", "**.patch"]
46 | comment = "documentation"
47 | precedence = "closest"
48 | SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
49 | SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only"
50 |
51 | [[annotations]]
52 | path = ["**.toml", "licenseRule.json"]
53 | precedence = "override"
54 | SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
55 | SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
56 |
57 | [[annotations]]
58 | path = ["**/qt_attribution.json"]
59 | precedence = "override"
60 | SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
61 | SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only"
62 |
63 |
--------------------------------------------------------------------------------
/tests/auto/server_configuration/server/go/routers.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Server Configuration Test
3 | *
4 | * This specification is needed to check how various server configurations are handled.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | import (
13 | "net/http"
14 |
15 | "github.com/gin-gonic/gin"
16 | )
17 |
18 | // Route is the information for every URI.
19 | type Route struct {
20 | // Name is the name of this Route.
21 | Name string
22 | // Method is the string for the HTTP method. ex) GET, POST etc..
23 | Method string
24 | // Pattern is the pattern of the URI.
25 | Pattern string
26 | // HandlerFunc is the handler function of this route.
27 | HandlerFunc gin.HandlerFunc
28 | }
29 |
30 | // NewRouter returns a new router.
31 | func NewRouter(handleFunctions ApiHandleFunctions) *gin.Engine {
32 | return NewRouterWithGinEngine(gin.Default(), handleFunctions)
33 | }
34 |
35 | // NewRouter add routes to existing gin engine.
36 | func NewRouterWithGinEngine(router *gin.Engine, handleFunctions ApiHandleFunctions) *gin.Engine {
37 | for _, route := range getRoutes(handleFunctions) {
38 | if route.HandlerFunc == nil {
39 | route.HandlerFunc = DefaultHandleFunc
40 | }
41 | switch route.Method {
42 | case http.MethodGet:
43 | router.GET(route.Pattern, route.HandlerFunc)
44 | case http.MethodPost:
45 | router.POST(route.Pattern, route.HandlerFunc)
46 | case http.MethodPut:
47 | router.PUT(route.Pattern, route.HandlerFunc)
48 | case http.MethodPatch:
49 | router.PATCH(route.Pattern, route.HandlerFunc)
50 | case http.MethodDelete:
51 | router.DELETE(route.Pattern, route.HandlerFunc)
52 | }
53 | }
54 |
55 | return router
56 | }
57 |
58 | // Default handler for not yet implemented routes
59 | func DefaultHandleFunc(c *gin.Context) {
60 | c.String(http.StatusNotImplemented, "501 not implemented")
61 | }
62 |
63 | type ApiHandleFunctions struct {
64 |
65 | // Routes for the TestAPI part of the API
66 | TestAPI TestAPI
67 | }
68 |
69 | func getRoutes(handleFunctions ApiHandleFunctions) []Route {
70 | return []Route{
71 | {
72 | "DummyOperationv1",
73 | http.MethodPost,
74 | "/v1/operations/dummy",
75 | handleFunctions.TestAPI.DummyOperation,
76 | },
77 | {
78 | "DummyOperationv2",
79 | http.MethodPost,
80 | "/v2/operations/dummy",
81 | handleFunctions.TestAPI.DummyOperation,
82 | },
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/server/go/routers.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI 2.0 test
3 | *
4 | * This spec is mainly for testing Openapi 2.0
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | import (
13 | "net/http"
14 |
15 | "github.com/gin-gonic/gin"
16 | )
17 |
18 | // Route is the information for every URI.
19 | type Route struct {
20 | // Name is the name of this Route.
21 | Name string
22 | // Method is the string for the HTTP method. ex) GET, POST etc..
23 | Method string
24 | // Pattern is the pattern of the URI.
25 | Pattern string
26 | // HandlerFunc is the handler function of this route.
27 | HandlerFunc gin.HandlerFunc
28 | }
29 |
30 | // NewRouter returns a new router.
31 | func NewRouter(handleFunctions ApiHandleFunctions) *gin.Engine {
32 | return NewRouterWithGinEngine(gin.Default(), handleFunctions)
33 | }
34 |
35 | // NewRouter add routes to existing gin engine.
36 | func NewRouterWithGinEngine(router *gin.Engine, handleFunctions ApiHandleFunctions) *gin.Engine {
37 | for _, route := range getRoutes(handleFunctions) {
38 | if route.HandlerFunc == nil {
39 | route.HandlerFunc = DefaultHandleFunc
40 | }
41 | switch route.Method {
42 | case http.MethodGet:
43 | router.GET(route.Pattern, route.HandlerFunc)
44 | case http.MethodPost:
45 | router.POST(route.Pattern, route.HandlerFunc)
46 | case http.MethodPut:
47 | router.PUT(route.Pattern, route.HandlerFunc)
48 | case http.MethodPatch:
49 | router.PATCH(route.Pattern, route.HandlerFunc)
50 | case http.MethodDelete:
51 | router.DELETE(route.Pattern, route.HandlerFunc)
52 | }
53 | }
54 |
55 | return router
56 | }
57 |
58 | // Default handler for not yet implemented routes
59 | func DefaultHandleFunc(c *gin.Context) {
60 | c.String(http.StatusNotImplemented, "501 not implemented")
61 | }
62 |
63 | type ApiHandleFunctions struct {
64 |
65 | // Routes for the FakeAPI part of the API
66 | FakeAPI FakeAPI
67 | }
68 |
69 | func getRoutes(handleFunctions ApiHandleFunctions) []Route {
70 | return []Route{
71 | {
72 | "TestPathParameterCollectionFormat",
73 | http.MethodPost,
74 | "/v2/fake/test-path-parameters/:pipeId/:ioutilId/:httpId/:urlId/:multiContextId",
75 | handleFunctions.FakeAPI.TestPathParameterCollectionFormat,
76 | },
77 | {
78 | "TestQueryParameterCollectionFormat",
79 | http.MethodPost,
80 | "/v2/fake/test-query-parameters",
81 | handleFunctions.FakeAPI.TestQueryParameterCollectionFormat,
82 | },
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/tests/auto/cmake/RunCMake/LibraryInstallation/build_and_install_lib.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | # This project builds and installs the client library generated from the spec,
5 | # and the public headers created for the client.
6 |
7 | find_package(Qt6 REQUIRED COMPONENTS Core Network Test OpenApi OpenApiCommon)
8 |
9 | # We need to set this explicitly, so it gets baked into the installed client library,
10 | # because it does not get processed by our deployment code.
11 | # Otherwise the application in the other project would fail to find the dependencies of the
12 | # client library at runtime on Linux.
13 | set(CMAKE_INSTALL_RPATH "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_LIBS}")
14 |
15 | qt_standard_project_setup(REQUIRES 6.10)
16 |
17 | # Build the libraries
18 | qt_add_library(CompressionClient)
19 | qt6_add_openapi_client(CompressionClient
20 | SPEC_FILE
21 | "${CMAKE_CURRENT_SOURCE_DIR}/src/compression.yaml"
22 | OUTPUT_PUBLIC_HEADERS_DIR
23 | client_public_headers_dir
24 | OUTPUT_PRIVATE_HEADERS_DIR
25 | client_private_headers_dir
26 | )
27 |
28 | # Propagate the installed include dirs for any consuming project.
29 | target_include_directories(CompressionClient INTERFACE
30 | "$"
31 | "$"
32 | )
33 |
34 | # Install the prebuilt libraries
35 | install(
36 | TARGETS CompressionClient
37 | EXPORT CompressionClientTargets
38 | ARCHIVE DESTINATION lib
39 | LIBRARY DESTINATION lib
40 | RUNTIME DESTINATION bin
41 | )
42 |
43 | # Install the cmake files to find the libraries in another project
44 | install(EXPORT
45 | CompressionClientTargets
46 | NAMESPACE CompressionClient::
47 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CompressionClient"
48 | )
49 |
50 | # Create a helper file that includes the above cmake file via full path, so it's easier to
51 | # consume in the other project
52 | set(rel_targets_path "cmake/CompressionClient/CompressionClientTargets.cmake")
53 | set(full_targets_path "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${rel_targets_path}")
54 | set(include_file_path "${CMAKE_TARGETS_INCLUDE_PATH}")
55 | file(GENERATE OUTPUT "${include_file_path}"
56 | CONTENT "include(\"${full_targets_path}\")\n"
57 | )
58 |
59 | # Install the public and private headers for the libraries.
60 | # Slash at the end is important to install the files, and not the directory.
61 | install(
62 | DIRECTORY "${client_public_headers_dir}/"
63 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
64 | )
65 | install(
66 | DIRECTORY "${client_private_headers_dir}/"
67 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/private"
68 | )
69 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/servervariable.cpp.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 |
3 | #include "{{prefixLowerCase}}servervariable.h"
4 |
5 | #include
6 | #include
7 |
8 | {{#cppCommonNamespaceDeclarations}}
9 | namespace {{this}} {
10 | {{/cppCommonNamespaceDeclarations}}
11 |
12 | class {{prefix}}ServerVariablePrivate : public QSharedData
13 | {
14 | public:
15 | QString m_value;
16 | QString m_description;
17 | QSet m_enumValues;
18 | };
19 |
20 | {{prefix}}ServerVariable::{{prefix}}ServerVariable(const QString &description,
21 | const QString &defaultValue,
22 | const QSet &enumValues)
23 | : {{prefix}}ServerVariable()
24 | {
25 | d_ptr->m_value = defaultValue;
26 | d_ptr->m_description = description;
27 | d_ptr->m_enumValues = enumValues;
28 | }
29 |
30 | {{prefix}}ServerVariable::{{prefix}}ServerVariable()
31 | : d_ptr(new {{prefix}}ServerVariablePrivate)
32 | {}
33 |
34 | {{prefix}}ServerVariable::~{{prefix}}ServerVariable()
35 | = default;
36 |
37 | {{prefix}}ServerVariable::{{prefix}}ServerVariable(const {{prefix}}ServerVariable &other)
38 | = default;
39 |
40 | {{prefix}}ServerVariable &{{prefix}}ServerVariable::operator=(const {{prefix}}ServerVariable &other)
41 | {
42 | if (this != &other)
43 | d_ptr = other.d_ptr;
44 | return *this;
45 | }
46 |
47 | {{prefix}}ServerVariable::{{prefix}}ServerVariable({{prefix}}ServerVariable &&other) noexcept
48 | = default;
49 |
50 | {{prefix}}ServerVariable &{{prefix}}ServerVariable::operator=({{prefix}}ServerVariable &&other) noexcept
51 | {
52 | swap(other);
53 | return *this;
54 | }
55 |
56 | void {{prefix}}ServerVariable::swap({{prefix}}ServerVariable &other) noexcept
57 | {
58 | d_ptr.swap(other.d_ptr);
59 | }
60 |
61 | {{prefix}}ServerVariable::ServerError {{prefix}}ServerVariable::setValue(const QString& value)
62 | {
63 | if (!d_ptr->m_enumValues.empty() && !d_ptr->m_enumValues.contains(value))
64 | return ServerError::EnumValueNotFound;
65 |
66 | d_ptr.detach();
67 | d_ptr->m_value = value;
68 | return ServerError::NoError;
69 | }
70 |
71 | QString {{prefix}}ServerVariable::value() const
72 | {
73 | return d_ptr->m_value;
74 | }
75 |
76 | QSet {{prefix}}ServerVariable::enumValues() const
77 | {
78 | return d_ptr->m_enumValues;
79 | }
80 |
81 | QString {{prefix}}ServerVariable::description() const
82 | {
83 | return d_ptr->m_description;
84 | }
85 |
86 | bool
87 | comparesEqual(const {{prefix}}ServerVariable &lhs, const {{prefix}}ServerVariable &rhs) noexcept
88 | {
89 | return lhs.d_ptr->m_value == rhs.d_ptr->m_value
90 | && lhs.d_ptr->m_description == rhs.d_ptr->m_description
91 | && lhs.d_ptr->m_enumValues == rhs.d_ptr->m_enumValues;
92 | }
93 |
94 | {{#cppCommonNamespaceDeclarations}}
95 | } // namespace {{this}}
96 | {{/cppCommonNamespaceDeclarations}}
97 |
--------------------------------------------------------------------------------
/tests/auto/cmake/RunCMake/LibraryInstallation/RunCMakeTest.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | include(QtRunCMake)
5 |
6 | set(check_deps_case "find_openapi_deps")
7 | set(main_build_case "build_and_install_lib")
8 | set(consume_case "consume_installed_lib")
9 |
10 | # A file that will say if all openapi deps are found.
11 | set(DEPS_AVAILABLE_INCLUDE_PATH
12 | "${RunCMake_BINARY_DIR}/${check_deps_case}-build/DepsAvailable.cmake")
13 |
14 | function(run_cmake_and_build case)
15 | set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
16 |
17 | # Set an install prefix where the first project will be installed.
18 | set(cmake_install_prefix ${RunCMake_BINARY_DIR}/installed)
19 |
20 | # A file that will include the client library target, created by the first project, consumed
21 | # by the second one.
22 | set(cmake_targets_include_path
23 | "${RunCMake_BINARY_DIR}/${main_build_case}-build/CompressionTargetsInclude.cmake")
24 |
25 | set(options
26 | "-DQt6_DIR=${Qt6_DIR}"
27 | "-DCMAKE_INSTALL_PREFIX=${cmake_install_prefix}"
28 | "-DCMAKE_TARGETS_INCLUDE_PATH=${cmake_targets_include_path}"
29 | "-DDEPS_AVAILABLE_INCLUDE_PATH=${DEPS_AVAILABLE_INCLUDE_PATH}"
30 | )
31 |
32 | # Configure.
33 | if(case STREQUAL "${check_deps_case}")
34 | # Don't error out due to stderr output.
35 | set(RunCMake_TEST_OUTPUT_MERGE 1)
36 | endif()
37 | run_cmake_with_options(${case} ${options})
38 |
39 | # Do not remove the current RunCMake_TEST_BINARY_DIR for the next operations.
40 | set(RunCMake_TEST_NO_CLEAN 1)
41 |
42 | # Merge output, because some of the tooling outputs to stderr even when everything is fine,
43 | # and CMake treats it as an error.
44 | set(RunCMake_TEST_OUTPUT_MERGE 1)
45 |
46 | # Build and install
47 | if(NOT case STREQUAL "${check_deps_case}")
48 | run_cmake_command(${case}-build "${CMAKE_COMMAND}" --build .)
49 | run_cmake_command(${case}-install "${CMAKE_COMMAND}" --install .)
50 | endif()
51 |
52 | # Run the test executable at the end
53 | if(case STREQUAL "${consume_case}")
54 | if(CMAKE_HOST_WIN32)
55 | message(STATUS "Skipping RunCMake.LibraryInstallation test, because it hasn't been "
56 | "fixed for Windows hosts yet")
57 | else()
58 | run_cmake_command(${case}-test "${CMAKE_CTEST_COMMAND}" -V)
59 | endif()
60 | endif()
61 | endfunction()
62 |
63 | # Check if all openapi dependencies are available. If not, skip the rest of the steps.
64 | run_cmake_and_build("${check_deps_case}")
65 | include("${DEPS_AVAILABLE_INCLUDE_PATH}")
66 |
67 | if(NOT DEPS_AVAILABLE)
68 | message(STATUS "Skipping RunCMake.LibraryInstallation test, because not all OpenAPI "
69 | "dependencies are available.")
70 | return()
71 | endif()
72 |
73 | # Build and install the libraries.
74 | run_cmake_and_build("${main_build_case}")
75 |
76 | # Find, and link to the installed libraries, and build an executable.
77 | run_cmake_and_build("${consume_case}")
78 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/CMakeLists.txt.mustache:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.16)
2 |
3 | project({{{commonLibraryName}}} VERSION 0.1 LANGUAGES CXX)
4 |
5 | set(CMAKE_CXX_STANDARD 17)
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 |
8 | find_package(Qt6 REQUIRED COMPONENTS Core Network)
9 | {{#contentCompression}}
10 | find_package(ZLIB REQUIRED)
11 | {{/contentCompression}}
12 | qt_standard_project_setup()
13 |
14 | include(GNUInstallDirs)
15 | include(CMakePackageConfigHelpers)
16 |
17 | qt_add_library(${PROJECT_NAME}
18 | {{prefixLowerCase}}baseapi.h
19 | {{prefixLowerCase}}helpers.h
20 | {{prefixLowerCase}}httprequest.h
21 | {{prefixLowerCase}}object.h
22 | {{prefixLowerCase}}enum.h
23 | {{prefixLowerCase}}httpfileelement.h
24 | {{prefixLowerCase}}serverconfiguration.h
25 | {{prefixLowerCase}}servervariable.h
26 | {{prefixLowerCase}}baseapi.cpp
27 | {{prefixLowerCase}}helpers.cpp
28 | {{prefixLowerCase}}httprequest.cpp
29 | {{prefixLowerCase}}object.cpp
30 | {{prefixLowerCase}}enum.cpp
31 | {{prefixLowerCase}}httpfileelement.cpp
32 | {{prefixLowerCase}}serverconfiguration.cpp
33 | {{prefixLowerCase}}servervariable.cpp
34 | )
35 |
36 | target_include_directories(${PROJECT_NAME}
37 | PUBLIC
38 | $
39 | $
40 | {{#contentCompression}}
41 | PRIVATE
42 | ${ZLIB_INCLUDE_DIRS}
43 | {{/contentCompression}}
44 | )
45 |
46 | get_target_property(target_type ${PROJECT_NAME} TYPE)
47 | if(target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
48 | target_compile_definitions(${PROJECT_NAME} PRIVATE {{prefix}}_COMMON_LIB_SHARED)
49 | elseif(target_type STREQUAL "STATIC_LIBRARY")
50 | target_compile_definitions(${PROJECT_NAME} PRIVATE {{prefix}}_COMMON_LIB_STATIC)
51 | endif()
52 | target_compile_definitions(${PROJECT_NAME} PRIVATE {{prefix}}_BUILD_COMMON_LIB)
53 |
54 | target_link_libraries(${PROJECT_NAME}
55 | PUBLIC
56 | Qt::Core
57 | Qt::Network
58 | {{#contentCompression}}
59 | PRIVATE
60 | ZLIB::ZLIB
61 | {{/contentCompression}}
62 | )
63 |
64 | configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.in
65 | "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
66 | INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
67 | )
68 |
69 | install(
70 | TARGETS ${PROJECT_NAME}
71 | EXPORT ${PROJECT_NAME}Targets
72 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
73 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
74 | RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
75 | INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
76 | )
77 |
78 | install(
79 | FILES ${HEADER_FILES}
80 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
81 | )
82 |
83 | install(
84 | FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
85 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
86 | )
87 |
88 | install(
89 | EXPORT ${PROJECT_NAME}Targets
90 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
91 | )
92 |
--------------------------------------------------------------------------------
/tests/auto/petstore/server/go/api_store.go:
--------------------------------------------------------------------------------
1 | /*
2 | * OpenAPI Petstore
3 | *
4 | * This is a sample of Petstore application. For this sample, you can use the api key `special-key` to test the authorization filters.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | import (
13 | "github.com/gin-gonic/gin"
14 | "fmt"
15 | "net/http"
16 | "strconv"
17 | "time"
18 | )
19 |
20 | type StoreAPI struct {
21 | Orders map[int64]Order
22 | }
23 |
24 | func (api *StoreAPI) InitializeOrdersMap() {
25 | if api.Orders == nil {
26 | api.Orders = make(map[int64]Order)
27 | }
28 | }
29 |
30 | // Delete /v2/store/order/:orderId
31 | // Delete purchase order by ID
32 | func (api *StoreAPI) DeleteOrder(c *gin.Context) {
33 | api.InitializeOrdersMap()
34 |
35 | orderIdStr := c.Param("orderId")
36 | if orderIdStr == "" {
37 | c.JSON(http.StatusBadRequest, gin.H{"error": "missing orderId"})
38 | return
39 | }
40 | orderId, err := strconv.ParseInt(orderIdStr, 10, 64)
41 | if err != nil {
42 | c.JSON(http.StatusBadRequest, gin.H{"error": "Failed to parse orderId"})
43 | return
44 | }
45 |
46 | // The spec tells that we should return 404 if the ID is not found,
47 | // but the test always expects 200!
48 | // _, ok := api.Orders[orderId]
49 | // if !ok {
50 | // c.JSON(http.StatusNotFound, gin.H{"error": "orderId not found"})
51 | // return
52 | // }
53 | delete(api.Orders, orderId)
54 |
55 | // The test expects us to sleep for 1 second before answering!
56 | time.Sleep(1000 * time.Millisecond)
57 |
58 | c.JSON(http.StatusOK, gin.H{"status": "OK"})
59 | }
60 |
61 | // Get /v2/store/inventory
62 | // Returns pet inventories by status
63 | func (api *StoreAPI) GetInventory(c *gin.Context) {
64 | response := make(map[string]int32)
65 | c.JSON(http.StatusOK, response)
66 | }
67 |
68 | // Get /v2/store/order/:orderId
69 | // Find purchase order by ID
70 | func (api *StoreAPI) GetOrderById(c *gin.Context) {
71 | api.InitializeOrdersMap()
72 |
73 | orderIdStr := c.Param("orderId")
74 | if orderIdStr == "" {
75 | c.JSON(http.StatusBadRequest, gin.H{"error": "missing orderId"})
76 | return
77 | }
78 | orderId, err := strconv.ParseInt(orderIdStr, 10, 64)
79 | if err != nil {
80 | c.JSON(http.StatusBadRequest, gin.H{"error": "Failed to parse orderId"})
81 | return
82 | }
83 |
84 | order, ok := api.Orders[orderId]
85 |
86 | if !ok {
87 | c.JSON(http.StatusNotFound, gin.H{"error": "orderId not found"})
88 | return
89 | }
90 |
91 | c.JSON(http.StatusOK, order)
92 | }
93 |
94 | // Post /v2/store/order
95 | // Place an order for a pet
96 | func (api *StoreAPI) PlaceOrder(c *gin.Context) {
97 | api.InitializeOrdersMap()
98 |
99 | var requestOrder Order
100 | if err := c.ShouldBindJSON(&requestOrder); err != nil {
101 | fmt.Println("PlaceOrder: failed to parse order", err)
102 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
103 | return
104 | }
105 |
106 | api.Orders[requestOrder.Id] = requestOrder
107 |
108 | var response Order
109 | response.ShipDate = time.Date(1900, 1, 30, 0, 0, 01, 0, time.Now().Location())
110 |
111 | c.JSON(http.StatusOK, response)
112 | }
113 |
114 |
--------------------------------------------------------------------------------
/tests/auto/linking_several_clients/application/TestConfiguration1.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | #include "client1testapi.h"
5 | #include "client2testapi.h"
6 |
7 | #include
8 | #include
9 |
10 | using namespace Qt::StringLiterals;
11 | using namespace QtCommonOpenAPI;
12 |
13 | namespace QtOpenAPI {
14 |
15 | /**
16 | *
17 | * The following test checks if several separate client libraries
18 | * can use common resources by linking them to libraries and
19 | * the resulting executable file.
20 | *
21 | * The test uses an executable binary and 3 libraries:
22 | * cpp-qt-test-config1-app, TestClient1, TestClient2, TestCommon.
23 | *
24 | * NOTE:
25 | * The test does not require a server side, as we are not testing
26 | * the data transfer here.
27 | * Another reason is servers don't support several yaml files
28 | * generation. It means we will have to manually create a lot of code
29 | * on the server side.
30 | * But since the data transferring is not a point of the current
31 | * test, it would be preferable to skip such steps for now.
32 | *
33 | * The first test client is generated with following oiptions:
34 | * --additional-properties=...,commonLibrary=Use-Common-Lib,commonLibraryName=TestCommon --package-name=TestClient1
35 | * It means the Qt6 OpenAPI generator generates 2 separate libraries:
36 | * - TestClient1 library
37 | * - TestCommon library
38 | *
39 | * The second test client is generated with following oiptions:
40 | * --additional-properties=...,commonLibrary=Skip-Common-Files --package-name=TestClient2
41 | *
42 | * It means the Qt6 OpenAPI generator generates the following library:
43 | * - TestClient2 library
44 | *
45 | * For receiving access to common resources, like QOAIBaseApi
46 | * or QOAIHttpRequestInput classes, the TestClient2 library
47 | * links to the TestCommon library.
48 | *
49 | * See in the CMakeLists.txt:
50 | * target_link_libraries(TestClient2
51 | * PRIVATE
52 | * TestCommon
53 | * )
54 | *
55 | * Such generation configuration protects us from a possible
56 | * "multiple defined symbols" problem.
57 | *
58 | * The resulting test application links all 3 libraries,
59 | * creates objects of those libraries, and calls APIs of
60 | * TestClient2 and TestClient1.
61 | *
62 | **/
63 | class TestConfiguration1 : public QObject {
64 | Q_OBJECT
65 |
66 | private Q_SLOTS:
67 | void testLibraries();
68 | };
69 |
70 | void TestConfiguration1::testLibraries()
71 | {
72 | Client1TestApi api1;
73 | Client2TestApi api2;
74 | QOAIHttpFileElement object("NoName.txt");
75 | bool done = true;
76 |
77 | api1.simpleExplodeString("Test String"_L1, this,
78 | [&](const QRestReply &reply, const QString &) {
79 | done = reply.isSuccess();
80 | });
81 |
82 | QTRY_COMPARE_EQ(done, false);
83 |
84 | done = true;
85 | api2.simpleExplodeInt(12345, this,
86 | [&](const QRestReply &reply, const QString &) {
87 | done = reply.isSuccess();
88 | });
89 | QTRY_COMPARE_EQ(done, false);
90 | }
91 |
92 | } // QtOpenAPI
93 |
94 | QTEST_MAIN(QtOpenAPI::TestConfiguration1)
95 | #include "TestConfiguration1.moc"
96 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/servervariable.h.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | /**
3 | * Representing a Server Variable for server URL template substitution.
4 | */
5 | #ifndef {{prefix}}_SERVERVARIABLE_H
6 | #define {{prefix}}_SERVERVARIABLE_H
7 |
8 | #include "{{packageNameLowerCase}}commonexports.h"
9 |
10 | #include
11 | #include
12 |
13 | {{#cppCommonNamespaceDeclarations}}
14 | namespace {{this}} {
15 | {{/cppCommonNamespaceDeclarations}}
16 |
17 | class {{prefix}}ServerVariablePrivate;
18 | class {{prefix}}ServerVariable {
19 | public:
20 | enum class ServerError
21 | {
22 | NoError = 0, // Success
23 | ServerVariableNotFound = -1,
24 | EnumValueNotFound = -2, // The value is not defined in m_enumValues
25 | OperationNotFound = -3,
26 | ServerIndexNotFound = -4,
27 | };
28 |
29 | /**
30 | * @param description A description for the server variable.
31 | * @param defaultValue The default value to use for substitution.
32 | * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
33 | */
34 | {{packageNameUpperCase}}_COMMON_EXPORT
35 | {{prefix}}ServerVariable(const QString &description, const QString &defaultValue, const QSet &enumValues);
36 |
37 | {{packageNameUpperCase}}_COMMON_EXPORT {{prefix}}ServerVariable();
38 | {{packageNameUpperCase}}_COMMON_EXPORT ~{{prefix}}ServerVariable();
39 |
40 | {{packageNameUpperCase}}_COMMON_EXPORT
41 | {{prefix}}ServerVariable(const {{prefix}}ServerVariable &other);
42 | {{packageNameUpperCase}}_COMMON_EXPORT
43 | {{prefix}}ServerVariable &operator=(const {{prefix}}ServerVariable &other);
44 |
45 | {{packageNameUpperCase}}_COMMON_EXPORT
46 | {{prefix}}ServerVariable({{prefix}}ServerVariable &&other) noexcept;
47 | {{packageNameUpperCase}}_COMMON_EXPORT
48 | {{prefix}}ServerVariable &operator=({{prefix}}ServerVariable &&other) noexcept;
49 |
50 | {{packageNameUpperCase}}_COMMON_EXPORT void swap({{prefix}}ServerVariable &other) noexcept;
51 |
52 | {{packageNameUpperCase}}_COMMON_EXPORT ServerError setValue(const QString& value);
53 |
54 | {{packageNameUpperCase}}_COMMON_EXPORT QString value() const;
55 | {{packageNameUpperCase}}_COMMON_EXPORT QSet enumValues() const;
56 | {{packageNameUpperCase}}_COMMON_EXPORT QString description() const;
57 |
58 | private:
59 | {{packageNameUpperCase}}_COMMON_EXPORT friend bool
60 | comparesEqual(const {{prefix}}ServerVariable &lhs, const {{prefix}}ServerVariable &rhs) noexcept;
61 |
62 | friend bool
63 | operator==(const {{prefix}}ServerVariable &lhs, const {{prefix}}ServerVariable &rhs) noexcept
64 | { return comparesEqual(lhs, rhs); }
65 | friend bool
66 | operator!=(const {{prefix}}ServerVariable &lhs, const {{prefix}}ServerVariable &rhs) noexcept
67 | { return !comparesEqual(lhs, rhs); }
68 |
69 | friend size_t qHash(const {{prefix}}ServerVariable &value) = delete;
70 | friend size_t qHash(const {{prefix}}ServerVariable &value, size_t seed) = delete;
71 |
72 | QExplicitlySharedDataPointer<{{prefix}}ServerVariablePrivate> d_ptr;
73 | };
74 |
75 | {{#cppCommonNamespaceDeclarations}}
76 | } // namespace {{this}}
77 | {{/cppCommonNamespaceDeclarations}}
78 |
79 | #endif // {{prefix}}_SERVERVARIABLE_H
80 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/client/openapi2.0/openapi2.0.yaml:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | swagger: '2.0'
5 | info:
6 | description: "This spec is mainly for testing Openapi 2.0"
7 | version: 1.0.0
8 | title: OpenAPI 2.0 test
9 | license:
10 | name: Apache-2.0
11 | url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
12 | host: 127.0.0.1:10300
13 | basePath: /v2
14 | schemes:
15 | - http
16 | paths:
17 | /fake/test-query-parameters:
18 | post:
19 | tags:
20 | - fake
21 | description: 'To test the collection format in query parameters'
22 | operationId: testQueryParameterCollectionFormat
23 | parameters:
24 | - name: pipe
25 | in: query
26 | required: true
27 | type: array
28 | items:
29 | type: string
30 | collectionFormat: pipes
31 | - name: ioutil
32 | in: query
33 | required: true
34 | type: array
35 | items:
36 | type: string
37 | collectionFormat: tsv
38 | - name: http
39 | in: query
40 | required: true
41 | type: array
42 | items:
43 | type: string
44 | collectionFormat: ssv
45 | - name: url
46 | in: query
47 | required: true
48 | type: array
49 | items:
50 | type: string
51 | collectionFormat: csv
52 | - name: multiContext
53 | in: query
54 | required: true
55 | type: array
56 | items:
57 | type: string
58 | collectionFormat: multi
59 | consumes:
60 | - application/json
61 | responses:
62 | '200':
63 | description: Success
64 | schema:
65 | type: string
66 | '400':
67 | description: Not success
68 | /fake/test-path-parameters/{pipeId}/{ioutilId}/{httpId}/{urlId}/{multiContextId}:
69 | post:
70 | tags:
71 | - fake
72 | description: 'To test the collection format in path parameters'
73 | operationId: testPathParameterCollectionFormat
74 | parameters:
75 | - name: pipeId
76 | in: path
77 | required: true
78 | type: array
79 | items:
80 | type: string
81 | collectionFormat: pipes
82 | - name: ioutilId
83 | in: path
84 | required: true
85 | type: array
86 | items:
87 | type: string
88 | collectionFormat: tsv
89 | - name: httpId
90 | in: path
91 | required: true
92 | type: array
93 | items:
94 | type: string
95 | collectionFormat: ssv
96 | - name: urlId
97 | in: path
98 | required: true
99 | type: array
100 | items:
101 | type: string
102 | collectionFormat: csv
103 | - name: multiContextId
104 | in: path
105 | required: true
106 | type: array
107 | items:
108 | type: string
109 | collectionFormat: multi
110 | consumes:
111 | - application/json
112 | responses:
113 | '200':
114 | description: Success
115 | schema:
116 | type: string
117 | '400':
118 | description: Not success
119 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/model-header.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | {{#models}}{{#model}}/*
3 | * {{classname}}.h
4 | *
5 | * {{description}}
6 | */
7 |
8 | #ifndef {{classname}}_H
9 | #define {{classname}}_H
10 |
11 | #include "{{packageNameLowerCase}}exports.h"
12 | {{#isEnum}}
13 | #include "{{prefixLowerCase}}enum.h"
14 | {{/isEnum}}
15 | {{^isEnum}}
16 | #include "{{prefixLowerCase}}object.h"
17 | {{/isEnum}}
18 | {{#enableQmlCode}}
19 | #include
20 | {{/enableQmlCode}}
21 |
22 | {{/model}}{{/models}}{{#imports}}{{{import}}}
23 | {{/imports}}
24 |
25 | {{#models}}
26 | {{#model}}
27 | {{#cppNamespaceDeclarations}}
28 | namespace {{this}} {
29 | {{/cppNamespaceDeclarations}}
30 | {{#vendorExtensions.x-has-forward-declarations}}
31 | {{#vendorExtensions.x-forward-declarations}}{{.}}
32 | {{/vendorExtensions.x-forward-declarations}}{{/vendorExtensions.x-has-forward-declarations}}
33 | class {{packageNameUpperCase}}_EXPORT {{classname}} : public {{cppCommonNamespace}}::{{prefix}}{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Enum{{/isEnum}} {
34 | Q_GADGET{{#enableQmlCode}}
35 | QML_VALUE_TYPE(data{{classname}}){{/enableQmlCode}}
36 | {{^isEnum}}{{#vars}}
37 | Q_PROPERTY({{{dataType}}} {{getter}} READ {{getter}} WRITE {{setter}}){{/vars}}{{/isEnum}}{{#isEnum}}{{/isEnum}}
38 | public:
39 | {{classname}}();
40 | {{classname}}(const QString &json);
41 | ~{{classname}}() override;
42 |
43 | QString asJson() const override;
44 | QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const override;
45 | void fromJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}(const QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} &json) override;
46 | void fromJson(const QString &jsonString) override;
47 | {{^isEnum}}{{#vars}}
48 | {{#deprecated}}Q_DECL_DEPRECATED {{/deprecated}}{{{dataType}}} {{getter}}() const;
49 | {{#deprecated}}Q_DECL_DEPRECATED {{/deprecated}}void {{setter}}(const {{{dataType}}} &{{name}});
50 | {{#deprecated}}Q_DECL_DEPRECATED {{/deprecated}}bool is{{#camelcase}}{{name}}{{/camelcase}}Set() const;
51 | {{#deprecated}}Q_DECL_DEPRECATED {{/deprecated}}bool is{{#camelcase}}{{name}}{{/camelcase}}Valid() const;
52 | {{/vars}}{{/isEnum}}{{#isEnum}}
53 | {{#allowableValues}}
54 | enum class e{{classname}} {{#enumVars}}{{#-first}}{{^isString}}: int {{/isString}}{{/-first}}{{/enumVars}}{
55 | INVALID_VALUE_OPENAPI_GENERATED = 0,
56 | {{#enumVars}}
57 | {{#enumDescription}}
58 | /**
59 | * {{.}}
60 | */
61 | {{/enumDescription}}
62 | {{{name}}}{{^-last}},{{/-last}}
63 | {{/enumVars}}
64 | };{{/allowableValues}}
65 | {{classname}}::e{{classname}} getValue() const;
66 | void setValue({{classname}}::e{{classname}} value);{{/isEnum}}
67 | bool isSet() const override;
68 | bool isValid() const override;
69 |
70 | private:
71 | void initializeModel();
72 | {{^isEnum}}{{#vars}}
73 | {{{dataType}}} m_{{name}};
74 | bool m_{{name}}IsSet;
75 | bool m_{{name}}IsValid;
76 | {{/vars}}{{/isEnum}}{{#isEnum}}
77 | e{{classname}} m_value;
78 | bool m_valueIsSet;
79 | bool m_valueIsValid;
80 | {{/isEnum}}};
81 |
82 | {{#cppNamespaceDeclarations}}
83 | } // namespace {{this}}
84 | {{/cppNamespaceDeclarations}}
85 |
86 | Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{classname}})
87 |
88 | #endif // {{classname}}_H
89 | {{/model}}
90 | {{/models}}
91 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/api-header.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | #ifndef {{classname}}_H
3 | #define {{classname}}_H
4 |
5 | #include "{{prefixLowerCase}}baseapi.h"
6 | #include "{{packageNameLowerCase}}exports.h"
7 | #include {{#enableQmlCode}}
8 | #include {{/enableQmlCode}}
9 |
10 | {{#imports}}{{{import}}}
11 | {{/imports}}
12 |
13 | {{#cppNamespaceDeclarations}}
14 | namespace {{this}} {
15 | {{/cppNamespaceDeclarations}}
16 |
17 | {{#cppCommonNamespaceDeclarations}}
18 | using namespace {{this}};
19 | {{/cppCommonNamespaceDeclarations}}
20 |
21 | class {{packageNameUpperCase}}_EXPORT {{classname}} : public {{prefix}}BaseApi {
22 | Q_OBJECT{{#enableQmlCode}}
23 | QML_ELEMENT{{/enableQmlCode}}
24 | public:
25 | {{classname}}() : {{classname}}(nullptr) {}
26 | explicit {{classname}}(QObject *parent);
27 | ~{{classname}}() override;
28 |
29 | void initializeServerConfigs();
30 | {{#operations}}{{#operation}}
31 | /**
32 | * \internal
33 | * The auto-generated API:
34 | * void {{nickname}}({{#hasParams}}{{#allParams}}const {{#required}}{{{dataType}}} &{{/required}}{{^required}}::{{cppCommonNamespace}}::OptionalParam<{{{dataType}}}> &{{/required}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/hasParams}});
35 | * void {{nickname}}({{#hasParams}}{{#allParams}}const {{#required}}{{{dataType}}} &{{/required}}{{^required}}::{{cppCommonNamespace}}::OptionalParam<{{{dataType}}}> &{{/required}}{{paramName}}, {{/allParams}}{{/hasParams}}QObject *object, [&](const QRestReply &reply{{#returnType}}, const {{{.}}} &summary{{/returnType}}){});
36 | * \endinternal
37 | */
38 | {{#hasParams}}{{^returnType}}{{prefix}}_ADD_OPERATION_WITH_NO_RESPONSE_IMPL{{/returnType}}{{#returnType}}{{prefix}}_ADD_OPERATION_IMPL{{/returnType}}{{/hasParams}}{{^hasParams}}{{^returnType}}{{prefix}}_ADD_EMPTY_OPERATION_IMPL{{/returnType}}{{#returnType}}{{prefix}}_ADD_NO_PARAMS_OPERATION_WITH_RESPONSE_IMPL{{/returnType}}{{/hasParams}}({{nickname}}{{#hasParams}}, ({{#allParams}}const {{#required}}{{{dataType}}}{{/required}}{{^required}}::{{cppCommonNamespace}}::OptionalParam<{{{dataType}}}>{{/required}} &{{paramName}}{{^required}} = ::{{cppCommonNamespace}}::OptionalParam<{{{dataType}}}>(){{/required}}{{^-last}}, {{/-last}}{{/allParams}}), ({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{/hasParams}}{{#returnType}}, (const {{{.}}} &){{/returnType}}{{#isDeprecated}}, Q_DECL_DEPRECATED{{/isDeprecated}}{{^isDeprecated}}, /* non-deprecated */{{/isDeprecated}})
39 | {{/operation}}{{/operations}}
40 | Q_SIGNALS:{{#operations}}{{#operation}}
41 | /** Signal is emitted, if {{nickname}}() request completed successfully.{{#returnType}} The \a summary contains a serialized server response.{{/returnType}} */
42 | void {{nickname}}Finished({{#returnType}}{{^isPrimitiveType}}const {{/isPrimitiveType}}{{{.}}} {{^isPrimitiveType}}&{{/isPrimitiveType}}summary{{/returnType}});{{#addDownloadProgress}}
43 | void {{nickname}}Progress(qint64 bytesReceived, qint64 bytesTotal);{{/addDownloadProgress}}
44 | /** Signal is emitted, if {{nickname}}() request completed with an error. \a errorType and \a errorStr contain an information about the error. */
45 | void {{nickname}}ErrorOccurred(QNetworkReply::NetworkError errorType, const QString &errorStr);{{/operation}}{{/operations}}
46 |
47 | protected:
48 | QString m_testOperationPath;
49 | QByteArray m_requestContent;
50 | };
51 |
52 | {{#cppNamespaceDeclarations}}
53 | } // namespace {{this}}
54 | {{/cppNamespaceDeclarations}}
55 | #endif
56 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/ApiBridges.h:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | #ifndef APIBRIDGES_H
5 | #define APIBRIDGES_H
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | #include "color.h"
12 | #include "colorsapi.h"
13 | #include "credentials.h"
14 | #include "usersapi.h"
15 |
16 | struct ForeignColorsAPI
17 | {
18 | Q_GADGET
19 | QML_FOREIGN(QtOpenAPI::ColorsApi)
20 | QML_SINGLETON
21 | QML_NAMED_ELEMENT(ColorsApi)
22 |
23 | public:
24 | inline static QtOpenAPI::ColorsApi *s_singletonInstance = nullptr;
25 |
26 | static QtOpenAPI::ColorsApi *create(QQmlEngine *, QJSEngine *engine)
27 | {
28 | // The instance has to exist before it is used. We cannot replace it.
29 | Q_ASSERT(s_singletonInstance);
30 |
31 | // The engine has to have the same thread affinity as the singleton.
32 | Q_ASSERT(engine->thread() == s_singletonInstance->thread());
33 |
34 | // There can only be one engine accessing the singleton.
35 | if (s_engine)
36 | Q_ASSERT(engine == s_engine);
37 | else
38 | s_engine = engine;
39 |
40 | // Explicitly specify C++ ownership so that the engine doesn't delete
41 | // the instance.
42 | QJSEngine::setObjectOwnership(s_singletonInstance,
43 | QJSEngine::CppOwnership);
44 | return s_singletonInstance;
45 | }
46 |
47 | private:
48 | inline static QJSEngine *s_engine = nullptr;
49 | };
50 |
51 | struct ForeignUsersAPI
52 | {
53 | Q_GADGET
54 | QML_FOREIGN(QtOpenAPI::UsersApi)
55 | QML_SINGLETON
56 | QML_NAMED_ELEMENT(UsersApi)
57 |
58 | public:
59 | inline static QtOpenAPI::UsersApi *s_singletonInstance = nullptr;
60 |
61 | static QtOpenAPI::UsersApi *create(QQmlEngine *, QJSEngine *engine)
62 | {
63 | // The instance has to exist before it is used. We cannot replace it.
64 | Q_ASSERT(s_singletonInstance);
65 |
66 | // The engine has to have the same thread affinity as the singleton.
67 | Q_ASSERT(engine->thread() == s_singletonInstance->thread());
68 |
69 | // There can only be one engine accessing the singleton.
70 | if (s_engine)
71 | Q_ASSERT(engine == s_engine);
72 | else
73 | s_engine = engine;
74 |
75 | // Explicitly specify C++ ownership so that the engine doesn't delete
76 | // the instance.
77 | QJSEngine::setObjectOwnership(s_singletonInstance,
78 | QJSEngine::CppOwnership);
79 | return s_singletonInstance;
80 | }
81 |
82 | private:
83 | inline static QJSEngine *s_engine = nullptr;
84 | };
85 |
86 | class Credentials: public QObject
87 | {
88 | Q_OBJECT
89 | QML_ELEMENT
90 | QML_SINGLETON
91 | public:
92 | Q_INVOKABLE QtOpenAPI::Credentials create(const QString &email, const QString &password)
93 | {
94 | QtOpenAPI::Credentials credentials;
95 | credentials.setEmail(email);
96 | credentials.setPassword(password);
97 | return credentials;
98 | }
99 | };
100 |
101 | class Color: public QObject
102 | {
103 | Q_OBJECT
104 | QML_ELEMENT
105 | QML_SINGLETON
106 | public:
107 | Q_INVOKABLE QtOpenAPI::Color create(const QJsonObject &json)
108 | {
109 | QtOpenAPI::Color color;
110 | color.fromJsonObject(json);
111 | return color;
112 | }
113 | };
114 |
115 | #endif // APIBRIDGES_H
116 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/serverconfiguration.h.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | /**
3 | * Representing a Server configuration.
4 | */
5 | #ifndef {{prefix}}_SERVERVCONFIGURATION_H
6 | #define {{prefix}}_SERVERVCONFIGURATION_H
7 |
8 | #include "{{packageNameLowerCase}}commonexports.h"
9 | #include "{{prefixLowerCase}}servervariable.h"
10 |
11 | #include
12 | #include
13 |
14 | QT_BEGIN_NAMESPACE
15 | class QUrl;
16 | QT_END_NAMESPACE
17 |
18 | {{#cppCommonNamespaceDeclarations}}
19 | namespace {{this}} {
20 | {{/cppCommonNamespaceDeclarations}}
21 |
22 | class {{prefix}}ServerConfigurationPrivate;
23 |
24 | class {{prefix}}ServerConfiguration {
25 | public:
26 | /**
27 | * @param urlTemplate A URL template to the target host.
28 | * @param description A description of the host designated by the URL.
29 | * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
30 | */
31 | {{packageNameUpperCase}}_COMMON_EXPORT
32 | {{prefix}}ServerConfiguration(const QString &urlTemplate, const QString &description,
33 | const QMap &variables);
34 | {{packageNameUpperCase}}_COMMON_EXPORT {{prefix}}ServerConfiguration();
35 | {{packageNameUpperCase}}_COMMON_EXPORT ~{{prefix}}ServerConfiguration();
36 |
37 | {{packageNameUpperCase}}_COMMON_EXPORT
38 | {{prefix}}ServerConfiguration(const {{prefix}}ServerConfiguration &other);
39 | {{packageNameUpperCase}}_COMMON_EXPORT
40 | {{prefix}}ServerConfiguration &operator=(const {{prefix}}ServerConfiguration &other);
41 |
42 | {{packageNameUpperCase}}_COMMON_EXPORT
43 | {{prefix}}ServerConfiguration({{prefix}}ServerConfiguration &&other) noexcept;
44 | {{packageNameUpperCase}}_COMMON_EXPORT
45 | {{prefix}}ServerConfiguration &operator=({{prefix}}ServerConfiguration &&other) noexcept;
46 |
47 | {{packageNameUpperCase}}_COMMON_EXPORT void swap({{prefix}}ServerConfiguration &other) noexcept;
48 |
49 | /**
50 | * Original URL template
51 | *
52 | * @return Original URL template.
53 | */
54 | {{packageNameUpperCase}}_COMMON_EXPORT QString urlTemplate() const;
55 |
56 | /**
57 | * Format URL template using server's variables.
58 | *
59 | * @return URL, where the server variables are substituted with actual values.
60 | */
61 | {{packageNameUpperCase}}_COMMON_EXPORT QUrl url() const;
62 |
63 | {{packageNameUpperCase}}_COMMON_EXPORT {{prefix}}ServerVariable::ServerError
64 | setVariableValue(const QString &variable, const QString &value);
65 |
66 | private:
67 | {{packageNameUpperCase}}_COMMON_EXPORT friend bool
68 | comparesEqual(const {{prefix}}ServerConfiguration &lhs, const {{prefix}}ServerConfiguration &rhs) noexcept;
69 |
70 | friend bool
71 | operator==(const {{prefix}}ServerConfiguration &lhs, const {{prefix}}ServerConfiguration &rhs) noexcept
72 | { return comparesEqual(lhs, rhs); }
73 | friend bool
74 | operator!=(const {{prefix}}ServerConfiguration &lhs, const {{prefix}}ServerConfiguration &rhs) noexcept
75 | { return !comparesEqual(lhs, rhs); }
76 |
77 | friend size_t qHash(const {{prefix}}ServerConfiguration &value) = delete;
78 | friend size_t qHash(const {{prefix}}ServerConfiguration &value, size_t seed) = delete;
79 |
80 | QExplicitlySharedDataPointer<{{prefix}}ServerConfigurationPrivate> d_ptr;
81 | };
82 |
83 | {{#cppCommonNamespaceDeclarations}}
84 | } // namespace {{this}}
85 | {{/cppCommonNamespaceDeclarations}}
86 |
87 | #endif // {{prefix}}_SERVERVCONFIGURATION_H
88 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/httpfileelement.h.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | #ifndef {{prefix}}_HTTP_FILE_ELEMENT_H
3 | #define {{prefix}}_HTTP_FILE_ELEMENT_H
4 |
5 | #include "{{packageNameLowerCase}}commonexports.h"
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | QT_BEGIN_NAMESPACE
12 | class QJsonValue;
13 | QT_END_NAMESPACE
14 |
15 | {{#cppCommonNamespaceDeclarations}}
16 | namespace {{this}} {
17 | {{/cppCommonNamespaceDeclarations}}
18 |
19 | class {{prefix}}HttpFileElementPrivate;
20 |
21 | class {{prefix}}HttpFileElement
22 | {
23 | public:
24 | {{packageNameUpperCase}}_COMMON_EXPORT
25 | {{prefix}}HttpFileElement();
26 | {{packageNameUpperCase}}_COMMON_EXPORT
27 | explicit {{prefix}}HttpFileElement(const QString &localFilename);
28 | {{packageNameUpperCase}}_COMMON_EXPORT
29 | {{prefix}}HttpFileElement(const {{prefix}}HttpFileElement &other);
30 | {{packageNameUpperCase}}_COMMON_EXPORT
31 | {{prefix}}HttpFileElement({{prefix}}HttpFileElement &&other) noexcept;
32 | {{packageNameUpperCase}}_COMMON_EXPORT
33 | {{prefix}}HttpFileElement &operator=(const {{prefix}}HttpFileElement &other);
34 | {{packageNameUpperCase}}_COMMON_EXPORT
35 | {{prefix}}HttpFileElement &operator=({{prefix}}HttpFileElement &&other) noexcept;
36 | {{packageNameUpperCase}}_COMMON_EXPORT
37 | ~{{prefix}}HttpFileElement();
38 |
39 | {{packageNameUpperCase}}_COMMON_EXPORT
40 | void swap({{prefix}}HttpFileElement &other) noexcept;
41 |
42 | {{packageNameUpperCase}}_COMMON_EXPORT void setMimeType(const QString &mime);
43 | {{packageNameUpperCase}}_COMMON_EXPORT void setVariableName(const QString &name);
44 | {{packageNameUpperCase}}_COMMON_EXPORT void setTemporary(bool temp);
45 |
46 | {{packageNameUpperCase}}_COMMON_EXPORT QString mimeType() const;
47 | {{packageNameUpperCase}}_COMMON_EXPORT QString filename() const;
48 | {{packageNameUpperCase}}_COMMON_EXPORT QString variableName() const;
49 | {{packageNameUpperCase}}_COMMON_EXPORT bool isTemporary() const;
50 |
51 | {{packageNameUpperCase}}_COMMON_EXPORT QString requestFilename() const;
52 | {{packageNameUpperCase}}_COMMON_EXPORT bool isSet() const;
53 | {{packageNameUpperCase}}_COMMON_EXPORT bool fromStringValue(const QString &instr);
54 | {{packageNameUpperCase}}_COMMON_EXPORT bool fromJsonValue(const QJsonValue &jval);
55 | {{packageNameUpperCase}}_COMMON_EXPORT bool saveToLocalFile(const QByteArray &bytes);
56 | {{packageNameUpperCase}}_COMMON_EXPORT QString asJson() const;
57 | {{packageNameUpperCase}}_COMMON_EXPORT QJsonValue asJsonValue() const;
58 | {{packageNameUpperCase}}_COMMON_EXPORT QByteArray loadFromLocalFile() const;
59 |
60 | private:
61 | {{packageNameUpperCase}}_COMMON_EXPORT friend bool
62 | comparesEqual(const {{prefix}}HttpFileElement &lhs, const {{prefix}}HttpFileElement &rhs) noexcept;
63 |
64 | friend bool
65 | operator==(const {{prefix}}HttpFileElement &lhs, const {{prefix}}HttpFileElement &rhs) noexcept
66 | { return comparesEqual(lhs, rhs); }
67 | friend bool
68 | operator!=(const {{prefix}}HttpFileElement &lhs, const {{prefix}}HttpFileElement &rhs) noexcept
69 | { return !comparesEqual(lhs, rhs); }
70 |
71 | friend size_t qHash(const {{prefix}}HttpFileElement &value) = delete;
72 | friend size_t qHash(const {{prefix}}HttpFileElement &value, size_t seed) = delete;
73 |
74 | QExplicitlySharedDataPointer<{{prefix}}HttpFileElementPrivate> d;
75 | };
76 |
77 | {{#cppCommonNamespaceDeclarations}}
78 | } // namespace {{this}}
79 | {{/cppCommonNamespaceDeclarations}}
80 |
81 | Q_DECLARE_METATYPE({{#cppCommonNamespaceDeclarations}}{{this}}::{{/cppCommonNamespaceDeclarations}}{{prefix}}HttpFileElement)
82 |
83 | #endif // {{prefix}}_HTTP_FILE_ELEMENT_H
84 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/serverconfiguration.cpp.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 |
3 | #include "{{prefixLowerCase}}serverconfiguration.h"
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | {{#cppCommonNamespaceDeclarations}}
11 | namespace {{this}} {
12 | {{/cppCommonNamespaceDeclarations}}
13 |
14 | class {{prefix}}ServerConfigurationPrivate : public QSharedData
15 | {
16 | public:
17 | QString m_urlTemplate;
18 | QString m_description;
19 | QMap m_variables;
20 | };
21 |
22 | {{prefix}}ServerConfiguration::{{prefix}}ServerConfiguration()
23 | : d_ptr(new {{prefix}}ServerConfigurationPrivate)
24 | {}
25 |
26 | {{prefix}}ServerConfiguration::{{prefix}}ServerConfiguration(const QString &urlTemplate, const QString &description,
27 | const QMap &variables)
28 | : {{prefix}}ServerConfiguration()
29 | {
30 | d_ptr->m_urlTemplate = urlTemplate;
31 | d_ptr->m_description = description;
32 | d_ptr->m_variables = variables;
33 | }
34 |
35 | {{prefix}}ServerConfiguration::~{{prefix}}ServerConfiguration()
36 | = default;
37 |
38 | {{prefix}}ServerConfiguration::{{prefix}}ServerConfiguration(const {{prefix}}ServerConfiguration &other)
39 | = default;
40 |
41 | {{prefix}}ServerConfiguration &{{prefix}}ServerConfiguration::operator=(const {{prefix}}ServerConfiguration &other)
42 | {
43 | if (this != &other)
44 | d_ptr = other.d_ptr;
45 | return *this;
46 | }
47 |
48 | {{prefix}}ServerConfiguration::{{prefix}}ServerConfiguration({{prefix}}ServerConfiguration &&other) noexcept
49 | = default;
50 |
51 | {{prefix}}ServerConfiguration &{{prefix}}ServerConfiguration::operator=({{prefix}}ServerConfiguration &&other) noexcept
52 | {
53 | swap(other);
54 | return *this;
55 | }
56 |
57 | void {{prefix}}ServerConfiguration::swap({{prefix}}ServerConfiguration &other) noexcept
58 | {
59 | d_ptr.swap(other.d_ptr);
60 | }
61 |
62 | QString {{prefix}}ServerConfiguration::urlTemplate() const
63 | {
64 | return d_ptr->m_urlTemplate;
65 | }
66 |
67 | QUrl {{prefix}}ServerConfiguration::url() const
68 | {
69 | if (d_ptr->m_variables.empty())
70 | return QUrl(d_ptr->m_urlTemplate); // nothing to substitute
71 |
72 | QString url = d_ptr->m_urlTemplate;
73 | // go through variables and replace placeholders
74 | for (const auto &[name, serverVariable] : d_ptr->m_variables.asKeyValueRange()) {
75 | const QString value = serverVariable.value();
76 | const auto enumValues = serverVariable.enumValues();
77 | if (!enumValues.empty() && !enumValues.contains(value)) {
78 | qWarning("The variable %s in the server URL has an invalid value %s.",
79 | qPrintable(name), qPrintable(value));
80 | }
81 | const QString varTemplate = u'{' + name + u'}';
82 | url = url.replace(varTemplate, value);
83 | }
84 | return QUrl(url);
85 | }
86 |
87 | {{prefix}}ServerVariable::ServerError
88 | {{prefix}}ServerConfiguration::setVariableValue(const QString &variable, const QString &value)
89 | {
90 | d_ptr.detach();
91 | auto it = d_ptr->m_variables.find(variable);
92 | if (it == d_ptr->m_variables.end())
93 | return {{prefix}}ServerVariable::ServerError::ServerVariableNotFound;
94 | return it->setValue(value);
95 | }
96 |
97 | bool
98 | comparesEqual(const {{prefix}}ServerConfiguration &lhs, const {{prefix}}ServerConfiguration &rhs) noexcept
99 | {
100 | return lhs.d_ptr->m_urlTemplate == rhs.d_ptr->m_urlTemplate
101 | && lhs.d_ptr->m_description == rhs.d_ptr->m_description
102 | && lhs.d_ptr->m_variables == rhs.d_ptr->m_variables;
103 | }
104 |
105 | {{#cppCommonNamespaceDeclarations}}
106 | } // namespace {{this}}
107 | {{/cppCommonNamespaceDeclarations}}
108 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/CMakeLists.txt.mustache:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.16)
2 |
3 | project({{{packageName}}} VERSION 0.1 LANGUAGES CXX)
4 |
5 | set(CMAKE_CXX_STANDARD 17)
6 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 |
8 | find_package(Qt6 REQUIRED COMPONENTS Core Network{{#enableQmlCode}} Qml{{/enableQmlCode}})
9 | qt_standard_project_setup()
10 |
11 | include(GNUInstallDirs)
12 | include(CMakePackageConfigHelpers)
13 |
14 | qt_add_library(${PROJECT_NAME}
15 | {{#models}}
16 | {{#model}}
17 | {{#lambda.lowercase}}{{{classname}}}{{/lambda.lowercase}}.h
18 | {{/model}}
19 | {{/models}}
20 | {{#apiInfo}}
21 | {{#apis}}
22 | {{#operations}}
23 | {{#lambda.lowercase}}{{{classname}}}{{/lambda.lowercase}}.h
24 | {{/operations}}
25 | {{/apis}}
26 | {{/apiInfo}}
27 | {{#models}}
28 | {{#model}}
29 | {{#lambda.lowercase}}{{{classname}}}{{/lambda.lowercase}}.cpp
30 | {{/model}}
31 | {{/models}}
32 | {{#apiInfo}}
33 | {{#apis}}
34 | {{#operations}}
35 | {{#lambda.lowercase}}{{{classname}}}{{/lambda.lowercase}}.cpp
36 | {{/operations}}
37 | {{/apis}}
38 | {{/apiInfo}}
39 | ){{#enableQmlCode}}
40 |
41 | qt_policy(SET QTP0001 NEW)
42 | qt_policy(SET QTP0004 NEW)
43 | qt_add_library(${PROJECT_NAME}_module)
44 | qt_add_qml_module(${PROJECT_NAME}_module
45 | URI client
46 | VERSION 1.0
47 | )
48 | target_include_directories(${PROJECT_NAME}_module
49 | PRIVATE
50 | ${CMAKE_CURRENT_BINARY_DIR} # find autogenerated header
51 | )
52 | target_link_libraries(${PROJECT_NAME}_module
53 | PRIVATE
54 | ${PROJECT_NAME}
55 | )
56 | qt_generate_foreign_qml_types(${PROJECT_NAME} ${PROJECT_NAME}_module)
57 | # Make sure the backing library is found on Windows next to the executable
58 | set_target_properties(
59 | ${PROJECT_NAME}_module
60 | PROPERTIES
61 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..
62 | LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..
63 | ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..
64 | ){{/enableQmlCode}}
65 |
66 | target_include_directories(${PROJECT_NAME}
67 | PUBLIC
68 | $
69 | $
70 | {{#enableCommonLibGeneration}}
71 | $
72 | $
73 | {{/enableCommonLibGeneration}}
74 | )
75 |
76 | get_target_property(target_type ${PROJECT_NAME} TYPE)
77 | if(target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
78 | target_compile_definitions(${PROJECT_NAME} PRIVATE {{prefix}}_LIB_SHARED)
79 | elseif(target_type STREQUAL "STATIC_LIBRARY")
80 | target_compile_definitions(${PROJECT_NAME} PRIVATE {{prefix}}_LIB_STATIC)
81 | endif()
82 | target_compile_definitions(${PROJECT_NAME} PRIVATE {{prefix}}_BUILD_LIB)
83 |
84 | target_link_libraries(${PROJECT_NAME}
85 | PUBLIC
86 | Qt::Core
87 | Qt::Network
88 | {{#enableQmlCode}}
89 | Qt::QmlIntegration
90 | {{/enableQmlCode}}
91 | {{#enableCommonLibGeneration}}
92 | PRIVATE
93 | {{{commonLibraryName}}}
94 | {{/enableCommonLibGeneration}}
95 | )
96 |
97 | configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.in
98 | "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
99 | INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
100 | )
101 |
102 | install(
103 | TARGETS ${PROJECT_NAME}
104 | EXPORT ${PROJECT_NAME}Targets
105 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
106 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
107 | RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
108 | INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
109 | )
110 |
111 | install(
112 | FILES ${HEADER_FILES}
113 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
114 | )
115 |
116 | install(
117 | FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
118 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
119 | )
120 |
121 | install(
122 | EXPORT ${PROJECT_NAME}Targets
123 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
124 | )
125 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2025 The Qt Company Ltd.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | if(NOT Java_JAVAC_EXECUTABLE)
5 | message(FATAL_ERROR "Missing Java_JAVAC_EXECUTABLE to be set.")
6 | endif()
7 |
8 | if(NOT OPENAPI_MAVEN_EXECUTABLE)
9 | message(FATAL_ERROR "Missing OPENAPI_MAVEN_EXECUTABLE to be set.")
10 | endif()
11 |
12 | set(QT6_OPENAPI_GENERATOR_CLI
13 | "${CMAKE_CURRENT_BINARY_DIR}/target/cpp-qt6-client-openapi-generator-${QT_OPENAPI_GENERATOR_VERSION}.jar"
14 | )
15 |
16 | set(source_files
17 | src/main/java/org/qtproject/qt/codegen/CppQt6AbstractCodegen.java
18 | src/main/java/org/qtproject/qt/codegen/CppQt6ClientGenerator.java
19 | src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig
20 | src/main/resources/cpp-qt6-client/CMakeConfig.mustache
21 | src/main/resources/cpp-qt6-client/CMakeLists.txt.mustache
22 | src/main/resources/cpp-qt6-client/README.mustache
23 | src/main/resources/cpp-qt6-client/api-body.mustache
24 | src/main/resources/cpp-qt6-client/api-header.mustache
25 | src/main/resources/cpp-qt6-client/common/CMakeConfig.mustache
26 | src/main/resources/cpp-qt6-client/common/CMakeLists.txt.mustache
27 | src/main/resources/cpp-qt6-client/common/httpfileelement.cpp.mustache
28 | src/main/resources/cpp-qt6-client/common/httpfileelement.h.mustache
29 | src/main/resources/cpp-qt6-client/common/httprequest.cpp.mustache
30 | src/main/resources/cpp-qt6-client/common/httprequest.h.mustache
31 | src/main/resources/cpp-qt6-client/common/serverconfiguration.cpp.mustache
32 | src/main/resources/cpp-qt6-client/common/serverconfiguration.h.mustache
33 | src/main/resources/cpp-qt6-client/common/servervariable.cpp.mustache
34 | src/main/resources/cpp-qt6-client/common/servervariable.h.mustache
35 | src/main/resources/cpp-qt6-client/common/api-base-body.mustache
36 | src/main/resources/cpp-qt6-client/common/api-base-header.mustache
37 | src/main/resources/cpp-qt6-client/common/common-exports.mustache
38 | src/main/resources/cpp-qt6-client/common/enum-body.mustache
39 | src/main/resources/cpp-qt6-client/common/enum-header.mustache
40 | src/main/resources/cpp-qt6-client/common/helpers-body.mustache
41 | src/main/resources/cpp-qt6-client/common/helpers-header.mustache
42 | src/main/resources/cpp-qt6-client/common/object-body.mustache
43 | src/main/resources/cpp-qt6-client/common/object-header.mustache
44 | src/main/resources/cpp-qt6-client/doc/Doxyfile.in.mustache
45 | src/main/resources/cpp-qt6-client/exports.mustache
46 | src/main/resources/cpp-qt6-client/licenseInfo.mustache
47 | src/main/resources/cpp-qt6-client/model-body.mustache
48 | src/main/resources/cpp-qt6-client/model-header.mustache
49 | src/test/java/org/qtproject/qt/codegen/CppQt6ClientGeneratorTest.java
50 | pom.xml
51 | logback.xml
52 | )
53 |
54 |
55 | # Define a custom command to run 'mvn package'
56 | add_custom_command(
57 | OUTPUT "${QT6_OPENAPI_GENERATOR_CLI}"
58 | COMMAND "${OPENAPI_MAVEN_EXECUTABLE}"
59 | -f "${CMAKE_CURRENT_SOURCE_DIR}/pom.xml" package
60 | -Dqt.build.dir=${CMAKE_CURRENT_BINARY_DIR}/target
61 | # Copy the built generator to libexec build dir, so that standalone tests work with no-prefix
62 | # builds as well.
63 | COMMAND "${CMAKE_COMMAND}" -E copy_if_different
64 | "${QT6_OPENAPI_GENERATOR_CLI}"
65 | "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}"
66 | DEPENDS
67 | ${source_files}
68 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
69 | COMMENT "Building the Qt6 Client Code Generator with Maven"
70 | VERBATIM
71 | USES_TERMINAL
72 | )
73 |
74 | # Define a custom target that depends on the above output
75 | add_custom_target(
76 | QtOpenAPIGenerator ALL
77 | DEPENDS
78 | "${QT6_OPENAPI_GENERATOR_CLI}"
79 | )
80 |
81 | add_executable(QtOpenAPIGeneratorJar IMPORTED GLOBAL)
82 | add_executable("${QT_CMAKE_EXPORT_NAMESPACE}::QtOpenAPIGeneratorJar" ALIAS QtOpenAPIGeneratorJar)
83 | set_target_properties(QtOpenAPIGeneratorJar PROPERTIES
84 | IMPORTED_LOCATION
85 | "${QT6_OPENAPI_GENERATOR_CLI}"
86 | )
87 |
88 | if(INSTALL_LIBEXECDIR)
89 | set(qt_install_libexec_dir "${INSTALL_LIBEXECDIR}")
90 | elseif(QT6_INSTALL_LIBEXECS)
91 | set(qt_install_libexec_dir "${QT6_INSTALL_LIBEXECS}")
92 | endif()
93 |
94 | qt_install(FILES "${QT6_OPENAPI_GENERATOR_CLI}" DESTINATION "${qt_install_libexec_dir}")
95 |
--------------------------------------------------------------------------------
/tests/auto/responses/server/go/routers.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Responses Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates different response media types.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | import (
13 | "net/http"
14 |
15 | "github.com/gin-gonic/gin"
16 | )
17 |
18 | // Route is the information for every URI.
19 | type Route struct {
20 | // Name is the name of this Route.
21 | Name string
22 | // Method is the string for the HTTP method. ex) GET, POST etc..
23 | Method string
24 | // Pattern is the pattern of the URI.
25 | Pattern string
26 | // HandlerFunc is the handler function of this route.
27 | HandlerFunc gin.HandlerFunc
28 | }
29 |
30 | // NewRouter returns a new router.
31 | func NewRouter(handleFunctions ApiHandleFunctions) *gin.Engine {
32 | return NewRouterWithGinEngine(gin.Default(), handleFunctions)
33 | }
34 |
35 | // NewRouter add routes to existing gin engine.
36 | func NewRouterWithGinEngine(router *gin.Engine, handleFunctions ApiHandleFunctions) *gin.Engine {
37 | for _, route := range getRoutes(handleFunctions) {
38 | if route.HandlerFunc == nil {
39 | route.HandlerFunc = DefaultHandleFunc
40 | }
41 | switch route.Method {
42 | case http.MethodGet:
43 | router.GET(route.Pattern, route.HandlerFunc)
44 | case http.MethodPost:
45 | router.POST(route.Pattern, route.HandlerFunc)
46 | case http.MethodPut:
47 | router.PUT(route.Pattern, route.HandlerFunc)
48 | case http.MethodPatch:
49 | router.PATCH(route.Pattern, route.HandlerFunc)
50 | case http.MethodDelete:
51 | router.DELETE(route.Pattern, route.HandlerFunc)
52 | }
53 | }
54 |
55 | return router
56 | }
57 |
58 | // Default handler for not yet implemented routes
59 | func DefaultHandleFunc(c *gin.Context) {
60 | c.String(http.StatusNotImplemented, "501 not implemented")
61 | }
62 |
63 | type ApiHandleFunctions struct {
64 |
65 | // Routes for the TestAPI part of the API
66 | TestAPI TestAPI
67 | }
68 |
69 | func getRoutes(handleFunctions ApiHandleFunctions) []Route {
70 | return []Route{
71 | {
72 | "ApplicationJsonEncodedObjectResponse",
73 | http.MethodGet,
74 | "/v2/response/application/json/object",
75 | handleFunctions.TestAPI.ApplicationJsonEncodedObjectResponse,
76 | },
77 | {
78 | "ApplicationJsonStringResponse",
79 | http.MethodGet,
80 | "/v2/response/application/json/string",
81 | handleFunctions.TestAPI.ApplicationJsonStringResponse,
82 | },
83 | {
84 | "ApplicationJsonArrayResponse",
85 | http.MethodGet,
86 | "/v2/response/application/json/array",
87 | handleFunctions.TestAPI.ApplicationJsonArrayResponse,
88 | },
89 | {
90 | "ApplicationJsonMapResponse",
91 | http.MethodGet,
92 | "/v2/response/application/json/map",
93 | handleFunctions.TestAPI.ApplicationJsonMapResponse,
94 | },
95 | {
96 | "TextPlainStringResponse",
97 | http.MethodGet,
98 | "/v2/response/text/plain/string",
99 | handleFunctions.TestAPI.TextPlainStringResponse,
100 | },
101 | {
102 | "ApplicationPdfInlineResponse",
103 | http.MethodGet,
104 | "/v2/response/application/pdf/inline/:fileId",
105 | handleFunctions.TestAPI.ApplicationPdfInlineResponse,
106 | },
107 | {
108 | "ApplicationPdfSaveResponse",
109 | http.MethodGet,
110 | "/v2/response/application/pdf/save/:fileId",
111 | handleFunctions.TestAPI.ApplicationPdfSaveResponse,
112 | },
113 | {
114 | "ApplicationEncodedPdfSaveResponse",
115 | http.MethodGet,
116 | "/v2/response/application/pdf/save/encoded/:fileId",
117 | handleFunctions.TestAPI.ApplicationEncodedPdfSaveResponse,
118 | },
119 | {
120 | "InlineImageResponse",
121 | http.MethodGet,
122 | "/v2/response/image/inline/:imageId",
123 | handleFunctions.TestAPI.InlineImageResponse,
124 | },
125 | {
126 | "SaveImageResponse",
127 | http.MethodGet,
128 | "/v2/response/image/save/:imageId",
129 | handleFunctions.TestAPI.SaveImageResponse,
130 | },
131 | {
132 | "ApplicationOctetStreamResponse",
133 | http.MethodGet,
134 | "/v2/response/application/octet-stream/:fileId",
135 | handleFunctions.TestAPI.ApplicationOctetStreamResponse,
136 | },
137 | {
138 | "EmptyResponse",
139 | http.MethodGet,
140 | "/v2/response/empty",
141 | handleFunctions.TestAPI.EmptyResponse,
142 | },
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/tests/auto/openapi2.0/client/openapi2.0/tst_openapi2_0.cpp:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3 |
4 | #include "../client/fakeapi.h"
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | namespace QtOpenAPI {
14 |
15 | static QProcess serverProcess;
16 | void startServerProcess()
17 | {
18 | serverProcess.start(SERVER_PATH);
19 | if (!serverProcess.waitForStarted()) {
20 | qFatal() << "Couldn't start the server: " << serverProcess.errorString();
21 | exit(EXIT_FAILURE);
22 | }
23 | // give the process some time to properly start up the server
24 | QThread::currentThread()->msleep(1000);
25 | }
26 |
27 | QString getStatusString(const QString &summary)
28 | {
29 | QJsonDocument doc = QJsonDocument::fromJson(summary.toUtf8());
30 | if (!doc.isNull() && doc.isObject()) {
31 | QJsonObject obj = doc.object();
32 | return obj.value("status").toString();
33 | }
34 | return QString();
35 | }
36 |
37 | class OperationParametersBackport : public FakeApi {
38 | Q_OBJECT
39 |
40 | private Q_SLOTS:
41 | void initTestCase()
42 | {
43 | if (serverProcess.state() != QProcess::ProcessState::Running)
44 | startServerProcess();
45 | }
46 | void testCollectionFormats();
47 | void cleanupTestCase();
48 | };
49 |
50 | void OperationParametersBackport::testCollectionFormats()
51 | {
52 | QList pipe, ioutil, http, url, context;
53 |
54 | for (auto i = 0; i < 3; i++)
55 | pipe.append("pipe" + QString::number(i));
56 |
57 | for (auto i = 0; i < 3; i++)
58 | ioutil.append("ioutil" + QString::number(i));
59 |
60 | for (auto i = 0; i < 3; i++)
61 | http.append("http" + QString::number(i));
62 |
63 | for (auto i = 0; i < 3; i++)
64 | url.append("url" + QString::number(i));
65 |
66 | for (auto i = 0; i < 3; i++)
67 | context.append("context" + QString::number(i));
68 |
69 | // NOTE: the CORE generator always returns 'collectionFormat=csv' for
70 | // 'collectionFormat: tsv', because there is no direct mapping
71 | // with the latest OpenApi versions.
72 | // The Qt6 client generator uses style=form for 'collectionFormat: tsv' case.
73 | bool done = false;
74 | testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, this, [&](const QRestReply &reply, const QString &summary) {
75 | if ((done = reply.isSuccess())) {
76 | QString expected("/v2/fake/test-query-parameters?pipe=pipe0%7Cpipe1%7Cpipe2&ioutil=ioutil0,ioutil1,ioutil2&http=http0%20http1%20http2&url=url0,url1,url2&multiContext=context0&multiContext=context1&multiContext=context2");
77 | QCOMPARE("/v2" + m_testOperationPath, expected);
78 | QCOMPARE(getStatusString(summary), expected);
79 | } else {
80 | qWarning() << "testQueryParameterCollectionFormat Error: " << reply.errorString();
81 | }
82 | });
83 | QTRY_COMPARE_EQ(done, true);
84 |
85 | // NOTE: the CORE generator always returns 'collectionFormat=csv' for all PATH parameters,
86 | // no matter what we specify in the yaml file.
87 | // So the Qt6 client generator uses style=simple for all of them.
88 | done = false;
89 | testPathParameterCollectionFormat(pipe, ioutil, http, url, context, this, [&](const QRestReply &reply, const QString &summary) {
90 | if ((done = reply.isSuccess())) {
91 | QString expected("/v2/fake/test-path-parameters/pipe0,pipe1,pipe2/ioutil0,ioutil1,ioutil2/http0,http1,http2/url0,url1,url2/context0,context1,context2");
92 | QCOMPARE("/v2" + m_testOperationPath, expected);
93 | QCOMPARE(getStatusString(summary), expected);
94 | } else {
95 | qWarning() << "testPathParameterCollectionFormat Error: " << reply.errorString();
96 | }
97 |
98 | });
99 | QTRY_COMPARE_EQ(done, true);
100 | }
101 |
102 | void OperationParametersBackport::cleanupTestCase()
103 | {
104 | if (serverProcess.state() == QProcess::ProcessState::Running) {
105 | serverProcess.kill();
106 | serverProcess.waitForFinished();
107 | }
108 | }
109 |
110 | } // QtOpenAPI
111 |
112 | QTEST_MAIN(QtOpenAPI::OperationParametersBackport)
113 | #include "tst_openapi2_0.moc"
114 |
--------------------------------------------------------------------------------
/examples/openapi/colorpalette/ColorPalette/ColorDialogEditor.qml:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2025 The Qt Company Ltd.
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3 |
4 | import QtQuick
5 | import QtQuick.Controls
6 | import QtQuick.Layouts
7 | import QtQuick.Dialogs
8 |
9 | import QtOpenApiExampleStyle
10 |
11 | Popup {
12 | id: colorEditor
13 | // Popup for adding or updating a color
14 | padding: 10
15 | modal: true
16 | focus: true
17 | anchors.centerIn: parent
18 | closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
19 | signal colorAdded(string name, string color, string pantone_value)
20 | signal colorUpdated(string name, string color, string pantone_value, int cid)
21 |
22 | property bool newColor: true
23 | property int colorId: -1
24 | property alias currentColor: colordialogButton.buttonColor
25 |
26 | function createNewColor() {
27 | newColor = true
28 | colorNameField.text = "cute green"
29 | currentColor = "#41cd52" // colorRGBField.text updates automatically
30 | colorPantoneField.text = "PMS 802C"
31 | open()
32 | }
33 |
34 | function updateColor(data) {
35 | newColor = false
36 | colorNameField.text = data.name
37 | currentColor = data.color
38 | colorPantoneField.text = data.pantone_value
39 | colorId = data.id
40 | open()
41 | }
42 |
43 | ColorDialog {
44 | id: colorDialog
45 | title: qsTr("Choose a color")
46 | onAccepted: {
47 | colorEditor.currentColor = Qt.color(colorDialog.selectedColor)
48 | colorDialog.close()
49 | }
50 | onRejected: {
51 | colorDialog.close()
52 | }
53 | }
54 |
55 | ColumnLayout {
56 | anchors.fill: parent
57 | spacing: 10
58 |
59 | GridLayout {
60 | columns: 2
61 | rowSpacing: 10
62 | columnSpacing: 10
63 |
64 | Label {
65 | text: qsTr("Color Name")
66 | }
67 | TextField {
68 | id: colorNameField
69 | padding: 10
70 | }
71 |
72 | Label {
73 | text: qsTr("Pantone Value")
74 | }
75 | TextField {
76 | id: colorPantoneField
77 | padding: 10
78 | }
79 |
80 | Label {
81 | text: qsTr("Rgb Value")
82 | }
83 |
84 | TextField {
85 | id: colorRGBField
86 | text: colorEditor.currentColor.toString()
87 | readOnly: true
88 | padding: 10
89 | }
90 | }
91 |
92 | Button {
93 | id: colordialogButton
94 | Layout.fillWidth: true
95 | Layout.preferredHeight: 30
96 | text: qsTr("Set Color")
97 | textColor: isColorDark(buttonColor) ? "#E6E6E6" : "#191919"
98 |
99 | onClicked: colorDialog.open()
100 |
101 | function isColorDark(color) {
102 | return (0.2125 * color.r + 0.7154 * color.g + 0.0721 * color.b) < 0.5;
103 | }
104 | }
105 |
106 | RowLayout {
107 | Layout.fillWidth: true
108 | spacing: 10
109 |
110 | Button {
111 | text: qsTr("Cancel")
112 | onClicked: colorEditor.close()
113 | Layout.fillWidth: true
114 | }
115 |
116 | Button {
117 | Layout.fillWidth: true
118 | text: colorEditor.newColor ? qsTr("Add") : qsTr("Update")
119 |
120 | buttonColor: "#2CDE85"
121 | textColor: "#FFFFFF"
122 |
123 | onClicked: {
124 | if (colorEditor.newColor) {
125 | colorEditor.colorAdded(colorNameField.text,
126 | colorRGBField.text,
127 | colorPantoneField.text)
128 | } else {
129 | colorEditor.colorUpdated(colorNameField.text,
130 | colorRGBField.text,
131 | colorPantoneField.text,
132 | colorEditor.colorId)
133 | }
134 | colorEditor.close()
135 | }
136 | }
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/src/tools/qtopenapi-generator/src/main/resources/cpp-qt6-client/common/httprequest.h.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 |
3 | #ifndef {{prefix}}_HTTPREQUESTWORKER_H
4 | #define {{prefix}}_HTTPREQUESTWORKER_H
5 |
6 | #include "{{packageNameLowerCase}}commonexports.h"
7 |
8 | #include
9 | #include // for argument default value initialization
10 |
11 | #include
12 |
13 | QT_BEGIN_NAMESPACE
14 | class QHttpHeaders;
15 | class QHttpMultiPart;
16 | class QNetworkRequest;
17 | class QNetworkRequestFactory;
18 | class QRestAccessManager;
19 | class QRestReply;
20 | class QUrlQuery;
21 | QT_END_NAMESPACE
22 |
23 | {{#cppCommonNamespaceDeclarations}}
24 | namespace {{this}} {
25 | {{/cppCommonNamespaceDeclarations}}
26 |
27 | class {{prefix}}HttpFileElement;
28 |
29 | class {{prefix}}HttpRequestInputPrivate;
30 |
31 | class {{prefix}}HttpRequestInput
32 | {
33 | public:
34 | enum class VariableLayout {
35 | NotSet,
36 | Address,
37 | UrlEncoded,
38 | Multipart,
39 | };
40 |
41 | {{packageNameUpperCase}}_COMMON_EXPORT {{prefix}}HttpRequestInput();
42 | {{packageNameUpperCase}}_COMMON_EXPORT ~{{prefix}}HttpRequestInput();
43 | {{packageNameUpperCase}}_COMMON_EXPORT
44 | {{prefix}}HttpRequestInput(const QString &vUrlStr, const QString &vHttpMethod);
45 | Q_DISABLE_COPY_MOVE({{prefix}}HttpRequestInput)
46 |
47 | {{packageNameUpperCase}}_COMMON_EXPORT
48 | void addVariable(const QString &key, const QString &value);
49 | {{packageNameUpperCase}}_COMMON_EXPORT
50 | void addFieldHeaders(const QString &key, const QString &value);
51 | {{packageNameUpperCase}}_COMMON_EXPORT
52 | void addFile(const QString &variableName, const QString &localFilename, const QString &mimeType);
53 |
54 | {{packageNameUpperCase}}_COMMON_EXPORT void setVariableLayout(VariableLayout layout);
55 | {{packageNameUpperCase}}_COMMON_EXPORT VariableLayout variableLayout() const;
56 |
57 | {{packageNameUpperCase}}_COMMON_EXPORT void setHeaders(const QHttpHeaders &newHeaders);
58 | {{packageNameUpperCase}}_COMMON_EXPORT QHttpHeaders headers() const;
59 | {{packageNameUpperCase}}_COMMON_EXPORT QHttpHeaders &headers();
60 |
61 | {{packageNameUpperCase}}_COMMON_EXPORT void setIsFormData(bool isForm);
62 | {{packageNameUpperCase}}_COMMON_EXPORT bool isFormData() const;
63 |
64 | {{packageNameUpperCase}}_COMMON_EXPORT QString httpMethod() const;
65 |
66 | {{packageNameUpperCase}}_COMMON_EXPORT bool hasMultiPart() const;
67 | {{packageNameUpperCase}}_COMMON_EXPORT QHttpMultiPart* multiPart() const;
68 | {{packageNameUpperCase}}_COMMON_EXPORT QHttpMultiPart* takeMultiPart();
69 |
70 | {{packageNameUpperCase}}_COMMON_EXPORT void setRequestBody(const QByteArray &data);
71 | {{packageNameUpperCase}}_COMMON_EXPORT QByteArray requestBody() const;
72 |
73 | private:
74 | friend bool
75 | operator==(const {{prefix}}HttpRequestInput &lhs, const {{prefix}}HttpRequestInput &rhs) = delete;
76 | friend bool
77 | operator!=(const {{prefix}}HttpRequestInput &lhs, const {{prefix}}HttpRequestInput &rhs) = delete;
78 |
79 | friend size_t qHash(const {{prefix}}HttpRequestInput &value) = delete;
80 | friend size_t qHash(const {{prefix}}HttpRequestInput &value, size_t seed) = delete;
81 |
82 | friend class {{prefix}}HttpRequestInputPrivate;
83 | std::unique_ptr<{{prefix}}HttpRequestInputPrivate> d_ptr;
84 | };
85 |
86 | namespace {{prefix}}HttpRequestWorker {
87 | {{packageNameUpperCase}}_COMMON_EXPORT {{prefix}}HttpFileElement getHttpFileElement(const QMap &files, const QString &fieldname = {});
88 | {{packageNameUpperCase}}_COMMON_EXPORT QNetworkRequest getNetworkRequest({{prefix}}HttpRequestInput &input, QByteArray &requestContent, std::shared_ptr factory, bool responseCompressionEnabled, bool requestCompressionEnabled);
89 | {{packageNameUpperCase}}_COMMON_EXPORT QByteArray parseResponse(const QRestReply &reply, const QString &workDir, QMap *files = nullptr);
90 |
91 | enum class CompressionType {
92 | Deflate,
93 | Gzip,
94 | None,
95 | };
96 | {{packageNameUpperCase}}_COMMON_EXPORT QByteArray decompressData(const QByteArray &data, CompressionType compressionType);
97 | {{packageNameUpperCase}}_COMMON_EXPORT QByteArray compressData(const QByteArray &input, int level, CompressionType compressionType);
98 | } // namespace {{prefix}}HttpRequestWorker
99 |
100 | {{#cppCommonNamespaceDeclarations}}
101 | } // namespace {{this}}
102 | {{/cppCommonNamespaceDeclarations}}
103 |
104 | #endif // {{prefix}}_HTTPREQUESTWORKER_H
105 |
--------------------------------------------------------------------------------
/tests/auto/mediatype/server/go/routers.go:
--------------------------------------------------------------------------------
1 | /*
2 | * Operation Parameters Test
3 | *
4 | * This specification is intended for testing purposes. It demonstrates a wide range of content types for requestBody. The goal is to verify correct url for each case.
5 | *
6 | * API version: 1.0.0
7 | * Generated by: OpenAPI Generator (https://openapi-generator.tech)
8 | */
9 |
10 | package openapi
11 |
12 | import (
13 | "net/http"
14 |
15 | "github.com/gin-gonic/gin"
16 | )
17 |
18 | // Route is the information for every URI.
19 | type Route struct {
20 | // Name is the name of this Route.
21 | Name string
22 | // Method is the string for the HTTP method. ex) GET, POST etc..
23 | Method string
24 | // Pattern is the pattern of the URI.
25 | Pattern string
26 | // HandlerFunc is the handler function of this route.
27 | HandlerFunc gin.HandlerFunc
28 | }
29 |
30 | // NewRouter returns a new router.
31 | func NewRouter(handleFunctions ApiHandleFunctions) *gin.Engine {
32 | return NewRouterWithGinEngine(gin.Default(), handleFunctions)
33 | }
34 |
35 | // NewRouter add routes to existing gin engine.
36 | func NewRouterWithGinEngine(router *gin.Engine, handleFunctions ApiHandleFunctions) *gin.Engine {
37 | for _, route := range getRoutes(handleFunctions) {
38 | if route.HandlerFunc == nil {
39 | route.HandlerFunc = DefaultHandleFunc
40 | }
41 | switch route.Method {
42 | case http.MethodGet:
43 | router.GET(route.Pattern, route.HandlerFunc)
44 | case http.MethodPost:
45 | router.POST(route.Pattern, route.HandlerFunc)
46 | case http.MethodPut:
47 | router.PUT(route.Pattern, route.HandlerFunc)
48 | case http.MethodPatch:
49 | router.PATCH(route.Pattern, route.HandlerFunc)
50 | case http.MethodDelete:
51 | router.DELETE(route.Pattern, route.HandlerFunc)
52 | }
53 | }
54 |
55 | return router
56 | }
57 |
58 | // Default handler for not yet implemented routes
59 | func DefaultHandleFunc(c *gin.Context) {
60 | c.String(http.StatusNotImplemented, "501 not implemented")
61 | }
62 |
63 | type ApiHandleFunctions struct {
64 |
65 | // Routes for the TestAPI part of the API
66 | TestAPI TestAPI
67 | }
68 |
69 | func getRoutes(handleFunctions ApiHandleFunctions) []Route {
70 | return []Route{
71 | {
72 | "BinaryType",
73 | http.MethodPost,
74 | "/v2/reqBody/octetstream/binaryType",
75 | handleFunctions.TestAPI.BinaryType,
76 | },
77 | {
78 | "PostApplicationJsonArray",
79 | http.MethodPost,
80 | "/v2/reqBody/appjson/array/postApplicationJsonArray",
81 | handleFunctions.TestAPI.PostApplicationJsonArray,
82 | },
83 | {
84 | "PostApplicationJsonBool",
85 | http.MethodPost,
86 | "/v2/reqBody/appjson/bool/postApplicationJsonBool",
87 | handleFunctions.TestAPI.PostApplicationJsonBool,
88 | },
89 | {
90 | "PostApplicationJsonInt",
91 | http.MethodPost,
92 | "/v2/reqBody/appjson/integer/postApplicationJsonInt",
93 | handleFunctions.TestAPI.PostApplicationJsonInt,
94 | },
95 | {
96 | "PostApplicationJsonMap",
97 | http.MethodPost,
98 | "/v2/reqBody/appjson/object/postApplicationJsonMap",
99 | handleFunctions.TestAPI.PostApplicationJsonMap,
100 | },
101 | {
102 | "PostApplicationJsonObject",
103 | http.MethodPost,
104 | "/v2/reqBody/appjson/object/postApplicationJsonObject",
105 | handleFunctions.TestAPI.PostApplicationJsonObject,
106 | },
107 | {
108 | "PostApplicationJsonSeveralObjects",
109 | http.MethodPost,
110 | "/v2/reqBody/appjson/object/postApplicationJsonSeveralObjects",
111 | handleFunctions.TestAPI.PostApplicationJsonSeveralObjects,
112 | },
113 | {
114 | "PostApplicationJsonString",
115 | http.MethodPost,
116 | "/v2/reqBody/appjson/string/postApplicationJsonString",
117 | handleFunctions.TestAPI.PostApplicationJsonString,
118 | },
119 | {
120 | "PostMultiPartData",
121 | http.MethodPost,
122 | "/v2/reqBody/multipart/postMultiPartData",
123 | handleFunctions.TestAPI.PostMultiPartData,
124 | },
125 | {
126 | "PostPlainTextType",
127 | http.MethodPost,
128 | "/v2/reqBody/string/postPlainTextType",
129 | handleFunctions.TestAPI.PostPlainTextType,
130 | },
131 | {
132 | "PostUrlEncodedFields",
133 | http.MethodPost,
134 | "/v2/reqBody/urlencoded/postUrlEncodedFields",
135 | handleFunctions.TestAPI.PostUrlEncodedFields,
136 | },
137 | {
138 | "PostUrlEncodedNestedObject",
139 | http.MethodPost,
140 | "/v2/reqBody/urlencoded/postUrlEncodedNestedObject",
141 | handleFunctions.TestAPI.PostUrlEncodedNestedObject,
142 | },
143 | {
144 | "PostUrlEncodedObject",
145 | http.MethodPost,
146 | "/v2/reqBody/urlencoded/postUrlEncodedObject",
147 | handleFunctions.TestAPI.PostUrlEncodedObject,
148 | },
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/licenseRule.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "comment": ["file_pattern_ending: strings matched against the end of a file name.",
4 | "location keys: regular expression matched against the beginning of",
5 | "the file path (relative to the git submodule root).",
6 | "spdx: list of SPDX-License-Expression's allowed in the matching files.",
7 | "-------------------------------------------------------",
8 | "Files with the following endings are Build System licensed,",
9 | "unless they are examples",
10 | "Files with other endings can also be build system files"
11 | ],
12 | "file_pattern_ending": ["CMakeLists.txt", ".cmake", ".pro", ".pri", ".prf",
13 | "configure", "configure.bat", "cmake.in", "plist.in", "CMakeLists.txt.in",
14 | ".cmake.conf", ".tag", "ci_config_linux.json", "dependencies.yaml",
15 | "module_config.yaml", "make_openapi_generator_cli_as_debian.sh",
16 | "changelog", "control", "install", "rules", "source/format"],
17 | "location": {
18 | "": {
19 | "comment": "Default",
20 | "file type": "build system",
21 | "spdx": ["BSD-3-Clause"]
22 | },
23 | "coin/": {
24 | "comment": "Debian packaging rules",
25 | "file type": "build system",
26 | "spdx": ["BSD-3-Clause"]
27 | },
28 | "(.*)(examples/|snippets/)": {
29 | "comment": "Example takes precedence",
30 | "file type": "examples and snippets",
31 | "spdx": ["LicenseRef-Qt-Commercial OR BSD-3-Clause"]
32 | }
33 | }
34 | },
35 | {
36 | "comments": ["Files with the following endings are infrastructure licensed"],
37 | "file_pattern_ending": [".gitattributes", ".gitignore", ".gitmodules", ".gitreview",
38 | "_clang-format", "licenseRule.json", "REUSE.toml"],
39 | "location":{
40 | "": {
41 | "comment": "Default",
42 | "file type": "infrastructure",
43 | "spdx": ["LicenseRef-Qt-Commercial OR BSD-3-Clause"]
44 | }
45 | }
46 | },
47 | {
48 | "comments": ["Files with the following endings are Tool licensed,",
49 | "unless they are examples.",
50 | "Files with other endings can also be tool files."],
51 | "file_pattern_ending": [".sh", ".py", ".pl", ".bat", ".ps1"],
52 | "location":{
53 | "": {
54 | "comment": "Default",
55 | "file type": "tools and utils",
56 | "spdx": ["LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0"]
57 | },
58 | "(.*)(examples/|snippets/)": {
59 | "comment": "Example takes precedence",
60 | "file type": "examples and snippets",
61 | "spdx": ["LicenseRef-Qt-Commercial OR BSD-3-Clause"]
62 | }
63 | }
64 | },
65 | {
66 | "comment": "Files with the following endings are Documentation licensed.",
67 | "file_pattern_ending": [".qdoc", ".qdocinc" , ".qdocconf", "README", "qt_attribution.json",
68 | "config_help.txt"],
69 | "location":{
70 | "": {
71 | "comment": "",
72 | "file type": "documentation",
73 | "spdx": ["LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only"]
74 | }
75 | }
76 | },
77 | {
78 | "comment": ["All other files",
79 | "The licensing is defined only by the file location in the Qt module repository.",
80 | "NO key for this case!",
81 | "This needs to be the last entry of the file."],
82 | "location": {
83 | "src/tools/qtopenapi-generator": {
84 | "comment": "",
85 | "file type": "3rd party",
86 | "spdx": ["Apache-2.0"]
87 | },
88 | "src/openapicommon": {
89 | "comment": "",
90 | "file type": "module and plugin",
91 | "spdx": ["LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only"]
92 | },
93 | "tests/auto": {
94 | "comment": "Default",
95 | "file type": "test",
96 | "spdx": ["LicenseRef-Qt-Commercial OR GPL-3.0-only"]
97 | },
98 | "(.*)(examples/|snippets/)": {
99 | "comment": "Default",
100 | "file type": "examples and snippets",
101 | "spdx": ["LicenseRef-Qt-Commercial OR BSD-3-Clause"]
102 | },
103 | "examples/openapi/colorpalette/icons/": {
104 | "comment": "",
105 | "file type": "3rd party",
106 | "spdx": ["Apache-2.0"]
107 | }
108 | }
109 | }
110 | ]
111 |
--------------------------------------------------------------------------------