diff --git a/bin/configs/cpp-restsdk-client-everything.yaml b/bin/configs/cpp-restsdk-client-everything.yaml new file mode 100644 index 000000000000..ffa996a0f004 --- /dev/null +++ b/bin/configs/cpp-restsdk-client-everything.yaml @@ -0,0 +1,6 @@ +generatorName: cpp-restsdk +outputDir: samples/client/petstore/cpp-restsdk/client-everything +inputSpec: modules/openapi-generator/src/test/resources/3_0/issues-anytype-object-set-petstore-everything.yaml +templateDir: modules/openapi-generator/src/main/resources/cpp-rest-sdk-client +additionalProperties: + packageName: CppRestPetstoreClient diff --git a/docs/generators/cpp-pistache-server.md b/docs/generators/cpp-pistache-server.md index f35b6398eea6..35886a25a0a2 100644 --- a/docs/generators/cpp-pistache-server.md +++ b/docs/generators/cpp-pistache-server.md @@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ---------- | ------- | |nlohmann::json|#include <nlohmann/json.hpp>| |std::map|#include <map>| +|std::set|#include <set>| |std::string|#include <string>| |std::vector|#include <vector>| diff --git a/docs/generators/cpp-restsdk.md b/docs/generators/cpp-restsdk.md index ed3157397d85..aef6bfe1c397 100644 --- a/docs/generators/cpp-restsdk.md +++ b/docs/generators/cpp-restsdk.md @@ -36,6 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |HttpContent|#include "HttpContent.h"| |Object|#include "Object.h"| |std::map|#include <map>| +|std::set|#include <set>| |std::string|#include <string>| |std::vector|#include <vector>| |utility::datetime|#include <cpprest/details/basic_types.h>| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java index 92638aaec3c8..1d1084596b28 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java @@ -70,7 +70,10 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen { /** std:map (for map) */ private static final String STD_MAP = "std::map"; - /** std:vector (for array, set) */ + /** std:set (for set) */ + private static final String STD_SET = "std::set"; + + /** std:vector (for array) */ private static final String STD_VECTOR = "std::vector"; @Override @@ -148,7 +151,7 @@ public CppPistacheServerCodegen() { typeMapping.put("boolean", "bool"); typeMapping.put("array", STD_VECTOR); typeMapping.put("map", STD_MAP); - typeMapping.put("set", STD_VECTOR); + typeMapping.put("set", STD_SET); typeMapping.put("file", STD_STRING); typeMapping.put("object", NLOHMANN_JSON); typeMapping.put("binary", STD_STRING); @@ -161,6 +164,7 @@ public CppPistacheServerCodegen() { super.importMapping = new HashMap<>(); importMapping.put(STD_VECTOR, "#include "); importMapping.put(STD_MAP, "#include "); + importMapping.put(STD_SET, "#include "); importMapping.put(STD_STRING, "#include "); importMapping.put(NLOHMANN_JSON, "#include "); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java index 518247ec8d96..19e8dfdf504d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java @@ -20,7 +20,6 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import io.swagger.v3.oas.models.Operation; -import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.servers.Server; @@ -161,6 +160,7 @@ public CppRestSdkClientCodegen() { typeMapping.put("long", "int64_t"); typeMapping.put("boolean", "bool"); typeMapping.put("array", "std::vector"); + typeMapping.put("set", "std::set"); typeMapping.put("map", "std::map"); typeMapping.put("file", "HttpContent"); typeMapping.put("object", "Object"); @@ -173,6 +173,7 @@ public CppRestSdkClientCodegen() { super.importMapping = new HashMap<>(); importMapping.put("std::vector", "#include "); importMapping.put("std::map", "#include "); + importMapping.put("std::set", "#include "); importMapping.put("std::string", "#include "); importMapping.put("HttpContent", "#include \"HttpContent.h\""); importMapping.put("Object", "#include \"Object.h\""); diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache index d3489fad4026..ca7d7c684dd6 100644 --- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/helpers-header.mustache @@ -13,6 +13,7 @@ #include #include #include +#include namespace {{helpersNamespace}} { @@ -82,6 +83,15 @@ namespace {{helpersNamespace}} return true; } + /// + /// Determine if the given vector only has unique elements. T must provide the == operator. + /// + template + bool hasOnlyUniqueItems(const std::set& set) + { + return true; + } + std::string toStringValue(const std::string &value); std::string toStringValue(const int32_t value); std::string toStringValue(const int64_t value); diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-header.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-header.mustache index a108b96f5d9d..665c9e7e8a32 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-header.mustache @@ -17,6 +17,7 @@ #include #include +#include #include {{#modelNamespaceDeclarations}} @@ -52,6 +53,8 @@ public: static utility::string_t toString( const std::shared_ptr& val ); template static utility::string_t toString( const std::vector & val ); + template + static utility::string_t toString( const std::set & val ); static web::json::value toJson( bool val ); static web::json::value toJson( float val ); @@ -68,6 +71,8 @@ public: template static web::json::value toJson( const std::vector& val ); template + static web::json::value toJson( const std::set& val ); + template static web::json::value toJson( const std::map& val ); static bool fromString( const utility::string_t& val, bool & ); @@ -85,6 +90,8 @@ public: template static bool fromString( const utility::string_t& val, std::vector & ); template + static bool fromString( const utility::string_t& val, std::set & ); + template static bool fromString( const utility::string_t& val, std::map & ); static bool fromJson( const web::json::value& val, bool & ); @@ -102,6 +109,8 @@ public: template static bool fromJson( const web::json::value& val, std::vector & ); template + static bool fromJson( const web::json::value& val, std::set & ); + template static bool fromJson( const web::json::value& val, std::map & ); @@ -120,6 +129,8 @@ public: template static std::shared_ptr toHttpContent( const utility::string_t& name, const std::vector& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); template + static std::shared_ptr toHttpContent( const utility::string_t& name, const std::set& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + template static std::shared_ptr toHttpContent( const utility::string_t& name, const std::map& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); static bool fromHttpContent( std::shared_ptr val, bool & ); @@ -136,6 +147,8 @@ public: template static bool fromHttpContent( std::shared_ptr val, std::vector & ); template + static bool fromHttpContent( std::shared_ptr val, std::set & ); + template static bool fromHttpContent( std::shared_ptr val, std::map & ); static utility::string_t toBase64( utility::string_t value ); @@ -155,6 +168,8 @@ utility::string_t ModelBase::toString( const std::shared_ptr& val ) } return utility::string_t(ss.str()); } + +// std::vector to string template utility::string_t ModelBase::toString( const std::vector & val ) { @@ -169,6 +184,24 @@ utility::string_t ModelBase::toString( const std::vector & val ) } return strArray; } + +// std::set to string +template +utility::string_t ModelBase::toString( const std::set & val ) +{ + utility::string_t strArray; + for ( const auto &item : val ) + { + strArray.append( toString(item) + "," ); + } + if (val.count() > 0) + { + strArray.pop_back(); + } + return strArray; +} + + template web::json::value ModelBase::toJson( const std::shared_ptr& val ) { @@ -179,6 +212,8 @@ web::json::value ModelBase::toJson( const std::shared_ptr& val ) } return retVal; } + +// std::vector to json template web::json::value ModelBase::toJson( const std::vector& value ) { @@ -189,6 +224,21 @@ web::json::value ModelBase::toJson( const std::vector& value ) } return web::json::value::array(ret); } + +// std::set to json +template +web::json::value ModelBase::toJson( const std::set& value ) +{ + // There's no protoype web::json::value::array(...) taking a std::set parameter. Converting to std::vector to get an array. + std::vector ret; + for ( const auto& x : value ) + { + ret.push_back( toJson(x) ); + } + return web::json::value::array(ret); +} + + template web::json::value ModelBase::toJson( const std::map& val ) { @@ -279,6 +329,7 @@ std::shared_ptr ModelBase::toHttpContent(const utility::string_t& n } return content; } + template std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const std::vector& value, const utility::string_t& contentType ) { @@ -290,6 +341,7 @@ std::shared_ptr ModelBase::toHttpContent( const utility::string_t& content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) ); return content; } + template std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const std::map& value, const utility::string_t& contentType ) { diff --git a/modules/openapi-generator/src/test/resources/3_0/cpp-restsdk/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/cpp-restsdk/petstore.yaml index a8f9809a1249..a9dd84f01f44 100644 --- a/modules/openapi-generator/src/test/resources/3_0/cpp-restsdk/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/cpp-restsdk/petstore.yaml @@ -725,6 +725,44 @@ components: - available - pending - sold + + certificates: + description: pedigree and other certificates + type: array + uniqueItems: true + + items: + type: string + + vaccinationBook: + description: Vaccination book of the pet + type: object + + required: + - vaccines + + properties: + vaccines: + type: array + uniqueItems: true + + items: + title: vaccine + type: object + + required: + - date + - boosterRequired + + properties: + date: + format: date + description: vaccination date + + boosterRequired: + type: boolean + description: true if a booster is still needed to complete the vaccination + xml: name: Pet ApiResponse: diff --git a/modules/openapi-generator/src/test/resources/3_0/issues-anytype-object-set-petstore-everything.yaml b/modules/openapi-generator/src/test/resources/3_0/issues-anytype-object-set-petstore-everything.yaml index 3fa84d89af69..da9323c15127 100644 --- a/modules/openapi-generator/src/test/resources/3_0/issues-anytype-object-set-petstore-everything.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/issues-anytype-object-set-petstore-everything.yaml @@ -763,9 +763,9 @@ components: - pending - sold - # --------------------------------------------------------- - # Properties that dedicate this configuration to this issue - # --------------------------------------------------------- + # ----------------------------------------------------------------------- + # Properties that dedicate this configuration to some issues or checkings + # ----------------------------------------------------------------------- # https://github.com/OpenAPITools/openapi-generator/issues/2769 # object property (leading to Object.h) @@ -782,21 +782,44 @@ components: description: to help you installing your pet at home # Leading to Set.h + certificates: + description: pedigree and other certificates + type: array + uniqueItems: true + + items: + type: string + # https://github.com/OpenAPITools/openapi-generator/issues/14234 - bestFriends: - description: Pet best friends! + vaccinationBook: + description: Vaccination book of the pet type: object required: - - bestFriends + - vaccines properties: - bestFriends: + vaccines: type: array uniqueItems: true items: - type: string + title: vaccine + type: object + + required: + - date + - boosterRequired + + properties: + date: + format: date + description: vaccination date + + boosterRequired: + type: boolean + description: true if a booster is still needed to complete the vaccination + xml: name: Pet diff --git a/samples/client/petstore/cpp-restsdk/client-everything/.gitignore b/samples/client/petstore/cpp-restsdk/client-everything/.gitignore new file mode 100644 index 000000000000..4581ef2eeefc --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/.gitignore @@ -0,0 +1,29 @@ +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app diff --git a/samples/client/petstore/cpp-restsdk/client-everything/.openapi-generator-ignore b/samples/client/petstore/cpp-restsdk/client-everything/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/cpp-restsdk/client-everything/.openapi-generator/FILES b/samples/client/petstore/cpp-restsdk/client-everything/.openapi-generator/FILES new file mode 100644 index 000000000000..ecda37dab83d --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/.openapi-generator/FILES @@ -0,0 +1,46 @@ +.gitignore +CMakeLists.txt +Config.cmake.in +README.md +git_push.sh +include/CppRestPetstoreClient/AnyType.h +include/CppRestPetstoreClient/ApiClient.h +include/CppRestPetstoreClient/ApiConfiguration.h +include/CppRestPetstoreClient/ApiException.h +include/CppRestPetstoreClient/HttpContent.h +include/CppRestPetstoreClient/IHttpBody.h +include/CppRestPetstoreClient/JsonBody.h +include/CppRestPetstoreClient/ModelBase.h +include/CppRestPetstoreClient/MultipartFormData.h +include/CppRestPetstoreClient/Object.h +include/CppRestPetstoreClient/api/PetApi.h +include/CppRestPetstoreClient/api/StoreApi.h +include/CppRestPetstoreClient/api/UserApi.h +include/CppRestPetstoreClient/model/ApiResponse.h +include/CppRestPetstoreClient/model/Category.h +include/CppRestPetstoreClient/model/Order.h +include/CppRestPetstoreClient/model/Pet.h +include/CppRestPetstoreClient/model/Pet_vaccinationBook.h +include/CppRestPetstoreClient/model/Tag.h +include/CppRestPetstoreClient/model/User.h +include/CppRestPetstoreClient/model/Vaccine.h +src/AnyType.cpp +src/ApiClient.cpp +src/ApiConfiguration.cpp +src/ApiException.cpp +src/HttpContent.cpp +src/JsonBody.cpp +src/ModelBase.cpp +src/MultipartFormData.cpp +src/Object.cpp +src/api/PetApi.cpp +src/api/StoreApi.cpp +src/api/UserApi.cpp +src/model/ApiResponse.cpp +src/model/Category.cpp +src/model/Order.cpp +src/model/Pet.cpp +src/model/Pet_vaccinationBook.cpp +src/model/Tag.cpp +src/model/User.cpp +src/model/Vaccine.cpp diff --git a/samples/client/petstore/cpp-restsdk/client-everything/.openapi-generator/VERSION b/samples/client/petstore/cpp-restsdk/client-everything/.openapi-generator/VERSION new file mode 100644 index 000000000000..ecb21862b1ee --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.6.0-SNAPSHOT diff --git a/samples/client/petstore/cpp-restsdk/client-everything/CMakeLists.txt b/samples/client/petstore/cpp-restsdk/client-everything/CMakeLists.txt new file mode 100644 index 000000000000..1212e2c4d0fd --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/CMakeLists.txt @@ -0,0 +1,93 @@ +# +# OpenAPI Petstore +# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +# +# The version of the OpenAPI document: 1.0.0 +# +# https://openapi-generator.tech +# +# NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech). + +cmake_minimum_required (VERSION 3.1) + +project(CppRestPetstoreClient) + +# Force -fPIC even if the project is configured for building a static library. +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CXX_STANDARD_REQUIRED ON) + +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +find_package(cpprestsdk REQUIRED) +find_package(Boost REQUIRED) + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +file(GLOB_RECURSE HEADER_FILES "include/*.h") +file(GLOB_RECURSE SOURCE_FILES "src/*.cpp") + +add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES}) + +target_compile_options(${PROJECT_NAME} + PRIVATE + $<$,$,$>: + -Wall -Wno-unused-variable> +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + $ + $ +) + +if (UNIX) + message(STATUS "Building client library for Linux/Unix") + if (BUILD_SHARED_LIBS) + target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers cpprestsdk::cpprest) + else() + target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers cpprestsdk::cpprest crypto) + endif() +else() + message(STATUS "Building client library for Windows") + if (BUILD_SHARED_LIBS) + target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers cpprestsdk::cpprest) + else() + target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers cpprestsdk::cpprest bcrypt) + endif() +endif() + +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" +) + +install( + TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}Targets + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} +) + +install( + EXPORT ${PROJECT_NAME}Targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} +) \ No newline at end of file diff --git a/samples/client/petstore/cpp-restsdk/client-everything/Config.cmake.in b/samples/client/petstore/cpp-restsdk/client-everything/Config.cmake.in new file mode 100644 index 000000000000..9015c2ba5eef --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/Config.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake) + +check_required_components("@PROJECT_NAME@") diff --git a/samples/client/petstore/cpp-restsdk/client-everything/README.md b/samples/client/petstore/cpp-restsdk/client-everything/README.md new file mode 100644 index 000000000000..cbccfb751593 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/README.md @@ -0,0 +1,51 @@ +# C++ API client + +This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: +- Generator version: 7.6.0-SNAPSHOT +- Build package: org.openapitools.codegen.languages.CppRestSdkClientCodegen + +- API namespace: org.openapitools.client.api +- Model namespace: org.openapitools.client.model + +## Installation + +### Prerequisites + +Install [cpprestsdk](https://github.com/Microsoft/cpprestsdk). + +- Windows: `vcpkg install cpprestsdk cpprestsdk:x64-windows boost-uuid boost-uuid:x64-windows` +- Mac: `brew install cpprestsdk` +- Linux: `sudo apt-get install libcpprest-dev` + +### Build + +```sh +cmake -DCPPREST_ROOT=/usr -DCMAKE_CXX_FLAGS="-I/usr/local/opt/openssl/include" -DCMAKE_MODULE_LINKER_FLAGS="-L/usr/local/opt/openssl/lib" +make +``` + +### Build on Windows with Visual Studio (VS2017) + +- Right click on folder containing source code +- Select 'Open in visual studio' +- Once visual studio opens, CMake should show up in top menu bar. +- Select CMake > Build All. + +*Note: If the CMake menu item doesn't show up in Visual Studio, CMake +for Visual Studio must be installed. In this case, open the 'Visual Studio +Installer' application. Select 'modify' Visual Studio 2017. Make sure +'Desktop Development with C++' is installed, and specifically that 'Visual +C++ tools for CMake' is selected in the 'Installation Details' section. + +Also be sure to review the CMakeLists.txt file. Edits are likely required.* + +## Author + + + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/git_push.sh b/samples/client/petstore/cpp-restsdk/client-everything/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/AnyType.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/AnyType.h new file mode 100644 index 000000000000..0d92c89bb5ec --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/AnyType.h @@ -0,0 +1,58 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * AnyType.h + * + * This is the implementation of an any JSON type. + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_AnyType_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_AnyType_H_ + + +#include "CppRestPetstoreClient/Object.h" + +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class AnyType : public Object { +public: + AnyType(); + virtual ~AnyType(); + + ///////////////////////////////////////////// + /// ModelBase overrides + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value &json) override; + + void toMultipart(std::shared_ptr multipart, + const utility::string_t &namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, + const utility::string_t &namePrefix) override; + +private: + web::json::value m_value; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_AnyType_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ApiClient.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ApiClient.h new file mode 100644 index 000000000000..677c37e348af --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ApiClient.h @@ -0,0 +1,114 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * ApiClient.h + * + * This is an API client responsible for stating the HTTP calls + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ +#define ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ + + +#include "CppRestPetstoreClient/ApiConfiguration.h" +#include "CppRestPetstoreClient/ApiException.h" +#include "CppRestPetstoreClient/IHttpBody.h" +#include "CppRestPetstoreClient/HttpContent.h" + +#if defined (_WIN32) || defined (_WIN64) +#undef U +#endif + +#include +#include + +#include +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +using namespace org::openapitools::client::model; + +class ApiClient +{ +public: + ApiClient( std::shared_ptr configuration = nullptr ); + virtual ~ApiClient(); + + typedef std::function ResponseHandlerType; + + const ResponseHandlerType& getResponseHandler() const; + void setResponseHandler(const ResponseHandlerType& responseHandler); + + std::shared_ptr getConfiguration() const; + void setConfiguration(std::shared_ptr configuration); + + static utility::string_t parameterToString(utility::string_t value); + static utility::string_t parameterToString(int32_t value); + static utility::string_t parameterToString(int64_t value); + static utility::string_t parameterToString(float value); + static utility::string_t parameterToString(double value); + static utility::string_t parameterToString(const utility::datetime &value); + static utility::string_t parameterToString(bool value); + template + static utility::string_t parameterToString(const std::vector& value); + template + static utility::string_t parameterToString(const std::shared_ptr& value); + + pplx::task callApi( + const utility::string_t& path, + const utility::string_t& method, + const std::map& queryParams, + const std::shared_ptr postBody, + const std::map& headerParams, + const std::map& formParams, + const std::map>& fileParams, + const utility::string_t& contentType + ) const; + +protected: + + ResponseHandlerType m_ResponseHandler; + std::shared_ptr m_Configuration; +}; + +template +utility::string_t ApiClient::parameterToString(const std::vector& value) +{ + utility::stringstream_t ss; + + for( size_t i = 0; i < value.size(); i++) + { + if( i > 0) ss << utility::conversions::to_string_t(", "); + ss << ApiClient::parameterToString(value[i]); + } + + return ss.str(); +} + +template +utility::string_t ApiClient::parameterToString(const std::shared_ptr& value) +{ + return parameterToString(*value.get()); +} + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ApiConfiguration.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ApiConfiguration.h new file mode 100644 index 000000000000..48f91cee599e --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ApiConfiguration.h @@ -0,0 +1,66 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * ApiConfiguration.h + * + * This class represents a single item of a multipart-formdata request. + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ +#define ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ + + + +#include +#include + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +class ApiConfiguration +{ +public: + ApiConfiguration(); + virtual ~ApiConfiguration(); + + const web::http::client::http_client_config& getHttpConfig() const; + void setHttpConfig( web::http::client::http_client_config& value ); + + utility::string_t getBaseUrl() const; + void setBaseUrl( const utility::string_t value ); + + utility::string_t getUserAgent() const; + void setUserAgent( const utility::string_t value ); + + std::map& getDefaultHeaders(); + const std::map& getDefaultHeaders() const; + + utility::string_t getApiKey( const utility::string_t& prefix) const; + void setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ); + +protected: + utility::string_t m_BaseUrl; + std::map m_DefaultHeaders; + std::map m_ApiKeys; + web::http::client::http_client_config m_HttpConfig; + utility::string_t m_UserAgent; +}; + +} +} +} +} +#endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ApiException.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ApiException.h new file mode 100644 index 000000000000..771427117e14 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ApiException.h @@ -0,0 +1,60 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * ApiException.h + * + * This is the exception being thrown in case the api call was not successful + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiException_H_ +#define ORG_OPENAPITOOLS_CLIENT_API_ApiException_H_ + + + +#include +#include + +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +class ApiException + : public web::http::http_exception +{ +public: + ApiException( int errorCode + , const utility::string_t& message + , std::shared_ptr content = nullptr ); + ApiException( int errorCode + , const utility::string_t& message + , std::map& headers + , std::shared_ptr content = nullptr ); + virtual ~ApiException(); + + std::map& getHeaders(); + std::shared_ptr getContent() const; + +protected: + std::shared_ptr m_Content; + std::map m_Headers; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiBase_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/HttpContent.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/HttpContent.h new file mode 100644 index 000000000000..fb7927babdbe --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/HttpContent.h @@ -0,0 +1,69 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * HttpContent.h + * + * This class represents a single item of a multipart-formdata request. + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ + + + +#include + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class HttpContent +{ +public: + HttpContent(); + virtual ~HttpContent(); + + virtual utility::string_t getContentDisposition() const; + virtual void setContentDisposition( const utility::string_t& value ); + + virtual utility::string_t getName() const; + virtual void setName( const utility::string_t& value ); + + virtual utility::string_t getFileName() const; + virtual void setFileName( const utility::string_t& value ); + + virtual utility::string_t getContentType() const; + virtual void setContentType( const utility::string_t& value ); + + virtual std::shared_ptr getData() const; + virtual void setData( std::shared_ptr value ); + + virtual void writeTo( std::ostream& stream ); + +protected: + // NOTE: no utility::string_t here because those strings can only contain ascii + utility::string_t m_ContentDisposition; + utility::string_t m_Name; + utility::string_t m_FileName; + utility::string_t m_ContentType; + std::shared_ptr m_Data; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/IHttpBody.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/IHttpBody.h new file mode 100644 index 000000000000..f94ff4299dc0 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/IHttpBody.h @@ -0,0 +1,42 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * IHttpBody.h + * + * This is the interface for contents that can be sent to a remote HTTP server. + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ + + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class IHttpBody +{ +public: + virtual ~IHttpBody() { } + + virtual void writeTo( std::ostream& stream ) = 0; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/JsonBody.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/JsonBody.h new file mode 100644 index 000000000000..424cb499f74b --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/JsonBody.h @@ -0,0 +1,49 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * JsonBody.h + * + * This is a JSON http body which can be submitted via http + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ + + +#include "CppRestPetstoreClient/IHttpBody.h" + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class JsonBody + : public IHttpBody +{ +public: + JsonBody( const web::json::value& value ); + virtual ~JsonBody(); + + void writeTo( std::ostream& target ) override; + +protected: + web::json::value m_Json; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ModelBase.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ModelBase.h new file mode 100644 index 000000000000..40167660cb9f --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/ModelBase.h @@ -0,0 +1,394 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * ModelBase.h + * + * This is the base class for all model classes + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ + + + +#include "CppRestPetstoreClient/HttpContent.h" +#include "CppRestPetstoreClient/MultipartFormData.h" + +#include +#include + +#include +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class ModelBase +{ +public: + ModelBase(); + virtual ~ModelBase(); + + virtual void validate() = 0; + + virtual web::json::value toJson() const = 0; + virtual bool fromJson( const web::json::value& json ) = 0; + + virtual void toMultipart( std::shared_ptr multipart, const utility::string_t& namePrefix ) const = 0; + virtual bool fromMultiPart( std::shared_ptr multipart, const utility::string_t& namePrefix ) = 0; + + virtual bool isSet() const; + + static utility::string_t toString( const bool val ); + static utility::string_t toString( const float val ); + static utility::string_t toString( const double val ); + static utility::string_t toString( const int32_t val ); + static utility::string_t toString( const int64_t val ); + static utility::string_t toString( const utility::string_t &val ); + static utility::string_t toString( const utility::datetime &val ); + static utility::string_t toString( const web::json::value &val ); + static utility::string_t toString( const std::shared_ptr& val ); + template + static utility::string_t toString( const std::shared_ptr& val ); + template + static utility::string_t toString( const std::vector & val ); + template + static utility::string_t toString( const std::set & val ); + + static web::json::value toJson( bool val ); + static web::json::value toJson( float val ); + static web::json::value toJson( double val ); + static web::json::value toJson( int32_t val ); + static web::json::value toJson( int64_t val ); + static web::json::value toJson( const utility::string_t& val ); + static web::json::value toJson( const utility::datetime& val ); + static web::json::value toJson( const web::json::value& val ); + static web::json::value toJson( const std::shared_ptr& val ); + template + static web::json::value toJson( const std::shared_ptr& val ); + static web::json::value toJson( const std::shared_ptr& val ); + template + static web::json::value toJson( const std::vector& val ); + template + static web::json::value toJson( const std::set& val ); + template + static web::json::value toJson( const std::map& val ); + + static bool fromString( const utility::string_t& val, bool & ); + static bool fromString( const utility::string_t& val, float & ); + static bool fromString( const utility::string_t& val, double & ); + static bool fromString( const utility::string_t& val, int32_t & ); + static bool fromString( const utility::string_t& val, int64_t & ); + static bool fromString( const utility::string_t& val, utility::string_t & ); + static bool fromString( const utility::string_t& val, utility::datetime & ); + static bool fromString( const utility::string_t& val, web::json::value & ); + static bool fromString( const utility::string_t& val, std::shared_ptr & ); + template + static bool fromString( const utility::string_t& val, std::shared_ptr& ); + static bool fromString( const utility::string_t& val, std::shared_ptr& outVal ); + template + static bool fromString( const utility::string_t& val, std::vector & ); + template + static bool fromString( const utility::string_t& val, std::set & ); + template + static bool fromString( const utility::string_t& val, std::map & ); + + static bool fromJson( const web::json::value& val, bool & ); + static bool fromJson( const web::json::value& val, float & ); + static bool fromJson( const web::json::value& val, double & ); + static bool fromJson( const web::json::value& val, int32_t & ); + static bool fromJson( const web::json::value& val, int64_t & ); + static bool fromJson( const web::json::value& val, utility::string_t & ); + static bool fromJson( const web::json::value& val, utility::datetime & ); + static bool fromJson( const web::json::value& val, web::json::value & ); + static bool fromJson( const web::json::value& val, std::shared_ptr & ); + template + static bool fromJson( const web::json::value& val, std::shared_ptr& ); + static bool fromJson( const web::json::value& val, std::shared_ptr &outVal ); + template + static bool fromJson( const web::json::value& val, std::vector & ); + template + static bool fromJson( const web::json::value& val, std::set & ); + template + static bool fromJson( const web::json::value& val, std::map & ); + + + static std::shared_ptr toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, float value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = utility::conversions::to_string_t("")); + static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = utility::conversions::to_string_t("")); + static std::shared_ptr toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType = utility::conversions::to_string_t("application/json") ); + static std::shared_ptr toHttpContent( const utility::string_t& name, const std::shared_ptr& ); + template + static std::shared_ptr toHttpContent( const utility::string_t& name, const std::shared_ptr& , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") ); + static std::shared_ptr toHttpContent(const utility::string_t& name, const std::shared_ptr& value , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") ); + template + static std::shared_ptr toHttpContent( const utility::string_t& name, const std::vector& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + template + static std::shared_ptr toHttpContent( const utility::string_t& name, const std::set& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + template + static std::shared_ptr toHttpContent( const utility::string_t& name, const std::map& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + + static bool fromHttpContent( std::shared_ptr val, bool & ); + static bool fromHttpContent( std::shared_ptr val, float & ); + static bool fromHttpContent( std::shared_ptr val, double & ); + static bool fromHttpContent( std::shared_ptr val, int64_t & ); + static bool fromHttpContent( std::shared_ptr val, int32_t & ); + static bool fromHttpContent( std::shared_ptr val, utility::string_t & ); + static bool fromHttpContent( std::shared_ptr val, utility::datetime & ); + static bool fromHttpContent( std::shared_ptr val, web::json::value & ); + static bool fromHttpContent( std::shared_ptr val, std::shared_ptr& ); + template + static bool fromHttpContent( std::shared_ptr val, std::shared_ptr& ); + template + static bool fromHttpContent( std::shared_ptr val, std::vector & ); + template + static bool fromHttpContent( std::shared_ptr val, std::set & ); + template + static bool fromHttpContent( std::shared_ptr val, std::map & ); + + static utility::string_t toBase64( utility::string_t value ); + static utility::string_t toBase64( std::shared_ptr value ); + static std::shared_ptr fromBase64( const utility::string_t& encoded ); +protected: + bool m_IsSet; +}; + +template +utility::string_t ModelBase::toString( const std::shared_ptr& val ) +{ + utility::stringstream_t ss; + if( val != nullptr ) + { + val->toJson().serialize(ss); + } + return utility::string_t(ss.str()); +} + +// std::vector to string +template +utility::string_t ModelBase::toString( const std::vector & val ) +{ + utility::string_t strArray; + for ( const auto &item : val ) + { + strArray.append( toString(item) + "," ); + } + if (val.count() > 0) + { + strArray.pop_back(); + } + return strArray; +} + +// std::set to string +template +utility::string_t ModelBase::toString( const std::set & val ) +{ + utility::string_t strArray; + for ( const auto &item : val ) + { + strArray.append( toString(item) + "," ); + } + if (val.count() > 0) + { + strArray.pop_back(); + } + return strArray; +} + + +template +web::json::value ModelBase::toJson( const std::shared_ptr& val ) +{ + web::json::value retVal; + if(val != nullptr) + { + retVal = val->toJson(); + } + return retVal; +} + +// std::vector to json +template +web::json::value ModelBase::toJson( const std::vector& value ) +{ + std::vector ret; + for ( const auto& x : value ) + { + ret.push_back( toJson(x) ); + } + return web::json::value::array(ret); +} + +// std::set to json +template +web::json::value ModelBase::toJson( const std::set& value ) +{ + // There's no protoype web::json::value::array(...) taking a std::set parameter. Converting to std::vector to get an array. + std::vector ret; + for ( const auto& x : value ) + { + ret.push_back( toJson(x) ); + } + return web::json::value::array(ret); +} + + +template +web::json::value ModelBase::toJson( const std::map& val ) +{ + web::json::value obj; + for ( const auto &itemkey : val ) + { + obj[itemkey.first] = toJson( itemkey.second ); + } + return obj; +} +template +bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr& outVal ) +{ + bool ok = false; + if(outVal == nullptr) + { + outVal = std::shared_ptr(new T()); + } + if( outVal != nullptr ) + { + ok = outVal->fromJson(web::json::value::parse(val)); + } + return ok; +} +template +bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr &outVal ) +{ + bool ok = false; + if(outVal == nullptr) + { + outVal = std::shared_ptr(new T()); + } + if( outVal != nullptr ) + { + ok = outVal->fromJson(val); + } + return ok; +} +template +bool ModelBase::fromJson( const web::json::value& val, std::vector &outVal ) +{ + bool ok = true; + if (val.is_array()) + { + for (const web::json::value & jitem : val.as_array()) + { + T item; + ok &= fromJson(jitem, item); + outVal.push_back(item); + } + } + else + { + ok = false; + } + return ok; +} +template +bool ModelBase::fromJson( const web::json::value& jval, std::map &outVal ) +{ + bool ok = true; + if ( jval.is_object() ) + { + auto obj = jval.as_object(); + for( auto objItr = obj.begin() ; objItr != obj.end() ; objItr++ ) + { + T itemVal; + ok &= fromJson(objItr->second, itemVal); + outVal.insert(std::pair(objItr->first, itemVal)); + } + } + else + { + ok = false; + } + return ok; +} +template +std::shared_ptr ModelBase::toHttpContent(const utility::string_t& name, const std::shared_ptr& value , const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + if (value != nullptr ) + { + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string( value->toJson().serialize() ) ) ) ); + } + return content; +} + +template +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const std::vector& value, const utility::string_t& contentType ) +{ + web::json::value json_array = ModelBase::toJson(value); + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) ); + return content; +} + +template +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const std::map& value, const utility::string_t& contentType ) +{ + web::json::value jobj = ModelBase::toJson(value); + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(jobj.serialize()) ) ) ); + return content; +} +template +bool ModelBase::fromHttpContent( std::shared_ptr val, std::shared_ptr& outVal ) +{ + utility::string_t str; + if(val == nullptr) return false; + if( outVal == nullptr ) + { + outVal = std::shared_ptr(new T()); + } + ModelBase::fromHttpContent(val, str); + return fromString(str, outVal); +} +template +bool ModelBase::fromHttpContent( std::shared_ptr val, std::vector & ) +{ + return true; +} +template +bool ModelBase::fromHttpContent( std::shared_ptr val, std::map & ) +{ + return true; +} +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/MultipartFormData.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/MultipartFormData.h new file mode 100644 index 000000000000..f4761c6f3cac --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/MultipartFormData.h @@ -0,0 +1,61 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * MultipartFormData.h + * + * This class represents a container for building application/x-multipart-formdata requests. + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ + + +#include "CppRestPetstoreClient/IHttpBody.h" +#include "CppRestPetstoreClient/HttpContent.h" + +#include + +#include +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class MultipartFormData + : public IHttpBody +{ +public: + MultipartFormData(); + MultipartFormData(const utility::string_t& boundary); + virtual ~MultipartFormData(); + + virtual void add( std::shared_ptr content ); + virtual utility::string_t getBoundary(); + virtual std::shared_ptr getContent(const utility::string_t& name) const; + virtual bool hasContent(const utility::string_t& name) const; + virtual void writeTo( std::ostream& target ); + +protected: + std::vector> m_Contents; + utility::string_t m_Boundary; + std::map> m_ContentLookup; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/Object.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/Object.h new file mode 100644 index 000000000000..de9df4c1bde4 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/Object.h @@ -0,0 +1,62 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * Object.h + * + * This is the implementation of a JSON object. + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class Object : public ModelBase +{ +public: + Object(); + virtual ~Object(); + + ///////////////////////////////////////////// + /// ModelBase overrides + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Object manipulation + web::json::value getValue(const utility::string_t& key) const; + void setValue(const utility::string_t& key, const web::json::value& value); + +private: + web::json::value m_object; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/api/PetApi.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/api/PetApi.h new file mode 100644 index 000000000000..275bda18c470 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/api/PetApi.h @@ -0,0 +1,150 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * PetApi.h + * + * + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ +#define ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ + + + +#include "CppRestPetstoreClient/ApiClient.h" + +#include "CppRestPetstoreClient/model/ApiResponse.h" +#include "CppRestPetstoreClient/HttpContent.h" +#include "CppRestPetstoreClient/model/Pet.h" +#include +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +using namespace org::openapitools::client::model; + + + +class PetApi +{ +public: + + explicit PetApi( std::shared_ptr apiClient ); + + virtual ~PetApi(); + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Pet object that needs to be added to the store + pplx::task> addPet( + std::shared_ptr pet + ) const; + /// + /// Deletes a pet + /// + /// + /// + /// + /// Pet id to delete + /// (optional, default to utility::conversions::to_string_t("")) + pplx::task deletePet( + int64_t petId, + boost::optional apiKey + ) const; + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma separated strings + /// + /// Status values that need to be considered for filter + pplx::task>> findPetsByStatus( + std::vector status + ) const; + /// + /// Finds Pets by tags + /// + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + pplx::task>> findPetsByTags( + std::vector tags + ) const; + /// + /// Find pet by ID + /// + /// + /// Returns a single pet + /// + /// ID of pet to return + pplx::task> getPetById( + int64_t petId + ) const; + /// + /// Update an existing pet + /// + /// + /// + /// + /// Pet object that needs to be added to the store + pplx::task> updatePet( + std::shared_ptr pet + ) const; + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// ID of pet that needs to be updated + /// Updated name of the pet (optional, default to utility::conversions::to_string_t("")) + /// Updated status of the pet (optional, default to utility::conversions::to_string_t("")) + pplx::task updatePetWithForm( + int64_t petId, + boost::optional name, + boost::optional status + ) const; + /// + /// uploads an image + /// + /// + /// + /// + /// ID of pet to update + /// Additional data to pass to server (optional, default to utility::conversions::to_string_t("")) + /// file to upload (optional, default to utility::conversions::to_string_t("")) + pplx::task> uploadFile( + int64_t petId, + boost::optional additionalMetadata, + boost::optional> file + ) const; + +protected: + std::shared_ptr m_ApiClient; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ */ + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/api/StoreApi.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/api/StoreApi.h new file mode 100644 index 000000000000..e030a86d67ea --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/api/StoreApi.h @@ -0,0 +1,96 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * StoreApi.h + * + * + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ +#define ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ + + + +#include "CppRestPetstoreClient/ApiClient.h" + +#include "CppRestPetstoreClient/model/Order.h" +#include +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +using namespace org::openapitools::client::model; + + + +class StoreApi +{ +public: + + explicit StoreApi( std::shared_ptr apiClient ); + + virtual ~StoreApi(); + + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + pplx::task deleteOrder( + utility::string_t orderId + ) const; + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + pplx::task> getInventory( + ) const; + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// + /// ID of pet that needs to be fetched + pplx::task> getOrderById( + int64_t orderId + ) const; + /// + /// Place an order for a pet + /// + /// + /// + /// + /// order placed for purchasing the pet + pplx::task> placeOrder( + std::shared_ptr order + ) const; + +protected: + std::shared_ptr m_ApiClient; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ */ + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/api/UserApi.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/api/UserApi.h new file mode 100644 index 000000000000..9e0c7b544f93 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/api/UserApi.h @@ -0,0 +1,140 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * UserApi.h + * + * + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ +#define ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ + + + +#include "CppRestPetstoreClient/ApiClient.h" + +#include "CppRestPetstoreClient/model/User.h" +#include +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +using namespace org::openapitools::client::model; + + + +class UserApi +{ +public: + + explicit UserApi( std::shared_ptr apiClient ); + + virtual ~UserApi(); + + /// + /// Create user + /// + /// + /// This can only be done by the logged in user. + /// + /// Created user object + pplx::task createUser( + std::shared_ptr user + ) const; + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + pplx::task createUsersWithArrayInput( + std::vector> user + ) const; + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + pplx::task createUsersWithListInput( + std::vector> user + ) const; + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + pplx::task deleteUser( + utility::string_t username + ) const; + /// + /// Get user by user name + /// + /// + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + pplx::task> getUserByName( + utility::string_t username + ) const; + /// + /// Logs user into the system + /// + /// + /// + /// + /// The user name for login + /// The password for login in clear text + pplx::task loginUser( + utility::string_t username, + utility::string_t password + ) const; + /// + /// Logs out current logged in user session + /// + /// + /// + /// + pplx::task logoutUser( + ) const; + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + pplx::task updateUser( + utility::string_t username, + std::shared_ptr user + ) const; + +protected: + std::shared_ptr m_ApiClient; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ */ + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/ApiResponse.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/ApiResponse.h new file mode 100644 index 000000000000..f76ed8bc6c1c --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/ApiResponse.h @@ -0,0 +1,99 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * ApiResponse.h + * + * Describes the result of uploading an image resource + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + +/// +/// Describes the result of uploading an image resource +/// +class ApiResponse + : public ModelBase +{ +public: + ApiResponse(); + virtual ~ApiResponse(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// ApiResponse members + + /// + /// + /// + int32_t getCode() const; + bool codeIsSet() const; + void unsetCode(); + + void setCode(int32_t value); + + /// + /// + /// + utility::string_t getType() const; + bool typeIsSet() const; + void unsetType(); + + void setType(const utility::string_t& value); + + /// + /// + /// + utility::string_t getMessage() const; + bool messageIsSet() const; + void unsetMessage(); + + void setMessage(const utility::string_t& value); + + +protected: + int32_t m_Code; + bool m_CodeIsSet; + utility::string_t m_Type; + bool m_TypeIsSet; + utility::string_t m_Message; + bool m_MessageIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Category.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Category.h new file mode 100644 index 000000000000..f2f3052a1529 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Category.h @@ -0,0 +1,88 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * Category.h + * + * A category for a pet + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + +/// +/// A category for a pet +/// +class Category + : public ModelBase +{ +public: + Category(); + virtual ~Category(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Category members + + /// + /// + /// + int64_t getId() const; + bool idIsSet() const; + void unsetId(); + + void setId(int64_t value); + + /// + /// + /// + utility::string_t getName() const; + bool nameIsSet() const; + void unsetName(); + + void setName(const utility::string_t& value); + + +protected: + int64_t m_Id; + bool m_IdIsSet; + utility::string_t m_Name; + bool m_NameIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Order.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Order.h new file mode 100644 index 000000000000..fd1deb8c03b9 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Order.h @@ -0,0 +1,132 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * Order.h + * + * An order for a pets from the pet store + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + +/// +/// An order for a pets from the pet store +/// +class Order + : public ModelBase +{ +public: + Order(); + virtual ~Order(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Order members + + /// + /// + /// + int64_t getId() const; + bool idIsSet() const; + void unsetId(); + + void setId(int64_t value); + + /// + /// + /// + int64_t getPetId() const; + bool petIdIsSet() const; + void unsetPetId(); + + void setPetId(int64_t value); + + /// + /// + /// + int32_t getQuantity() const; + bool quantityIsSet() const; + void unsetQuantity(); + + void setQuantity(int32_t value); + + /// + /// + /// + utility::datetime getShipDate() const; + bool shipDateIsSet() const; + void unsetShipDate(); + + void setShipDate(const utility::datetime& value); + + /// + /// Order Status + /// + utility::string_t getStatus() const; + bool statusIsSet() const; + void unsetStatus(); + + void setStatus(const utility::string_t& value); + + /// + /// + /// + bool isComplete() const; + bool completeIsSet() const; + void unsetComplete(); + + void setComplete(bool value); + + +protected: + int64_t m_Id; + bool m_IdIsSet; + int64_t m_PetId; + bool m_PetIdIsSet; + int32_t m_Quantity; + bool m_QuantityIsSet; + utility::datetime m_ShipDate; + bool m_ShipDateIsSet; + utility::string_t m_Status; + bool m_StatusIsSet; + bool m_Complete; + bool m_CompleteIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Pet.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Pet.h new file mode 100644 index 000000000000..545ab9816c84 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Pet.h @@ -0,0 +1,186 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * Pet.h + * + * A pet for sale in the pet store + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include "CppRestPetstoreClient/model/Tag.h" +#include "CppRestPetstoreClient/model/Category.h" +#include +#include "CppRestPetstoreClient/Object.h" +#include "CppRestPetstoreClient/model/Pet_vaccinationBook.h" +#include +#include "CppRestPetstoreClient/AnyType.h" +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class Category; +class Tag; +class Pet_vaccinationBook; + +/// +/// A pet for sale in the pet store +/// +class Pet + : public ModelBase +{ +public: + Pet(); + virtual ~Pet(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Pet members + + /// + /// + /// + int64_t getId() const; + bool idIsSet() const; + void unsetId(); + + void setId(int64_t value); + + /// + /// + /// + std::shared_ptr getCategory() const; + bool categoryIsSet() const; + void unsetCategory(); + + void setCategory(const std::shared_ptr& value); + + /// + /// + /// + utility::string_t getName() const; + bool nameIsSet() const; + void unsetName(); + + void setName(const utility::string_t& value); + + /// + /// + /// + std::vector& getPhotoUrls(); + bool photoUrlsIsSet() const; + void unsetPhotoUrls(); + + void setPhotoUrls(const std::vector& value); + + /// + /// + /// + std::vector>& getTags(); + bool tagsIsSet() const; + void unsetTags(); + + void setTags(const std::vector>& value); + + /// + /// pet status in the store + /// + utility::string_t getStatus() const; + bool statusIsSet() const; + void unsetStatus(); + + void setStatus(const utility::string_t& value); + + /// + /// last veterinarian visit advice + /// + std::shared_ptr getVeterinarianVisit() const; + bool veterinarianVisitIsSet() const; + void unsetVeterinarianVisit(); + + void setVeterinarianVisit(const std::shared_ptr& value); + + /// + /// to help you installing your pet at home + /// + std::vector>& getGoodies(); + bool goodiesIsSet() const; + void unsetGoodies(); + + void setGoodies(const std::vector>& value); + + /// + /// pedigree and other certificates + /// + std::set& getCertificates(); + bool certificatesIsSet() const; + void unsetCertificates(); + + void setCertificates(const std::set& value); + + /// + /// + /// + std::shared_ptr getVaccinationBook() const; + bool vaccinationBookIsSet() const; + void unsetVaccinationBook(); + + void setVaccinationBook(const std::shared_ptr& value); + + +protected: + int64_t m_Id; + bool m_IdIsSet; + std::shared_ptr m_Category; + bool m_CategoryIsSet; + utility::string_t m_Name; + bool m_NameIsSet; + std::vector m_PhotoUrls; + bool m_PhotoUrlsIsSet; + std::vector> m_Tags; + bool m_TagsIsSet; + utility::string_t m_Status; + bool m_StatusIsSet; + std::shared_ptr m_VeterinarianVisit; + bool m_VeterinarianVisitIsSet; + std::vector> m_Goodies; + bool m_GoodiesIsSet; + std::set m_Certificates; + bool m_CertificatesIsSet; + std::shared_ptr m_VaccinationBook; + bool m_VaccinationBookIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Pet_vaccinationBook.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Pet_vaccinationBook.h new file mode 100644 index 000000000000..e82de6ab65aa --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Pet_vaccinationBook.h @@ -0,0 +1,79 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * Pet_vaccinationBook.h + * + * Vaccination book of the pet + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include "CppRestPetstoreClient/model/Vaccine.h" +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class Vaccine; + +/// +/// Vaccination book of the pet +/// +class Pet_vaccinationBook + : public ModelBase +{ +public: + Pet_vaccinationBook(); + virtual ~Pet_vaccinationBook(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Pet_vaccinationBook members + + /// + /// + /// + std::set>& getVaccines(); + bool vaccinesIsSet() const; + void unsetVaccines(); + + void setVaccines(const std::set>& value); + + +protected: + std::set> m_Vaccines; + bool m_VaccinesIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Tag.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Tag.h new file mode 100644 index 000000000000..ab2cc68dd217 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Tag.h @@ -0,0 +1,88 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * Tag.h + * + * A tag for a pet + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + +/// +/// A tag for a pet +/// +class Tag + : public ModelBase +{ +public: + Tag(); + virtual ~Tag(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Tag members + + /// + /// + /// + int64_t getId() const; + bool idIsSet() const; + void unsetId(); + + void setId(int64_t value); + + /// + /// + /// + utility::string_t getName() const; + bool nameIsSet() const; + void unsetName(); + + void setName(const utility::string_t& value); + + +protected: + int64_t m_Id; + bool m_IdIsSet; + utility::string_t m_Name; + bool m_NameIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/User.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/User.h new file mode 100644 index 000000000000..09ef969ca36f --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/User.h @@ -0,0 +1,154 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * User.h + * + * A User who is purchasing from the pet store + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + +/// +/// A User who is purchasing from the pet store +/// +class User + : public ModelBase +{ +public: + User(); + virtual ~User(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// User members + + /// + /// + /// + int64_t getId() const; + bool idIsSet() const; + void unsetId(); + + void setId(int64_t value); + + /// + /// + /// + utility::string_t getUsername() const; + bool usernameIsSet() const; + void unsetUsername(); + + void setUsername(const utility::string_t& value); + + /// + /// + /// + utility::string_t getFirstName() const; + bool firstNameIsSet() const; + void unsetFirstName(); + + void setFirstName(const utility::string_t& value); + + /// + /// + /// + utility::string_t getLastName() const; + bool lastNameIsSet() const; + void unsetLastName(); + + void setLastName(const utility::string_t& value); + + /// + /// + /// + utility::string_t getEmail() const; + bool emailIsSet() const; + void unsetEmail(); + + void setEmail(const utility::string_t& value); + + /// + /// + /// + utility::string_t getPassword() const; + bool passwordIsSet() const; + void unsetPassword(); + + void setPassword(const utility::string_t& value); + + /// + /// + /// + utility::string_t getPhone() const; + bool phoneIsSet() const; + void unsetPhone(); + + void setPhone(const utility::string_t& value); + + /// + /// User Status + /// + int32_t getUserStatus() const; + bool userStatusIsSet() const; + void unsetUserStatus(); + + void setUserStatus(int32_t value); + + +protected: + int64_t m_Id; + bool m_IdIsSet; + utility::string_t m_Username; + bool m_UsernameIsSet; + utility::string_t m_FirstName; + bool m_FirstNameIsSet; + utility::string_t m_LastName; + bool m_LastNameIsSet; + utility::string_t m_Email; + bool m_EmailIsSet; + utility::string_t m_Password; + bool m_PasswordIsSet; + utility::string_t m_Phone; + bool m_PhoneIsSet; + int32_t m_UserStatus; + bool m_UserStatusIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Vaccine.h b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Vaccine.h new file mode 100644 index 000000000000..81eceace2a77 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/include/CppRestPetstoreClient/model/Vaccine.h @@ -0,0 +1,88 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * Vaccine.h + * + * + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include "CppRestPetstoreClient/AnyType.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + +/// +/// +/// +class Vaccine + : public ModelBase +{ +public: + Vaccine(); + virtual ~Vaccine(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Vaccine members + + /// + /// vaccination date + /// + std::shared_ptr getDate() const; + bool dateIsSet() const; + void unsetdate(); + + void setDate(const std::shared_ptr& value); + + /// + /// true if a booster is still needed to complete the vaccination + /// + bool isBoosterRequired() const; + bool boosterRequiredIsSet() const; + void unsetBoosterRequired(); + + void setBoosterRequired(bool value); + + +protected: + std::shared_ptr m_date; + bool m_dateIsSet; + bool m_BoosterRequired; + bool m_BoosterRequiredIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/AnyType.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/AnyType.cpp new file mode 100644 index 000000000000..a04a2692c6ac --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/AnyType.cpp @@ -0,0 +1,52 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +#include "CppRestPetstoreClient/AnyType.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +AnyType::AnyType() { m_value = web::json::value::null(); } + +AnyType::~AnyType() {} + +void AnyType::validate() {} + +web::json::value AnyType::toJson() const { return m_value; } + +bool AnyType::fromJson(const web::json::value &val) { + m_value = val; + m_IsSet = true; + return isSet(); +} + +void AnyType::toMultipart(std::shared_ptr multipart, + const utility::string_t &prefix) const { + if (m_value.is_object()) { + return Object::toMultipart(multipart, prefix); + } + throw std::runtime_error("AnyType::toMultipart: unsupported type"); +} + +bool AnyType::fromMultiPart(std::shared_ptr multipart, + const utility::string_t &prefix) { + if (m_value.is_object()) { + return Object::fromMultiPart(multipart, prefix); + } + return false; +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/ApiClient.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/ApiClient.cpp new file mode 100644 index 000000000000..59db8802160e --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/ApiClient.cpp @@ -0,0 +1,208 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +#include "CppRestPetstoreClient/ApiClient.h" +#include "CppRestPetstoreClient/MultipartFormData.h" +#include "CppRestPetstoreClient/ModelBase.h" + +#include +#include +#include + +template +utility::string_t toString(const T value) +{ + utility::ostringstream_t out; + out << std::setprecision(std::numeric_limits::digits10) << std::fixed << value; + return out.str(); +} + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +using namespace org::openapitools::client::model; + +ApiClient::ApiClient(std::shared_ptr configuration ) + : m_Configuration(configuration) +{ +} +ApiClient::~ApiClient() +{ +} + +const ApiClient::ResponseHandlerType& ApiClient::getResponseHandler() const { + return m_ResponseHandler; +} + +void ApiClient::setResponseHandler(const ResponseHandlerType& responseHandler) { + m_ResponseHandler = responseHandler; +} + +std::shared_ptr ApiClient::getConfiguration() const +{ + return m_Configuration; +} +void ApiClient::setConfiguration(std::shared_ptr configuration) +{ + m_Configuration = configuration; +} + + +utility::string_t ApiClient::parameterToString(utility::string_t value) +{ + return value; +} +utility::string_t ApiClient::parameterToString(int64_t value) +{ + std::stringstream valueAsStringStream; + valueAsStringStream << value; + return utility::conversions::to_string_t(valueAsStringStream.str()); +} +utility::string_t ApiClient::parameterToString(int32_t value) +{ + std::stringstream valueAsStringStream; + valueAsStringStream << value; + return utility::conversions::to_string_t(valueAsStringStream.str()); +} + +utility::string_t ApiClient::parameterToString(float value) +{ + return utility::conversions::to_string_t(toString(value)); +} + +utility::string_t ApiClient::parameterToString(double value) +{ + return utility::conversions::to_string_t(toString(value)); +} + +utility::string_t ApiClient::parameterToString(const utility::datetime &value) +{ + return utility::conversions::to_string_t(value.to_string(utility::datetime::ISO_8601)); +} + +utility::string_t ApiClient::parameterToString(bool value) +{ + std::stringstream valueAsStringStream; + valueAsStringStream << std::boolalpha << value; + return utility::conversions::to_string_t(valueAsStringStream.str()); +} + +pplx::task ApiClient::callApi( + const utility::string_t& path, + const utility::string_t& method, + const std::map& queryParams, + const std::shared_ptr postBody, + const std::map& headerParams, + const std::map& formParams, + const std::map>& fileParams, + const utility::string_t& contentType +) const +{ + if (postBody != nullptr && formParams.size() != 0) + { + throw ApiException(400, utility::conversions::to_string_t("Cannot have body and form params")); + } + + if (postBody != nullptr && fileParams.size() != 0) + { + throw ApiException(400, utility::conversions::to_string_t("Cannot have body and file params")); + } + + if (fileParams.size() > 0 && contentType != utility::conversions::to_string_t("multipart/form-data")) + { + throw ApiException(400, utility::conversions::to_string_t("Operations with file parameters must be called with multipart/form-data")); + } + + web::http::client::http_client client(m_Configuration->getBaseUrl(), m_Configuration->getHttpConfig()); + + web::http::http_request request; + for (const auto& kvp : headerParams) + { + request.headers().add(kvp.first, kvp.second); + } + + if (fileParams.size() > 0) + { + MultipartFormData uploadData; + for (const auto& kvp : formParams) + { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + } + for (const auto& kvp : fileParams) + { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + } + std::stringstream data; + uploadData.writeTo(data); + auto bodyString = data.str(); + const auto length = bodyString.size(); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, utility::conversions::to_string_t("multipart/form-data; boundary=") + uploadData.getBoundary()); + } + else + { + if (postBody != nullptr) + { + std::stringstream data; + postBody->writeTo(data); + auto bodyString = data.str(); + const auto length = bodyString.size(); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType); + } + else + { + if (contentType == utility::conversions::to_string_t("application/json")) + { + web::json::value body_data = web::json::value::object(); + for (auto& kvp : formParams) + { + body_data[kvp.first] = ModelBase::toJson(kvp.second); + } + if (!formParams.empty()) + { + request.set_body(body_data); + } + } + else + { + web::http::uri_builder formData; + for (const auto& kvp : formParams) + { + formData.append_query(kvp.first, kvp.second); + } + if (!formParams.empty()) + { + request.set_body(formData.query(), utility::conversions::to_string_t("application/x-www-form-urlencoded")); + } + } + } + } + + web::http::uri_builder builder(path); + for (const auto& kvp : queryParams) + { + builder.append_query(kvp.first, kvp.second); + } + request.set_request_uri(builder.to_uri()); + request.set_method(method); + if ( !request.headers().has( web::http::header_names::user_agent ) ) + { + request.headers().add( web::http::header_names::user_agent, m_Configuration->getUserAgent() ); + } + + return client.request(request); +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/ApiConfiguration.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/ApiConfiguration.cpp new file mode 100644 index 000000000000..262b65d43c16 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/ApiConfiguration.cpp @@ -0,0 +1,85 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +#include "CppRestPetstoreClient/ApiConfiguration.h" + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +ApiConfiguration::ApiConfiguration() +{ +} + +ApiConfiguration::~ApiConfiguration() +{ +} + +const web::http::client::http_client_config& ApiConfiguration::getHttpConfig() const +{ + return m_HttpConfig; +} + +void ApiConfiguration::setHttpConfig( web::http::client::http_client_config& value ) +{ + m_HttpConfig = value; +} + +utility::string_t ApiConfiguration::getBaseUrl() const +{ + return m_BaseUrl; +} + +void ApiConfiguration::setBaseUrl( const utility::string_t value ) +{ + m_BaseUrl = value; +} + +utility::string_t ApiConfiguration::getUserAgent() const +{ + return m_UserAgent; +} + +void ApiConfiguration::setUserAgent( const utility::string_t value ) +{ + m_UserAgent = value; +} + +std::map& ApiConfiguration::getDefaultHeaders() +{ + return m_DefaultHeaders; +} + +const std::map& ApiConfiguration::getDefaultHeaders() const +{ + return m_DefaultHeaders; +} + +utility::string_t ApiConfiguration::getApiKey( const utility::string_t& prefix) const +{ + auto result = m_ApiKeys.find(prefix); + if( result != m_ApiKeys.end() ) + { + return result->second; + } + return utility::conversions::to_string_t(""); +} + +void ApiConfiguration::setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ) +{ + m_ApiKeys[prefix] = apiKey; +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/ApiException.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/ApiException.cpp new file mode 100644 index 000000000000..f95842f0561a --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/ApiException.cpp @@ -0,0 +1,53 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +#include "CppRestPetstoreClient/ApiException.h" + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +ApiException::ApiException( int errorCode + , const utility::string_t& message + , std::shared_ptr content /*= nullptr*/ ) + : web::http::http_exception( errorCode, message ) + , m_Content(content) +{ +} +ApiException::ApiException( int errorCode + , const utility::string_t& message + , std::map& headers + , std::shared_ptr content /*= nullptr*/ ) + : web::http::http_exception( errorCode, message ) + , m_Content(content) + , m_Headers(headers) +{ +} + +ApiException::~ApiException() +{ +} + +std::shared_ptr ApiException::getContent() const +{ + return m_Content; +} + +std::map& ApiException::getHeaders() +{ + return m_Headers; +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/HttpContent.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/HttpContent.cpp new file mode 100644 index 000000000000..64d485baa4b0 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/HttpContent.cpp @@ -0,0 +1,86 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +#include "CppRestPetstoreClient/HttpContent.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +HttpContent::HttpContent() +{ +} + +HttpContent::~HttpContent() +{ +} + +utility::string_t HttpContent::getContentDisposition() const +{ + return m_ContentDisposition; +} + +void HttpContent::setContentDisposition( const utility::string_t & value ) +{ + m_ContentDisposition = value; +} + +utility::string_t HttpContent::getName() const +{ + return m_Name; +} + +void HttpContent::setName( const utility::string_t & value ) +{ + m_Name = value; +} + +utility::string_t HttpContent::getFileName() const +{ + return m_FileName; +} + +void HttpContent::setFileName( const utility::string_t & value ) +{ + m_FileName = value; +} + +utility::string_t HttpContent::getContentType() const +{ + return m_ContentType; +} + +void HttpContent::setContentType( const utility::string_t & value ) +{ + m_ContentType = value; +} + +std::shared_ptr HttpContent::getData() const +{ + return m_Data; +} + +void HttpContent::setData( std::shared_ptr value ) +{ + m_Data = value; +} + +void HttpContent::writeTo( std::ostream& stream ) +{ + m_Data->seekg( 0, m_Data->beg ); + stream << m_Data->rdbuf(); +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/JsonBody.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/JsonBody.cpp new file mode 100644 index 000000000000..96c4e969668c --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/JsonBody.cpp @@ -0,0 +1,36 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +#include "CppRestPetstoreClient/JsonBody.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +JsonBody::JsonBody( const web::json::value& json) + : m_Json(json) +{ +} + +JsonBody::~JsonBody() +{ +} + +void JsonBody::writeTo( std::ostream& target ) +{ + m_Json.serialize(target); +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/ModelBase.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/ModelBase.cpp new file mode 100644 index 000000000000..2d0362910b59 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/ModelBase.cpp @@ -0,0 +1,665 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +#include "CppRestPetstoreClient/ModelBase.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +ModelBase::ModelBase(): m_IsSet(false) +{ +} +ModelBase::~ModelBase() +{ +} +bool ModelBase::isSet() const +{ + return m_IsSet; +} +utility::string_t ModelBase::toString( const bool val ) +{ + utility::stringstream_t ss; + ss << val; + return utility::string_t(ss.str()); +} +utility::string_t ModelBase::toString( const float val ) +{ + utility::stringstream_t ss; + ss << val; + return utility::string_t(ss.str()); +} +utility::string_t ModelBase::toString( const double val ) +{ + utility::stringstream_t ss; + ss << val; + return utility::string_t(ss.str()); +} +utility::string_t ModelBase::toString( const int32_t val ) +{ + utility::stringstream_t ss; + ss << val; + return utility::string_t(ss.str()); +} +utility::string_t ModelBase::toString( const int64_t val ) +{ + utility::stringstream_t ss; + ss << val; + return utility::string_t(ss.str()); +} +utility::string_t ModelBase::toString (const utility::string_t &val ) +{ + utility::stringstream_t ss; + ss << val; + return utility::string_t(ss.str()); +} +utility::string_t ModelBase::toString( const utility::datetime &val ) +{ + return val.to_string(utility::datetime::ISO_8601); +} +utility::string_t ModelBase::toString( const web::json::value &val ) +{ + return val.serialize(); +} +utility::string_t ModelBase::toString( const std::shared_ptr& val ) +{ + utility::stringstream_t ss; + if( val != nullptr ) + { + ss << val->getData(); + } + return utility::string_t(ss.str()); +} +web::json::value ModelBase::toJson(bool value) +{ + return web::json::value::boolean(value); +} +web::json::value ModelBase::toJson( float value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( double value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( int32_t value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( int64_t value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( const utility::string_t& value ) +{ + return web::json::value::string(value); +} +web::json::value ModelBase::toJson( const utility::datetime& value ) +{ + return web::json::value::string(value.to_string(utility::datetime::ISO_8601)); +} +web::json::value ModelBase::toJson( const web::json::value& value ) +{ + return value; +} +web::json::value ModelBase::toJson( const std::shared_ptr& content ) +{ + web::json::value value; + if(content != nullptr) + { + value[utility::conversions::to_string_t("ContentDisposition")] = ModelBase::toJson(content->getContentDisposition()); + value[utility::conversions::to_string_t("ContentType")] = ModelBase::toJson(content->getContentType()); + value[utility::conversions::to_string_t("FileName")] = ModelBase::toJson(content->getFileName()); + value[utility::conversions::to_string_t("InputStream")] = web::json::value::string( ModelBase::toBase64(content->getData()) ); + } + return value; +} +web::json::value ModelBase::toJson( const std::shared_ptr& val ) +{ + web::json::value retVal; + if(val != nullptr) + { + retVal = toJson(*val); + } + return retVal; +} +bool ModelBase::fromString( const utility::string_t& val, bool &outVal ) +{ + utility::stringstream_t ss(val); + bool success = true; + try + { + ss >> outVal; + } + catch (...) + { + success = false; + } + return success; +} +bool ModelBase::fromString( const utility::string_t& val, float &outVal ) +{ + utility::stringstream_t ss(val); + bool success = true; + try + { + ss >> outVal; + } + catch (...) + { + int64_t intVal = 0; + success = ModelBase::fromString(val, intVal); + if(success) + { + outVal = static_cast(intVal); + } + } + return success; +} +bool ModelBase::fromString( const utility::string_t& val, double &outVal ) +{ + utility::stringstream_t ss(val); + bool success = true; + try + { + ss >> outVal; + } + catch (...) + { + int64_t intVal = 0; + success = ModelBase::fromString(val, intVal); + if(success) + { + outVal = static_cast(intVal); + } + } + return success; +} +bool ModelBase::fromString( const utility::string_t& val, int32_t &outVal ) +{ + utility::stringstream_t ss(val); + bool success = true; + try + { + ss >> outVal; + } + catch (...) + { + success = false; + } + return success; +} +bool ModelBase::fromString( const utility::string_t& val, int64_t &outVal ) +{ + utility::stringstream_t ss(val); + bool success = true; + try + { + ss >> outVal; + } + catch (...) + { + success = false; + } + return success; +} +bool ModelBase::fromString( const utility::string_t& val, utility::string_t &outVal ) +{ + utility::stringstream_t ss(val); + bool success = true; + try + { + ss >> outVal; + } + catch (...) + { + success = false; + } + return success; +} +bool ModelBase::fromString( const utility::string_t& val, utility::datetime &outVal ) +{ + bool success = true; + auto dt = utility::datetime::from_string(val, utility::datetime::ISO_8601); + if( dt.is_initialized() ) + { + outVal = dt; + } + else + { + success = false; + } + return success; +} +bool ModelBase::fromString( const utility::string_t& val, web::json::value &outVal ) +{ + outVal = web::json::value::parse(val); + return !outVal.is_null(); +} +bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr& outVal ) +{ + bool ok = true; + if(outVal == nullptr) + { + outVal = std::shared_ptr(new HttpContent()); + } + if(outVal != nullptr) + { + outVal->setData(std::shared_ptr(new std::stringstream(utility::conversions::to_utf8string(val)))); + } + else + { + ok = false; + } + return ok; +} +bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr& outVal ) +{ + bool ok = false; + if(outVal == nullptr) + { + outVal = std::shared_ptr(new utility::datetime()); + } + if( outVal != nullptr ) + { + ok = fromJson(web::json::value::parse(val), *outVal); + } + return ok; +} +bool ModelBase::fromJson( const web::json::value& val, bool & outVal ) +{ + outVal = !val.is_boolean() ? false : val.as_bool(); + return val.is_boolean(); +} +bool ModelBase::fromJson( const web::json::value& val, float & outVal ) +{ + outVal = (!val.is_double() && !val.is_integer()) ? std::numeric_limits::quiet_NaN(): static_cast(val.as_double()); + return val.is_double() || val.is_integer(); +} +bool ModelBase::fromJson( const web::json::value& val, double & outVal ) +{ + outVal = (!val.is_double() && !val.is_integer()) ? std::numeric_limits::quiet_NaN(): val.as_double(); + return val.is_double() || val.is_integer(); +} +bool ModelBase::fromJson( const web::json::value& val, int32_t & outVal ) +{ + outVal = !val.is_integer() ? std::numeric_limits::quiet_NaN() : val.as_integer(); + return val.is_integer(); +} +bool ModelBase::fromJson( const web::json::value& val, int64_t & outVal ) +{ + outVal = !val.is_number() ? std::numeric_limits::quiet_NaN() : val.as_number().to_int64(); + return val.is_number(); +} +bool ModelBase::fromJson( const web::json::value& val, utility::string_t & outVal ) +{ + outVal = val.is_string() ? val.as_string() : utility::conversions::to_string_t(""); + return val.is_string(); +} +bool ModelBase::fromJson( const web::json::value& val, utility::datetime & outVal ) +{ + outVal = val.is_null() ? utility::datetime::from_string(utility::conversions::to_string_t("NULL"), utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601); + return outVal.is_initialized(); +} +bool ModelBase::fromJson( const web::json::value& val, web::json::value & outVal ) +{ + outVal = val; + return !val.is_null(); +} +bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr& content ) +{ + bool result = false; + if( content != nullptr) + { + result = true; + if(content == nullptr) + { + content = std::shared_ptr(new HttpContent()); + } + if(val.has_field(utility::conversions::to_string_t("ContentDisposition"))) + { + utility::string_t value; + result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("ContentDisposition")), value); + content->setContentDisposition( value ); + } + if(val.has_field(utility::conversions::to_string_t("ContentType"))) + { + utility::string_t value; + result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("ContentType")), value); + content->setContentType( value ); + } + if(val.has_field(utility::conversions::to_string_t("FileName"))) + { + utility::string_t value; + result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("FileName")), value); + content->setFileName( value ); + } + if(val.has_field(utility::conversions::to_string_t("InputStream"))) + { + utility::string_t value; + result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("InputStream")), value); + content->setData( ModelBase::fromBase64( value ) ); + } + } + return result; +} +bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr &outVal ) +{ + bool ok = false; + if(outVal == nullptr) + { + outVal = std::shared_ptr(new utility::datetime()); + } + if( outVal != nullptr ) + { + ok = fromJson(val, *outVal); + } + return ok; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + std::stringstream* valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData( std::shared_ptr( valueAsStringStream ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, float value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + std::stringstream* valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData( std::shared_ptr( valueAsStringStream ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + std::stringstream* valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData( std::shared_ptr( valueAsStringStream ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + std::stringstream* valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData( std::shared_ptr( valueAsStringStream ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + std::stringstream* valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData( std::shared_ptr( valueAsStringStream) ) ; + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType) +{ + std::shared_ptr content(new HttpContent); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(value) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601) ) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(value.serialize()) ) ) ); + return content; +} +std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const std::shared_ptr& value ) +{ + std::shared_ptr content( new HttpContent ); + if( value != nullptr ) + { + content->setName( name ); + content->setContentDisposition( value->getContentDisposition() ); + content->setContentType( value->getContentType() ); + content->setData( value->getData() ); + content->setFileName( value->getFileName() ); + } + return content; +} +std::shared_ptr ModelBase::toHttpContent(const utility::string_t& name, const std::shared_ptr& value , const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + if (value != nullptr ) + { + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string( toJson(*value).serialize() ) ) ) ); + } + return content; +} +bool ModelBase::fromHttpContent(std::shared_ptr val, bool & outVal ) +{ + utility::string_t str; + if( val == nullptr ) return false; + ModelBase::fromHttpContent(val, str); + return fromString(str, outVal); +} +bool ModelBase::fromHttpContent(std::shared_ptr val, float & outVal ) +{ + utility::string_t str; + if( val == nullptr ) return false; + ModelBase::fromHttpContent(val, str); + return fromString(str, outVal); +} +bool ModelBase::fromHttpContent(std::shared_ptr val, double & outVal ) +{ + utility::string_t str; + if( val == nullptr ) return false; + ModelBase::fromHttpContent(val, str); + return fromString(str, outVal); +} +bool ModelBase::fromHttpContent(std::shared_ptr val, int32_t & outVal ) +{ + utility::string_t str; + if( val == nullptr ) return false; + ModelBase::fromHttpContent(val, str); + return fromString(str, outVal); +} +bool ModelBase::fromHttpContent(std::shared_ptr val, int64_t & outVal ) +{ + utility::string_t str; + if( val == nullptr ) return false; + ModelBase::fromHttpContent(val, str); + return fromString(str, outVal); +} +bool ModelBase::fromHttpContent(std::shared_ptr val, utility::string_t & outVal ) +{ + if( val == nullptr ) return false; + std::shared_ptr data = val->getData(); + data->seekg( 0, data->beg ); + + std::string str((std::istreambuf_iterator(*data.get())), + std::istreambuf_iterator()); + outVal = utility::conversions::to_string_t(str); + return true; +} +bool ModelBase::fromHttpContent(std::shared_ptr val, utility::datetime & outVal ) +{ + utility::string_t str; + if( val == nullptr ) return false; + ModelBase::fromHttpContent(val, str); + outVal = utility::datetime::from_string(str, utility::datetime::ISO_8601); + return true; +} +bool ModelBase::fromHttpContent(std::shared_ptr val, web::json::value & outVal ) +{ + utility::string_t str; + if( val == nullptr ) return false; + ModelBase::fromHttpContent(val, str); + return fromString(str, outVal); +} +bool ModelBase::fromHttpContent(std::shared_ptr val, std::shared_ptr& outVal ) +{ + utility::string_t str; + if( val == nullptr ) return false; + if( outVal == nullptr ) + { + outVal = std::shared_ptr(new HttpContent()); + } + ModelBase::fromHttpContent(val, str); + return fromString(str, outVal); +} +// base64 encoding/decoding based on : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B +const static char Base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +const static char Base64PadChar = '='; +utility::string_t ModelBase::toBase64( utility::string_t value ) +{ + std::shared_ptr source( new std::stringstream( utility::conversions::to_utf8string(value) ) ); + return ModelBase::toBase64(source); +} +utility::string_t ModelBase::toBase64( std::shared_ptr value ) +{ + value->seekg( 0, value->end ); + size_t length = value->tellg(); + value->seekg( 0, value->beg ); + utility::string_t base64; + base64.reserve( ((length / 3) + (length % 3 > 0)) * 4 ); + char read[3] = { 0 }; + uint32_t temp; + for ( size_t idx = 0; idx < length / 3; idx++ ) + { + value->read( read, 3 ); + temp = (read[0]) << 16; + temp += (read[1]) << 8; + temp += (read[2]); + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); + base64.append( 1, Base64Chars[(temp & 0x0000003F)] ); + } + switch ( length % 3 ) + { + case 1: + value->read( read, 1 ); + temp = read[0] << 16; + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 2, Base64PadChar ); + break; + case 2: + value->read( read, 2 ); + temp = read[0] << 16; + temp += read[1] << 8; + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); + base64.append( 1, Base64PadChar ); + break; + } + return base64; +} +std::shared_ptr ModelBase::fromBase64( const utility::string_t& encoded ) +{ + std::shared_ptr result(new std::stringstream); + + char outBuf[3] = { 0 }; + uint32_t temp = 0; + + utility::string_t::const_iterator cursor = encoded.begin(); + while ( cursor < encoded.end() ) + { + for ( size_t quantumPosition = 0; quantumPosition < 4; quantumPosition++ ) + { + temp <<= 6; + if ( *cursor >= 0x41 && *cursor <= 0x5A ) + { + temp |= *cursor - 0x41; + } + else if ( *cursor >= 0x61 && *cursor <= 0x7A ) + { + temp |= *cursor - 0x47; + } + else if ( *cursor >= 0x30 && *cursor <= 0x39 ) + { + temp |= *cursor + 0x04; + } + else if ( *cursor == 0x2B ) + { + temp |= 0x3E; //change to 0x2D for URL alphabet + } + else if ( *cursor == 0x2F ) + { + temp |= 0x3F; //change to 0x5F for URL alphabet + } + else if ( *cursor == Base64PadChar ) //pad + { + switch ( encoded.end() - cursor ) + { + case 1: //One pad character + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + result->write( outBuf, 2 ); + return result; + case 2: //Two pad characters + outBuf[0] = (temp >> 10) & 0x000000FF; + result->write( outBuf, 1 ); + return result; + default: + throw web::json::json_exception( utility::conversions::to_string_t( "Invalid Padding in Base 64!" ).c_str() ); + } + } + else + { + throw web::json::json_exception( utility::conversions::to_string_t( "Non-Valid Character in Base 64!" ).c_str() ); + } + ++cursor; + } + + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + outBuf[2] = (temp) & 0x000000FF; + result->write( outBuf, 3 ); + } + + return result; +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/MultipartFormData.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/MultipartFormData.cpp new file mode 100644 index 000000000000..9bf32a946a73 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/MultipartFormData.cpp @@ -0,0 +1,112 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +#include "CppRestPetstoreClient/MultipartFormData.h" +#include "CppRestPetstoreClient/ModelBase.h" + +#include +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +MultipartFormData::MultipartFormData() +{ + utility::stringstream_t uuidString; + uuidString << boost::uuids::random_generator()(); + m_Boundary = uuidString.str(); +} + +MultipartFormData::MultipartFormData(const utility::string_t& boundary) + : m_Boundary(boundary) +{ + +} + +MultipartFormData::~MultipartFormData() +{ +} + +utility::string_t MultipartFormData::getBoundary() +{ + return m_Boundary; +} + +void MultipartFormData::add( std::shared_ptr content ) +{ + m_Contents.push_back( content ); + m_ContentLookup[content->getName()] = content; +} + +bool MultipartFormData::hasContent(const utility::string_t& name) const +{ + return m_ContentLookup.find(name) != m_ContentLookup.end(); +} + +std::shared_ptr MultipartFormData::getContent(const utility::string_t& name) const +{ + auto result = m_ContentLookup.find(name); + if(result == m_ContentLookup.end()) + { + return std::shared_ptr(nullptr); + } + return result->second; +} + +void MultipartFormData::writeTo( std::ostream& target ) +{ + for ( size_t i = 0; i < m_Contents.size(); i++ ) + { + std::shared_ptr content = m_Contents[i]; + + // boundary + target << "\r\n" << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n"; + + // headers + target << "Content-Disposition: " << utility::conversions::to_utf8string( content->getContentDisposition() ); + if ( content->getName().size() > 0 ) + { + target << "; name=\"" << utility::conversions::to_utf8string( content->getName() ) << "\""; + } + if ( content->getFileName().size() > 0 ) + { + target << "; filename=\"" << utility::conversions::to_utf8string( content->getFileName() ) << "\""; + } + target << "\r\n"; + + if ( content->getContentType().size() > 0 ) + { + target << "Content-Type: " << utility::conversions::to_utf8string( content->getContentType() ) << "\r\n"; + } + + target << "\r\n"; + + // body + std::shared_ptr data = content->getData(); + + data->seekg( 0, data->end ); + std::vector dataBytes( data->tellg() ); + + data->seekg( 0, data->beg ); + data->read( &dataBytes[0], dataBytes.size() ); + + std::copy( dataBytes.begin(), dataBytes.end(), std::ostreambuf_iterator( target ) ); + } + + target << "\r\n--" << utility::conversions::to_utf8string( m_Boundary ) << "--\r\n"; +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/Object.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/Object.cpp new file mode 100644 index 000000000000..561f361d2801 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/Object.cpp @@ -0,0 +1,91 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +#include "CppRestPetstoreClient/Object.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +Object::Object() +{ + m_object = web::json::value::object(); +} + +Object::~Object() +{ +} + +void Object::validate() +{ + +} + +web::json::value Object::toJson() const +{ + return m_object; +} + +bool Object::fromJson(const web::json::value& val) +{ + if (val.is_object()) + { + m_object = val; + m_IsSet = true; + } + return isSet(); +} + +void Object::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("object"), m_object)); +} + +bool Object::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } + + if( ModelBase::fromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object")), m_object ) ) + { + m_IsSet = true; + } + return isSet(); +} + +web::json::value Object::getValue(const utility::string_t& key) const +{ + return m_object.at(key); +} + + +void Object::setValue(const utility::string_t& key, const web::json::value& value) +{ + if( !value.is_null() ) + { + m_object[key] = value; + m_IsSet = true; + } +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/api/PetApi.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/api/PetApi.cpp new file mode 100644 index 000000000000..ff8a1b23ad83 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/api/PetApi.cpp @@ -0,0 +1,1096 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +#include "CppRestPetstoreClient/api/PetApi.h" +#include "CppRestPetstoreClient/IHttpBody.h" +#include "CppRestPetstoreClient/JsonBody.h" +#include "CppRestPetstoreClient/MultipartFormData.h" + +#include + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +using namespace org::openapitools::client::model; + +PetApi::PetApi( std::shared_ptr apiClient ) + : m_ApiClient(apiClient) +{ +} + +PetApi::~PetApi() +{ +} + +pplx::task> PetApi::addPet(std::shared_ptr pet) const +{ + + // verify the required parameter 'pet' is set + if (pet == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'pet' when calling PetApi->addPet")); + } + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->addPet does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(pet); + + + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); + + if(pet.get()) + { + pet->toMultipart(localVarMultipart, utility::conversions::to_string_t("pet")); + } + + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->addPet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling addPet: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling addPet: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::shared_ptr localVarResult(new Pet()); + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + ModelBase::fromJson(localVarJson, localVarResult); + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling addPet: unsupported response type")); + } + + return localVarResult; + }); +} +pplx::task PetApi::deletePet(int64_t petId, boost::optional apiKey) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), web::uri::encode_uri(ApiClient::parameterToString(petId))); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->deletePet does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + if (apiKey) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = ApiClient::parameterToString(*apiKey); + } + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->deletePet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling deletePet: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling deletePet: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} +pplx::task>> PetApi::findPetsByStatus(std::vector status) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/findByStatus"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->findPetsByStatus does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + { + localVarQueryParams[utility::conversions::to_string_t("status")] = ApiClient::parameterToString(status); + } + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->findPetsByStatus does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling findPetsByStatus: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling findPetsByStatus: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::vector> localVarResult; + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + for( auto& localVarItem : localVarJson.as_array() ) + { + std::shared_ptr localVarItemObj; + ModelBase::fromJson(localVarItem, localVarItemObj); + localVarResult.push_back(localVarItemObj); + } + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling findPetsByStatus: unsupported response type")); + } + + return localVarResult; + }); +} +pplx::task>> PetApi::findPetsByTags(std::vector tags) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/findByTags"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->findPetsByTags does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + { + localVarQueryParams[utility::conversions::to_string_t("tags")] = ApiClient::parameterToString(tags); + } + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->findPetsByTags does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling findPetsByTags: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling findPetsByTags: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::vector> localVarResult; + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + for( auto& localVarItem : localVarJson.as_array() ) + { + std::shared_ptr localVarItemObj; + ModelBase::fromJson(localVarItem, localVarItemObj); + localVarResult.push_back(localVarItemObj); + } + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling findPetsByTags: unsupported response type")); + } + + return localVarResult; + }); +} +pplx::task> PetApi::getPetById(int64_t petId) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), web::uri::encode_uri(ApiClient::parameterToString(petId))); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->getPetById does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->getPetById does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getPetById: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getPetById: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::shared_ptr localVarResult(new Pet()); + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + ModelBase::fromJson(localVarJson, localVarResult); + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getPetById: unsupported response type")); + } + + return localVarResult; + }); +} +pplx::task> PetApi::updatePet(std::shared_ptr pet) const +{ + + // verify the required parameter 'pet' is set + if (pet == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'pet' when calling PetApi->updatePet")); + } + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->updatePet does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(pet); + + + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); + + if(pet.get()) + { + pet->toMultipart(localVarMultipart, utility::conversions::to_string_t("pet")); + } + + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->updatePet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling updatePet: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling updatePet: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::shared_ptr localVarResult(new Pet()); + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + ModelBase::fromJson(localVarJson, localVarResult); + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling updatePet: unsupported response type")); + } + + return localVarResult; + }); +} +pplx::task PetApi::updatePetWithForm(int64_t petId, boost::optional name, boost::optional status) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), web::uri::encode_uri(ApiClient::parameterToString(petId))); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->updatePetWithForm does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/x-www-form-urlencoded") ); + + if (name) + { + localVarFormParams[ utility::conversions::to_string_t("name") ] = ApiClient::parameterToString(*name); + } + if (status) + { + localVarFormParams[ utility::conversions::to_string_t("status") ] = ApiClient::parameterToString(*status); + } + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->updatePetWithForm does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling updatePetWithForm: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling updatePetWithForm: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} +pplx::task> PetApi::uploadFile(int64_t petId, boost::optional additionalMetadata, boost::optional> file) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}/uploadImage"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), web::uri::encode_uri(ApiClient::parameterToString(petId))); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->uploadFile does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") ); + + if (additionalMetadata) + { + localVarFormParams[ utility::conversions::to_string_t("additionalMetadata") ] = ApiClient::parameterToString(*additionalMetadata); + } + if (file && *file != nullptr) + { + localVarFileParams[ utility::conversions::to_string_t("file") ] = *file; + } + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->uploadFile does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling uploadFile: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling uploadFile: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::shared_ptr localVarResult(new ApiResponse()); + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + ModelBase::fromJson(localVarJson, localVarResult); + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling uploadFile: unsupported response type")); + } + + return localVarResult; + }); +} + +} +} +} +} + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/api/StoreApi.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/api/StoreApi.cpp new file mode 100644 index 000000000000..c7608091749a --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/api/StoreApi.cpp @@ -0,0 +1,552 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +#include "CppRestPetstoreClient/api/StoreApi.h" +#include "CppRestPetstoreClient/IHttpBody.h" +#include "CppRestPetstoreClient/JsonBody.h" +#include "CppRestPetstoreClient/MultipartFormData.h" + +#include + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +using namespace org::openapitools::client::model; + +StoreApi::StoreApi( std::shared_ptr apiClient ) + : m_ApiClient(apiClient) +{ +} + +StoreApi::~StoreApi() +{ +} + +pplx::task StoreApi::deleteOrder(utility::string_t orderId) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), web::uri::encode_uri(ApiClient::parameterToString(orderId))); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("StoreApi->deleteOrder does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("StoreApi->deleteOrder does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling deleteOrder: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling deleteOrder: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} +pplx::task> StoreApi::getInventory() const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/inventory"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("StoreApi->getInventory does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("StoreApi->getInventory does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getInventory: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getInventory: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::map localVarResult; + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + for( auto& localVarItem : localVarJson.as_object() ) + { + int32_t localVarItemObj; + ModelBase::fromJson(localVarItem.second, localVarItemObj); + localVarResult[localVarItem.first] = localVarItemObj; + } + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getInventory: unsupported response type")); + } + + return localVarResult; + }); +} +pplx::task> StoreApi::getOrderById(int64_t orderId) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), web::uri::encode_uri(ApiClient::parameterToString(orderId))); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("StoreApi->getOrderById does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("StoreApi->getOrderById does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getOrderById: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getOrderById: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::shared_ptr localVarResult(new Order()); + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + ModelBase::fromJson(localVarJson, localVarResult); + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getOrderById: unsupported response type")); + } + + return localVarResult; + }); +} +pplx::task> StoreApi::placeOrder(std::shared_ptr order) const +{ + + // verify the required parameter 'order' is set + if (order == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'order' when calling StoreApi->placeOrder")); + } + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/order"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("StoreApi->placeOrder does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(order); + + + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); + + if(order.get()) + { + order->toMultipart(localVarMultipart, utility::conversions::to_string_t("order")); + } + + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("StoreApi->placeOrder does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling placeOrder: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling placeOrder: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::shared_ptr localVarResult(new Order()); + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + ModelBase::fromJson(localVarJson, localVarResult); + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling placeOrder: unsupported response type")); + } + + return localVarResult; + }); +} + +} +} +} +} + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/api/UserApi.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/api/UserApi.cpp new file mode 100644 index 000000000000..d877c40a70d5 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/api/UserApi.cpp @@ -0,0 +1,1075 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +#include "CppRestPetstoreClient/api/UserApi.h" +#include "CppRestPetstoreClient/IHttpBody.h" +#include "CppRestPetstoreClient/JsonBody.h" +#include "CppRestPetstoreClient/MultipartFormData.h" + +#include + +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +using namespace org::openapitools::client::model; + +UserApi::UserApi( std::shared_ptr apiClient ) + : m_ApiClient(apiClient) +{ +} + +UserApi::~UserApi() +{ +} + +pplx::task UserApi::createUser(std::shared_ptr user) const +{ + + // verify the required parameter 'user' is set + if (user == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'user' when calling UserApi->createUser")); + } + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->createUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(user); + + + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); + + if(user.get()) + { + user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user")); + } + + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->createUser does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling createUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling createUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} +pplx::task UserApi::createUsersWithArrayInput(std::vector> user) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithArray"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + { + std::vector localVarJsonArray; + for( auto& localVarItem : user ) + { + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); + + } + localVarJson = web::json::value::array(localVarJsonArray); + } + + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); + + { + std::vector localVarJsonArray; + for( auto& localVarItem : user ) + { + localVarJsonArray.push_back(ModelBase::toJson(localVarItem)); + } + localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), localVarJsonArray, utility::conversions::to_string_t("application/json"))); + } + + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling createUsersWithArrayInput: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling createUsersWithArrayInput: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} +pplx::task UserApi::createUsersWithListInput(std::vector> user) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithList"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + { + std::vector localVarJsonArray; + for( auto& localVarItem : user ) + { + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); + + } + localVarJson = web::json::value::array(localVarJsonArray); + } + + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); + + { + std::vector localVarJsonArray; + for( auto& localVarItem : user ) + { + localVarJsonArray.push_back(ModelBase::toJson(localVarItem)); + } + localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), localVarJsonArray, utility::conversions::to_string_t("application/json"))); + } + + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling createUsersWithListInput: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling createUsersWithListInput: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} +pplx::task UserApi::deleteUser(utility::string_t username) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), web::uri::encode_uri(ApiClient::parameterToString(username))); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->deleteUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->deleteUser does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling deleteUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling deleteUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} +pplx::task> UserApi::getUserByName(utility::string_t username) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), web::uri::encode_uri(ApiClient::parameterToString(username))); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->getUserByName does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->getUserByName does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getUserByName: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getUserByName: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + std::shared_ptr localVarResult(new User()); + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + ModelBase::fromJson(localVarJson, localVarResult); + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getUserByName: unsupported response type")); + } + + return localVarResult; + }); +} +pplx::task UserApi::loginUser(utility::string_t username, utility::string_t password) const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/login"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + // plain text + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("text/plain")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->loginUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + { + localVarQueryParams[utility::conversions::to_string_t("username")] = ApiClient::parameterToString(username); + } + { + localVarQueryParams[utility::conversions::to_string_t("password")] = ApiClient::parameterToString(password); + } + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->loginUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling loginUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling loginUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + utility::string_t localVarResult(utility::conversions::to_string_t("")); + + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + ModelBase::fromJson(localVarJson, localVarResult); + } + else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain")) + { + localVarResult = localVarResponse; + } + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // { + // TODO multipart response parsing + // } + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling loginUser: unsupported response type")); + } + + return localVarResult; + }); +} +pplx::task UserApi::logoutUser() const +{ + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/logout"); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->logoutUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->logoutUser does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling logoutUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling logoutUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} +pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr user) const +{ + + // verify the required parameter 'user' is set + if (user == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'user' when calling UserApi->updateUser")); + } + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), web::uri::encode_uri(ApiClient::parameterToString(username))); + + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; + + std::unordered_set localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->updateUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(user); + + + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); + + if(user.get()) + { + user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user")); + } + + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end()) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->updateUser does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { + if (m_ApiClient->getResponseHandler()) + { + m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); + } + + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling updateUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + + // check response content type + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling updateUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} + +} +} +} +} + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/model/ApiResponse.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/model/ApiResponse.cpp new file mode 100644 index 000000000000..1e490aeb41cc --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/model/ApiResponse.cpp @@ -0,0 +1,216 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/ApiResponse.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +ApiResponse::ApiResponse() +{ + m_Code = 0; + m_CodeIsSet = false; + m_Type = utility::conversions::to_string_t(""); + m_TypeIsSet = false; + m_Message = utility::conversions::to_string_t(""); + m_MessageIsSet = false; +} + +ApiResponse::~ApiResponse() +{ +} + +void ApiResponse::validate() +{ + // TODO: implement validation +} + +web::json::value ApiResponse::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_CodeIsSet) + { + val[utility::conversions::to_string_t(U("code"))] = ModelBase::toJson(m_Code); + } + if(m_TypeIsSet) + { + val[utility::conversions::to_string_t(U("type"))] = ModelBase::toJson(m_Type); + } + if(m_MessageIsSet) + { + val[utility::conversions::to_string_t(U("message"))] = ModelBase::toJson(m_Message); + } + + return val; +} + +bool ApiResponse::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("code")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("code"))); + if(!fieldValue.is_null()) + { + int32_t refVal_setCode; + ok &= ModelBase::fromJson(fieldValue, refVal_setCode); + setCode(refVal_setCode); + } + } + if(val.has_field(utility::conversions::to_string_t(U("type")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("type"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setType; + ok &= ModelBase::fromJson(fieldValue, refVal_setType); + setType(refVal_setType); + } + } + if(val.has_field(utility::conversions::to_string_t(U("message")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("message"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setMessage; + ok &= ModelBase::fromJson(fieldValue, refVal_setMessage); + setMessage(refVal_setMessage); + } + } + return ok; +} + +void ApiResponse::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_CodeIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("code")), m_Code)); + } + if(m_TypeIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("type")), m_Type)); + } + if(m_MessageIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("message")), m_Message)); + } +} + +bool ApiResponse::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("code")))) + { + int32_t refVal_setCode; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("code"))), refVal_setCode ); + setCode(refVal_setCode); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("type")))) + { + utility::string_t refVal_setType; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("type"))), refVal_setType ); + setType(refVal_setType); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("message")))) + { + utility::string_t refVal_setMessage; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("message"))), refVal_setMessage ); + setMessage(refVal_setMessage); + } + return ok; +} + +int32_t ApiResponse::getCode() const +{ + return m_Code; +} + +void ApiResponse::setCode(int32_t value) +{ + m_Code = value; + m_CodeIsSet = true; +} + +bool ApiResponse::codeIsSet() const +{ + return m_CodeIsSet; +} + +void ApiResponse::unsetCode() +{ + m_CodeIsSet = false; +} +utility::string_t ApiResponse::getType() const +{ + return m_Type; +} + +void ApiResponse::setType(const utility::string_t& value) +{ + m_Type = value; + m_TypeIsSet = true; +} + +bool ApiResponse::typeIsSet() const +{ + return m_TypeIsSet; +} + +void ApiResponse::unsetType() +{ + m_TypeIsSet = false; +} +utility::string_t ApiResponse::getMessage() const +{ + return m_Message; +} + +void ApiResponse::setMessage(const utility::string_t& value) +{ + m_Message = value; + m_MessageIsSet = true; +} + +bool ApiResponse::messageIsSet() const +{ + return m_MessageIsSet; +} + +void ApiResponse::unsetMessage() +{ + m_MessageIsSet = false; +} +} +} +} +} + + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/model/Category.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Category.cpp new file mode 100644 index 000000000000..b5c1c510fcad --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Category.cpp @@ -0,0 +1,170 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/Category.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +Category::Category() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Name = utility::conversions::to_string_t(""); + m_NameIsSet = false; +} + +Category::~Category() +{ +} + +void Category::validate() +{ + // TODO: implement validation +} + +web::json::value Category::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[utility::conversions::to_string_t(U("id"))] = ModelBase::toJson(m_Id); + } + if(m_NameIsSet) + { + val[utility::conversions::to_string_t(U("name"))] = ModelBase::toJson(m_Name); + } + + return val; +} + +bool Category::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("id")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id"))); + if(!fieldValue.is_null()) + { + int64_t refVal_setId; + ok &= ModelBase::fromJson(fieldValue, refVal_setId); + setId(refVal_setId); + } + } + if(val.has_field(utility::conversions::to_string_t(U("name")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("name"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setName; + ok &= ModelBase::fromJson(fieldValue, refVal_setName); + setName(refVal_setName); + } + } + return ok; +} + +void Category::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id)); + } + if(m_NameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("name")), m_Name)); + } +} + +bool Category::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("id")))) + { + int64_t refVal_setId; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId ); + setId(refVal_setId); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("name")))) + { + utility::string_t refVal_setName; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("name"))), refVal_setName ); + setName(refVal_setName); + } + return ok; +} + +int64_t Category::getId() const +{ + return m_Id; +} + +void Category::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} + +bool Category::idIsSet() const +{ + return m_IdIsSet; +} + +void Category::unsetId() +{ + m_IdIsSet = false; +} +utility::string_t Category::getName() const +{ + return m_Name; +} + +void Category::setName(const utility::string_t& value) +{ + m_Name = value; + m_NameIsSet = true; +} + +bool Category::nameIsSet() const +{ + return m_NameIsSet; +} + +void Category::unsetName() +{ + m_NameIsSet = false; +} +} +} +} +} + + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/model/Order.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Order.cpp new file mode 100644 index 000000000000..968629998558 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Order.cpp @@ -0,0 +1,354 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/Order.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +Order::Order() +{ + m_Id = 0L; + m_IdIsSet = false; + m_PetId = 0L; + m_PetIdIsSet = false; + m_Quantity = 0; + m_QuantityIsSet = false; + m_ShipDate = utility::datetime(); + m_ShipDateIsSet = false; + m_Status = utility::conversions::to_string_t(""); + m_StatusIsSet = false; + m_Complete = false; + m_CompleteIsSet = false; +} + +Order::~Order() +{ +} + +void Order::validate() +{ + // TODO: implement validation +} + +web::json::value Order::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[utility::conversions::to_string_t(U("id"))] = ModelBase::toJson(m_Id); + } + if(m_PetIdIsSet) + { + val[utility::conversions::to_string_t(U("petId"))] = ModelBase::toJson(m_PetId); + } + if(m_QuantityIsSet) + { + val[utility::conversions::to_string_t(U("quantity"))] = ModelBase::toJson(m_Quantity); + } + if(m_ShipDateIsSet) + { + val[utility::conversions::to_string_t(U("shipDate"))] = ModelBase::toJson(m_ShipDate); + } + if(m_StatusIsSet) + { + val[utility::conversions::to_string_t(U("status"))] = ModelBase::toJson(m_Status); + } + if(m_CompleteIsSet) + { + val[utility::conversions::to_string_t(U("complete"))] = ModelBase::toJson(m_Complete); + } + + return val; +} + +bool Order::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("id")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id"))); + if(!fieldValue.is_null()) + { + int64_t refVal_setId; + ok &= ModelBase::fromJson(fieldValue, refVal_setId); + setId(refVal_setId); + } + } + if(val.has_field(utility::conversions::to_string_t(U("petId")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("petId"))); + if(!fieldValue.is_null()) + { + int64_t refVal_setPetId; + ok &= ModelBase::fromJson(fieldValue, refVal_setPetId); + setPetId(refVal_setPetId); + } + } + if(val.has_field(utility::conversions::to_string_t(U("quantity")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("quantity"))); + if(!fieldValue.is_null()) + { + int32_t refVal_setQuantity; + ok &= ModelBase::fromJson(fieldValue, refVal_setQuantity); + setQuantity(refVal_setQuantity); + } + } + if(val.has_field(utility::conversions::to_string_t(U("shipDate")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("shipDate"))); + if(!fieldValue.is_null()) + { + utility::datetime refVal_setShipDate; + ok &= ModelBase::fromJson(fieldValue, refVal_setShipDate); + setShipDate(refVal_setShipDate); + } + } + if(val.has_field(utility::conversions::to_string_t(U("status")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("status"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setStatus; + ok &= ModelBase::fromJson(fieldValue, refVal_setStatus); + setStatus(refVal_setStatus); + } + } + if(val.has_field(utility::conversions::to_string_t(U("complete")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("complete"))); + if(!fieldValue.is_null()) + { + bool refVal_setComplete; + ok &= ModelBase::fromJson(fieldValue, refVal_setComplete); + setComplete(refVal_setComplete); + } + } + return ok; +} + +void Order::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id)); + } + if(m_PetIdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("petId")), m_PetId)); + } + if(m_QuantityIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("quantity")), m_Quantity)); + } + if(m_ShipDateIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("shipDate")), m_ShipDate)); + } + if(m_StatusIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("status")), m_Status)); + } + if(m_CompleteIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("complete")), m_Complete)); + } +} + +bool Order::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("id")))) + { + int64_t refVal_setId; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId ); + setId(refVal_setId); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("petId")))) + { + int64_t refVal_setPetId; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("petId"))), refVal_setPetId ); + setPetId(refVal_setPetId); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("quantity")))) + { + int32_t refVal_setQuantity; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("quantity"))), refVal_setQuantity ); + setQuantity(refVal_setQuantity); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("shipDate")))) + { + utility::datetime refVal_setShipDate; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("shipDate"))), refVal_setShipDate ); + setShipDate(refVal_setShipDate); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("status")))) + { + utility::string_t refVal_setStatus; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("status"))), refVal_setStatus ); + setStatus(refVal_setStatus); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("complete")))) + { + bool refVal_setComplete; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("complete"))), refVal_setComplete ); + setComplete(refVal_setComplete); + } + return ok; +} + +int64_t Order::getId() const +{ + return m_Id; +} + +void Order::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} + +bool Order::idIsSet() const +{ + return m_IdIsSet; +} + +void Order::unsetId() +{ + m_IdIsSet = false; +} +int64_t Order::getPetId() const +{ + return m_PetId; +} + +void Order::setPetId(int64_t value) +{ + m_PetId = value; + m_PetIdIsSet = true; +} + +bool Order::petIdIsSet() const +{ + return m_PetIdIsSet; +} + +void Order::unsetPetId() +{ + m_PetIdIsSet = false; +} +int32_t Order::getQuantity() const +{ + return m_Quantity; +} + +void Order::setQuantity(int32_t value) +{ + m_Quantity = value; + m_QuantityIsSet = true; +} + +bool Order::quantityIsSet() const +{ + return m_QuantityIsSet; +} + +void Order::unsetQuantity() +{ + m_QuantityIsSet = false; +} +utility::datetime Order::getShipDate() const +{ + return m_ShipDate; +} + +void Order::setShipDate(const utility::datetime& value) +{ + m_ShipDate = value; + m_ShipDateIsSet = true; +} + +bool Order::shipDateIsSet() const +{ + return m_ShipDateIsSet; +} + +void Order::unsetShipDate() +{ + m_ShipDateIsSet = false; +} +utility::string_t Order::getStatus() const +{ + return m_Status; +} + +void Order::setStatus(const utility::string_t& value) +{ + m_Status = value; + m_StatusIsSet = true; +} + +bool Order::statusIsSet() const +{ + return m_StatusIsSet; +} + +void Order::unsetStatus() +{ + m_StatusIsSet = false; +} +bool Order::isComplete() const +{ + return m_Complete; +} + +void Order::setComplete(bool value) +{ + m_Complete = value; + m_CompleteIsSet = true; +} + +bool Order::completeIsSet() const +{ + return m_CompleteIsSet; +} + +void Order::unsetComplete() +{ + m_CompleteIsSet = false; +} +} +} +} +} + + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/model/Pet.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Pet.cpp new file mode 100644 index 000000000000..5c2d85473cec --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Pet.cpp @@ -0,0 +1,531 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/Pet.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +Pet::Pet() +{ + m_Id = 0L; + m_IdIsSet = false; + m_CategoryIsSet = false; + m_Name = utility::conversions::to_string_t(""); + m_NameIsSet = false; + m_PhotoUrlsIsSet = false; + m_TagsIsSet = false; + m_Status = utility::conversions::to_string_t(""); + m_StatusIsSet = false; + m_VeterinarianVisitIsSet = false; + m_GoodiesIsSet = false; + m_CertificatesIsSet = false; + m_VaccinationBookIsSet = false; +} + +Pet::~Pet() +{ +} + +void Pet::validate() +{ + // TODO: implement validation +} + +web::json::value Pet::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[utility::conversions::to_string_t(U("id"))] = ModelBase::toJson(m_Id); + } + if(m_CategoryIsSet) + { + val[utility::conversions::to_string_t(U("category"))] = ModelBase::toJson(m_Category); + } + if(m_NameIsSet) + { + val[utility::conversions::to_string_t(U("name"))] = ModelBase::toJson(m_Name); + } + if(m_PhotoUrlsIsSet) + { + val[utility::conversions::to_string_t(U("photoUrls"))] = ModelBase::toJson(m_PhotoUrls); + } + if(m_TagsIsSet) + { + val[utility::conversions::to_string_t(U("tags"))] = ModelBase::toJson(m_Tags); + } + if(m_StatusIsSet) + { + val[utility::conversions::to_string_t(U("status"))] = ModelBase::toJson(m_Status); + } + if(m_VeterinarianVisitIsSet) + { + val[utility::conversions::to_string_t(U("veterinarianVisit"))] = ModelBase::toJson(m_VeterinarianVisit); + } + if(m_GoodiesIsSet) + { + val[utility::conversions::to_string_t(U("goodies"))] = ModelBase::toJson(m_Goodies); + } + if(m_CertificatesIsSet) + { + val[utility::conversions::to_string_t(U("certificates"))] = ModelBase::toJson(m_Certificates); + } + if(m_VaccinationBookIsSet) + { + val[utility::conversions::to_string_t(U("vaccinationBook"))] = ModelBase::toJson(m_VaccinationBook); + } + + return val; +} + +bool Pet::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("id")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id"))); + if(!fieldValue.is_null()) + { + int64_t refVal_setId; + ok &= ModelBase::fromJson(fieldValue, refVal_setId); + setId(refVal_setId); + } + } + if(val.has_field(utility::conversions::to_string_t(U("category")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("category"))); + if(!fieldValue.is_null()) + { + std::shared_ptr refVal_setCategory; + ok &= ModelBase::fromJson(fieldValue, refVal_setCategory); + setCategory(refVal_setCategory); + } + } + if(val.has_field(utility::conversions::to_string_t(U("name")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("name"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setName; + ok &= ModelBase::fromJson(fieldValue, refVal_setName); + setName(refVal_setName); + } + } + if(val.has_field(utility::conversions::to_string_t(U("photoUrls")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("photoUrls"))); + if(!fieldValue.is_null()) + { + std::vector refVal_setPhotoUrls; + ok &= ModelBase::fromJson(fieldValue, refVal_setPhotoUrls); + setPhotoUrls(refVal_setPhotoUrls); + } + } + if(val.has_field(utility::conversions::to_string_t(U("tags")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("tags"))); + if(!fieldValue.is_null()) + { + std::vector> refVal_setTags; + ok &= ModelBase::fromJson(fieldValue, refVal_setTags); + setTags(refVal_setTags); + } + } + if(val.has_field(utility::conversions::to_string_t(U("status")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("status"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setStatus; + ok &= ModelBase::fromJson(fieldValue, refVal_setStatus); + setStatus(refVal_setStatus); + } + } + if(val.has_field(utility::conversions::to_string_t(U("veterinarianVisit")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("veterinarianVisit"))); + if(!fieldValue.is_null()) + { + std::shared_ptr refVal_setVeterinarianVisit; + ok &= ModelBase::fromJson(fieldValue, refVal_setVeterinarianVisit); + setVeterinarianVisit(refVal_setVeterinarianVisit); + } + } + if(val.has_field(utility::conversions::to_string_t(U("goodies")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("goodies"))); + if(!fieldValue.is_null()) + { + std::vector> refVal_setGoodies; + ok &= ModelBase::fromJson(fieldValue, refVal_setGoodies); + setGoodies(refVal_setGoodies); + } + } + if(val.has_field(utility::conversions::to_string_t(U("certificates")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("certificates"))); + if(!fieldValue.is_null()) + { + std::set refVal_setCertificates; + ok &= ModelBase::fromJson(fieldValue, refVal_setCertificates); + setCertificates(refVal_setCertificates); + } + } + if(val.has_field(utility::conversions::to_string_t(U("vaccinationBook")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("vaccinationBook"))); + if(!fieldValue.is_null()) + { + std::shared_ptr refVal_setVaccinationBook; + ok &= ModelBase::fromJson(fieldValue, refVal_setVaccinationBook); + setVaccinationBook(refVal_setVaccinationBook); + } + } + return ok; +} + +void Pet::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id)); + } + if(m_CategoryIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("category")), m_Category)); + } + if(m_NameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("name")), m_Name)); + } + if(m_PhotoUrlsIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("photoUrls")), m_PhotoUrls)); + } + if(m_TagsIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("tags")), m_Tags)); + } + if(m_StatusIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("status")), m_Status)); + } + if(m_VeterinarianVisitIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("veterinarianVisit")), m_VeterinarianVisit)); + } + if(m_GoodiesIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("goodies")), m_Goodies)); + } + if(m_CertificatesIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("certificates")), m_Certificates)); + } + if(m_VaccinationBookIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("vaccinationBook")), m_VaccinationBook)); + } +} + +bool Pet::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("id")))) + { + int64_t refVal_setId; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId ); + setId(refVal_setId); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("category")))) + { + std::shared_ptr refVal_setCategory; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("category"))), refVal_setCategory ); + setCategory(refVal_setCategory); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("name")))) + { + utility::string_t refVal_setName; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("name"))), refVal_setName ); + setName(refVal_setName); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("photoUrls")))) + { + std::vector refVal_setPhotoUrls; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("photoUrls"))), refVal_setPhotoUrls ); + setPhotoUrls(refVal_setPhotoUrls); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("tags")))) + { + std::vector> refVal_setTags; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("tags"))), refVal_setTags ); + setTags(refVal_setTags); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("status")))) + { + utility::string_t refVal_setStatus; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("status"))), refVal_setStatus ); + setStatus(refVal_setStatus); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("veterinarianVisit")))) + { + std::shared_ptr refVal_setVeterinarianVisit; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("veterinarianVisit"))), refVal_setVeterinarianVisit ); + setVeterinarianVisit(refVal_setVeterinarianVisit); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("goodies")))) + { + std::vector> refVal_setGoodies; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("goodies"))), refVal_setGoodies ); + setGoodies(refVal_setGoodies); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("certificates")))) + { + std::set refVal_setCertificates; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("certificates"))), refVal_setCertificates ); + setCertificates(refVal_setCertificates); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("vaccinationBook")))) + { + std::shared_ptr refVal_setVaccinationBook; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("vaccinationBook"))), refVal_setVaccinationBook ); + setVaccinationBook(refVal_setVaccinationBook); + } + return ok; +} + +int64_t Pet::getId() const +{ + return m_Id; +} + +void Pet::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} + +bool Pet::idIsSet() const +{ + return m_IdIsSet; +} + +void Pet::unsetId() +{ + m_IdIsSet = false; +} +std::shared_ptr Pet::getCategory() const +{ + return m_Category; +} + +void Pet::setCategory(const std::shared_ptr& value) +{ + m_Category = value; + m_CategoryIsSet = true; +} + +bool Pet::categoryIsSet() const +{ + return m_CategoryIsSet; +} + +void Pet::unsetCategory() +{ + m_CategoryIsSet = false; +} +utility::string_t Pet::getName() const +{ + return m_Name; +} + +void Pet::setName(const utility::string_t& value) +{ + m_Name = value; + m_NameIsSet = true; +} + +bool Pet::nameIsSet() const +{ + return m_NameIsSet; +} + +void Pet::unsetName() +{ + m_NameIsSet = false; +} +std::vector& Pet::getPhotoUrls() +{ + return m_PhotoUrls; +} + +void Pet::setPhotoUrls(const std::vector& value) +{ + m_PhotoUrls = value; + m_PhotoUrlsIsSet = true; +} + +bool Pet::photoUrlsIsSet() const +{ + return m_PhotoUrlsIsSet; +} + +void Pet::unsetPhotoUrls() +{ + m_PhotoUrlsIsSet = false; +} +std::vector>& Pet::getTags() +{ + return m_Tags; +} + +void Pet::setTags(const std::vector>& value) +{ + m_Tags = value; + m_TagsIsSet = true; +} + +bool Pet::tagsIsSet() const +{ + return m_TagsIsSet; +} + +void Pet::unsetTags() +{ + m_TagsIsSet = false; +} +utility::string_t Pet::getStatus() const +{ + return m_Status; +} + +void Pet::setStatus(const utility::string_t& value) +{ + m_Status = value; + m_StatusIsSet = true; +} + +bool Pet::statusIsSet() const +{ + return m_StatusIsSet; +} + +void Pet::unsetStatus() +{ + m_StatusIsSet = false; +} +std::shared_ptr Pet::getVeterinarianVisit() const +{ + return m_VeterinarianVisit; +} + +void Pet::setVeterinarianVisit(const std::shared_ptr& value) +{ + m_VeterinarianVisit = value; + m_VeterinarianVisitIsSet = true; +} + +bool Pet::veterinarianVisitIsSet() const +{ + return m_VeterinarianVisitIsSet; +} + +void Pet::unsetVeterinarianVisit() +{ + m_VeterinarianVisitIsSet = false; +} +std::vector>& Pet::getGoodies() +{ + return m_Goodies; +} + +void Pet::setGoodies(const std::vector>& value) +{ + m_Goodies = value; + m_GoodiesIsSet = true; +} + +bool Pet::goodiesIsSet() const +{ + return m_GoodiesIsSet; +} + +void Pet::unsetGoodies() +{ + m_GoodiesIsSet = false; +} +std::set& Pet::getCertificates() +{ + return m_Certificates; +} + +void Pet::setCertificates(const std::set& value) +{ + m_Certificates = value; + m_CertificatesIsSet = true; +} + +bool Pet::certificatesIsSet() const +{ + return m_CertificatesIsSet; +} + +void Pet::unsetCertificates() +{ + m_CertificatesIsSet = false; +} +std::shared_ptr Pet::getVaccinationBook() const +{ + return m_VaccinationBook; +} + +void Pet::setVaccinationBook(const std::shared_ptr& value) +{ + m_VaccinationBook = value; + m_VaccinationBookIsSet = true; +} + +bool Pet::vaccinationBookIsSet() const +{ + return m_VaccinationBookIsSet; +} + +void Pet::unsetVaccinationBook() +{ + m_VaccinationBookIsSet = false; +} +} +} +} +} + + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/model/Pet_vaccinationBook.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Pet_vaccinationBook.cpp new file mode 100644 index 000000000000..082e038bf2ed --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Pet_vaccinationBook.cpp @@ -0,0 +1,123 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/Pet_vaccinationBook.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +Pet_vaccinationBook::Pet_vaccinationBook() +{ + m_VaccinesIsSet = false; +} + +Pet_vaccinationBook::~Pet_vaccinationBook() +{ +} + +void Pet_vaccinationBook::validate() +{ + // TODO: implement validation +} + +web::json::value Pet_vaccinationBook::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_VaccinesIsSet) + { + val[utility::conversions::to_string_t(U("vaccines"))] = ModelBase::toJson(m_Vaccines); + } + + return val; +} + +bool Pet_vaccinationBook::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("vaccines")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("vaccines"))); + if(!fieldValue.is_null()) + { + std::set> refVal_setVaccines; + ok &= ModelBase::fromJson(fieldValue, refVal_setVaccines); + setVaccines(refVal_setVaccines); + } + } + return ok; +} + +void Pet_vaccinationBook::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_VaccinesIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("vaccines")), m_Vaccines)); + } +} + +bool Pet_vaccinationBook::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("vaccines")))) + { + std::set> refVal_setVaccines; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("vaccines"))), refVal_setVaccines ); + setVaccines(refVal_setVaccines); + } + return ok; +} + +std::set>& Pet_vaccinationBook::getVaccines() +{ + return m_Vaccines; +} + +void Pet_vaccinationBook::setVaccines(const std::set>& value) +{ + m_Vaccines = value; + m_VaccinesIsSet = true; +} + +bool Pet_vaccinationBook::vaccinesIsSet() const +{ + return m_VaccinesIsSet; +} + +void Pet_vaccinationBook::unsetVaccines() +{ + m_VaccinesIsSet = false; +} +} +} +} +} + + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/model/Tag.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Tag.cpp new file mode 100644 index 000000000000..b88a0a7638f8 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Tag.cpp @@ -0,0 +1,170 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/Tag.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +Tag::Tag() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Name = utility::conversions::to_string_t(""); + m_NameIsSet = false; +} + +Tag::~Tag() +{ +} + +void Tag::validate() +{ + // TODO: implement validation +} + +web::json::value Tag::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[utility::conversions::to_string_t(U("id"))] = ModelBase::toJson(m_Id); + } + if(m_NameIsSet) + { + val[utility::conversions::to_string_t(U("name"))] = ModelBase::toJson(m_Name); + } + + return val; +} + +bool Tag::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("id")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id"))); + if(!fieldValue.is_null()) + { + int64_t refVal_setId; + ok &= ModelBase::fromJson(fieldValue, refVal_setId); + setId(refVal_setId); + } + } + if(val.has_field(utility::conversions::to_string_t(U("name")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("name"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setName; + ok &= ModelBase::fromJson(fieldValue, refVal_setName); + setName(refVal_setName); + } + } + return ok; +} + +void Tag::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id)); + } + if(m_NameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("name")), m_Name)); + } +} + +bool Tag::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("id")))) + { + int64_t refVal_setId; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId ); + setId(refVal_setId); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("name")))) + { + utility::string_t refVal_setName; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("name"))), refVal_setName ); + setName(refVal_setName); + } + return ok; +} + +int64_t Tag::getId() const +{ + return m_Id; +} + +void Tag::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} + +bool Tag::idIsSet() const +{ + return m_IdIsSet; +} + +void Tag::unsetId() +{ + m_IdIsSet = false; +} +utility::string_t Tag::getName() const +{ + return m_Name; +} + +void Tag::setName(const utility::string_t& value) +{ + m_Name = value; + m_NameIsSet = true; +} + +bool Tag::nameIsSet() const +{ + return m_NameIsSet; +} + +void Tag::unsetName() +{ + m_NameIsSet = false; +} +} +} +} +} + + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/model/User.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/model/User.cpp new file mode 100644 index 000000000000..17baeeed2e8e --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/model/User.cpp @@ -0,0 +1,446 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/User.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +User::User() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Username = utility::conversions::to_string_t(""); + m_UsernameIsSet = false; + m_FirstName = utility::conversions::to_string_t(""); + m_FirstNameIsSet = false; + m_LastName = utility::conversions::to_string_t(""); + m_LastNameIsSet = false; + m_Email = utility::conversions::to_string_t(""); + m_EmailIsSet = false; + m_Password = utility::conversions::to_string_t(""); + m_PasswordIsSet = false; + m_Phone = utility::conversions::to_string_t(""); + m_PhoneIsSet = false; + m_UserStatus = 0; + m_UserStatusIsSet = false; +} + +User::~User() +{ +} + +void User::validate() +{ + // TODO: implement validation +} + +web::json::value User::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[utility::conversions::to_string_t(U("id"))] = ModelBase::toJson(m_Id); + } + if(m_UsernameIsSet) + { + val[utility::conversions::to_string_t(U("username"))] = ModelBase::toJson(m_Username); + } + if(m_FirstNameIsSet) + { + val[utility::conversions::to_string_t(U("firstName"))] = ModelBase::toJson(m_FirstName); + } + if(m_LastNameIsSet) + { + val[utility::conversions::to_string_t(U("lastName"))] = ModelBase::toJson(m_LastName); + } + if(m_EmailIsSet) + { + val[utility::conversions::to_string_t(U("email"))] = ModelBase::toJson(m_Email); + } + if(m_PasswordIsSet) + { + val[utility::conversions::to_string_t(U("password"))] = ModelBase::toJson(m_Password); + } + if(m_PhoneIsSet) + { + val[utility::conversions::to_string_t(U("phone"))] = ModelBase::toJson(m_Phone); + } + if(m_UserStatusIsSet) + { + val[utility::conversions::to_string_t(U("userStatus"))] = ModelBase::toJson(m_UserStatus); + } + + return val; +} + +bool User::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("id")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id"))); + if(!fieldValue.is_null()) + { + int64_t refVal_setId; + ok &= ModelBase::fromJson(fieldValue, refVal_setId); + setId(refVal_setId); + } + } + if(val.has_field(utility::conversions::to_string_t(U("username")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("username"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setUsername; + ok &= ModelBase::fromJson(fieldValue, refVal_setUsername); + setUsername(refVal_setUsername); + } + } + if(val.has_field(utility::conversions::to_string_t(U("firstName")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("firstName"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setFirstName; + ok &= ModelBase::fromJson(fieldValue, refVal_setFirstName); + setFirstName(refVal_setFirstName); + } + } + if(val.has_field(utility::conversions::to_string_t(U("lastName")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("lastName"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setLastName; + ok &= ModelBase::fromJson(fieldValue, refVal_setLastName); + setLastName(refVal_setLastName); + } + } + if(val.has_field(utility::conversions::to_string_t(U("email")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("email"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setEmail; + ok &= ModelBase::fromJson(fieldValue, refVal_setEmail); + setEmail(refVal_setEmail); + } + } + if(val.has_field(utility::conversions::to_string_t(U("password")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("password"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setPassword; + ok &= ModelBase::fromJson(fieldValue, refVal_setPassword); + setPassword(refVal_setPassword); + } + } + if(val.has_field(utility::conversions::to_string_t(U("phone")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("phone"))); + if(!fieldValue.is_null()) + { + utility::string_t refVal_setPhone; + ok &= ModelBase::fromJson(fieldValue, refVal_setPhone); + setPhone(refVal_setPhone); + } + } + if(val.has_field(utility::conversions::to_string_t(U("userStatus")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("userStatus"))); + if(!fieldValue.is_null()) + { + int32_t refVal_setUserStatus; + ok &= ModelBase::fromJson(fieldValue, refVal_setUserStatus); + setUserStatus(refVal_setUserStatus); + } + } + return ok; +} + +void User::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id)); + } + if(m_UsernameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("username")), m_Username)); + } + if(m_FirstNameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("firstName")), m_FirstName)); + } + if(m_LastNameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("lastName")), m_LastName)); + } + if(m_EmailIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("email")), m_Email)); + } + if(m_PasswordIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("password")), m_Password)); + } + if(m_PhoneIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("phone")), m_Phone)); + } + if(m_UserStatusIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("userStatus")), m_UserStatus)); + } +} + +bool User::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("id")))) + { + int64_t refVal_setId; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId ); + setId(refVal_setId); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("username")))) + { + utility::string_t refVal_setUsername; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("username"))), refVal_setUsername ); + setUsername(refVal_setUsername); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("firstName")))) + { + utility::string_t refVal_setFirstName; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("firstName"))), refVal_setFirstName ); + setFirstName(refVal_setFirstName); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("lastName")))) + { + utility::string_t refVal_setLastName; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("lastName"))), refVal_setLastName ); + setLastName(refVal_setLastName); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("email")))) + { + utility::string_t refVal_setEmail; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("email"))), refVal_setEmail ); + setEmail(refVal_setEmail); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("password")))) + { + utility::string_t refVal_setPassword; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("password"))), refVal_setPassword ); + setPassword(refVal_setPassword); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("phone")))) + { + utility::string_t refVal_setPhone; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("phone"))), refVal_setPhone ); + setPhone(refVal_setPhone); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("userStatus")))) + { + int32_t refVal_setUserStatus; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("userStatus"))), refVal_setUserStatus ); + setUserStatus(refVal_setUserStatus); + } + return ok; +} + +int64_t User::getId() const +{ + return m_Id; +} + +void User::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} + +bool User::idIsSet() const +{ + return m_IdIsSet; +} + +void User::unsetId() +{ + m_IdIsSet = false; +} +utility::string_t User::getUsername() const +{ + return m_Username; +} + +void User::setUsername(const utility::string_t& value) +{ + m_Username = value; + m_UsernameIsSet = true; +} + +bool User::usernameIsSet() const +{ + return m_UsernameIsSet; +} + +void User::unsetUsername() +{ + m_UsernameIsSet = false; +} +utility::string_t User::getFirstName() const +{ + return m_FirstName; +} + +void User::setFirstName(const utility::string_t& value) +{ + m_FirstName = value; + m_FirstNameIsSet = true; +} + +bool User::firstNameIsSet() const +{ + return m_FirstNameIsSet; +} + +void User::unsetFirstName() +{ + m_FirstNameIsSet = false; +} +utility::string_t User::getLastName() const +{ + return m_LastName; +} + +void User::setLastName(const utility::string_t& value) +{ + m_LastName = value; + m_LastNameIsSet = true; +} + +bool User::lastNameIsSet() const +{ + return m_LastNameIsSet; +} + +void User::unsetLastName() +{ + m_LastNameIsSet = false; +} +utility::string_t User::getEmail() const +{ + return m_Email; +} + +void User::setEmail(const utility::string_t& value) +{ + m_Email = value; + m_EmailIsSet = true; +} + +bool User::emailIsSet() const +{ + return m_EmailIsSet; +} + +void User::unsetEmail() +{ + m_EmailIsSet = false; +} +utility::string_t User::getPassword() const +{ + return m_Password; +} + +void User::setPassword(const utility::string_t& value) +{ + m_Password = value; + m_PasswordIsSet = true; +} + +bool User::passwordIsSet() const +{ + return m_PasswordIsSet; +} + +void User::unsetPassword() +{ + m_PasswordIsSet = false; +} +utility::string_t User::getPhone() const +{ + return m_Phone; +} + +void User::setPhone(const utility::string_t& value) +{ + m_Phone = value; + m_PhoneIsSet = true; +} + +bool User::phoneIsSet() const +{ + return m_PhoneIsSet; +} + +void User::unsetPhone() +{ + m_PhoneIsSet = false; +} +int32_t User::getUserStatus() const +{ + return m_UserStatus; +} + +void User::setUserStatus(int32_t value) +{ + m_UserStatus = value; + m_UserStatusIsSet = true; +} + +bool User::userStatusIsSet() const +{ + return m_UserStatusIsSet; +} + +void User::unsetUserStatus() +{ + m_UserStatusIsSet = false; +} +} +} +} +} + + diff --git a/samples/client/petstore/cpp-restsdk/client-everything/src/model/Vaccine.cpp b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Vaccine.cpp new file mode 100644 index 000000000000..73f040f8b0ac --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client-everything/src/model/Vaccine.cpp @@ -0,0 +1,169 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/Vaccine.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +Vaccine::Vaccine() +{ + m_dateIsSet = false; + m_BoosterRequired = false; + m_BoosterRequiredIsSet = false; +} + +Vaccine::~Vaccine() +{ +} + +void Vaccine::validate() +{ + // TODO: implement validation +} + +web::json::value Vaccine::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_dateIsSet) + { + val[utility::conversions::to_string_t(U("date"))] = ModelBase::toJson(m_date); + } + if(m_BoosterRequiredIsSet) + { + val[utility::conversions::to_string_t(U("boosterRequired"))] = ModelBase::toJson(m_BoosterRequired); + } + + return val; +} + +bool Vaccine::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("date")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("date"))); + if(!fieldValue.is_null()) + { + std::shared_ptr refVal_setDate; + ok &= ModelBase::fromJson(fieldValue, refVal_setDate); + setDate(refVal_setDate); + } + } + if(val.has_field(utility::conversions::to_string_t(U("boosterRequired")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("boosterRequired"))); + if(!fieldValue.is_null()) + { + bool refVal_setBoosterRequired; + ok &= ModelBase::fromJson(fieldValue, refVal_setBoosterRequired); + setBoosterRequired(refVal_setBoosterRequired); + } + } + return ok; +} + +void Vaccine::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_dateIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("date")), m_date)); + } + if(m_BoosterRequiredIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("boosterRequired")), m_BoosterRequired)); + } +} + +bool Vaccine::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("date")))) + { + std::shared_ptr refVal_setDate; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("date"))), refVal_setDate ); + setDate(refVal_setDate); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("boosterRequired")))) + { + bool refVal_setBoosterRequired; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("boosterRequired"))), refVal_setBoosterRequired ); + setBoosterRequired(refVal_setBoosterRequired); + } + return ok; +} + +std::shared_ptr Vaccine::getDate() const +{ + return m_date; +} + +void Vaccine::setDate(const std::shared_ptr& value) +{ + m_date = value; + m_dateIsSet = true; +} + +bool Vaccine::dateIsSet() const +{ + return m_dateIsSet; +} + +void Vaccine::unsetdate() +{ + m_dateIsSet = false; +} +bool Vaccine::isBoosterRequired() const +{ + return m_BoosterRequired; +} + +void Vaccine::setBoosterRequired(bool value) +{ + m_BoosterRequired = value; + m_BoosterRequiredIsSet = true; +} + +bool Vaccine::boosterRequiredIsSet() const +{ + return m_BoosterRequiredIsSet; +} + +void Vaccine::unsetBoosterRequired() +{ + m_BoosterRequiredIsSet = false; +} +} +} +} +} + + diff --git a/samples/client/petstore/cpp-restsdk/client/.openapi-generator/FILES b/samples/client/petstore/cpp-restsdk/client/.openapi-generator/FILES index 2691d1503cb8..ecda37dab83d 100644 --- a/samples/client/petstore/cpp-restsdk/client/.openapi-generator/FILES +++ b/samples/client/petstore/cpp-restsdk/client/.openapi-generator/FILES @@ -20,8 +20,10 @@ include/CppRestPetstoreClient/model/ApiResponse.h include/CppRestPetstoreClient/model/Category.h include/CppRestPetstoreClient/model/Order.h include/CppRestPetstoreClient/model/Pet.h +include/CppRestPetstoreClient/model/Pet_vaccinationBook.h include/CppRestPetstoreClient/model/Tag.h include/CppRestPetstoreClient/model/User.h +include/CppRestPetstoreClient/model/Vaccine.h src/AnyType.cpp src/ApiClient.cpp src/ApiConfiguration.cpp @@ -38,5 +40,7 @@ src/model/ApiResponse.cpp src/model/Category.cpp src/model/Order.cpp src/model/Pet.cpp +src/model/Pet_vaccinationBook.cpp src/model/Tag.cpp src/model/User.cpp +src/model/Vaccine.cpp diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/ModelBase.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/ModelBase.h index d3a1766c2d50..40167660cb9f 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/ModelBase.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/ModelBase.h @@ -27,6 +27,7 @@ #include #include +#include #include namespace org { @@ -63,6 +64,8 @@ class ModelBase static utility::string_t toString( const std::shared_ptr& val ); template static utility::string_t toString( const std::vector & val ); + template + static utility::string_t toString( const std::set & val ); static web::json::value toJson( bool val ); static web::json::value toJson( float val ); @@ -79,6 +82,8 @@ class ModelBase template static web::json::value toJson( const std::vector& val ); template + static web::json::value toJson( const std::set& val ); + template static web::json::value toJson( const std::map& val ); static bool fromString( const utility::string_t& val, bool & ); @@ -96,6 +101,8 @@ class ModelBase template static bool fromString( const utility::string_t& val, std::vector & ); template + static bool fromString( const utility::string_t& val, std::set & ); + template static bool fromString( const utility::string_t& val, std::map & ); static bool fromJson( const web::json::value& val, bool & ); @@ -113,6 +120,8 @@ class ModelBase template static bool fromJson( const web::json::value& val, std::vector & ); template + static bool fromJson( const web::json::value& val, std::set & ); + template static bool fromJson( const web::json::value& val, std::map & ); @@ -131,6 +140,8 @@ class ModelBase template static std::shared_ptr toHttpContent( const utility::string_t& name, const std::vector& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); template + static std::shared_ptr toHttpContent( const utility::string_t& name, const std::set& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + template static std::shared_ptr toHttpContent( const utility::string_t& name, const std::map& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); static bool fromHttpContent( std::shared_ptr val, bool & ); @@ -147,6 +158,8 @@ class ModelBase template static bool fromHttpContent( std::shared_ptr val, std::vector & ); template + static bool fromHttpContent( std::shared_ptr val, std::set & ); + template static bool fromHttpContent( std::shared_ptr val, std::map & ); static utility::string_t toBase64( utility::string_t value ); @@ -166,6 +179,8 @@ utility::string_t ModelBase::toString( const std::shared_ptr& val ) } return utility::string_t(ss.str()); } + +// std::vector to string template utility::string_t ModelBase::toString( const std::vector & val ) { @@ -180,6 +195,24 @@ utility::string_t ModelBase::toString( const std::vector & val ) } return strArray; } + +// std::set to string +template +utility::string_t ModelBase::toString( const std::set & val ) +{ + utility::string_t strArray; + for ( const auto &item : val ) + { + strArray.append( toString(item) + "," ); + } + if (val.count() > 0) + { + strArray.pop_back(); + } + return strArray; +} + + template web::json::value ModelBase::toJson( const std::shared_ptr& val ) { @@ -190,6 +223,8 @@ web::json::value ModelBase::toJson( const std::shared_ptr& val ) } return retVal; } + +// std::vector to json template web::json::value ModelBase::toJson( const std::vector& value ) { @@ -200,6 +235,21 @@ web::json::value ModelBase::toJson( const std::vector& value ) } return web::json::value::array(ret); } + +// std::set to json +template +web::json::value ModelBase::toJson( const std::set& value ) +{ + // There's no protoype web::json::value::array(...) taking a std::set parameter. Converting to std::vector to get an array. + std::vector ret; + for ( const auto& x : value ) + { + ret.push_back( toJson(x) ); + } + return web::json::value::array(ret); +} + + template web::json::value ModelBase::toJson( const std::map& val ) { @@ -290,6 +340,7 @@ std::shared_ptr ModelBase::toHttpContent(const utility::string_t& n } return content; } + template std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const std::vector& value, const utility::string_t& contentType ) { @@ -301,6 +352,7 @@ std::shared_ptr ModelBase::toHttpContent( const utility::string_t& content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) ); return content; } + template std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, const std::map& value, const utility::string_t& contentType ) { diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h index 1cba25431325..416eaf06afaf 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h @@ -24,7 +24,9 @@ #include "CppRestPetstoreClient/model/Tag.h" #include "CppRestPetstoreClient/model/Category.h" #include +#include "CppRestPetstoreClient/model/Pet_vaccinationBook.h" #include +#include namespace org { namespace openapitools { @@ -33,6 +35,7 @@ namespace model { class Category; class Tag; +class Pet_vaccinationBook; /// /// A pet for sale in the pet store @@ -112,6 +115,24 @@ class Pet void setStatus(const utility::string_t& value); + /// + /// pedigree and other certificates + /// + std::set& getCertificates(); + bool certificatesIsSet() const; + void unsetCertificates(); + + void setCertificates(const std::set& value); + + /// + /// + /// + std::shared_ptr getVaccinationBook() const; + bool vaccinationBookIsSet() const; + void unsetVaccinationBook(); + + void setVaccinationBook(const std::shared_ptr& value); + protected: int64_t m_Id; @@ -126,6 +147,10 @@ class Pet bool m_TagsIsSet; utility::string_t m_Status; bool m_StatusIsSet; + std::set m_Certificates; + bool m_CertificatesIsSet; + std::shared_ptr m_VaccinationBook; + bool m_VaccinationBookIsSet; }; diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet_vaccinationBook.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet_vaccinationBook.h new file mode 100644 index 000000000000..e82de6ab65aa --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet_vaccinationBook.h @@ -0,0 +1,79 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * Pet_vaccinationBook.h + * + * Vaccination book of the pet + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include "CppRestPetstoreClient/model/Vaccine.h" +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class Vaccine; + +/// +/// Vaccination book of the pet +/// +class Pet_vaccinationBook + : public ModelBase +{ +public: + Pet_vaccinationBook(); + virtual ~Pet_vaccinationBook(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Pet_vaccinationBook members + + /// + /// + /// + std::set>& getVaccines(); + bool vaccinesIsSet() const; + void unsetVaccines(); + + void setVaccines(const std::set>& value); + + +protected: + std::set> m_Vaccines; + bool m_VaccinesIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Vaccine.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Vaccine.h new file mode 100644 index 000000000000..81eceace2a77 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Vaccine.h @@ -0,0 +1,88 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * Vaccine.h + * + * + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_ + + +#include "CppRestPetstoreClient/ModelBase.h" + +#include "CppRestPetstoreClient/AnyType.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + +/// +/// +/// +class Vaccine + : public ModelBase +{ +public: + Vaccine(); + virtual ~Vaccine(); + + ///////////////////////////////////////////// + /// ModelBase overrides + + void validate() override; + + web::json::value toJson() const override; + bool fromJson(const web::json::value& json) override; + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override; + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override; + + ///////////////////////////////////////////// + /// Vaccine members + + /// + /// vaccination date + /// + std::shared_ptr getDate() const; + bool dateIsSet() const; + void unsetdate(); + + void setDate(const std::shared_ptr& value); + + /// + /// true if a booster is still needed to complete the vaccination + /// + bool isBoosterRequired() const; + bool boosterRequiredIsSet() const; + void unsetBoosterRequired(); + + void setBoosterRequired(bool value); + + +protected: + std::shared_ptr m_date; + bool m_dateIsSet; + bool m_BoosterRequired; + bool m_BoosterRequiredIsSet; +}; + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client/src/model/Pet.cpp b/samples/client/petstore/cpp-restsdk/client/src/model/Pet.cpp index cf3fb502098a..b4fba4a2629c 100644 --- a/samples/client/petstore/cpp-restsdk/client/src/model/Pet.cpp +++ b/samples/client/petstore/cpp-restsdk/client/src/model/Pet.cpp @@ -31,6 +31,8 @@ Pet::Pet() m_TagsIsSet = false; m_Status = utility::conversions::to_string_t(""); m_StatusIsSet = false; + m_CertificatesIsSet = false; + m_VaccinationBookIsSet = false; } Pet::~Pet() @@ -71,6 +73,14 @@ web::json::value Pet::toJson() const { val[utility::conversions::to_string_t(U("status"))] = ModelBase::toJson(m_Status); } + if(m_CertificatesIsSet) + { + val[utility::conversions::to_string_t(U("certificates"))] = ModelBase::toJson(m_Certificates); + } + if(m_VaccinationBookIsSet) + { + val[utility::conversions::to_string_t(U("vaccinationBook"))] = ModelBase::toJson(m_VaccinationBook); + } return val; } @@ -139,6 +149,26 @@ bool Pet::fromJson(const web::json::value& val) setStatus(refVal_setStatus); } } + if(val.has_field(utility::conversions::to_string_t(U("certificates")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("certificates"))); + if(!fieldValue.is_null()) + { + std::set refVal_setCertificates; + ok &= ModelBase::fromJson(fieldValue, refVal_setCertificates); + setCertificates(refVal_setCertificates); + } + } + if(val.has_field(utility::conversions::to_string_t(U("vaccinationBook")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("vaccinationBook"))); + if(!fieldValue.is_null()) + { + std::shared_ptr refVal_setVaccinationBook; + ok &= ModelBase::fromJson(fieldValue, refVal_setVaccinationBook); + setVaccinationBook(refVal_setVaccinationBook); + } + } return ok; } @@ -173,6 +203,14 @@ void Pet::toMultipart(std::shared_ptr multipart, const utilit { multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("status")), m_Status)); } + if(m_CertificatesIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("certificates")), m_Certificates)); + } + if(m_VaccinationBookIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("vaccinationBook")), m_VaccinationBook)); + } } bool Pet::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) @@ -220,6 +258,18 @@ bool Pet::fromMultiPart(std::shared_ptr multipart, const util ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("status"))), refVal_setStatus ); setStatus(refVal_setStatus); } + if(multipart->hasContent(utility::conversions::to_string_t(U("certificates")))) + { + std::set refVal_setCertificates; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("certificates"))), refVal_setCertificates ); + setCertificates(refVal_setCertificates); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("vaccinationBook")))) + { + std::shared_ptr refVal_setVaccinationBook; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("vaccinationBook"))), refVal_setVaccinationBook ); + setVaccinationBook(refVal_setVaccinationBook); + } return ok; } @@ -343,6 +393,46 @@ void Pet::unsetStatus() { m_StatusIsSet = false; } +std::set& Pet::getCertificates() +{ + return m_Certificates; +} + +void Pet::setCertificates(const std::set& value) +{ + m_Certificates = value; + m_CertificatesIsSet = true; +} + +bool Pet::certificatesIsSet() const +{ + return m_CertificatesIsSet; +} + +void Pet::unsetCertificates() +{ + m_CertificatesIsSet = false; +} +std::shared_ptr Pet::getVaccinationBook() const +{ + return m_VaccinationBook; +} + +void Pet::setVaccinationBook(const std::shared_ptr& value) +{ + m_VaccinationBook = value; + m_VaccinationBookIsSet = true; +} + +bool Pet::vaccinationBookIsSet() const +{ + return m_VaccinationBookIsSet; +} + +void Pet::unsetVaccinationBook() +{ + m_VaccinationBookIsSet = false; +} } } } diff --git a/samples/client/petstore/cpp-restsdk/client/src/model/Pet_vaccinationBook.cpp b/samples/client/petstore/cpp-restsdk/client/src/model/Pet_vaccinationBook.cpp new file mode 100644 index 000000000000..082e038bf2ed --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client/src/model/Pet_vaccinationBook.cpp @@ -0,0 +1,123 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/Pet_vaccinationBook.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +Pet_vaccinationBook::Pet_vaccinationBook() +{ + m_VaccinesIsSet = false; +} + +Pet_vaccinationBook::~Pet_vaccinationBook() +{ +} + +void Pet_vaccinationBook::validate() +{ + // TODO: implement validation +} + +web::json::value Pet_vaccinationBook::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_VaccinesIsSet) + { + val[utility::conversions::to_string_t(U("vaccines"))] = ModelBase::toJson(m_Vaccines); + } + + return val; +} + +bool Pet_vaccinationBook::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("vaccines")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("vaccines"))); + if(!fieldValue.is_null()) + { + std::set> refVal_setVaccines; + ok &= ModelBase::fromJson(fieldValue, refVal_setVaccines); + setVaccines(refVal_setVaccines); + } + } + return ok; +} + +void Pet_vaccinationBook::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_VaccinesIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("vaccines")), m_Vaccines)); + } +} + +bool Pet_vaccinationBook::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("vaccines")))) + { + std::set> refVal_setVaccines; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("vaccines"))), refVal_setVaccines ); + setVaccines(refVal_setVaccines); + } + return ok; +} + +std::set>& Pet_vaccinationBook::getVaccines() +{ + return m_Vaccines; +} + +void Pet_vaccinationBook::setVaccines(const std::set>& value) +{ + m_Vaccines = value; + m_VaccinesIsSet = true; +} + +bool Pet_vaccinationBook::vaccinesIsSet() const +{ + return m_VaccinesIsSet; +} + +void Pet_vaccinationBook::unsetVaccines() +{ + m_VaccinesIsSet = false; +} +} +} +} +} + + diff --git a/samples/client/petstore/cpp-restsdk/client/src/model/Vaccine.cpp b/samples/client/petstore/cpp-restsdk/client/src/model/Vaccine.cpp new file mode 100644 index 000000000000..73f040f8b0ac --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client/src/model/Vaccine.cpp @@ -0,0 +1,169 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/Vaccine.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + + +Vaccine::Vaccine() +{ + m_dateIsSet = false; + m_BoosterRequired = false; + m_BoosterRequiredIsSet = false; +} + +Vaccine::~Vaccine() +{ +} + +void Vaccine::validate() +{ + // TODO: implement validation +} + +web::json::value Vaccine::toJson() const +{ + + web::json::value val = web::json::value::object(); + + if(m_dateIsSet) + { + val[utility::conversions::to_string_t(U("date"))] = ModelBase::toJson(m_date); + } + if(m_BoosterRequiredIsSet) + { + val[utility::conversions::to_string_t(U("boosterRequired"))] = ModelBase::toJson(m_BoosterRequired); + } + + return val; +} + +bool Vaccine::fromJson(const web::json::value& val) +{ + bool ok = true; + + if(val.has_field(utility::conversions::to_string_t(U("date")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("date"))); + if(!fieldValue.is_null()) + { + std::shared_ptr refVal_setDate; + ok &= ModelBase::fromJson(fieldValue, refVal_setDate); + setDate(refVal_setDate); + } + } + if(val.has_field(utility::conversions::to_string_t(U("boosterRequired")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("boosterRequired"))); + if(!fieldValue.is_null()) + { + bool refVal_setBoosterRequired; + ok &= ModelBase::fromJson(fieldValue, refVal_setBoosterRequired); + setBoosterRequired(refVal_setBoosterRequired); + } + } + return ok; +} + +void Vaccine::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + if(m_dateIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("date")), m_date)); + } + if(m_BoosterRequiredIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("boosterRequired")), m_BoosterRequired)); + } +} + +bool Vaccine::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) +{ + bool ok = true; + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U("."))) + { + namePrefix += utility::conversions::to_string_t(U(".")); + } + + if(multipart->hasContent(utility::conversions::to_string_t(U("date")))) + { + std::shared_ptr refVal_setDate; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("date"))), refVal_setDate ); + setDate(refVal_setDate); + } + if(multipart->hasContent(utility::conversions::to_string_t(U("boosterRequired")))) + { + bool refVal_setBoosterRequired; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("boosterRequired"))), refVal_setBoosterRequired ); + setBoosterRequired(refVal_setBoosterRequired); + } + return ok; +} + +std::shared_ptr Vaccine::getDate() const +{ + return m_date; +} + +void Vaccine::setDate(const std::shared_ptr& value) +{ + m_date = value; + m_dateIsSet = true; +} + +bool Vaccine::dateIsSet() const +{ + return m_dateIsSet; +} + +void Vaccine::unsetdate() +{ + m_dateIsSet = false; +} +bool Vaccine::isBoosterRequired() const +{ + return m_BoosterRequired; +} + +void Vaccine::setBoosterRequired(bool value) +{ + m_BoosterRequired = value; + m_BoosterRequiredIsSet = true; +} + +bool Vaccine::boosterRequiredIsSet() const +{ + return m_BoosterRequiredIsSet; +} + +void Vaccine::unsetBoosterRequired() +{ + m_BoosterRequiredIsSet = false; +} +} +} +} +} + + diff --git a/samples/server/petstore/cpp-pistache-everything/.openapi-generator/FILES b/samples/server/petstore/cpp-pistache-everything/.openapi-generator/FILES index c0724b40461a..8d2d9fc52434 100644 --- a/samples/server/petstore/cpp-pistache-everything/.openapi-generator/FILES +++ b/samples/server/petstore/cpp-pistache-everything/.openapi-generator/FILES @@ -24,9 +24,11 @@ model/Order.cpp model/Order.h model/Pet.cpp model/Pet.h -model/Pet_bestFriends.cpp -model/Pet_bestFriends.h +model/Pet_vaccinationBook.cpp +model/Pet_vaccinationBook.h model/Tag.cpp model/Tag.h model/User.cpp model/User.h +model/Vaccine.cpp +model/Vaccine.h diff --git a/samples/server/petstore/cpp-pistache-everything/model/Helpers.h b/samples/server/petstore/cpp-pistache-everything/model/Helpers.h index 176b817de1eb..832ac04c98ef 100644 --- a/samples/server/petstore/cpp-pistache-everything/model/Helpers.h +++ b/samples/server/petstore/cpp-pistache-everything/model/Helpers.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace org::openapitools::server::helpers { @@ -92,6 +93,15 @@ namespace org::openapitools::server::helpers return true; } + /// + /// Determine if the given vector only has unique elements. T must provide the == operator. + /// + template + bool hasOnlyUniqueItems(const std::set& set) + { + return true; + } + std::string toStringValue(const std::string &value); std::string toStringValue(const int32_t value); std::string toStringValue(const int64_t value); diff --git a/samples/server/petstore/cpp-pistache-everything/model/Pet.cpp b/samples/server/petstore/cpp-pistache-everything/model/Pet.cpp index 5c5971cc8c1c..e1bc313982be 100644 --- a/samples/server/petstore/cpp-pistache-everything/model/Pet.cpp +++ b/samples/server/petstore/cpp-pistache-everything/model/Pet.cpp @@ -30,7 +30,8 @@ Pet::Pet() m_StatusIsSet = false; m_VeterinarianVisitIsSet = false; m_GoodiesIsSet = false; - m_BestFriendsIsSet = false; + m_CertificatesIsSet = false; + m_VaccinationBookIsSet = false; } @@ -111,6 +112,32 @@ bool Pet::validate(std::stringstream& msg, const std::string& pathPrefix) const + i++; + } + } + + } + + if (certificatesIsSet()) + { + const std::set& value = m_Certificates; + const std::string currentValuePath = _pathPrefix + ".certificates"; + + + if (!org::openapitools::server::helpers::hasOnlyUniqueItems(value)) + { + success = false; + msg << currentValuePath << ": may not contain the same item more than once;"; + } + { // Recursive validation of array elements + const std::string oldValuePath = currentValuePath; + int i = 0; + for (const std::string& value : value) + { + const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; + + + i++; } } @@ -150,7 +177,10 @@ bool Pet::operator==(const Pet& rhs) const ((!goodiesIsSet() && !rhs.goodiesIsSet()) || (goodiesIsSet() && rhs.goodiesIsSet() && getGoodies() == rhs.getGoodies())) && - ((!bestFriendsIsSet() && !rhs.bestFriendsIsSet()) || (bestFriendsIsSet() && rhs.bestFriendsIsSet() && getBestFriends() == rhs.getBestFriends())) + ((!certificatesIsSet() && !rhs.certificatesIsSet()) || (certificatesIsSet() && rhs.certificatesIsSet() && getCertificates() == rhs.getCertificates())) && + + + ((!vaccinationBookIsSet() && !rhs.vaccinationBookIsSet()) || (vaccinationBookIsSet() && rhs.vaccinationBookIsSet() && getVaccinationBook() == rhs.getVaccinationBook())) ; } @@ -177,8 +207,10 @@ void to_json(nlohmann::json& j, const Pet& o) j["veterinarianVisit"] = o.m_VeterinarianVisit; if(o.goodiesIsSet() || !o.m_Goodies.empty()) j["goodies"] = o.m_Goodies; - if(o.bestFriendsIsSet()) - j["bestFriends"] = o.m_BestFriends; + if(o.certificatesIsSet() || !o.m_Certificates.empty()) + j["certificates"] = o.m_Certificates; + if(o.vaccinationBookIsSet()) + j["vaccinationBook"] = o.m_VaccinationBook; } @@ -216,10 +248,15 @@ void from_json(const nlohmann::json& j, Pet& o) j.at("goodies").get_to(o.m_Goodies); o.m_GoodiesIsSet = true; } - if(j.find("bestFriends") != j.end()) + if(j.find("certificates") != j.end()) + { + j.at("certificates").get_to(o.m_Certificates); + o.m_CertificatesIsSet = true; + } + if(j.find("vaccinationBook") != j.end()) { - j.at("bestFriends").get_to(o.m_BestFriends); - o.m_BestFriendsIsSet = true; + j.at("vaccinationBook").get_to(o.m_VaccinationBook); + o.m_VaccinationBookIsSet = true; } } @@ -342,22 +379,39 @@ void Pet::unsetGoodies() { m_GoodiesIsSet = false; } -org::openapitools::server::model::Pet_bestFriends Pet::getBestFriends() const +std::set Pet::getCertificates() const +{ + return m_Certificates; +} +void Pet::setCertificates(std::set const& value) +{ + m_Certificates = value; + m_CertificatesIsSet = true; +} +bool Pet::certificatesIsSet() const +{ + return m_CertificatesIsSet; +} +void Pet::unsetCertificates() +{ + m_CertificatesIsSet = false; +} +org::openapitools::server::model::Pet_vaccinationBook Pet::getVaccinationBook() const { - return m_BestFriends; + return m_VaccinationBook; } -void Pet::setBestFriends(org::openapitools::server::model::Pet_bestFriends const& value) +void Pet::setVaccinationBook(org::openapitools::server::model::Pet_vaccinationBook const& value) { - m_BestFriends = value; - m_BestFriendsIsSet = true; + m_VaccinationBook = value; + m_VaccinationBookIsSet = true; } -bool Pet::bestFriendsIsSet() const +bool Pet::vaccinationBookIsSet() const { - return m_BestFriendsIsSet; + return m_VaccinationBookIsSet; } -void Pet::unsetBestFriends() +void Pet::unsetVaccinationBook() { - m_BestFriendsIsSet = false; + m_VaccinationBookIsSet = false; } diff --git a/samples/server/petstore/cpp-pistache-everything/model/Pet.h b/samples/server/petstore/cpp-pistache-everything/model/Pet.h index 289698030791..e3c5986e2d24 100644 --- a/samples/server/petstore/cpp-pistache-everything/model/Pet.h +++ b/samples/server/petstore/cpp-pistache-everything/model/Pet.h @@ -21,10 +21,11 @@ #include "Tag.h" #include -#include "Pet_bestFriends.h" +#include "Pet_vaccinationBook.h" #include #include "Category.h" #include +#include #include namespace org::openapitools::server::model @@ -116,12 +117,19 @@ class Pet bool goodiesIsSet() const; void unsetGoodies(); /// + /// pedigree and other certificates + /// + std::set getCertificates() const; + void setCertificates(std::set const& value); + bool certificatesIsSet() const; + void unsetCertificates(); + /// /// /// - org::openapitools::server::model::Pet_bestFriends getBestFriends() const; - void setBestFriends(org::openapitools::server::model::Pet_bestFriends const& value); - bool bestFriendsIsSet() const; - void unsetBestFriends(); + org::openapitools::server::model::Pet_vaccinationBook getVaccinationBook() const; + void setVaccinationBook(org::openapitools::server::model::Pet_vaccinationBook const& value); + bool vaccinationBookIsSet() const; + void unsetVaccinationBook(); friend void to_json(nlohmann::json& j, const Pet& o); friend void from_json(const nlohmann::json& j, Pet& o); @@ -142,8 +150,10 @@ class Pet bool m_VeterinarianVisitIsSet; std::vector m_Goodies; bool m_GoodiesIsSet; - org::openapitools::server::model::Pet_bestFriends m_BestFriends; - bool m_BestFriendsIsSet; + std::set m_Certificates; + bool m_CertificatesIsSet; + org::openapitools::server::model::Pet_vaccinationBook m_VaccinationBook; + bool m_VaccinationBookIsSet; }; diff --git a/samples/server/petstore/cpp-pistache-everything/model/Pet_vaccinationBook.cpp b/samples/server/petstore/cpp-pistache-everything/model/Pet_vaccinationBook.cpp new file mode 100644 index 000000000000..9117677c43c8 --- /dev/null +++ b/samples/server/petstore/cpp-pistache-everything/model/Pet_vaccinationBook.cpp @@ -0,0 +1,116 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ + + +#include "Pet_vaccinationBook.h" +#include "Helpers.h" + +#include + +namespace org::openapitools::server::model +{ + +Pet_vaccinationBook::Pet_vaccinationBook() +{ + +} + +void Pet_vaccinationBook::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool Pet_vaccinationBook::validate(std::stringstream& msg) const +{ + return validate(msg, ""); +} + +bool Pet_vaccinationBook::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Pet_vaccinationBook" : pathPrefix; + + + + /* Vaccines */ { + const std::set& value = m_Vaccines; + const std::string currentValuePath = _pathPrefix + ".vaccines"; + + + if (!org::openapitools::server::helpers::hasOnlyUniqueItems(value)) + { + success = false; + msg << currentValuePath << ": may not contain the same item more than once;"; + } + { // Recursive validation of array elements + const std::string oldValuePath = currentValuePath; + int i = 0; + for (const org::openapitools::server::model::Vaccine& value : value) + { + const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; + + success = value.validate(msg, currentValuePath + ".vaccines") && success; + + i++; + } + } + + } + + return success; +} + +bool Pet_vaccinationBook::operator==(const Pet_vaccinationBook& rhs) const +{ + return + + + (getVaccines() == rhs.getVaccines()) + + + ; +} + +bool Pet_vaccinationBook::operator!=(const Pet_vaccinationBook& rhs) const +{ + return !(*this == rhs); +} + +void to_json(nlohmann::json& j, const Pet_vaccinationBook& o) +{ + j = nlohmann::json::object(); + j["vaccines"] = o.m_Vaccines; + +} + +void from_json(const nlohmann::json& j, Pet_vaccinationBook& o) +{ + j.at("vaccines").get_to(o.m_Vaccines); + +} + +std::set Pet_vaccinationBook::getVaccines() const +{ + return m_Vaccines; +} +void Pet_vaccinationBook::setVaccines(std::set const& value) +{ + m_Vaccines = value; +} + + +} // namespace org::openapitools::server::model + diff --git a/samples/server/petstore/cpp-pistache-everything/model/Pet_vaccinationBook.h b/samples/server/petstore/cpp-pistache-everything/model/Pet_vaccinationBook.h new file mode 100644 index 000000000000..47977d741c4b --- /dev/null +++ b/samples/server/petstore/cpp-pistache-everything/model/Pet_vaccinationBook.h @@ -0,0 +1,78 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +/* + * Pet_vaccinationBook.h + * + * Vaccination book of the pet + */ + +#ifndef Pet_vaccinationBook_H_ +#define Pet_vaccinationBook_H_ + + +#include "Vaccine.h" +#include +#include + +namespace org::openapitools::server::model +{ + +/// +/// Vaccination book of the pet +/// +class Pet_vaccinationBook +{ +public: + Pet_vaccinationBook(); + virtual ~Pet_vaccinationBook() = default; + + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + /// + /// Helper overload for validate. Used when one model stores another model and calls it's validate. + /// Not meant to be called outside that case. + /// + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; + + bool operator==(const Pet_vaccinationBook& rhs) const; + bool operator!=(const Pet_vaccinationBook& rhs) const; + + ///////////////////////////////////////////// + /// Pet_vaccinationBook members + + /// + /// + /// + std::set getVaccines() const; + void setVaccines(std::set const& value); + + friend void to_json(nlohmann::json& j, const Pet_vaccinationBook& o); + friend void from_json(const nlohmann::json& j, Pet_vaccinationBook& o); +protected: + std::set m_Vaccines; + + +}; + +} // namespace org::openapitools::server::model + +#endif /* Pet_vaccinationBook_H_ */ diff --git a/samples/server/petstore/cpp-pistache-everything/model/Vaccine.cpp b/samples/server/petstore/cpp-pistache-everything/model/Vaccine.cpp new file mode 100644 index 000000000000..ae81354eb06e --- /dev/null +++ b/samples/server/petstore/cpp-pistache-everything/model/Vaccine.cpp @@ -0,0 +1,104 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ + + +#include "Vaccine.h" +#include "Helpers.h" + +#include + +namespace org::openapitools::server::model +{ + +Vaccine::Vaccine() +{ + m_BoosterRequired = false; + +} + +void Vaccine::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool Vaccine::validate(std::stringstream& msg) const +{ + return validate(msg, ""); +} + +bool Vaccine::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Vaccine" : pathPrefix; + + + return success; +} + +bool Vaccine::operator==(const Vaccine& rhs) const +{ + return + + + (getDate() == rhs.getDate()) + && + + (isBoosterRequired() == rhs.isBoosterRequired()) + + + ; +} + +bool Vaccine::operator!=(const Vaccine& rhs) const +{ + return !(*this == rhs); +} + +void to_json(nlohmann::json& j, const Vaccine& o) +{ + j = nlohmann::json::object(); + j["date"] = o.m_date; + j["boosterRequired"] = o.m_BoosterRequired; + +} + +void from_json(const nlohmann::json& j, Vaccine& o) +{ + j.at("date").get_to(o.m_date); + j.at("boosterRequired").get_to(o.m_BoosterRequired); + +} + +nlohmann::json Vaccine::getDate() const +{ + return m_date; +} +void Vaccine::setDate(nlohmann::json const& value) +{ + m_date = value; +} +bool Vaccine::isBoosterRequired() const +{ + return m_BoosterRequired; +} +void Vaccine::setBoosterRequired(bool const value) +{ + m_BoosterRequired = value; +} + + +} // namespace org::openapitools::server::model + diff --git a/samples/server/petstore/cpp-pistache-everything/model/Vaccine.h b/samples/server/petstore/cpp-pistache-everything/model/Vaccine.h new file mode 100644 index 000000000000..da87ece1a0ce --- /dev/null +++ b/samples/server/petstore/cpp-pistache-everything/model/Vaccine.h @@ -0,0 +1,84 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +/* + * Vaccine.h + * + * + */ + +#ifndef Vaccine_H_ +#define Vaccine_H_ + + +#include +#include + +namespace org::openapitools::server::model +{ + +/// +/// +/// +class Vaccine +{ +public: + Vaccine(); + virtual ~Vaccine() = default; + + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + /// + /// Helper overload for validate. Used when one model stores another model and calls it's validate. + /// Not meant to be called outside that case. + /// + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; + + bool operator==(const Vaccine& rhs) const; + bool operator!=(const Vaccine& rhs) const; + + ///////////////////////////////////////////// + /// Vaccine members + + /// + /// vaccination date + /// + nlohmann::json getDate() const; + void setDate(nlohmann::json const& value); + /// + /// true if a booster is still needed to complete the vaccination + /// + bool isBoosterRequired() const; + void setBoosterRequired(bool const value); + + friend void to_json(nlohmann::json& j, const Vaccine& o); + friend void from_json(const nlohmann::json& j, Vaccine& o); +protected: + nlohmann::json m_date; + + bool m_BoosterRequired; + + +}; + +} // namespace org::openapitools::server::model + +#endif /* Vaccine_H_ */ diff --git a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/Helpers.h b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/Helpers.h index 93a2a510414c..f053b1a91a3a 100644 --- a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/Helpers.h +++ b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/Helpers.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace org::openapitools::server::helpers { @@ -92,6 +93,15 @@ namespace org::openapitools::server::helpers return true; } + /// + /// Determine if the given vector only has unique elements. T must provide the == operator. + /// + template + bool hasOnlyUniqueItems(const std::set& set) + { + return true; + } + std::string toStringValue(const std::string &value); std::string toStringValue(const int32_t value); std::string toStringValue(const int64_t value); diff --git a/samples/server/petstore/cpp-pistache/model/Helpers.h b/samples/server/petstore/cpp-pistache/model/Helpers.h index 176b817de1eb..832ac04c98ef 100644 --- a/samples/server/petstore/cpp-pistache/model/Helpers.h +++ b/samples/server/petstore/cpp-pistache/model/Helpers.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace org::openapitools::server::helpers { @@ -92,6 +93,15 @@ namespace org::openapitools::server::helpers return true; } + /// + /// Determine if the given vector only has unique elements. T must provide the == operator. + /// + template + bool hasOnlyUniqueItems(const std::set& set) + { + return true; + } + std::string toStringValue(const std::string &value); std::string toStringValue(const int32_t value); std::string toStringValue(const int64_t value);