Property names from @JsonProperty or @JsonbProperty should take precedence over property name, translated by PropertyNamingStrategy.
Let's take a look at the following case:
DTO class:
// doc-examples/example-kotlin/src/test/kotlin/example/BookTest.kt
@Serdeable
data class Book (
val title: String,
@JsonProperty("qty") val quantity: Int
)
'test global property strategy SNAKE_CASE with JsonProperty annotated fields' will fail:
Test Run :micronaut-serde-jackson:test > Partition 1 in session 1 on localhost-executor-1 > GlobalPropertyStrategySpec test global property strategy SNAKE_CASE with JsonProperty annotated fields FAILED
Condition not satisfied:
val == '{"explicit_foo_bar_prop_name":"hello","abc_xyz":123}'
| |
| false
| 19 differences (63% similarity)
| {"(---------)foo_bar(----------)":"hello","abc_xyz":123}
| {"(explicit_)foo_bar(_prop_name)":"hello","abc_xyz":123}
{"foo_bar":"hello","abc_xyz":123}
at io.micronaut.serde.jackson.GlobalPropertyStrategySpec.test global property strategy SNAKE_CASE with JsonProperty annotated fields(GlobalPropertyStrategySpec.groovy:59)
Expected Behavior
Property names from
@JsonProperty
or@JsonbProperty
should take precedence over property name, translated byPropertyNamingStrategy
.Let's take a look at the following case:
DTO class:
Define app configuration:
Run test:
result
should be{"title":"The Stand","qty":50}
with explicit property nameqty
, set by@JsonProperty
.Actual Behaviour
Actual
result
is{"title":"The Stand","quantity":50}
. Annotation property names are ignored.Steps To Reproduce
io.micronaut.serde.jackson.GlobalPropertyStrategySpec
:'test global property strategy SNAKE_CASE with JsonProperty annotated fields'
will fail:Environment Information
No response
Example Application
https://github.com/Myshkouski/micronaut-serialization/tree/425696c939401fc74b1ccf89df120793f37e85fb
Version
4.5.0