1- //
2- // UserController.hpp
3- // web-starter-project
4- //
5- // Created by Leonid on 2/12/18.
6- // Copyright © 2018 oatpp. All rights reserved.
7- //
81
92#ifndef UserController_hpp
103#define UserController_hpp
@@ -54,7 +47,7 @@ class UserController : public oatpp::web::server::api::ApiController {
5447
5548 ENDPOINT_INFO (root) {
5649 info->summary = " Index.html page" ;
57- info->addResponse <UserDto::ObjectWrapper >(Status::CODE_200, " text/html" );
50+ info->addResponse <String >(Status::CODE_200, " text/html" );
5851 }
5952 ENDPOINT (" GET" , " /" , root) {
6053 const char * html =
@@ -74,27 +67,27 @@ class UserController : public oatpp::web::server::api::ApiController {
7467
7568 ENDPOINT_INFO (createUser) {
7669 info->summary = " Create new User" ;
77- info->addConsumes <UserDto::ObjectWrapper >(" application/json" );
78- info->addResponse <UserDto::ObjectWrapper >(Status::CODE_200, " application/json" );
70+ info->addConsumes <UserDto>(" application/json" );
71+ info->addResponse <UserDto>(Status::CODE_200, " application/json" );
7972 }
8073 ENDPOINT (" POST" , " demo/api/users" , createUser,
81- BODY_DTO (UserDto::ObjectWrapper , userDto)) {
74+ BODY_DTO (UserDto, userDto)) {
8275 return createDtoResponse (Status::CODE_200, m_database->createUser (userDto));
8376 }
8477
8578
8679 ENDPOINT_INFO (putUser) {
8780 // general
8881 info->summary = " Update User by userId" ;
89- info->addConsumes <UserDto::ObjectWrapper >(" application/json" );
90- info->addResponse <UserDto::ObjectWrapper >(Status::CODE_200, " application/json" );
82+ info->addConsumes <UserDto>(" application/json" );
83+ info->addResponse <UserDto>(Status::CODE_200, " application/json" );
9184 info->addResponse <String>(Status::CODE_404, " text/plain" );
9285 // params specific
9386 info->pathParams [" userId" ].description = " User Identifier" ;
9487 }
9588 ENDPOINT (" PUT" , " demo/api/users/{userId}" , putUser,
9689 PATH (Int32, userId),
97- BODY_DTO(UserDto::ObjectWrapper , userDto)) {
90+ BODY_DTO(UserDto, userDto)) {
9891 userDto->id = userId;
9992 return createDtoResponse (Status::CODE_200, m_database->updateUser (userDto));
10093 }
@@ -103,7 +96,7 @@ class UserController : public oatpp::web::server::api::ApiController {
10396 ENDPOINT_INFO (getUserById) {
10497 // general
10598 info->summary = " Get one User by userId" ;
106- info->addResponse <UserDto::ObjectWrapper >(Status::CODE_200, " application/json" );
99+ info->addResponse <UserDto>(Status::CODE_200, " application/json" );
107100 info->addResponse <String>(Status::CODE_404, " text/plain" );
108101 // params specific
109102 info->pathParams [" userId" ].description = " User Identifier" ;
@@ -118,7 +111,7 @@ class UserController : public oatpp::web::server::api::ApiController {
118111
119112 ENDPOINT_INFO (getUsers) {
120113 info->summary = " get all stored users" ;
121- info->addResponse <List<UserDto::ObjectWrapper>::ObjectWrapper >(Status::CODE_200, " application/json" );
114+ info->addResponse <List<UserDto> >(Status::CODE_200, " application/json" );
122115 }
123116 ENDPOINT (" GET" , " demo/api/users" , getUsers) {
124117 return createDtoResponse (Status::CODE_200, m_database->getUsers ());
0 commit comments