diff --git a/CMakeLists.txt b/CMakeLists.txt index 679ed25..c9384ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +cmake_minimum_required(VERSION 3.20 FATAL_ERROR) ################################################################################################### ## These variables are passed to oatpp-module-install.cmake script ## use these variables to configure module installation set(OATPP_THIS_MODULE_NAME oatpp-swagger) ## name of the module (also name of folders in installation dirs) -set(OATPP_THIS_MODULE_VERSION "1.3.0") ## version of the module (also sufix of folders in installation dirs) +set(OATPP_THIS_MODULE_VERSION "1.4.0") ## version of the module (also sufix of folders in installation dirs) set(OATPP_THIS_MODULE_LIBRARIES oatpp-swagger) ## list of libraries to find when find_package is called set(OATPP_THIS_MODULE_TARGETS oatpp-swagger) ## list of targets to install set(OATPP_THIS_MODULE_DIRECTORIES oatpp-swagger) ## list of directories to install diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4388f95..b7ee3af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,7 +13,7 @@ add_library(${OATPP_THIS_MODULE_NAME} oatpp-swagger/oas3/Model.hpp) set_target_properties(${OATPP_THIS_MODULE_NAME} PROPERTIES - CXX_STANDARD 11 + CXX_STANDARD 17 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON ) diff --git a/src/oatpp-swagger/AsyncController.hpp b/src/oatpp-swagger/AsyncController.hpp index e4270ec..cfbb2ae 100644 --- a/src/oatpp-swagger/AsyncController.hpp +++ b/src/oatpp-swagger/AsyncController.hpp @@ -32,10 +32,10 @@ #include "oatpp/web/protocol/http/outgoing/StreamingBody.hpp" #include "oatpp/web/server/api/ApiController.hpp" -#include "oatpp/parser/json/mapping/ObjectMapper.hpp" +#include "oatpp/json/ObjectMapper.hpp" -#include "oatpp/core/macro/codegen.hpp" -#include "oatpp/core/macro/component.hpp" +#include "oatpp/macro/codegen.hpp" +#include "oatpp/macro/component.hpp" namespace oatpp { namespace swagger { @@ -79,20 +79,17 @@ public: */ static std::shared_ptr createShared(const web::server::api::Endpoints& endpointsList, OATPP_COMPONENT(std::shared_ptr, documentInfo), - OATPP_COMPONENT(std::shared_ptr, resources)){ - - auto serializerConfig = oatpp::parser::json::mapping::Serializer::Config::createShared(); - serializerConfig->includeNullFields = false; - - auto deserializerConfig = oatpp::parser::json::mapping::Deserializer::Config::createShared(); - deserializerConfig->allowUnknownFields = false; - - auto objectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared(serializerConfig, deserializerConfig); + OATPP_COMPONENT(std::shared_ptr, resources)) + { + + auto objectMapper = std::make_shared(); + objectMapper->serializerConfig().mapper.includeNullFields = false; + objectMapper->deserializerConfig().mapper.allowUnknownFields = false; std::shared_ptr generatorConfig; try { generatorConfig = OATPP_GET_COMPONENT(std::shared_ptr); - } catch (std::runtime_error e) { + } catch (std::runtime_error) { generatorConfig = std::make_shared(); } diff --git a/src/oatpp-swagger/Controller.hpp b/src/oatpp-swagger/Controller.hpp index 836cdb0..cac5769 100644 --- a/src/oatpp-swagger/Controller.hpp +++ b/src/oatpp-swagger/Controller.hpp @@ -31,11 +31,11 @@ #include "oatpp/web/server/api/ApiController.hpp" -#include "oatpp/parser/json/mapping/ObjectMapper.hpp" +#include "oatpp/json/ObjectMapper.hpp" #include "oatpp/web/protocol/http/outgoing/StreamingBody.hpp" -#include "oatpp/core/macro/codegen.hpp" -#include "oatpp/core/macro/component.hpp" +#include "oatpp/macro/codegen.hpp" +#include "oatpp/macro/component.hpp" namespace oatpp { namespace swagger { @@ -77,15 +77,12 @@ public: */ static std::shared_ptr createShared(const web::server::api::Endpoints& endpointsList, OATPP_COMPONENT(std::shared_ptr, documentInfo), - OATPP_COMPONENT(std::shared_ptr, resources)){ - - auto serializerConfig = oatpp::parser::json::mapping::Serializer::Config::createShared(); - serializerConfig->includeNullFields = false; - - auto deserializerConfig = oatpp::parser::json::mapping::Deserializer::Config::createShared(); - deserializerConfig->allowUnknownFields = false; - - auto objectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared(serializerConfig, deserializerConfig); + OATPP_COMPONENT(std::shared_ptr, resources)) + { + + auto objectMapper = std::make_shared(); + objectMapper->serializerConfig().mapper.includeNullFields = false; + objectMapper->deserializerConfig().mapper.allowUnknownFields = false; std::shared_ptr generatorConfig; try { diff --git a/src/oatpp-swagger/ControllerPaths.hpp b/src/oatpp-swagger/ControllerPaths.hpp index d94dcff..5c4b428 100644 --- a/src/oatpp-swagger/ControllerPaths.hpp +++ b/src/oatpp-swagger/ControllerPaths.hpp @@ -25,7 +25,7 @@ #ifndef oatpp_swagger_ControllerPaths_hpp #define oatpp_swagger_ControllerPaths_hpp -#include "oatpp/core/Types.hpp" +#include "oatpp/Types.hpp" namespace oatpp { namespace swagger { diff --git a/src/oatpp-swagger/Generator.cpp b/src/oatpp-swagger/Generator.cpp index f117d86..d0270bb 100644 --- a/src/oatpp-swagger/Generator.cpp +++ b/src/oatpp-swagger/Generator.cpp @@ -24,8 +24,9 @@ #include "Generator.hpp" -#include "oatpp/core/utils/ConversionUtils.hpp" -#include "oatpp/core/data/stream/BufferStream.hpp" +#include "oatpp/utils/Conversion.hpp" +#include "oatpp/data/stream/BufferStream.hpp" +#include "oatpp/base/Log.hpp" #include @@ -33,7 +34,7 @@ namespace oatpp { namespace swagger { oatpp::String Generator::getEnumSchemaName(const Type* type) { - auto polymorphicDispatcher = static_cast( + auto polymorphicDispatcher = static_cast( type->polymorphicDispatcher ); @@ -52,47 +53,47 @@ oatpp::Object Generator::generateSchemaForSimpleType(const Type* t auto result = oas3::Schema::createShared(); auto classId = type->classId.id; - if(classId == oatpp::data::mapping::type::__class::String::CLASS_ID.id) { + if(classId == oatpp::data::type::__class::String::CLASS_ID.id) { result->type = "string"; if(property != nullptr && !property->info.pattern.empty()) { result->pattern = property->info.pattern.c_str(); } - } else if(classId == oatpp::data::mapping::type::__class::Int8::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::Int8::CLASS_ID.id) { result->type = "integer"; result->minimum = std::numeric_limits::min(); result->maximum = std::numeric_limits::max(); - } else if(classId == oatpp::data::mapping::type::__class::UInt8::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::UInt8::CLASS_ID.id) { result->type = "integer"; result->minimum = std::numeric_limits::min(); result->maximum = std::numeric_limits::max(); - } else if(classId == oatpp::data::mapping::type::__class::Int16::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::Int16::CLASS_ID.id) { result->type = "integer"; result->minimum = std::numeric_limits::min(); result->maximum = std::numeric_limits::max(); - } else if(classId == oatpp::data::mapping::type::__class::UInt16::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::UInt16::CLASS_ID.id) { result->type = "integer"; result->minimum = std::numeric_limits::min(); result->maximum = std::numeric_limits::max(); - } else if(classId == oatpp::data::mapping::type::__class::Int32::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::Int32::CLASS_ID.id) { result->type = "integer"; result->minimum = std::numeric_limits::min(); result->maximum = std::numeric_limits::max(); - } else if(classId == oatpp::data::mapping::type::__class::UInt32::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::UInt32::CLASS_ID.id) { result->type = "integer"; result->minimum = std::numeric_limits::min(); result->maximum = std::numeric_limits::max(); - } else if(classId == oatpp::data::mapping::type::__class::Int64::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::Int64::CLASS_ID.id) { result->type = "integer"; result->format = "int64"; - } else if(classId == oatpp::data::mapping::type::__class::UInt64::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::UInt64::CLASS_ID.id) { result->type = "integer"; - } else if(classId == oatpp::data::mapping::type::__class::Float32::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::Float32::CLASS_ID.id) { result->type = "number"; result->format = "float"; - } else if(classId == oatpp::data::mapping::type::__class::Float64::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::Float64::CLASS_ID.id) { result->type = "number"; result->format = "double"; - } else if(classId == oatpp::data::mapping::type::__class::Boolean::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::Boolean::CLASS_ID.id) { result->type = "boolean"; } else { return nullptr; // Unknown simple type; @@ -118,7 +119,7 @@ oatpp::Object Generator::generateSchemaForTypeObject(const Type* t result->type = "object"; result->properties = {}; - auto polymorphicDispatcher = static_cast( + auto polymorphicDispatcher = static_cast( type->polymorphicDispatcher ); auto instance = polymorphicDispatcher->createObject(); @@ -164,7 +165,7 @@ oatpp::Object Generator::generateSchemaForEnum(const Type* type, b } - auto polymorphicDispatcher = static_cast( + auto polymorphicDispatcher = static_cast( type->polymorphicDispatcher ); @@ -172,7 +173,7 @@ oatpp::Object Generator::generateSchemaForEnum(const Type* type, b auto result = generateSchemaForType(interType, linkSchema, usedTypes); result->enumValues = oatpp::List::createShared(); - auto interEnum = polymorphicDispatcher->getInterpretedEnum(); + auto interEnum = polymorphicDispatcher->getInterpretedEnum(false); for(auto& v : interEnum) { result->enumValues->push_back(v); } @@ -203,17 +204,17 @@ oatpp::Object Generator::generateSchemaForType(const Type* type, b auto classId = type->classId.id; - if(classId == oatpp::data::mapping::type::__class::AbstractObject::CLASS_ID.id) { + if(classId == oatpp::data::type::__class::AbstractObject::CLASS_ID.id) { result = generateSchemaForTypeObject(type, linkSchema, usedTypes); - } else if(classId == oatpp::data::mapping::type::__class::AbstractVector::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::AbstractVector::CLASS_ID.id) { result = generateSchemaForCollection_1D(type, linkSchema, usedTypes, false); - } else if(classId == oatpp::data::mapping::type::__class::AbstractList::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::AbstractList::CLASS_ID.id) { result = generateSchemaForCollection_1D(type, linkSchema, usedTypes, false); - } else if(classId == oatpp::data::mapping::type::__class::AbstractUnorderedSet::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::AbstractUnorderedSet::CLASS_ID.id) { result = generateSchemaForCollection_1D(type, linkSchema, usedTypes, true); - } else if(classId == oatpp::data::mapping::type::__class::AbstractPairList::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::AbstractPairList::CLASS_ID.id) { result = generateSchemaForAbstractPairList(type, linkSchema, usedTypes, property); - } else if(classId == oatpp::data::mapping::type::__class::AbstractEnum::CLASS_ID.id) { + } else if(classId == oatpp::data::type::__class::AbstractEnum::CLASS_ID.id) { result = generateSchemaForEnum(type, linkSchema, usedTypes, property); } else { result = generateSchemaForSimpleType(type, property, defaultValue); @@ -357,7 +358,7 @@ oatpp::Fields> Generator::generateResponses(cons } response->description = hint.second.description.get() == nullptr ? hint.first.description : hint.second.description; - responses[oatpp::utils::conversion::int32ToStr(hint.first.code)] = response; + responses[oatpp::utils::Conversion::int32ToStr(hint.first.code)] = response; } @@ -508,7 +509,7 @@ void Generator::decomposeObject(const Type* type, UsedTypes& decomposedTypes) { decomposedTypes[type->nameQualifier] = type; - auto polymorphicDispatcher = static_cast( + auto polymorphicDispatcher = static_cast( type->polymorphicDispatcher ); auto properties = polymorphicDispatcher->getProperties(); @@ -528,7 +529,7 @@ void Generator::decomposeMap(const Type* type, UsedTypes& decomposedTypes) { OATPP_ASSERT(type && "[oatpp-swagger::oas3::Generator::decomposeMap()]: Error. Type should not be null."); // The only possible JSON representation of a PairList is A being a String, even if an numeric one - if (type->params.front()->classId.id == oatpp::data::mapping::type::__class::String::CLASS_ID.id) { + if (type->params.front()->classId.id == oatpp::data::type::__class::String::CLASS_ID.id) { decomposeType(type->params.back(), decomposedTypes); } @@ -546,17 +547,17 @@ void Generator::decomposeEnum(const Type* type, UsedTypes& decomposedTypes) { void Generator::decomposeType(const Type* type, UsedTypes& decomposedTypes) { OATPP_ASSERT(type && "[oatpp-swagger::oas3::Generator::decomposeType()]: Error. Type should not be null."); auto classId = type->classId.id; - if(classId == oatpp::data::mapping::type::__class::AbstractObject::CLASS_ID.id){ + if(classId == oatpp::data::type::__class::AbstractObject::CLASS_ID.id){ decomposeObject(type, decomposedTypes); - } else if(classId == oatpp::data::mapping::type::__class::AbstractVector::CLASS_ID.id){ + } else if(classId == oatpp::data::type::__class::AbstractVector::CLASS_ID.id){ decomposeCollection_1D(type, decomposedTypes); - } else if(classId == oatpp::data::mapping::type::__class::AbstractList::CLASS_ID.id){ + } else if(classId == oatpp::data::type::__class::AbstractList::CLASS_ID.id){ decomposeCollection_1D(type, decomposedTypes); - } else if(classId == oatpp::data::mapping::type::__class::AbstractUnorderedSet::CLASS_ID.id){ + } else if(classId == oatpp::data::type::__class::AbstractUnorderedSet::CLASS_ID.id){ decomposeCollection_1D(type, decomposedTypes); - } else if(classId == oatpp::data::mapping::type::__class::AbstractPairList::CLASS_ID.id){ + } else if(classId == oatpp::data::type::__class::AbstractPairList::CLASS_ID.id){ decomposeMap(type, decomposedTypes); - } else if(classId == oatpp::data::mapping::type::__class::AbstractEnum::CLASS_ID.id){ + } else if(classId == oatpp::data::type::__class::AbstractEnum::CLASS_ID.id){ decomposeEnum(type, decomposedTypes); } } diff --git a/src/oatpp-swagger/Model.hpp b/src/oatpp-swagger/Model.hpp index 36634e7..543936d 100644 --- a/src/oatpp-swagger/Model.hpp +++ b/src/oatpp-swagger/Model.hpp @@ -30,7 +30,7 @@ #ifndef oatpp_swagger_Config_hpp #define oatpp_swagger_Config_hpp -#include "oatpp/core/Types.hpp" +#include "oatpp/Types.hpp" namespace oatpp { namespace swagger { diff --git a/src/oatpp-swagger/Resources.cpp b/src/oatpp-swagger/Resources.cpp index 56135f6..04d58b3 100644 --- a/src/oatpp-swagger/Resources.cpp +++ b/src/oatpp-swagger/Resources.cpp @@ -23,6 +23,9 @@ ***************************************************************************/ #include "Resources.hpp" + +#include "oatpp/base/Log.hpp" + #include #include @@ -63,7 +66,7 @@ oatpp::String Resources::loadFromFile(const char* fileName) { } - OATPP_LOGE("oatpp::swagger::Resources::loadFromFile()", "Can't load file '%s'", fullFilename->c_str()); + OATPP_LOGe("oatpp::swagger::Resources::loadFromFile()", "Can't load file '{}'", fullFilename); throw std::runtime_error("[oatpp::swagger::Resources::loadFromFile(...)]: Can't load file. Please make sure you specified full path to oatpp-swagger/res folder"); } diff --git a/src/oatpp-swagger/Resources.hpp b/src/oatpp-swagger/Resources.hpp index 11c12e3..91bb821 100644 --- a/src/oatpp-swagger/Resources.hpp +++ b/src/oatpp-swagger/Resources.hpp @@ -25,9 +25,9 @@ #ifndef oatpp_swagger_Resources_hpp #define oatpp_swagger_Resources_hpp -#include "oatpp/core/Types.hpp" -#include "oatpp/core/data/stream/BufferStream.hpp" -#include "oatpp/core/data/stream/FileStream.hpp" +#include "oatpp/Types.hpp" +#include "oatpp/data/stream/BufferStream.hpp" +#include "oatpp/data/stream/FileStream.hpp" #include diff --git a/src/oatpp-swagger/Types.cpp b/src/oatpp-swagger/Types.cpp index 3b77a0e..f5dad71 100644 --- a/src/oatpp-swagger/Types.cpp +++ b/src/oatpp-swagger/Types.cpp @@ -27,7 +27,7 @@ namespace oatpp { namespace swagger { namespace __class { -const oatpp::data::mapping::type::ClassId Binary::CLASS_ID("string"); +const oatpp::data::type::ClassId Binary::CLASS_ID("string"); } }} diff --git a/src/oatpp-swagger/Types.hpp b/src/oatpp-swagger/Types.hpp index a0ec9d9..56eeb53 100644 --- a/src/oatpp-swagger/Types.hpp +++ b/src/oatpp-swagger/Types.hpp @@ -25,8 +25,7 @@ #ifndef oatpp_swagger_Types_hpp #define oatpp_swagger_Types_hpp -#include "oatpp/core/data/mapping/type/Type.hpp" -#include "oatpp/core/Types.hpp" +#include "oatpp/Types.hpp" namespace oatpp { namespace swagger { @@ -49,7 +48,7 @@ namespace __class { /** * CLASS_NAME = `"string"`. */ - static const oatpp::data::mapping::type::ClassId CLASS_ID; + static const oatpp::data::type::ClassId CLASS_ID; /** * Get type information. @@ -69,7 +68,7 @@ namespace __class { * Usage example: `info->addConsumes("application/octet-stream");`.
* For more info see: [Endpoint Annotation And API Documentation](/docs/components/api-controller/#endpoint-annotation-and-api-documentation). */ -typedef oatpp::data::mapping::type::ObjectWrapper Binary; +typedef oatpp::data::type::ObjectWrapper Binary; }} diff --git a/src/oatpp-swagger/oas3/Model.hpp b/src/oatpp-swagger/oas3/Model.hpp index 3a5e06b..e1daef9 100644 --- a/src/oatpp-swagger/oas3/Model.hpp +++ b/src/oatpp-swagger/oas3/Model.hpp @@ -31,8 +31,8 @@ #include "oatpp-swagger/Model.hpp" -#include "oatpp/core/data/mapping/type/Object.hpp" -#include "oatpp/core/macro/codegen.hpp" +#include "oatpp/data/type/Object.hpp" +#include "oatpp/macro/codegen.hpp" namespace oatpp { namespace swagger { namespace oas3 { #include OATPP_CODEGEN_BEGIN(DTO) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1975ac3..9e86066 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,7 +13,7 @@ add_executable(module-tests ) set_target_properties(module-tests PROPERTIES - CXX_STANDARD 11 + CXX_STANDARD 17 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON ) diff --git a/test/oatpp-swagger/AsyncControllerTest.cpp b/test/oatpp-swagger/AsyncControllerTest.cpp index 93e7fe4..e454a47 100644 --- a/test/oatpp-swagger/AsyncControllerTest.cpp +++ b/test/oatpp-swagger/AsyncControllerTest.cpp @@ -7,7 +7,7 @@ #include "test-controllers/TestAsyncController.hpp" #include "oatpp-swagger/AsyncController.hpp" -#include "oatpp/parser/json/mapping/ObjectMapper.hpp" +#include "oatpp/json/ObjectMapper.hpp" #include @@ -57,7 +57,7 @@ namespace { void AsyncControllerTest::onRun() { // Create ObjectMapper - auto objectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared(); + auto objectMapper = std::make_shared(); // Register swagger components SwaggerComponent swaggerComponent; @@ -71,7 +71,7 @@ void AsyncControllerTest::onRun() { auto swaggerController = oatpp::swagger::AsyncController::createShared(docEndpoints); // TODO test generated document here - OATPP_LOGV(TAG, "TODO implement test"); + OATPP_LOGv(TAG, "TODO implement test"); } diff --git a/test/oatpp-swagger/ControllerTest.cpp b/test/oatpp-swagger/ControllerTest.cpp index 7e2e7f9..a1f0775 100644 --- a/test/oatpp-swagger/ControllerTest.cpp +++ b/test/oatpp-swagger/ControllerTest.cpp @@ -7,8 +7,8 @@ #include "test-controllers/TestController.hpp" #include "oatpp-swagger/Controller.hpp" -#include "oatpp/parser/json/mapping/ObjectMapper.hpp" -#include "oatpp/core/data/stream/BufferStream.hpp" +#include "oatpp/json/ObjectMapper.hpp" +#include "oatpp/data/stream/BufferStream.hpp" #include @@ -68,7 +68,7 @@ void ControllerTest::onRun() { oatpp::data::stream::BufferOutputStream responseBuffer; // Create ObjectMapper - auto objectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared(); + auto objectMapper = std::make_shared(); // Register swagger components SwaggerComponent swaggerComponent; @@ -94,13 +94,13 @@ void ControllerTest::onRun() { auto responseText = stream.toString(); - oatpp::parser::Caret caret(responseText); + utils::parser::Caret caret(responseText); caret.findChar('{'); auto document = objectMapper->readFromCaret>(caret); if (caret.hasError()) { - OATPP_LOGD(TAG, "error='%s', pos=%d", caret.getErrorMessage(), caret.getPosition()); + OATPP_LOGd(TAG, "error='{}', pos={}", caret.getErrorMessage(), caret.getPosition()); } OATPP_ASSERT(caret.hasError() == false); @@ -115,12 +115,12 @@ void ControllerTest::onRun() { response->send(&stream, &responseBuffer, nullptr); auto responseText = stream.toString(); - OATPP_LOGD(TAG, responseText->c_str()); + OATPP_LOGd(TAG, responseText); } // TODO test generated document here - OATPP_LOGV(TAG, "TODO implement test"); + OATPP_LOGv(TAG, "TODO implement test"); } diff --git a/test/oatpp-swagger/test-controllers/TestAsyncController.hpp b/test/oatpp-swagger/test-controllers/TestAsyncController.hpp index af4f7e7..ce783d7 100644 --- a/test/oatpp-swagger/test-controllers/TestAsyncController.hpp +++ b/test/oatpp-swagger/test-controllers/TestAsyncController.hpp @@ -7,8 +7,8 @@ #define oatpp_swagger_test_TestAsyncController_hpp #include "oatpp/web/server/api/ApiController.hpp" -#include "oatpp/core/macro/codegen.hpp" -#include "oatpp/core/macro/component.hpp" +#include "oatpp/macro/codegen.hpp" +#include "oatpp/macro/component.hpp" // DTO //----------------------------------------------------------------------------- @@ -122,7 +122,9 @@ public: ENDPOINT_ASYNC_INIT(EchoDtoBody) Action act() override { - return request->readBodyToDtoAsync>(controller->getDefaultObjectMapper()).callbackTo(&EchoDtoBody::returnResponse); + return request->readBodyToDtoAsync>( + controller->getContentMappers()->getMapper("application/json") + ).callbackTo(&EchoDtoBody::returnResponse); } Action returnResponse(const oatpp::Object& body){ diff --git a/test/oatpp-swagger/test-controllers/TestController.hpp b/test/oatpp-swagger/test-controllers/TestController.hpp index 33ee1aa..82e3992 100644 --- a/test/oatpp-swagger/test-controllers/TestController.hpp +++ b/test/oatpp-swagger/test-controllers/TestController.hpp @@ -6,12 +6,12 @@ #define OATPP_SWAGGER_TESTCONTROLLER_HPP #include "oatpp/web/server/api/ApiController.hpp" -#include "oatpp/parser/json/mapping/ObjectMapper.hpp" +#include "oatpp/json/ObjectMapper.hpp" -#include "oatpp/core/data/mapping/type/Object.hpp" +#include "oatpp/data/type/Object.hpp" -#include "oatpp/core/macro/codegen.hpp" -#include "oatpp/core/macro/component.hpp" +#include "oatpp/macro/codegen.hpp" +#include "oatpp/macro/component.hpp" // DTO //----------------------------------------------------------------------------- @@ -73,7 +73,7 @@ namespace __class { class PointClass; } -typedef oatpp::data::mapping::type::Primitive Point; +typedef oatpp::data::type::Primitive Point; namespace __class { diff --git a/test/oatpp-swagger/tests.cpp b/test/oatpp-swagger/tests.cpp index 710e132..40a2527 100644 --- a/test/oatpp-swagger/tests.cpp +++ b/test/oatpp-swagger/tests.cpp @@ -11,19 +11,19 @@ void runTests() { int main() { - oatpp::base::Environment::init(); + oatpp::Environment::init(); runTests(); /* Print how much objects were created during app running, and what have left-probably leaked */ /* Disable object counting for release builds using '-D OATPP_DISABLE_ENV_OBJECT_COUNTERS' flag for better performance */ std::cout << "\nEnvironment:\n"; - std::cout << "objectsCount = " << oatpp::base::Environment::getObjectsCount() << "\n"; - std::cout << "objectsCreated = " << oatpp::base::Environment::getObjectsCreated() << "\n\n"; + std::cout << "objectsCount = " << oatpp::Environment::getObjectsCount() << "\n"; + std::cout << "objectsCreated = " << oatpp::Environment::getObjectsCreated() << "\n\n"; - OATPP_ASSERT(oatpp::base::Environment::getObjectsCount() == 0); + OATPP_ASSERT(oatpp::Environment::getObjectsCount() == 0); - oatpp::base::Environment::destroy(); + oatpp::Environment::destroy(); return 0; }