Skip to content

Commit c664c2d

Browse files
committed
Update to the latest oatpp APIs.
1 parent 3b2b7df commit c664c2d

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ target_include_directories(crud-lib PUBLIC src)
2020

2121
## link libs
2222

23-
find_package(oatpp 1.0.0 REQUIRED)
24-
find_package(oatpp-swagger 1.0.0 REQUIRED)
23+
find_package(oatpp 1.1.0 REQUIRED)
24+
find_package(oatpp-swagger 1.1.0 REQUIRED)
2525

2626
target_link_libraries(crud-lib
2727
PUBLIC oatpp::oatpp

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ $ docker run -p 8000:8000 -t example-crud
6363
```c++
6464
ENDPOINT_INFO(createUser) {
6565
info->summary = "Create new User";
66-
info->addConsumes<UserDto::ObjectWrapper>("application/json");
67-
info->addResponse<UserDto::ObjectWrapper>(Status::CODE_200, "application/json");
66+
info->addConsumes<UserDto>("application/json");
67+
info->addResponse<UserDto>(Status::CODE_200, "application/json");
6868
}
6969
ENDPOINT("POST", "demo/api/users", createUser,
70-
BODY_DTO(UserDto::ObjectWrapper, userDto)) {
70+
BODY_DTO(UserDto, userDto)) {
7171
return createDtoResponse(Status::CODE_200, m_database->createUser(userDto));
7272
}
7373
```
@@ -77,13 +77,13 @@ ENDPOINT("POST", "demo/api/users", createUser,
7777
```c++
7878
ENDPOINT_INFO(putUser) {
7979
info->summary = "Update User by userId";
80-
info->addConsumes<UserDto::ObjectWrapper>("application/json");
81-
info->addResponse<UserDto::ObjectWrapper>(Status::CODE_200, "application/json");
80+
info->addConsumes<UserDto>("application/json");
81+
info->addResponse<UserDto>(Status::CODE_200, "application/json");
8282
info->addResponse<String>(Status::CODE_404, "text/plain");
8383
}
8484
ENDPOINT("PUT", "demo/api/users/{userId}", putUser,
8585
PATH(Int32, userId),
86-
BODY_DTO(UserDto::ObjectWrapper, userDto)) {
86+
BODY_DTO(UserDto, userDto)) {
8787
userDto->id = userId;
8888
return createDtoResponse(Status::CODE_200, m_database->updateUser(userDto));
8989
}
@@ -94,7 +94,7 @@ ENDPOINT("PUT", "demo/api/users/{userId}", putUser,
9494
```c++
9595
ENDPOINT_INFO(getUserById) {
9696
info->summary = "Get one User by userId";
97-
info->addResponse<UserDto::ObjectWrapper>(Status::CODE_200, "application/json");
97+
info->addResponse<UserDto>(Status::CODE_200, "application/json");
9898
info->addResponse<String>(Status::CODE_404, "text/plain");
9999
}
100100
ENDPOINT("GET", "demo/api/users/{userId}", getUserById,
@@ -110,7 +110,7 @@ ENDPOINT("GET", "demo/api/users/{userId}", getUserById,
110110
```c++
111111
ENDPOINT_INFO(getUsers) {
112112
info->summary = "get all stored users";
113-
info->addResponse<List<UserDto::ObjectWrapper>::ObjectWrapper>(Status::CODE_200, "application/json");
113+
info->addResponse<List<UserDto>>(Status::CODE_200, "application/json");
114114
}
115115
ENDPOINT("GET", "demo/api/users", getUsers) {
116116
return createDtoResponse(Status::CODE_200, m_database->getUsers());

src/controller/UserController.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class UserController : public oatpp::web::server::api::ApiController {
5454

5555
ENDPOINT_INFO(root) {
5656
info->summary = "Index.html page";
57-
info->addResponse<UserDto::ObjectWrapper>(Status::CODE_200, "text/html");
57+
info->addResponse<String>(Status::CODE_200, "text/html");
5858
}
5959
ENDPOINT("GET", "/", root) {
6060
const char* html =
@@ -74,27 +74,27 @@ class UserController : public oatpp::web::server::api::ApiController {
7474

7575
ENDPOINT_INFO(createUser) {
7676
info->summary = "Create new User";
77-
info->addConsumes<UserDto::ObjectWrapper>("application/json");
78-
info->addResponse<UserDto::ObjectWrapper>(Status::CODE_200, "application/json");
77+
info->addConsumes<UserDto>("application/json");
78+
info->addResponse<UserDto>(Status::CODE_200, "application/json");
7979
}
8080
ENDPOINT("POST", "demo/api/users", createUser,
81-
BODY_DTO(UserDto::ObjectWrapper, userDto)) {
81+
BODY_DTO(UserDto, userDto)) {
8282
return createDtoResponse(Status::CODE_200, m_database->createUser(userDto));
8383
}
8484

8585

8686
ENDPOINT_INFO(putUser) {
8787
// general
8888
info->summary = "Update User by userId";
89-
info->addConsumes<UserDto::ObjectWrapper>("application/json");
90-
info->addResponse<UserDto::ObjectWrapper>(Status::CODE_200, "application/json");
89+
info->addConsumes<UserDto>("application/json");
90+
info->addResponse<UserDto>(Status::CODE_200, "application/json");
9191
info->addResponse<String>(Status::CODE_404, "text/plain");
9292
// params specific
9393
info->pathParams["userId"].description = "User Identifier";
9494
}
9595
ENDPOINT("PUT", "demo/api/users/{userId}", putUser,
9696
PATH(Int32, userId),
97-
BODY_DTO(UserDto::ObjectWrapper, userDto)) {
97+
BODY_DTO(UserDto, userDto)) {
9898
userDto->id = userId;
9999
return createDtoResponse(Status::CODE_200, m_database->updateUser(userDto));
100100
}
@@ -103,7 +103,7 @@ class UserController : public oatpp::web::server::api::ApiController {
103103
ENDPOINT_INFO(getUserById) {
104104
// general
105105
info->summary = "Get one User by userId";
106-
info->addResponse<UserDto::ObjectWrapper>(Status::CODE_200, "application/json");
106+
info->addResponse<UserDto>(Status::CODE_200, "application/json");
107107
info->addResponse<String>(Status::CODE_404, "text/plain");
108108
// params specific
109109
info->pathParams["userId"].description = "User Identifier";
@@ -118,7 +118,7 @@ class UserController : public oatpp::web::server::api::ApiController {
118118

119119
ENDPOINT_INFO(getUsers) {
120120
info->summary = "get all stored users";
121-
info->addResponse<List<UserDto::ObjectWrapper>::ObjectWrapper>(Status::CODE_200, "application/json");
121+
info->addResponse<List<UserDto>>(Status::CODE_200, "application/json");
122122
}
123123
ENDPOINT("GET", "demo/api/users", getUsers) {
124124
return createDtoResponse(Status::CODE_200, m_database->getUsers());

0 commit comments

Comments
 (0)