This repository was archived by the owner on Nov 7, 2019. It is now read-only.
This repository was archived by the owner on Nov 7, 2019. It is now read-only.
@JsonProperty annotations on enums are not respected if parameter names module is registered #32
Closed
Description
If you annotate an enum value with @JsonProperty("foo"), that value should be serialized/deserialized as "foo". This fails if the parameter names module is registered - I've made a test case at https://github.com/edwag/jackson-parameter-names-test-case to clarify what I mean.
I believe that this is what happens:
- The ParameterNamesAnnotationIntrospector is added to the SetupContext using insertAnnotationIntrospector, so it takes precedence over the default JacksonAnnotationIntrospector (i.e. it is the primary AnnotationIntrospector in an AnnotationIntrospectorPair).
- Because the ParameterNamesAnnotationIntrospector inherits findEnumValue from AnnotationIntrospector, when it inspects an enum value it just returns value.name()
- Because the ParameterNamesAnnotationIntrospector didn't return null, the default JacksonAnnotationIntrospector doesn't get a chance to inspect the enum value (due to the behaviour of AnnotationIntrospectorPair).
- We therefore use value.name() instead of the value of the @JsonProperty annotation.
I'd be happy to contribute a fix, but it's not obvious to me what the right way to fix this is (e.g. is this actually an issue with AnnotationIntrospectorPair?).
Metadata
Metadata
Assignees
Labels
No labels