首页 > 解决方案 > 是否有任何库可以使用 java 或 springboot 或 nodejs 将多个 json 模式组合成单个模式

问题描述

我有一个 Json 模式数组的输入,我需要将这些多个模式组合成单个模式,那么 java 或 springboot 中是否有任何库可以将多个模式组合成单个模式

我找到了我们可以使用nodejs https://www.npmjs.com/package/json-schema-merge-allof做的链接, 但步骤不清楚,所以无法理解实现它

我的输入 json 模式数组如下

[
{
        "$schema": "http://json-schema.org/draft-04/schema#",
        "title": "PartyAddressArray",
        "description": "PartyAddressArray",
        "type": "array",
        "items": {
            "$ref": "PartyAddress"
        }
    },
    {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "title": "PartyAddress",
        "description": "PartyAddress",
        "type": "object",
        "properties": {
            "id": {
                "description": "The unique identifier for a partyAddress",
                "type": "string"
            },
            "partyId": {
                "description": "The associated partyId for a partyAddress",
                "type": "string"
            },
            "addressType": {
                "description": "The address type for a partyAddress",
                "type": "string",
                "enum": [
                    "HOME",
                    "WORK",
                    "PERMANENT",
                    "COMMUNICATION",
                    "REGISTERED",
                    "SAIL",
                    "BUSINESS"
                ]
            },
            "languageCode": {
                "description": "The language code for a partyAddress",
                "type": "string",
                "maxLength": 10
            },
            "statusType": {
                "description": "The status type for a partyAddress",
                "type": "string",
                "enum": [
                    "PAST",
                    "CURRENT",
                    "FUTURE"
                ]
            },
            "effectiveDate": {
                "description": "The effective date for a partyAddress",
                "type": "string",
                "format": "date"
            },
            "endDate": {
                "description": "The end date for a partyAddress",
                "type": "string",
                "format": "date"
            },
            "postalAddress": {
                "description": "The postal address for a partyAddress",
                "$ref": "PostalAddress"
            }
        },
        "required": [
            "addressType",
            "statusType"
        ],
        "example": {
            "id": "b9e2d964-e3ef-4c04-aaa9-31c46122e4g5",
            "partyId": "ff77a7a1-a637-40d2-b8f5-7da261f8bdc3",
            "addressType": "HOME",
            "languageCode": "EG",
            "statusType": "CURRENT",
            "effectiveDate": "13/03/2019",
            "endDate": "19/03/2019",
            "postalAddress": {
                "country": "India",
                "state": "MH",
                "city": "Mumbai",
                "zip": "40060",
                "line1": "Goregoan East1",
                "line2": "Goregoan East2",
                "line3": "Goregoan East3",
                "line4": "Goregoan East4",
                "line5": "Goregoan East5",
                "line6": "Goregoan East6",
                "line7": "Goregoan East7",
                "line8": "Goregoan East8",
                "line9": "Goregoan East9",
                "line10": "Goregoan East10",
                "line11": "Goregoan East11",
                "line12": "Goregoan East12"
            }
        }
    }
]

我需要将上述所有 json 模式组合成单个模式

输入是一个带有 json 模式的数组,需要将所有模式组合成一个模式

标签: javanode.jsspring-boot

解决方案


推荐阅读