Order matters? #392
-
I'm trying to get the config to not have the generator re-order the properties when creating the schema. In other words, maintain the order the fields are declared in the POJO. Any guidance would be awesome. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @lawrencegrass, Fortunately, this had been raised before in #92, i.e., yes: this is possible. If your compiler happens to honour the declaration order, then you can disable the property sorting with this: configBuilder.forTypesInGeneral()
.withPropertySorter((_prop1, _prop2) -> 0); The standard sorting logic is defined in the Additionally, the |
Beta Was this translation helpful? Give feedback.
Hi @lawrencegrass,
Fortunately, this had been raised before in #92, i.e., yes: this is possible.
If your compiler happens to honour the declaration order, then you can disable the property sorting with this:
The standard sorting logic is defined in the
PropertySortUtils
class, in case you want to apply some other sorting behaviour.Additionally, the
JacksonModule
supports to sort an object's properties according to its@JsonPropertyOrder
annotation, if theJacksonOption.RESPECT_JSONPROPERTY_ORDER
was provided