Object mapper autoconfiguration
ObjectMapper is responsible for serialization and deserialization of DTO classes. Given auto-configuration configures ObjectMapper with features that confer with best practices.
Enabling feature
In order to enable the feature, following property should be added to application.properties file.
ee.bitweb.core.object-mapper.auto-configuration=true
Enabling of this feature assumes existence of ObjectMapper bean. This bean is created for example by autoconfiguration from org.springframework.boot:spring-boot-starter-web.
Regardless, you will need to include given dependency to enable Java Time module.
// https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: "${jacksonVersion}"
Features
String trimmer deserializer
ee.bitweb.core.object_mapper.deserializer.TrimmedStringDeserializer is a class capable of trimming excessive whitespaces from strings in values when deserializing payload.
Addition of JavaTimeModule
Java Time module is added to ObjectMapper, which allows for serialization and desirialization of java.time data types.
Disabling adjustment of dates to context time zone
By default, ObjectMapper will adjust ZonedDateTime data in payload to correspond to application's. This behaviour can introduce unexpected results, thus it is disabled.
Disabling of casting floats to integers
By default, if field is of type integer and in payload a float is passed, it would be cast to integer. This results in loss of information, thus loss of user's intent.
This can produce unexpected results, thus this feature is disabled.