From 45313a529e5f8fa8021c06e3a9f26585480657ee Mon Sep 17 00:00:00 2001 From: John Niang Date: Sun, 9 Apr 2023 21:44:15 +0800 Subject: [PATCH] Enable mapper feature: accept case-insensitive enums (#3707) #### What type of PR is this? /kind improvement /area core #### What this PR does / why we need it: After enabling this mapper feature, we could pass a enum value with any case in request body(JSON format). See https://github.com/FasterXML/jackson-databind/blob/39fdb63607a0e7a6dbf9d6be84fe7e380e661dcb/src/test/java/com/fasterxml/jackson/databind/deser/enums/EnumDeserializationTest.java#L22 for more. #### Does this PR introduce a user-facing change? ```release-note None ``` --- .../src/main/java/run/halo/app/config/HaloConfiguration.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/src/main/java/run/halo/app/config/HaloConfiguration.java b/application/src/main/java/run/halo/app/config/HaloConfiguration.java index fc67d21af..ef7f8a2bc 100644 --- a/application/src/main/java/run/halo/app/config/HaloConfiguration.java +++ b/application/src/main/java/run/halo/app/config/HaloConfiguration.java @@ -1,6 +1,7 @@ package run.halo.app.config; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.MapperFeature; import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -14,6 +15,7 @@ public class HaloConfiguration { Jackson2ObjectMapperBuilderCustomizer objectMapperCustomizer() { return builder -> { builder.serializationInclusion(JsonInclude.Include.NON_NULL); + builder.featuresToEnable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS); }; } } \ No newline at end of file