jsonschema2pojo
jsonschema2pojo copied to clipboard
Annotator#typeInfo is not called for generated Enums
We have to annotate all classes generated by jsonschema2pojo with a specific annotation (Quarkus @RegisterForReflection).
One of our json schemas now use an enum which is generated to an inner enum-class. Sadly the Annotator#typeInfo method is not called for this generated class.
As a workaround I implemented a custom RuleFactory which only returns a subclassed EnumRule which calls the annotators after its `#createEnum()'-invocation.
If just adding the typeInfo call to the EnumRule#createEnum is a valid solution to this issue, I could happily submit it as pull request...
I can't think of any problem this would cause. Feel free to submit a PR for this (and please include a test case). How do you attach the @RegisterForReflection annotation in typeInfo()?
Sorry for my late reaction... I added the PR #1433 for this issue which is I heavily inspired by the ObjectRule. The test case is not really great, but I didn't find a similar one for ObjectRule annotators.
Regarding the @RegisterForReflection: It was rather straight forward:
public class RegisterForReflectionAnnotator extends AbstractAnnotator {
@Override
public void typeInfo(JDefinedClass clazz, JsonNode schema) {
clazz.annotate(RegisterForReflection.class);
}
}
Your question and this straight-forward approach makes me think I missed something important? :-) Regarding this annotation, the PR #1394 would make the custom implementation superfluous and I could just add the RegisterForReflection by configuration. :-)