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 e422313 commit 8ff153c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@ package com.aamdigital.aambackendservice.rest

import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer
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

@Configuration
class ObjectMapperConfiguration {

@Bean
fun jsonCustomizer(): Jackson2ObjectMapperBuilderCustomizer {
return Jackson2ObjectMapperBuilderCustomizer { builder: Jackson2ObjectMapperBuilder ->
builder.featuresToEnable(
DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT,
DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE,
)
}
}


@Bean
@Primary
fun objectMapper(jsonCustomizer: Jackson2ObjectMapperBuilderCustomizer): ObjectMapper {
val builder = Jackson2ObjectMapperBuilder()
jsonCustomizer.customize(builder)
return builder.build()
fun objectMapper(): ObjectMapper {
val mapper = Jackson2ObjectMapperBuilder()
mapper.featuresToEnable(
DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT,
DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
)
return mapper.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ spring:
name: aam-backend-service
main:
banner-mode: off
allow-bean-definition-overriding: true
rabbitmq:
listener:
simple:
Expand All @@ -20,6 +21,7 @@ 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,6 +3,7 @@ spring:
name: aam-backend-service
main:
banner-mode: off
allow-bean-definition-overriding: true
rabbitmq:
listener:
simple:
Expand Down

0 comments on commit 8ff153c

Please sign in to comment.