Skip to content

Commit

Permalink
Enable mapper feature: accept case-insensitive enums (#3707)
Browse files Browse the repository at this point in the history
#### 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
```
  • Loading branch information
JohnNiang authored Apr 9, 2023
1 parent bfe8b3b commit 45313a5
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,6 +15,7 @@ public class HaloConfiguration {
Jackson2ObjectMapperBuilderCustomizer objectMapperCustomizer() {
return builder -> {
builder.serializationInclusion(JsonInclude.Include.NON_NULL);
builder.featuresToEnable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS);
};
}
}

0 comments on commit 45313a5

Please sign in to comment.