package cz.muni.fi.pa165.soccermanager.configuration;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.zalando.problem.jackson.ProblemModule;
import org.zalando.problem.violations.ConstraintViolationProblemModule;

@EnableAutoConfiguration(exclude = ErrorMvcAutoConfiguration.class)
@Configuration
public class MappingConfiguration {
  @Bean
  public ObjectMapper objectMapper() {
    return new ObjectMapper().registerModules(
        new ProblemModule(),
        new ConstraintViolationProblemModule(),
        new JavaTimeModule())
        .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
  }
}
