diff --git a/backend/build.gradle b/backend/build.gradle index df719116b..61add9d3a 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -2,7 +2,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent plugins { - id 'org.springframework.boot' version '3.3.5' + id 'org.springframework.boot' version '3.4.0' id 'io.spring.dependency-management' version '1.1.6' // If kotlin version bumped, check if gradle version can be bumped as well // Check here: https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin @@ -36,7 +36,7 @@ dependencies { implementation "io.github.microutils:kotlin-logging-jvm:3.0.5" implementation "org.postgresql:postgresql:42.7.4" implementation "org.apache.commons:commons-csv:1.12.0" - implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0" + implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0" implementation "org.flywaydb:flyway-database-postgresql:10.21.0" implementation "org.jetbrains.exposed:exposed-spring-boot-starter:0.56.0" implementation "org.jetbrains.exposed:exposed-jdbc:0.56.0" diff --git a/backend/src/main/kotlin/org/loculus/backend/utils/LocalDateJacksonModule.kt b/backend/src/main/kotlin/org/loculus/backend/utils/LocalDateJacksonModule.kt new file mode 100644 index 000000000..be687bfc7 --- /dev/null +++ b/backend/src/main/kotlin/org/loculus/backend/utils/LocalDateJacksonModule.kt @@ -0,0 +1,29 @@ +package org.loculus.backend.utils + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonSerializer +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.module.SimpleModule +import kotlinx.datetime.LocalDate +import org.springframework.context.annotation.Configuration + +@Configuration +class LocalDateJacksonModule : SimpleModule() { + init { + addSerializer(LocalDate::class.java, LocalDateSerializer()) + addDeserializer(LocalDate::class.java, LocalDateDeserializer()) + } +} + +class LocalDateSerializer : JsonSerializer() { + override fun serialize(value: LocalDate, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeString(value.toString()) + } +} + +class LocalDateDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): LocalDate = LocalDate.parse(p.text) +}