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-
91#ifndef UserController_hpp
102#define UserController_hpp
113
2416#include < iostream>
2517#include < fstream>
2618
19+ #include OATPP_CODEGEN_BEGIN(ApiController) // <-- codegen begin
20+
2721/* *
2822 * EXAMPLE ApiController
2923 * Basic examples of howto create ENDPOINTs
@@ -52,19 +46,14 @@ class UserController : public oatpp::web::server::api::ApiController {
5246 return std::shared_ptr<UserController>(new UserController (objectMapper));
5347 }
5448
55- /* *
56- * Begin ENDPOINTs generation ('ApiController' codegen)
57- */
58- #include OATPP_CODEGEN_BEGIN(ApiController)
59-
6049 ENDPOINT_INFO (createUser) {
6150 info->summary = " Create new User" ;
62- info->addConsumes <UserDto::ObjectWrapper >(" application/json" );
63- info->addResponse <UserDto::ObjectWrapper >(Status::CODE_200, " application/json" );
64- info->addResponse <ErrorDto::ObjectWrapper >(Status::CODE_500, " application/json" );
51+ info->addConsumes <UserDto>(" application/json" );
52+ info->addResponse <UserDto>(Status::CODE_200, " application/json" );
53+ info->addResponse <ErrorDto>(Status::CODE_500, " application/json" );
6554 }
6655 ENDPOINT (" POST" , " /users" , createUser,
67- BODY_DTO (UserDto::ObjectWrapper , user)) {
56+ BODY_DTO (UserDto, user)) {
6857 assertLogin (user->login );
6958 assertEmail (user->email );
7059 assertPassword (user->password );
@@ -76,8 +65,8 @@ class UserController : public oatpp::web::server::api::ApiController {
7665
7766 ENDPOINT_INFO (getUserByUid) {
7867 info->summary = " Get user by UID" ;
79- info->addResponse <UserDto::ObjectWrapper >(Status::CODE_200, " application/json" );
80- info->addResponse <ErrorDto::ObjectWrapper >(Status::CODE_500, " application/json" );
68+ info->addResponse <UserDto>(Status::CODE_200, " application/json" );
69+ info->addResponse <ErrorDto>(Status::CODE_500, " application/json" );
8170 }
8271 ENDPOINT (" GET" , " /users/uid/{userId}" , getUserByUid,
8372 PATH (String, userId)) {
@@ -90,8 +79,8 @@ class UserController : public oatpp::web::server::api::ApiController {
9079
9180 ENDPOINT_INFO (getUserByLogin) {
9281 info->summary = " Get user by Login" ;
93- info->addResponse <UserDto::ObjectWrapper >(Status::CODE_200, " application/json" );
94- info->addResponse <ErrorDto::ObjectWrapper >(Status::CODE_500, " application/json" );
82+ info->addResponse <UserDto>(Status::CODE_200, " application/json" );
83+ info->addResponse <ErrorDto>(Status::CODE_500, " application/json" );
9584 }
9685 ENDPOINT (" GET" , " /users/login/{login}" , getUserByLogin,
9786 PATH (String, login)) {
@@ -104,8 +93,8 @@ class UserController : public oatpp::web::server::api::ApiController {
10493
10594 ENDPOINT_INFO (getUserByEmail) {
10695 info->summary = " Get user by Email" ;
107- info->addResponse <UserDto::ObjectWrapper >(Status::CODE_200, " application/json" );
108- info->addResponse <ErrorDto::ObjectWrapper >(Status::CODE_500, " application/json" );
96+ info->addResponse <UserDto>(Status::CODE_200, " application/json" );
97+ info->addResponse <ErrorDto>(Status::CODE_500, " application/json" );
10998 }
11099 ENDPOINT (" GET" , " /users/email/{email}" , getUserByEmail,
111100 PATH (String, email)) {
@@ -116,11 +105,9 @@ class UserController : public oatpp::web::server::api::ApiController {
116105 }
117106
118107 // TODO Insert Your endpoints here !!!
119-
120- /* *
121- * Finish ENDPOINTs generation ('ApiController' codegen)
122- */
123- #include OATPP_CODEGEN_END(ApiController)
108+
124109};
125110
111+ #include OATPP_CODEGEN_END(ApiController) // <-- codegen end
112+
126113#endif /* UserController_hpp */
0 commit comments