Skip to content

Commit

Permalink
Added JsonApiConfiguration bean
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonandre committed Jan 13, 2025
1 parent d68b50d commit 02c8a22
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/ca/gc/aafc/agent/api/MainConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.toedter.spring.hateoas.jsonapi.JsonApiConfiguration;

@Configuration
@ComponentScan(basePackageClasses = DinaBaseApiAutoConfiguration.class)
@ImportAutoConfiguration(DinaBaseApiAutoConfiguration.class)
Expand All @@ -29,4 +33,15 @@ public DocumentOperationNotificationMessageProducer init() {
return new LogBasedMessageProducer();
}
}

@Bean
public JsonApiConfiguration jsonApiConfiguration() {
return new JsonApiConfiguration()
.withPluralizedTypeRendered(false)
.withPageMetaAutomaticallyCreated(false)
.withObjectMapperCustomizer(objectMapper -> {
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
objectMapper.registerModule(new JavaTimeModule());
});
}
}

0 comments on commit 02c8a22

Please sign in to comment.