From a8ceacbced457e11845929d0a5e49d277c88ca8c Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Sat, 23 May 2020 03:34:01 +0300 Subject: [PATCH] Update README.md --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index aaf2e918..2d2e3d15 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ For more info see [Api Controller](https://oatpp.io/docs/components/api-controll ```cpp ENDPOINT("PUT", "/users/{userId}", putUser, PATH(Int64, userId), - BODY_DTO(UserDto, userDto)) + BODY_DTO(Object, userDto)) { userDto->id = userId; return createDtoResponse(Status::CODE_200, m_database->updateUser(userDto)); @@ -65,7 +65,7 @@ For more info see [Api Controller / CORS](https://oatpp.io/docs/components/api-c ADD_CORS(putUser) ENDPOINT("PUT", "/users/{userId}", putUser, PATH(Int64, userId), - BODY_DTO(UserDto, userDto)) + BODY_DTO(Object, userDto)) { userDto->id = userId; return createDtoResponse(Status::CODE_200, m_database->updateUser(userDto)); @@ -82,7 +82,7 @@ using namespace oatpp::web::server::handler; ENDPOINT("PUT", "/users/{userId}", putUser, AUTHORIZATION(std::shared_ptr, authObject), PATH(Int64, userId), - BODY_DTO(UserDto, userDto)) + BODY_DTO(Object, userDto)) { OATPP_ASSERT_HTTP(authObject->userId == "Ivan" && authObject->password == "admin", Status::CODE_401, "Unauthorized"); userDto->id = userId; @@ -100,15 +100,15 @@ For more info see [Endpoint Annotation And API Documentation](https://oatpp.io/d ENDPOINT_INFO(putUser) { // general info->summary = "Update User by userId"; - info->addConsumes("application/json"); - info->addResponse(Status::CODE_200, "application/json"); + info->addConsumes>("application/json"); + info->addResponse>(Status::CODE_200, "application/json"); info->addResponse(Status::CODE_404, "text/plain"); // params specific info->pathParams["userId"].description = "User Identifier"; } ENDPOINT("PUT", "/users/{userId}", putUser, PATH(Int64, userId), - BODY_DTO(UserDto, userDto)) + BODY_DTO(Object, userDto)) { userDto->id = userId; return createDtoResponse(Status::CODE_200, m_database->updateUser(userDto)); @@ -137,7 +137,7 @@ public: ```cpp auto response = userService->getUserById(id); -auto user = response->readBodyToDto(objectMapper); +auto user = response->readBodyToDto>(objectMapper); ``` ### Object Mapping @@ -147,9 +147,9 @@ For more info see [Data Transfer Object (DTO)](https://oatpp.io/docs/components/ #### Declare DTO ```cpp -class UserDto : public oatpp::data::mapping::type::Object { +class UserDto : public oatpp::DTO { - DTO_INIT(UserDto, Object) + DTO_INIT(UserDto, DTO) DTO_FIELD(Int64, id); DTO_FIELD(String, name);