-1

我得到了一个像下面这样的pojo,

{

"id": "yyy",
"$schema": "http://json-schema.org/draft-04/schema#",
"packages": 
{
    "id": "#/packages",
    "description": "XXX",
    "type": "object",
    "properties": 
    {
        "xx": 
        {
            "description": "Total number of elements in the collection.",
            "type": "integer",
            "minimum": 1,
            "minLength": 1
        }
        ..............
        ...............         
    },
    "additionalProperties": false,
    "required": 
    [
        "xx",
        ...
        ... 
    ]
}
}

尝试使用生成 POJO 时,Jsonschema2POJO我只看到正在创建的包中没有类文件。甚至没有出现异常。

当我在“包”标签周围添加“属性”时,它会生成 pojo,但如果任何其他 json 引用此 json,我会收到"Path not present:packages"错误,而且它会使模式无效。

我想了解该工具对架构版本是否有任何限制?或者是否必须在提供的 json 中进行任何修改才能使其与该工具一起使用。请建议。

4

1 回答 1

1

用对我有用的东西回答自己,模式隐藏在包中,jsonschema2pojo 看不到它。要使用此模式,请将其放在文件的根目录,使用 $ref 从其他位置指向它(例如 "$ref":"#/packages".

单击https://github.com/joelittlejohn/jsonschema2pojo/issues/366以获取更多参考。

于 2015-06-11T07:24:25.927 回答