Open sonOfRa opened 4 years ago
Same thing is happening to me. Is there a workaround for this?
@giordanolucas well my workaround was transcribing the entire ~1200 line json schema by hand. Not for everyone I admit, but it does work (and faster than one would think).
@joelittlejohn do you have any idea on a solution for this?
You could probably work around this right now by adding an enum name suffix of 'Enum'. There's a config property to allow you to add this suffix.
To fix this in general I think we need to introduce an extra check here so that the enum is never given the same name as its enclosing class. It could be disambiguated with an underscore.
Normally I would suggest adding a prefix of "Type" to the enumeration but since it ends in "Type" already you get the weird duplicate "TypeType" suffix. While this generation should not happen maybe you should change the name of enclosing class to differentiate it like PaymentMethod or PaymentCategory.
Hi! In my example, I can not alter the source Json. Is there a way of configuring a global suffix for all Enums using the Java API? That would work for me.
The following schema is an excerpt of a larger schema, but I narrowed it down as much as I could so that the faulty behaviour still exists:
Generating code from this schema leads to code that does not compile:
The internal enum for the
PaymentType
class uses the same name as the enclosing class, which is invalid syntax in Java.The reason seems to be that the same names get derived for the
payment_types
array property, as well as thepayment_type
enum definition in the schema. Changing the schema is currently not really an option, as the schema in question is not under our control, we are just generating JSON according to the schema we are given.