I need to generate Java classes from a JSON schema file and came across jsonschema2pojo. However, I encountered a "problem" when using the ref keyword.
For example, if I use the following schema from http://spacetelescope.github.io/understanding-json-schema/structuring.html#extending:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"address": {
"type": "object",
"properties": {
"street_address": { "type": "string" },
"city": { "type": "string" },
"state": { "type": "string" }
},
"required": ["street_address", "city", "state"]
}
},
"type": "object",
"properties": {
"billing_address": { "$ref": "#/definitions/address" },
"shipping_address": { "$ref": "#/definitions/address" }
}
}
As expected, it generated a class named whatever you want to call it, containing an attribute billingAddress and an attribute shippingAddress.
However, it also generated two separate classes BillingAddress and ShippingAddress even though both attributes are referencing to address. Hence, I would rather have both attributes of type Address.
Is this possible to achieve with jsonschema2pojo?