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 39fdb63607/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
```
pull/3727/head
John Niang 2023-04-09 21:44:15 +08:00 committed by GitHub
parent bfe8b3ba58
commit 45313a529e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -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);
};
}
}