Skip to content

Commit

Permalink
fix: ObjectMapperConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwwinter committed Dec 10, 2024
1 parent 8ff153c commit f5fa229
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Primary
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter


@Configuration
class ObjectMapperConfiguration {

@Bean
@Primary
fun objectMapper(): ObjectMapper {
Expand All @@ -20,4 +22,14 @@ class ObjectMapperConfiguration {
)
return mapper.build()
}

@Bean
fun mappingJackson2HttpMessageConverter(): MappingJackson2HttpMessageConverter {
val builder = Jackson2ObjectMapperBuilder()
builder.featuresToEnable(
DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT,
DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
)
return MappingJackson2HttpMessageConverter(builder.build())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ spring:
name: aam-backend-service
main:
banner-mode: off
allow-bean-definition-overriding: true
jackson:
deserialization:
accept-empty-string-as-null-object: true
read-unknown-enum-values-using-default-value: true
rabbitmq:
listener:
simple:
Expand All @@ -21,7 +24,6 @@ spring:
multipart:
max-file-size: 5MB


server:
servlet:
context-path: /api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ spring:
name: aam-backend-service
main:
banner-mode: off
allow-bean-definition-overriding: true
jackson:
deserialization:
accept-empty-string-as-null-object: true
read-unknown-enum-values-using-default-value: true
rabbitmq:
listener:
simple:
Expand Down

0 comments on commit f5fa229

Please sign in to comment.