简体   繁体   English

JsonSchema2pojo不生成POJO

[英]JsonSchema2pojo doesnot generate POJO

I was given a pojo like below, 像下面这样给我一个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",
        ...
        ... 
    ]
}
}

When trying to generate POJO with the Jsonschema2POJO I just see the package being created with no class files in it. 当尝试使用Jsonschema2POJO生成POJO时,我只看到正在创建的没有类文件的包。 Even no exceptions occur. 即使没有异常发生。

When I add a "properties" around the "packages" tag then it generates the pojo but if any other json references this json i get a "Path not present:packages" error and moreover it makes the schema invalid. 当我在“ packages”标签周围添加“ properties”时,它会生成pojo,但如果有其他json引用此json,则会出现"Path not present:packages"错误,而且还会使架构无效。

I want to understand if there is any limitation with the tool on the schema version? 我想了解该工具在架构版本上是否有任何限制? Or is there any modifications that has to be done in the jsons provided to make it work with the tool. 还是在提供的json中必须进行任何修改才能使其与该工具一起使用。 Please suggest. 请提出建议。

Answering myself with something that worked for me, schema is hidden inside packages, it cannot be seen by jsonschema2pojo. 用对我有用的东西回答自己,模式隐藏在包中,jsonschema2pojo无法看到它。 To use this schema, either put it at the root of the file use a $ref to point to it from somewhere else (like "$ref":"#/packages". 要使用此架构,请将其放在文件的根目录中,并使用$ ref从其他位置指向它(例如“ $ ref”:“#/ packages”)。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM