You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My output for the products is this:
/**
*
* (Required)
*
*/ @JsonProperty("products") @NotNull @SiZe(min = 1)
private Set<Product> products = new HashSet<Product>();
If this had been defined using the definition in place, it will work correctly:
From joelittl...@gmail.com on April 05, 2013 16:35:59
Hi Brenton. Thanks for taking the time to raise this with complete examples. I think your diagnosis is correct :)
I fixed another, similar problem in 0.3.6 and I'm sure there are more. We really need to switch to a process where all these references are resolved before type generation starts. I'm going to try and prove this solution and I'll make sure that one way or another this is fixed in 0.3.7.
Original author: b...@hotmail.com (April 01, 2013 20:26:10)
@Valid is not being added to an array of objects that have been defined using a $ref parameter to reference the definition.
Here is a simplified version of the schema in question.
{
"id": "http://www.foo.com/schema",
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "object",
"properties": {
"id" : {
"type": "string"
},
"products": {
"type": "array",
"required": true,
"minItems": 1,
"items": { "$ref": "#definitions/product" },
"uniqueItems": true
}
},
"additionalProperties": false,
"definitions": {
"product": {
"type": "object",
"required": [ "productId" ],
"properties": {
"productId": {
"type": "string",
"pattern": "^\d{6}$"
}
},
"additionalProperties": {
"type": "string"
}
}
},
"links":[
{
"rel": "self",
"href": "{id}"
}, {
"rel": "parent",
"href": "{parent_id}"
}
]
}
My output for the products is this:
/**
*
* (Required)
*
*/
@JsonProperty("products")
@NotNull
@SiZe(min = 1)
private Set<Product> products = new HashSet<Product>();
If this had been defined using the definition in place, it will work correctly:
I would expect to be able to get @Valid on the array of objects no matter whether I was using a reference or extending the schema.
I am using version 0.3.6 with Java version 1.6.0_20
If I had to guess the cause, I would look at
Revision: e6415a0
/jsonschema2pojo-core/src/main/java/com/googlecode/jsonschema2pojo/rules/PropertyRule.java
private boolean isArrayOfObjects(JsonNode node)
It doesn't appear to be resolving any referenced or extended schema's before determine if it is an array of objects or not.
Original issue: http://code.google.com/p/jsonschema2pojo/issues/detail?id=97
The text was updated successfully, but these errors were encountered: