-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate javaType into 'existingJavaType' and 'javaType' #828
Comments
First off, great plugin. If this particular item has not been implemented yet, might it be possible to name it "existingJavaType"? We use UML modeling toolsets that aid in auto-generating API JSON specifications which in turn we then leverage jsonSchema2Pojo durings builds. We've experienced with other jsonSchema2Pojo extensions that deviate a bit from the "norm" that the extension can be improperly named to what seems intuitive which doesn't get picked up in our build process. One example is the existing feature for "extendsJavaClass" extension that the plugin supports. It never fails that periodically it will get declared as "extendsJavaType" (which does seem to make logical sense as an extension of "javaType") but the resulting POJOs don't pick it up and it takes another cycle to fix. Maybe a wish here...but if the plugin supported both "extendsJavaClass" for backwards compatibility as well as "extendsJavaType" perhaps it would eliminate this for anyone who's perhaps has also encountered it. In any event, just throwing out thoughts from day-to-day experience. |
Thanks!! |
Benefits I think we'll get after implementing this:
|
Yes, this is a big plus for us. We've observed the limitation that you're calling out in resolving our own existing classes within our gradle builds. So needless to say, when we caught that this was going to be in this next release we were pleased. |
It seems the feature of "existingJavaType" already works if we specify only "javaType" and no "type".
|
@pnmalav yes, that's right. javaType currently allows you to either create new classes or reference existing classes from the classpath. In the next release, you will use javaType to give a specific name to a new class. If you want to refer to an existing class, you will use existingJavaType. |
@joelittlejohn the example I provided works even if my.Custom is not in classpath. There is no Custom class created, unless I specify "type":"object". This will create a Custom class as well
|
@pnmalav thanks, I wasn't aware of this workaround. I think this is the kind of ambiguous behaviour that we need to fix. |
Thanks for this Plugin! @joelittlejohn in which version of:jsonschema2pojo-maven-plugin has this issue been fixed? |
@ajayboseac This change was introduced in 1.0.0-alpha3. Check the CHANGELOG.md (and the 'Milestone' field on this issue). |
At present
javaType
has two jobs, it can be used to reference an existing classpath type and also to give a newly generated type a fixed fully-qualified name. This was a bad design, for instance:We should split these features, so that the schema author needs to be explicit.
The text was updated successfully, but these errors were encountered: