Jaxb names customization #462
-
I'm using xjc for automatic generation of java classes hierarchy from a xsd issued by ISO (International Organization for Standardization).
Do you know if is there in Victools a smarter way to customize json schema generation using @xmlelement jaxb annotation already present in jaxb classes? @XmlElement(name = "GrpHdr", required = true)
@JacksonXmlProperty(namespace = "urn:iso:std:iso:20022:tech:xsd:pain.013.001.10")
@JsonProperty(required = true)
@NotNull
@Valid
protected GroupHeader groupHeader; Many thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @theseeker58, You correctly referred to Jackson's The example given there only needs a tiny adjustment to also apply for configBuilder.forFields()
.withPropertyNameOverrideResolver(field -> Optional
.ofNullable(field.getAnnotationConsideringFieldAndGetter(XmlElement.class))
.map(XmlElement::name).orElse(null)); That should do it. |
Beta Was this translation helpful? Give feedback.
-
Thank you @CarstenWickner you made my day!
For the record I'm preparing a benchmark to compare json schema validation vs. bean validation under heavy load even though I guess that, in a reactive approach caching the body vs. streaming can be penalizing. On the contrary json schema validation makes useless jaxb classes and the body can be directly mapped to avro classes (generated automatically from jaxb classes too) for subsequent kafka streaming. Considering that all stuff is automatically generated from the original xsd scheme it makes sense. Thank you again |
Beta Was this translation helpful? Give feedback.
Hi @theseeker58,
You correctly referred to Jackson's
@JsonProperty
annotations already being supported, which tells you it can be configured. 😃That's what "Property Name Overrides" are for (as I call them). They are mentioned in the documentation.
The example given there only needs a tiny adjustment to also apply for
@XmlElement
annotations:That should do it.