Documented oatpp::parser::json::mapping::Serializer::Config::alwaysIncludeRequired in changelog.

This commit is contained in:
Benedikt-Alexander Mokroß 2021-10-19 08:24:02 +02:00
parent cc6c54f3a9
commit 1da42223ba

View File

@ -14,6 +14,7 @@ Contents:
- [Response::getBody()](#responsegetbody)
- [data::stream::FIFOStream](#datastreamfifostream)
- [data::stream::BufferedInputStream](#datastreambufferedinputstream)
- [oatpp::parser::json::mapping::Serializer::Config::alwaysIncludeRequired](#oatppparserjsonmappingSerializerConfigalwaysIncludeRequired)
## The New oatpp::String
@ -199,7 +200,8 @@ ENDPOINT("GET", "videos/{videoId}", getVideoById,
## Response::getBody()
`oatpp::web::protocol::http::outgoing::Response` has a new method `getBody()` to retreive the body of the response. This is handy for response interceptors.
`oatpp::web::protocol::http::outgoing::Response` has a new method `getBody()` to retreive the body of the response.
This is handy for response interceptors.
## data::stream::FIFOStream
@ -223,3 +225,33 @@ You need to implement your own locking.
[`BufferedInputStream`](https://oatpp.io/api/latest/oatpp/core/data/stream/Stream/#bufferedinputstream) which unifies
the bufferd-stream-interface all existing buffered streams (`InputStreamBufferedProxy`, `BufferInputStream`,
`FIFOStream`) to allow for generalisation.
## oatpp::parser::json::mapping::Serializer::Config::alwaysIncludeRequired
If `oatpp::parser::json::mapping::Serializer::Config::includeNullFields == false` there might still be the requirement
to include some fields even if they are `nullptr`, because they are required by the deserializing end.
Consider the following DTO and endpoint-snippet.
```c++
class StatusDto : public oatpp::DTO {
DTO_INIT(StatusDto, DTO)
DTO_FIELD_INFO(status) {
info->required = true;
}
DTO_FIELD(String, status);
DTO_FIELD(Int32, code);
DTO_FIELD(String, message);
};
// endpoint code:
ENDPOINT("GET", "/status", status) {
auto dto = StatusDto::createShared();
dto->code = 200;
return createDtoResponse(Status::CODE_200, dto);
}
```
With a serializer with its config set to `Serializer::Config::includeNullFields = false`, the snippet would just yield `{"code":200}`.
However, `status` is a required field.
Now, one can set `Serializer::Config::alwaysIncludeRequired = true`.
With `alwaysIncludeRequired == true`, the same snippet would yield `{"status":null,"code":200}`, even with `includeNullFields == false`.