Skip to content
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

Add extension to force generated classes to implement additional interface(s) #60

Closed
joelittlejohn opened this issue Jun 23, 2013 · 5 comments

Comments

@joelittlejohn
Copy link
Owner

Original author: ottofoni...@gmail.com (July 08, 2012 11:47:30)

It may be convenient to ask generator to place super class (or interface) reference into generated DTO, for instance

Schema
{
...
"javaType":"model.json.Buffer",
"javaSuper":"model.AbstractModel",
"javaInterfaces": ["java.io.Serializable","api.CustomContract"],
"properties":{
"id":{
"type":"integer",
"id":"id"
},
"title":{
"type":"string",
"id":"title"
}
...
"type":"object"
}

Generated
...
public class Buffer extends AbtractModel implements Serializable, CustomContract {
private int id;
private String title;
...

It may also generate stub implementations of interface methods automatically if any.

Original issue: http://code.google.com/p/jsonschema2pojo/issues/detail?id=60

@joelittlejohn
Copy link
Owner Author

From joelittl...@gmail.com on July 08, 2012 18:18:02
If you have the super class on the classpath you should be able to achieve javaSuper using the existing 'extends' keyword like this:

{
"type" : "object",
"extends" : {
"type" : "object",
"javaType" : "model.AbstractModel"
}
}

@joelittlejohn
Copy link
Owner Author

From ottofoni...@gmail.com on July 09, 2012 09:16:53
Thank you for a quick response. Yes, it works by means of 'extends' feature.

It would be helpful to support generation serialVersionUID for Serializable classes also.

And may be the flag 'force' that forces generator overwrite existing classes also be helpful.

@joelittlejohn
Copy link
Owner Author

From joelittl...@gmail.com on October 21, 2012 20:24:39
Changing the scope of this based on the fact that super type can already be accommodated via the 'extends' schema keyword.

@joelittlejohn
Copy link
Owner Author

From joelittl...@gmail.com on June 19, 2013 23:51:11
Fixed for 0.3.7. There is now a new extension property "javaInterfaces" that takes an array of strings, where each string is the fully qualified name of a Java interface. The generated type will implement those interfaces.

@algomaster99
Copy link

algomaster99 commented Mar 1, 2024

Hi! Does this feature exist in the maven-plugin? I cannot seem to find it here.

EDIT: Sorry to bother. I found it here. I did not know that I would need to edit the schema because I was expecting it to be a configuration. I am not complaining was just looking in the wrong place I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants