Type.json (Enum)
{
"type" : "string",
"$schema" : "http://json-schema.org/draft-04/schema#",
"title": "type resource",
"name": "type resource",
"description": "List of types",
"id" : "type:v1",
"enum" :
[
"ACC1",
"ACC2"
]
}
Pojo1.json
"properties":{
"type" : {
"$ref" : "Type.json"
},
}
Pojo2.json
"properties":{
"type" : {
"$ref" : "Type.json"
},
}
Instead of creating a separate java file for enum, it creates a enum inside one of the POJOs and this inner public enum is referred by the other POJO.
Pojo2.java
private com.Pojo1.Type type;
How to create a separate java file for enum ? Thanks
It doesn't look like creating enums as separate classes is supported in jsonschema2pojo as an option.
The generation of enums is carried out by org.jsonschema2pojo.rules.EnumRule
The javadoc of which states:
A Java {@link Enum} is created, with constants for each of the enum values present in the schema. The enum name is derived from the nodeName, and the enum type itself is created as an inner class of the owning type. In the rare case that no owning type exists (the enum is the root of the schema), then the enum becomes a public class in its own right.
Sounds like you'll need to raise a feature request