Skip to content

Commit

Permalink
Fix Facade Service.
Browse files Browse the repository at this point in the history
  • Loading branch information
lganzzzo committed May 23, 2020
1 parent a155876 commit 8598a84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions facade/src/facade/controller/BookController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BookController : public oatpp::web::server::api::ApiController {
ENDPOINT_INFO(getBookById) {
// general
info->summary = "Get one Book by bookId";
info->addResponse<dto::BookInfoDto>(Status::CODE_200, "application/json");
info->addResponse<oatpp::Object<dto::BookInfoDto>>(Status::CODE_200, "application/json");
info->addResponse<String>(Status::CODE_404, "text/plain");
// params specific
info->pathParams["bookId"].description = "Book Identifier";
Expand All @@ -46,12 +46,12 @@ class BookController : public oatpp::web::server::api::ApiController {
auto response = bookService->getBookById(bookId);
OATPP_ASSERT_HTTP(response->getStatusCode() == 200, Status::CODE_500, "Unable to get book by id");

auto book = response->readBodyToDto<dto::BookDto>(getDefaultObjectMapper().get());
auto book = response->readBodyToDto<oatpp::Object<dto::BookDto>>(getDefaultObjectMapper().get());

response = userService->getUserById(book->authorId);
OATPP_ASSERT_HTTP(response->getStatusCode() == 200, Status::CODE_500, "Unable to get user by id");

auto user = response->readBodyToDto<dto::UserDto>(getDefaultObjectMapper().get());
auto user = response->readBodyToDto<oatpp::Object<dto::UserDto>>(getDefaultObjectMapper().get());

auto bookInfoDto = dto::BookInfoDto::createShared();
bookInfoDto->id = book->id;
Expand Down
2 changes: 1 addition & 1 deletion facade/src/facade/dto/BookInfoDto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BookInfoDto : public oatpp::DTO {

DTO_FIELD(Int64, id);
DTO_FIELD(String, title, "title");
DTO_FIELD(UserDto, author);
DTO_FIELD(Object<UserDto>, author);

};

Expand Down

0 comments on commit 8598a84

Please sign in to comment.