From 7048c0c787ae5a111292ac4321692fa36541e387 Mon Sep 17 00:00:00 2001 From: Fabian Klebert Date: Fri, 26 Apr 2024 17:16:01 +0200 Subject: [PATCH 1/5] Update README to reflect openssl build caveats --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da87af4..09d66e9 100644 --- a/README.md +++ b/README.md @@ -472,7 +472,7 @@ project(myapp) if (NOT TARGET zswag) FetchContent_Declare(zswag GIT_REPOSITORY "https://github.com/ndsev/zswag.git" - GIT_TAG "v1.5.0" + GIT_TAG "v1.6.6" GIT_SHALLOW ON) FetchContent_MakeAvailable(zswag) endif() @@ -498,6 +498,8 @@ target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}-zserio-cpp zswagcl) ``` +**Note:** OpenSSL is assumed to be installed or built using the `lib` not the `lib64` directory name. + The `add_executable` command above references the file `myapp/client.cpp`, which contains the code to actually use the zswag C++ client. From cbe5040546e64d702f54887b3d447ef6e6364cc7 Mon Sep 17 00:00:00 2001 From: Fabian Klebert Date: Fri, 26 Apr 2024 17:32:26 +0200 Subject: [PATCH 2/5] Treat HTTP 204 as error (#115) --- README.md | 6 ++++++ libs/zswagcl/src/openapi-client.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 09d66e9..346171b 100644 --- a/README.md +++ b/README.md @@ -611,6 +611,12 @@ on each platform: * [macOS `add-generic-password`](https://www.netmeister.org/blog/keychain-passwords.html) * [Windows `cmdkey`](https://www.scriptinglibrary.com/languages/powershell/how-to-manage-secrets-and-passwords-with-credentialmanager-and-powershell/) +## Client Result Code Handling + +Both clients (Python and C++) will treat any HTTP response code other than `200` as an error since zserio services are expected to return a parsable response object. The client will throw an exception with a descriptive message if the response code is not `200`. + +In case applications want to utilize for example the `204 (No Content)` response code, they have to catch the exception and handle it accordingly. + ## Swagger User Interface If you have installed `pip install "connexion[swagger-ui]"`, you can view diff --git a/libs/zswagcl/src/openapi-client.cpp b/libs/zswagcl/src/openapi-client.cpp index 351d926..da6c658 100644 --- a/libs/zswagcl/src/openapi-client.cpp +++ b/libs/zswagcl/src/openapi-client.cpp @@ -220,7 +220,7 @@ std::string OpenAPIClient::call(const std::string& methodIdent, auto result = resultFuture.get(); httpcl::log().debug("{} Response received (code {}, content length {} bytes).", debugContext, result.status, result.content.size()); - if (result.status >= 200 && result.status < 300) { + if (result.status == 200) { return std::move(result.content); } From 937c1834f3540e7ef3d4199798c8f44c309693d1 Mon Sep 17 00:00:00 2001 From: Fabian Klebert Date: Mon, 29 Apr 2024 11:40:15 +0200 Subject: [PATCH 3/5] Lower CMake requirement to work with Yocto kirkstone --- CMakeLists.txt | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b6e6e2..d1aa8d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,22 +1,29 @@ -cmake_minimum_required(VERSION 3.24) +cmake_minimum_required(VERSION 3.22.3) # to build without conan include(FetchContent) -if(NOT CONAN_PROVIDER_INCLUDED) - set(CONAN_PROVIDER_INCLUDED true) - FetchContent_Declare( - conan_provider - GIT_REPOSITORY https://github.com/Klebert-Engineering/cmake-conan - GIT_TAG zswag) - FetchContent_MakeAvailable(conan_provider) - set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${conan_provider_SOURCE_DIR}/conan_provider.cmake") +# Provide an option to disable Conan, defaulting to using Conan +option(WITH_CONAN "Build with Conan dependency management" ON) + +if(WITH_CONAN) + # Upgrade the required CMake version for Conan + cmake_minimum_required(VERSION 3.24) + if(NOT CONAN_PROVIDER_INCLUDED) + set(CONAN_PROVIDER_INCLUDED true) + FetchContent_Declare( + conan_provider + GIT_REPOSITORY https://github.com/Klebert-Engineering/cmake-conan + GIT_TAG zswag) + FetchContent_MakeAvailable(conan_provider) + set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${conan_provider_SOURCE_DIR}/conan_provider.cmake") + endif() endif() project(zswag) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(ZSWAG_VERSION 1.6.4) +set(ZSWAG_VERSION 1.6.7) option(ZSWAG_BUILD_WHEELS "Enable zswag whl-output to WHEEL_DEPLOY_DIRECTORY." ON) option(ZSWAG_KEYCHAIN_SUPPORT "Enable zswag keychain support." ON) From 5c130d43b8caeb289f6b93ef6a3ab23b94ab61ef Mon Sep 17 00:00:00 2001 From: Fabian Klebert Date: Mon, 29 Apr 2024 12:20:06 +0200 Subject: [PATCH 4/5] Update README and small renaming --- CMakeLists.txt | 4 ++-- README.md | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1aa8d8..1a41a2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,9 +3,9 @@ cmake_minimum_required(VERSION 3.22.3) # to build without conan include(FetchContent) # Provide an option to disable Conan, defaulting to using Conan -option(WITH_CONAN "Build with Conan dependency management" ON) +option(ZSWAG_WITH_CONAN "Build with Conan dependency management" ON) -if(WITH_CONAN) +if(ZSWAG_WITH_CONAN) # Upgrade the required CMake version for Conan cmake_minimum_required(VERSION 3.24) if(NOT CONAN_PROVIDER_INCLUDED) diff --git a/README.md b/README.md index 346171b..0bf3b7d 100644 --- a/README.md +++ b/README.md @@ -467,12 +467,17 @@ project(myapp) # libsecret, the following switch will disable keychain integration: # set(ZSWAG_KEYCHAIN_SUPPORT OFF) +# In case you want to build zswag without using conan +# make sure to provide targets for OpenSSL and spdlog +# and set the following switch to OFF: +# set(ZSWAG_WITH_CONAN OFF) + # This is how C++ will know about the zswag lib # and its dependencies, such as zserio. if (NOT TARGET zswag) FetchContent_Declare(zswag GIT_REPOSITORY "https://github.com/ndsev/zswag.git" - GIT_TAG "v1.6.6" + GIT_TAG "v1.6.7" GIT_SHALLOW ON) FetchContent_MakeAvailable(zswag) endif() From 4cec9afdae72b56a3de4ad48798fcebfc74ae894 Mon Sep 17 00:00:00 2001 From: Joseph Birkner Date: Mon, 29 Apr 2024 12:38:29 +0200 Subject: [PATCH 5/5] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0bf3b7d..09cda10 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ zswag is a set of libraries for using/hosting zserio services through OpenAPI. * [Client Environment Settings](#client-environment-settings) * [HTTP Proxies and Authentication](#persistent-http-headers-proxy-cookie-and-authentication) * [Swagger User Interface](#swagger-user-interface) + * [Client Result Code Handling](#client-result-code-handling) * [OpenAPI Options Interoperability](#openapi-options-interoperability) + [HTTP method](#http-method) + [Request Body](#request-body) @@ -503,7 +504,7 @@ target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}-zserio-cpp zswagcl) ``` -**Note:** OpenSSL is assumed to be installed or built using the `lib` not the `lib64` directory name. +**Note:** OpenSSL is assumed to be installed or built using the `lib` (not `lib64`) directory name. The `add_executable` command above references the file `myapp/client.cpp`, which contains the code to actually use the zswag C++ client.