joelittlejohn / jsonschema2pojo

Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc
http://www.jsonschema2pojo.org
Apache License 2.0
6.24k stars 1.66k forks source link

Propagate JSR annotations to getters/setters #897

Open valasatava opened 6 years ago

valasatava commented 6 years ago

When includeJsr303Annotations is set to true the resulting POJO has annotations attached to the fields. Is there a way to propagate annotations to getters/setters?

joelittlejohn commented 6 years ago

Is that needed for some validators? This has never been requested before so I'm unsure why it's needed.

valasatava commented 6 years ago

We would like to generate automatically GraphQL schema from POJOs preserving annotation for "required" fields. The tool we use (GraphQL SPQR) handles @NotNull annotations when they are attached to getters but not fields. Omitting accession methods in favor of public fields doesn't work for GraphQL SPQR library out of the box.