diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh index 2ab6fbeb71b4..56cd4f5161de 100755 --- a/CI/circle_parallel.sh +++ b/CI/circle_parallel.sh @@ -41,6 +41,10 @@ elif [ "$NODE_INDEX" = "2" ]; then # install cpprestsdk sudo apt-get install libcpprest-dev + wget "https://github.com/aminya/setup-cpp/releases/download/v0.37.0/setup-cpp-x64-linux" + chmod +x ./setup-cpp-x64-linux + sudo ./setup-cpp-x64-linux --compiler llvm --cmake true --ninja true + source ~/.cpprc # activate cpp environment variables # run go integration tests (cd samples/client/petstore/go && mvn integration-test) diff --git a/docs/generators/cpp-restsdk.md b/docs/generators/cpp-restsdk.md index aef6bfe1c397..f8095ede9104 100644 --- a/docs/generators/cpp-restsdk.md +++ b/docs/generators/cpp-restsdk.md @@ -249,7 +249,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |Union|✗|OAS3 |allOf|✗|OAS2,OAS3 |anyOf|✗|OAS3 -|oneOf|✗|OAS3 +|oneOf|✓|OAS3 |not|✗|OAS3 ### Security Feature 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 19e8dfdf504d..a802ea26f878 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 @@ -105,7 +105,8 @@ public CppRestSdkClientCodegen() { GlobalFeature.MultiServer ) .includeSchemaSupportFeatures( - SchemaSupportFeature.Polymorphism + SchemaSupportFeature.Polymorphism, + SchemaSupportFeature.oneOf ) .excludeParameterFeatures( ParameterFeature.Cookie diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache index 5338b5a9dc2a..f4275fd66e94 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache @@ -265,7 +265,7 @@ pplx::task<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{classname}}::{{ {{/authMethods}} return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("{{httpMethod}}"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -299,7 +299,7 @@ pplx::task<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{classname}}::{{ {{#vendorExtensions.x-codegen-response-ishttpcontent}} return localVarResponse.extract_vector(); }) - .then([=](std::vector localVarResponse) + .then([=, this](std::vector localVarResponse) { {{{returnType}}} localVarResult = std::make_shared(); std::shared_ptr stream = std::make_shared(std::string(localVarResponse.begin(), localVarResponse.end())); @@ -309,7 +309,7 @@ pplx::task<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{classname}}::{{ {{^vendorExtensions.x-codegen-response-ishttpcontent}} return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { {{^returnType}} return void(); diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/cmake-lists.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/cmake-lists.mustache index 0b21eeb050c8..f3b23e27b311 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/cmake-lists.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/cmake-lists.mustache @@ -8,16 +8,27 @@ # # NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech). -cmake_minimum_required (VERSION 3.1) +cmake_minimum_required (VERSION 3.5) -project({{{packageName}}}) +project({{{packageName}}} CXX) # Force -fPIC even if the project is configured for building a static library. set(CMAKE_POSITION_INDEPENDENT_CODE ON) -set(CXX_STANDARD_REQUIRED ON) +set(CXX_STANDARD_REQUIRED ON) if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) + if(DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION OR + DEFINED CMAKE_CXX20_EXTENSION_COMPILE_OPTION) + set(CMAKE_CXX_STANDARD 20) + elseif(DEFINED CMAKE_CXX17_STANDARD_COMPILE_OPTION OR + DEFINED CMAKE_CXX17_EXTENSION_COMPILE_OPTION) + set(CMAKE_CXX_STANDARD 17) + elseif(DEFINED CMAKE_CXX14_STANDARD_COMPILE_OPTION OR + DEFINED CMAKE_CXX14_EXTENSION_COMPILE_OPTION) + set(CMAKE_CXX_STANDARD 14) + else() + set(CMAKE_CXX_STANDARD 11) + endif() endif() if(NOT CMAKE_BUILD_TYPE) @@ -38,12 +49,12 @@ add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES}) target_compile_options(${PROJECT_NAME} PRIVATE $<$,$,$>: - -Wall -Wno-unused-variable> + -Wall -Wno-unused-variable -Wno-unused-lambda-capture> ) target_include_directories(${PROJECT_NAME} PUBLIC - $ + $ $ ) @@ -90,4 +101,4 @@ install( install( EXPORT ${PROJECT_NAME}Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} -) \ No newline at end of file +) diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-header.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-header.mustache index b5f070074df6..e7374f4a1018 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-header.mustache @@ -8,6 +8,11 @@ #ifndef {{modelHeaderGuardPrefix}}_{{classname}}_H_ #define {{modelHeaderGuardPrefix}}_{{classname}}_H_ +{{#oneOf}} +{{#-first}} +#include +{{/-first}} +{{/oneOf}} {{^parent}} {{{defaultInclude}}} #include "{{packageName}}/ModelBase.h" @@ -24,6 +29,60 @@ namespace {{this}} { {{#vendorExtensions.x-forward-declarations}}{{.}} {{/vendorExtensions.x-forward-declarations}} {{/vendorExtensions.x-has-forward-declarations}} +{{#oneOf}}{{#-first}} + +class {{declspec}} {{classname}} +{ +public: + {{classname}}() = default; + ~{{classname}}() = default; + + ///////////////////////////////////////////// + + void validate(); + + web::json::value toJson() const; + + template + bool fromJson(const web::json::value& json) { + // convert json to Target type + Target target; + if (!target.fromJson(json)) { + return false; + } + + m_variantValue = target; + return true; + } + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const; + + template + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) { + // convert multipart to Target type + Target target; + if (!target.fromMultiPart(multipart, namePrefix)) { + return false; + } + + m_variantValue = target; + return true; + } + + ///////////////////////////////////////////// + /// {{classname}} members + + using VariantType = std::variant<{{#oneOf}}{{^-first}}, {{/-first}}{{{.}}}{{/oneOf}}>; + + const VariantType& getVariant() const; + void setVariant(VariantType value); + +protected: + VariantType m_variantValue; +}; + +{{/-first}}{{/oneOf}} +{{^oneOf}} {{#isEnum}} class {{declspec}} {{classname}} : public {{{parent}}}{{^parent}}ModelBase{{/parent}} @@ -120,6 +179,7 @@ protected: }; {{/isEnum}} +{{/oneOf}} {{#modelNamespaceDeclarations}} } diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-source.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-source.mustache index e8d2ea96a402..49e9894da568 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/model-source.mustache @@ -6,7 +6,56 @@ {{#modelNamespaceDeclarations}} namespace {{this}} { {{/modelNamespaceDeclarations}} +{{#oneOf}}{{#-first}} +void {{classname}}::validate() +{ + // TODO: implement validation +} + +const {{classname}}::VariantType& {{classname}}::getVariant() const +{ + return m_variantValue; +} + +void {{classname}}::setVariant({{classname}}::VariantType value) +{ + m_variantValue = value; +} + +web::json::value {{classname}}::toJson() const +{ + web::json::value val = web::json::value::object(); + + std::visit([&](auto&& arg) { + using T = std::decay_t; + if constexpr (std::is_same_v) { + val = web::json::value::null(); + } else { + val = arg.toJson(); + } + }, m_variantValue); + + return val; +} + +void {{classname}}::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + std::visit([&](auto&& arg) { + using T = std::decay_t; + if constexpr (!std::is_same_v) { + arg.toMultipart(multipart, prefix); + } + }, m_variantValue); +} + +{{#oneOf}} +template bool {{classname}}::fromJson<{{.}}>(const web::json::value& json); +template bool {{classname}}::fromMultiPart<{{.}}>(std::shared_ptr multipart, const utility::string_t& namePrefix); +{{/oneOf}} + +{{/-first}}{{/oneOf}} +{{^oneOf}} {{#isEnum}} namespace @@ -269,6 +318,7 @@ void {{classname}}::unset{{name}}() {{/isInherited}} {{/vars}} {{/isEnum}} +{{/oneOf}} {{#modelNamespaceDeclarations}} } {{/modelNamespaceDeclarations}} 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 64ca7deaaf89..28dc856f83e1 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 @@ -569,6 +569,27 @@ paths: description: User not found security: - api_key: [] + /user_or_pet: + post: + tags: + - user_or_pet + summary: Create user or pet + description: This can only be done by the logged in user or pet. + operationId: createUserOrPet + responses: + default: + description: successful operation + security: + - api_key: [] + requestBody: + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/User' + - $ref: '#/components/schemas/Pet' + description: Created user or pet object + required: true externalDocs: description: Find out more about Swagger url: 'http://swagger.io' diff --git a/samples/client/petstore/cpp-restsdk/client/.openapi-generator/FILES b/samples/client/petstore/cpp-restsdk/client/.openapi-generator/FILES index 06401fbfbce3..0570b3e661c6 100644 --- a/samples/client/petstore/cpp-restsdk/client/.openapi-generator/FILES +++ b/samples/client/petstore/cpp-restsdk/client/.openapi-generator/FILES @@ -16,8 +16,10 @@ include/CppRestPetstoreClient/Object.h include/CppRestPetstoreClient/api/PetApi.h include/CppRestPetstoreClient/api/StoreApi.h include/CppRestPetstoreClient/api/UserApi.h +include/CppRestPetstoreClient/api/UserOrPetApi.h include/CppRestPetstoreClient/model/ApiResponse.h include/CppRestPetstoreClient/model/Category.h +include/CppRestPetstoreClient/model/CreateUserOrPet_request.h include/CppRestPetstoreClient/model/Order.h include/CppRestPetstoreClient/model/Pet.h include/CppRestPetstoreClient/model/SchemaWithSet.h @@ -37,8 +39,10 @@ src/Object.cpp src/api/PetApi.cpp src/api/StoreApi.cpp src/api/UserApi.cpp +src/api/UserOrPetApi.cpp src/model/ApiResponse.cpp src/model/Category.cpp +src/model/CreateUserOrPet_request.cpp src/model/Order.cpp src/model/Pet.cpp src/model/SchemaWithSet.cpp diff --git a/samples/client/petstore/cpp-restsdk/client/CMakeLists.txt b/samples/client/petstore/cpp-restsdk/client/CMakeLists.txt index 1212e2c4d0fd..4c8236584363 100644 --- a/samples/client/petstore/cpp-restsdk/client/CMakeLists.txt +++ b/samples/client/petstore/cpp-restsdk/client/CMakeLists.txt @@ -8,16 +8,27 @@ # # NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech). -cmake_minimum_required (VERSION 3.1) +cmake_minimum_required (VERSION 3.5) -project(CppRestPetstoreClient) +project(CppRestPetstoreClient CXX) # Force -fPIC even if the project is configured for building a static library. set(CMAKE_POSITION_INDEPENDENT_CODE ON) -set(CXX_STANDARD_REQUIRED ON) +set(CXX_STANDARD_REQUIRED ON) if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) + if(DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION OR + DEFINED CMAKE_CXX20_EXTENSION_COMPILE_OPTION) + set(CMAKE_CXX_STANDARD 20) + elseif(DEFINED CMAKE_CXX17_STANDARD_COMPILE_OPTION OR + DEFINED CMAKE_CXX17_EXTENSION_COMPILE_OPTION) + set(CMAKE_CXX_STANDARD 17) + elseif(DEFINED CMAKE_CXX14_STANDARD_COMPILE_OPTION OR + DEFINED CMAKE_CXX14_EXTENSION_COMPILE_OPTION) + set(CMAKE_CXX_STANDARD 14) + else() + set(CMAKE_CXX_STANDARD 11) + endif() endif() if(NOT CMAKE_BUILD_TYPE) @@ -38,12 +49,12 @@ add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES}) target_compile_options(${PROJECT_NAME} PRIVATE $<$,$,$>: - -Wall -Wno-unused-variable> + -Wall -Wno-unused-variable -Wno-unused-lambda-capture> ) target_include_directories(${PROJECT_NAME} PUBLIC - $ + $ $ ) @@ -90,4 +101,4 @@ install( 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/include/CppRestPetstoreClient/api/UserOrPetApi.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/api/UserOrPetApi.h new file mode 100644 index 000000000000..b620355822ae --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/api/UserOrPetApi.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.7.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * UserOrPetApi.h + * + * + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_API_UserOrPetApi_H_ +#define ORG_OPENAPITOOLS_CLIENT_API_UserOrPetApi_H_ + + + +#include "CppRestPetstoreClient/ApiClient.h" + +#include "CppRestPetstoreClient/model/CreateUserOrPet_request.h" +#include + +namespace org { +namespace openapitools { +namespace client { +namespace api { + +using namespace org::openapitools::client::model; + + + +class UserOrPetApi +{ +public: + + explicit UserOrPetApi( std::shared_ptr apiClient ); + + virtual ~UserOrPetApi(); + + /// + /// Create user or pet + /// + /// + /// This can only be done by the logged in user or pet. + /// + /// Created user or pet object + pplx::task createUserOrPet( + std::shared_ptr createUserOrPetRequest + ) const; + +protected: + std::shared_ptr m_ApiClient; +}; + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_API_UserOrPetApi_H_ */ + diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/ApiResponse.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/ApiResponse.h index 51070cb4ebf5..9ac0849a547b 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/ApiResponse.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/ApiResponse.h @@ -29,6 +29,7 @@ namespace client { namespace model { + /// /// Describes the result of uploading an image resource /// diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Category.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Category.h index 56c2e158283b..72b3bd910995 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Category.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Category.h @@ -29,6 +29,7 @@ namespace client { namespace model { + /// /// A category for a pet /// diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/CreateUserOrPet_request.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/CreateUserOrPet_request.h new file mode 100644 index 000000000000..723cd51b3b08 --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/CreateUserOrPet_request.h @@ -0,0 +1,98 @@ +/** + * 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.7.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * CreateUserOrPet_request.h + * + * + */ + +#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_CreateUserOrPet_request_H_ +#define ORG_OPENAPITOOLS_CLIENT_MODEL_CreateUserOrPet_request_H_ + +#include + +#include "CppRestPetstoreClient/ModelBase.h" + +#include "CppRestPetstoreClient/model/User.h" +#include "CppRestPetstoreClient/model/Tag.h" +#include "CppRestPetstoreClient/model/Category.h" +#include +#include "CppRestPetstoreClient/model/Pet.h" +#include + +namespace org { +namespace openapitools { +namespace client { +namespace model { + +class Category; +class Tag; + + +class CreateUserOrPet_request +{ +public: + CreateUserOrPet_request() = default; + ~CreateUserOrPet_request() = default; + + ///////////////////////////////////////////// + + void validate(); + + web::json::value toJson() const; + + template + bool fromJson(const web::json::value& json) { + // convert json to Target type + Target target; + if (!target.fromJson(json)) { + return false; + } + + m_variantValue = target; + return true; + } + + void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const; + + template + bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) { + // convert multipart to Target type + Target target; + if (!target.fromMultiPart(multipart, namePrefix)) { + return false; + } + + m_variantValue = target; + return true; + } + + ///////////////////////////////////////////// + /// CreateUserOrPet_request members + + using VariantType = std::variant; + + const VariantType& getVariant() const; + void setVariant(VariantType value); + +protected: + VariantType m_variantValue; +}; + + + +} +} +} +} + +#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_CreateUserOrPet_request_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Order.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Order.h index aa553ee97684..929b9cadd861 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Order.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Order.h @@ -29,6 +29,7 @@ namespace client { namespace model { + /// /// An order for a pets from the pet store /// 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 b00392e43c6d..8efc8946566e 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 @@ -34,6 +34,7 @@ namespace model { class Category; class Tag; + /// /// A pet for sale in the pet store /// diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/SchemaWithSet.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/SchemaWithSet.h index acc340488c8d..75e2272abf28 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/SchemaWithSet.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/SchemaWithSet.h @@ -32,6 +32,7 @@ namespace model { class SchemaWithSet_vaccinationBook; + /// /// Schema with a set property /// diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/SchemaWithSet_vaccinationBook.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/SchemaWithSet_vaccinationBook.h index 74dda9d58fc6..f19ef6935d22 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/SchemaWithSet_vaccinationBook.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/SchemaWithSet_vaccinationBook.h @@ -31,6 +31,7 @@ namespace model { class Vaccine; + /// /// Vaccination book of the pet /// diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Tag.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Tag.h index 078b2fb0f77c..0d515b01d279 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Tag.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Tag.h @@ -29,6 +29,7 @@ namespace client { namespace model { + /// /// A tag for a pet /// diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/User.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/User.h index 79199c5a76be..294358d30e32 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/User.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/User.h @@ -29,6 +29,7 @@ namespace client { namespace model { + /// /// A User who is purchasing from the pet store /// 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 index b86e1ff65b3c..90694a853899 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Vaccine.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Vaccine.h @@ -29,6 +29,7 @@ namespace client { namespace model { + /// /// /// diff --git a/samples/client/petstore/cpp-restsdk/client/pom.xml b/samples/client/petstore/cpp-restsdk/client/pom.xml index f127ec6ede34..6c5f5ed24c96 100644 --- a/samples/client/petstore/cpp-restsdk/client/pom.xml +++ b/samples/client/petstore/cpp-restsdk/client/pom.xml @@ -37,6 +37,7 @@ -DCMAKE_CXX_FLAGS="-I/usr/local/opt/openssl/include" -DCMAKE_MODULE_LINKER_FLAGS="-L/usr/local/opt/openssl/lib" + -DCMAKE_BUILD_TYPE=Debug diff --git a/samples/client/petstore/cpp-restsdk/client/src/api/PetApi.cpp b/samples/client/petstore/cpp-restsdk/client/src/api/PetApi.cpp index 65a4c04cf920..10063efefc4f 100644 --- a/samples/client/petstore/cpp-restsdk/client/src/api/PetApi.cpp +++ b/samples/client/petstore/cpp-restsdk/client/src/api/PetApi.cpp @@ -128,7 +128,7 @@ pplx::task> PetApi::addPet(std::shared_ptr pet) const // 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) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -161,7 +161,7 @@ pplx::task> PetApi::addPet(std::shared_ptr pet) const return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::shared_ptr localVarResult(new Pet()); @@ -256,7 +256,7 @@ pplx::task PetApi::deletePet(int64_t petId, boost::optionalcallApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -289,7 +289,7 @@ pplx::task PetApi::deletePet(int64_t petId, boost::optional>> PetApi::findPetsByStatus(std::vect // 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) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -399,7 +399,7 @@ pplx::task>> PetApi::findPetsByStatus(std::vect return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::vector> localVarResult; @@ -498,7 +498,7 @@ pplx::task>> PetApi::findPetsByTags(std::vector // 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) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -531,7 +531,7 @@ pplx::task>> PetApi::findPetsByTags(std::vector return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::vector> localVarResult; @@ -634,7 +634,7 @@ pplx::task> PetApi::getPetById(int64_t petId) const } return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -667,7 +667,7 @@ pplx::task> PetApi::getPetById(int64_t petId) const return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::shared_ptr localVarResult(new Pet()); @@ -783,7 +783,7 @@ pplx::task> PetApi::updatePet(std::shared_ptr pet) con // 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) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -816,7 +816,7 @@ pplx::task> PetApi::updatePet(std::shared_ptr pet) con return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::shared_ptr localVarResult(new Pet()); @@ -916,7 +916,7 @@ pplx::task PetApi::updatePetWithForm(int64_t petId, boost::optionalcallApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -949,7 +949,7 @@ pplx::task PetApi::updatePetWithForm(int64_t petId, boost::optional> PetApi::uploadFile(int64_t petId, boost // 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) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -1065,7 +1065,7 @@ pplx::task> PetApi::uploadFile(int64_t petId, boost return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::shared_ptr localVarResult(new ApiResponse()); diff --git a/samples/client/petstore/cpp-restsdk/client/src/api/StoreApi.cpp b/samples/client/petstore/cpp-restsdk/client/src/api/StoreApi.cpp index 3ac1ae0f7538..9b0cb610dc35 100644 --- a/samples/client/petstore/cpp-restsdk/client/src/api/StoreApi.cpp +++ b/samples/client/petstore/cpp-restsdk/client/src/api/StoreApi.cpp @@ -101,7 +101,7 @@ pplx::task StoreApi::deleteOrder(utility::string_t orderId) const return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -134,7 +134,7 @@ pplx::task StoreApi::deleteOrder(utility::string_t orderId) const return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { return void(); }); @@ -213,7 +213,7 @@ pplx::task> StoreApi::getInventory() const } return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -246,7 +246,7 @@ pplx::task> StoreApi::getInventory() const return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::map localVarResult; @@ -342,7 +342,7 @@ pplx::task> StoreApi::getOrderById(int64_t orderId) const return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -375,7 +375,7 @@ pplx::task> StoreApi::getOrderById(int64_t orderId) const return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::shared_ptr localVarResult(new Order()); @@ -488,7 +488,7 @@ pplx::task> StoreApi::placeOrder(std::shared_ptr o return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -521,7 +521,7 @@ pplx::task> StoreApi::placeOrder(std::shared_ptr o return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::shared_ptr localVarResult(new Order()); diff --git a/samples/client/petstore/cpp-restsdk/client/src/api/UserApi.cpp b/samples/client/petstore/cpp-restsdk/client/src/api/UserApi.cpp index 0b1e6bd1f485..65811119fcd2 100644 --- a/samples/client/petstore/cpp-restsdk/client/src/api/UserApi.cpp +++ b/samples/client/petstore/cpp-restsdk/client/src/api/UserApi.cpp @@ -131,7 +131,7 @@ pplx::task UserApi::createUser(std::shared_ptr user) const } return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -164,7 +164,7 @@ pplx::task UserApi::createUser(std::shared_ptr user) const return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { return void(); }); @@ -270,7 +270,7 @@ pplx::task UserApi::createUsersWithArrayInput(std::vectorcallApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -303,7 +303,7 @@ pplx::task UserApi::createUsersWithArrayInput(std::vector UserApi::createUsersWithListInput(std::vectorcallApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -442,7 +442,7 @@ pplx::task UserApi::createUsersWithListInput(std::vector UserApi::deleteUser(utility::string_t username) const } return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -554,7 +554,7 @@ pplx::task UserApi::deleteUser(utility::string_t username) const return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { return void(); }); @@ -627,7 +627,7 @@ pplx::task> UserApi::getUserByName(utility::string_t usern return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -660,7 +660,7 @@ pplx::task> UserApi::getUserByName(utility::string_t usern return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { std::shared_ptr localVarResult(new User()); @@ -761,7 +761,7 @@ pplx::task UserApi::loginUser(utility::string_t username, uti return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -794,7 +794,7 @@ pplx::task UserApi::loginUser(utility::string_t username, uti return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { utility::string_t localVarResult(utility::conversions::to_string_t("")); @@ -894,7 +894,7 @@ pplx::task UserApi::logoutUser() const } return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -927,7 +927,7 @@ pplx::task UserApi::logoutUser() const return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { return void(); }); @@ -1029,7 +1029,7 @@ pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr } return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) + .then([=, this](web::http::http_response localVarResponse) { if (m_ApiClient->getResponseHandler()) { @@ -1062,7 +1062,7 @@ pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr return localVarResponse.extract_string(); }) - .then([=](utility::string_t localVarResponse) + .then([=, this](utility::string_t localVarResponse) { return void(); }); diff --git a/samples/client/petstore/cpp-restsdk/client/src/api/UserOrPetApi.cpp b/samples/client/petstore/cpp-restsdk/client/src/api/UserOrPetApi.cpp new file mode 100644 index 000000000000..8837e1cdc6cb --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client/src/api/UserOrPetApi.cpp @@ -0,0 +1,177 @@ +/** + * 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.7.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +#include "CppRestPetstoreClient/api/UserOrPetApi.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; + +UserOrPetApi::UserOrPetApi( std::shared_ptr apiClient ) + : m_ApiClient(apiClient) +{ +} + +UserOrPetApi::~UserOrPetApi() +{ +} + +pplx::task UserOrPetApi::createUserOrPet(std::shared_ptr createUserOrPetRequest) const +{ + + // verify the required parameter 'createUserOrPetRequest' is set + if (createUserOrPetRequest == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'createUserOrPetRequest' when calling UserOrPetApi->createUserOrPet")); + } + + + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user_or_pet"); + + 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("UserOrPetApi->createUserOrPet 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(createUserOrPetRequest); + + + 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(createUserOrPetRequest.get()) + { + createUserOrPetRequest->toMultipart(localVarMultipart, utility::conversions::to_string_t("createUserOrPetRequest")); + } + + + 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("UserOrPetApi->createUserOrPet 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([=, this](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 createUserOrPet: ") + 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 createUserOrPet: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); + } + } + + return localVarResponse.extract_string(); + }) + .then([=, this](utility::string_t localVarResponse) + { + return void(); + }); +} + +} +} +} +} + diff --git a/samples/client/petstore/cpp-restsdk/client/src/model/CreateUserOrPet_request.cpp b/samples/client/petstore/cpp-restsdk/client/src/model/CreateUserOrPet_request.cpp new file mode 100644 index 000000000000..ff4369ed8dda --- /dev/null +++ b/samples/client/petstore/cpp-restsdk/client/src/model/CreateUserOrPet_request.cpp @@ -0,0 +1,74 @@ +/** + * 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.7.0-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "CppRestPetstoreClient/model/CreateUserOrPet_request.h" + +namespace org { +namespace openapitools { +namespace client { +namespace model { + + +void CreateUserOrPet_request::validate() +{ + // TODO: implement validation +} + +const CreateUserOrPet_request::VariantType& CreateUserOrPet_request::getVariant() const +{ + return m_variantValue; +} + +void CreateUserOrPet_request::setVariant(CreateUserOrPet_request::VariantType value) +{ + m_variantValue = value; +} + +web::json::value CreateUserOrPet_request::toJson() const +{ + web::json::value val = web::json::value::object(); + + std::visit([&](auto&& arg) { + using T = std::decay_t; + if constexpr (std::is_same_v) { + val = web::json::value::null(); + } else { + val = arg.toJson(); + } + }, m_variantValue); + + return val; +} + +void CreateUserOrPet_request::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const +{ + std::visit([&](auto&& arg) { + using T = std::decay_t; + if constexpr (!std::is_same_v) { + arg.toMultipart(multipart, prefix); + } + }, m_variantValue); +} + +template bool CreateUserOrPet_request::fromJson(const web::json::value& json); +template bool CreateUserOrPet_request::fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix); +template bool CreateUserOrPet_request::fromJson(const web::json::value& json); +template bool CreateUserOrPet_request::fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix); + + +} +} +} +} + +