首页 > 解决方案 > json to pojo 为自引用定义给出“路径不存在:定义”的错误

问题描述

我有一个在“定义”属性中有嵌套引用的 json 模式。我的意思是我定义了一个属性说“PropertyA”,然后定义了第二个属性称为“PropertyB”,它引用了“PropertyA”

当我使用https://www.jsonschema2pojo.org/上的预览按钮时,我得到了错误Path not present: definitions

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Inbox Item Datalake DTO",
    "definitions": {
        "PropertyA": {
            "type": "object",
            "properties": {
                "value": {
                    "type": "string"
                }
            }
        },
        "PropertyB": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/PropertyA"
                    },
                    "default": []
                }
            }
        }
    },
    "properties": {
        "FinalProperty": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/PropertyB"
            },
            "default": []
        }
    }
}

我在网上看到了一些关于使用绝对路径的帖子,但这是在完全相同的文件中,我没有看到任何关于此的内容,因此将不胜感激。

标签: jsonschemapojojsonschema2pojo

解决方案


推荐阅读