-
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
Support direct class inheritance with 'extendsJavaType', without using 'extends' #402
Comments
The proposed change is reflected in a pull request: #403 |
#402 support of existing java class inheritance
You can use extends with a javaType field and it works fine with existing classes. Did you try this? |
I tried with the latest snapshot and it didn't work for the type. Can you
|
@ahanin an example of what @brentryan is talking about would be:
It's a bit of a workaround and is a bit more intrusive in the schema than you were hoping. I was happy to merge as people have asked about this kind of feature in the past, and it's possible to implement this as a nicely isolated extension property. |
Ah, nice. Good to know. I am perhaps documentation blind :)
|
It works only when using maven jsonschema2pojo:generate. Updated: adding phase in the pom.xml will solve the problem <executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<phase>
compile
</phase>
</execution>
</executions>``` |
@anhquande would you create a relevant issue? |
If you reference a class from one of the dependencies, like where the custom annotator would live, you don't need to add phase. |
I found
javaInterfaces
rule useful, but, unfortunately, it doesn't meet all my needs. When generating POJOs I sometimes want them to inherit already existing class, that is not generated from schema, thereforeextends
is not enough.The solution to this could be a new
extendsJavaClass
rule to complimentjavaInterfaces
, which would take a java type to extends. Generics should be supported too. This way, another feature, is maybe required - reference a class being generated.extends
andextendsJavaClass
must be mutually exclusive.Example (article.schema):
${this}
(or any other placeholder) would have to be replace by the actual class name being generated, e.g.:The text was updated successfully, but these errors were encountered: