Skip to content

Commit 4f64caa

Browse files
committed
Update to the latest oatpp API.
1 parent 9b1e7f2 commit 4f64caa

12 files changed

+23
-107
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ target_include_directories(${project_name}-lib PUBLIC src)
2424

2525
## link libs
2626

27-
find_package(oatpp 1.0.0 REQUIRED)
28-
find_package(oatpp-swagger 1.0.0 REQUIRED)
27+
find_package(oatpp 1.1.0 REQUIRED)
28+
find_package(oatpp-swagger 1.1.0 REQUIRED)
2929

3030
target_link_libraries(${project_name}-lib
3131
PUBLIC oatpp::oatpp

src/App.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// main.cpp
3-
// web-starter-project
4-
//
5-
// Created by Leonid on 2/12/18.
6-
// Copyright © 2018 oatpp. All rights reserved.
7-
//
81

92
#include "./controller/UserController.hpp"
103
#include "./AppComponent.hpp"

src/AppComponent.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// AppComponent.hpp
3-
// file-service
4-
//
5-
// Created by Leonid on 8/13/18.
6-
// Copyright © 2018 oatpp. All rights reserved.
7-
//
81

92
#ifndef AppComponent_hpp
103
#define AppComponent_hpp

src/ServiceComponent.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// AppComponent.hpp
3-
// oatpp-web-starter
4-
//
5-
// Created by Leonid on 3/2/18.
6-
// Copyright © 2018 lganzzzo. All rights reserved.
7-
//
81

92
#ifndef ServiceComponent_hpp
103
#define ServiceComponent_hpp

src/SwaggerComponent.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// SwaggerComponent.hpp
3-
// file-service
4-
//
5-
// Created by Leonid on 8/13/18.
6-
// Copyright © 2018 oatpp. All rights reserved.
7-
//
81

92
#ifndef SwaggerComponent_hpp
103
#define SwaggerComponent_hpp

src/controller/UserController.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
//
2-
// UserController.cpp
3-
// user-service
4-
//
5-
// Created by Leonid on 12/21/18.
6-
// Copyright © 2018 lganzzzo. All rights reserved.
7-
//
8-
91
#include "UserController.hpp"
102

113
#include <stdio.h>

src/controller/UserController.hpp

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
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

@@ -24,6 +16,8 @@
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 */

src/db/Database.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// Database.cpp
3-
// user-service
4-
//
5-
// Created by Leonid on 12/20/18.
6-
// Copyright © 2018 lganzzzo. All rights reserved.
7-
//
81

92
#include "Database.hpp"
103

src/db/Database.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// Database.hpp
3-
// user-service
4-
//
5-
// Created by Leonid on 12/20/18.
6-
// Copyright © 2018 lganzzzo. All rights reserved.
7-
//
81

92
#ifndef Database_hpp
103
#define Database_hpp

src/dto/ConfigDto.hpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
//
2-
// ConfigDto.hpp
3-
// file-service
4-
//
5-
// Created by Leonid on 8/12/18.
6-
// Copyright © 2018 oatpp. All rights reserved.
7-
//
81

92
#ifndef ConfigDto_hpp
103
#define ConfigDto_hpp
114

12-
#include "oatpp/core/data/mapping/type/Object.hpp"
5+
#include "oatpp/core/Types.hpp"
136
#include "oatpp/core/macro/codegen.hpp"
147

158
#include OATPP_CODEGEN_BEGIN(DTO)
169

17-
class ConfigDto : public oatpp::data::mapping::type::Object {
10+
class ConfigDto : public oatpp::Object {
1811

1912
DTO_INIT(ConfigDto, Object)
2013

0 commit comments

Comments
 (0)