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
- //
8
1
9
2
#ifndef UserController_hpp
10
3
#define UserController_hpp
@@ -54,7 +47,7 @@ class UserController : public oatpp::web::server::api::ApiController {
54
47
55
48
ENDPOINT_INFO (root) {
56
49
info->summary = " Index.html page" ;
57
- info->addResponse <UserDto::ObjectWrapper >(Status::CODE_200, " text/html" );
50
+ info->addResponse <String >(Status::CODE_200, " text/html" );
58
51
}
59
52
ENDPOINT (" GET" , " /" , root) {
60
53
const char * html =
@@ -74,27 +67,27 @@ class UserController : public oatpp::web::server::api::ApiController {
74
67
75
68
ENDPOINT_INFO (createUser) {
76
69
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" );
79
72
}
80
73
ENDPOINT (" POST" , " demo/api/users" , createUser,
81
- BODY_DTO (UserDto::ObjectWrapper , userDto)) {
74
+ BODY_DTO (UserDto, userDto)) {
82
75
return createDtoResponse (Status::CODE_200, m_database->createUser (userDto));
83
76
}
84
77
85
78
86
79
ENDPOINT_INFO (putUser) {
87
80
// general
88
81
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" );
91
84
info->addResponse <String>(Status::CODE_404, " text/plain" );
92
85
// params specific
93
86
info->pathParams [" userId" ].description = " User Identifier" ;
94
87
}
95
88
ENDPOINT (" PUT" , " demo/api/users/{userId}" , putUser,
96
89
PATH (Int32, userId),
97
- BODY_DTO(UserDto::ObjectWrapper , userDto)) {
90
+ BODY_DTO(UserDto, userDto)) {
98
91
userDto->id = userId;
99
92
return createDtoResponse (Status::CODE_200, m_database->updateUser (userDto));
100
93
}
@@ -103,7 +96,7 @@ class UserController : public oatpp::web::server::api::ApiController {
103
96
ENDPOINT_INFO (getUserById) {
104
97
// general
105
98
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" );
107
100
info->addResponse <String>(Status::CODE_404, " text/plain" );
108
101
// params specific
109
102
info->pathParams [" userId" ].description = " User Identifier" ;
@@ -118,7 +111,7 @@ class UserController : public oatpp::web::server::api::ApiController {
118
111
119
112
ENDPOINT_INFO (getUsers) {
120
113
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" );
122
115
}
123
116
ENDPOINT (" GET" , " demo/api/users" , getUsers) {
124
117
return createDtoResponse (Status::CODE_200, m_database->getUsers ());
0 commit comments