Skip to content

Compile error when schema contains list with empty default value #59

@joelittlejohn

Description

@joelittlejohn

Original author: jemac...@gmail.com (July 08, 2012 01:30:24)

What steps will reproduce the problem?

  1. Generate code from this schema and compile:
    {
    "id": "test",
    "type": "object",
    "additionalProperties": false,
    "properties": {
    "basket": {
    "type": "array",
    "default": [],
    "items": {"type": "string"}
    }
    }
    }

What is the expected output?
Generated java code compiles successfully.

What do you see instead?
Basket_schema.java:20: cannot find symbol
symbol : constructor ArrayList(java.util.List<java.lang.Object>)
location: class java.util.ArrayList<java.lang.String>
private List<String> basket = new ArrayList<String>(Arrays.asList());

What version of the product are you using?
0.3.0

On what Java version?
java version "1.6.0_30"

Replacing this code (DefaultRule.getDefaultList(DefaultRule.java:159)):
newListImpl.arg(invokeAsList);
with this code:
if( invokeAsList.listArgs().length > 0 ){
newListImpl.arg(invokeAsList);
}
resolves the issue.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions