Update 1.2.5.md

This commit is contained in:
Leonid Stryzhevskyi 2021-01-03 19:33:24 +02:00 committed by GitHub
parent ebeb78b1e6
commit dea6301a30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ Contents:
- [Headers Multimap](#headers-multimap) - [Headers Multimap](#headers-multimap)
- [Better Router API](#better-router-api) - [Better Router API](#better-router-api)
- [ORM Clean Section](#orm-clean-section) - [ORM Clean Section](#orm-clean-section)
- [Swagger-UI Example Values](#swagger-ui-example-values)
- [New Modules](#new-modules) - [New Modules](#new-modules)
## Introduce ResponseInterceptor ## Introduce ResponseInterceptor
@ -163,6 +164,53 @@ SELECT name::varchar FROM users WHERE userId="<user-id-value>"
Note: unlike the `:userId` the `:varchar` char-sequence wasn't interpreted as a template parameter (unlike the `:userId`). Note: unlike the `:userId` the `:varchar` char-sequence wasn't interpreted as a template parameter (unlike the `:userId`).
## Swagger-UI Example Values
Now it's possible to add example-values to `RequestBody`, `Response`, and `Parameters` (Path, Headers, Queries)
### Add Consumes Examples
```cpp
ENDPOINT_INFO(myEndpoint) {
info->addConsumes<Object<MyDto>>("application/json")
.addExample("example_1", MyDto::createShared(... /* params here */ ))
.addExample("example_2", MyDto::createShared(... /* params here */ ))
.addExample("example_3", MyDto::createShared(... /* params here */ ));
}
```
### Add Response Examples
```cpp
ENDPOINT_INFO(myEndpoint) {
info->addResponse<Object<MyDto>>(Status::CODE_200, "application/json")
.addExample("Successful Response_1", MyDto::createShared(... /* params */ ));
info->addResponse<Object<ErrorDto>>(Status::CODE_404, "application/json")
.addExample("Error - Not found", ErrorDto::createShared(404, "Not Found"));
info->addResponse<Object<ErrorDto>>(Status::CODE_500, "application/json")
.addExample("Error - DB Connection", ErrorDto::createShared(500, "Can't connect to DB"))
.addExample("Error - Unknown", ErrorDto::createShared(500, "Unknown Error"));
}
```
### Add Parameter Examples
```cpp
ENDPOINT_INFO(myEndpoint) {
info->pathParams["userRole"]
.addExample("Admin", oatpp::Enum<UserRole>(UserRole::ADMIN))
.addExample("Guest", oatpp::Enum<UserRole>(UserRole::GUEST));
}
```
## New Modules ## New Modules
- [oatpp-openssl](https://github.com/oatpp/oatpp-openssl) - TLS adaptor for OpenSSL (Recommended to use). - [oatpp-openssl](https://github.com/oatpp/oatpp-openssl) - TLS adaptor for OpenSSL (Recommended to use).