多参考链式模式的模式验证

时间:2018-05-18 10:41:07

标签: json hive avro apache-nifi json-schema-validator

我想做三件事

  1. 针对JSON-Schema验证JSON
  2. 创建JSON-Schema到AVRO Schema转换器
  3. 创建JSON-Schema到Hive表转换器
  4. 我面临的问题是Schema有一个引用链。 我试图使用this JSON Schema Validator来解析引用和验证,但此时会出现一些错误。 但我还没能找到任何第二和第三项任务的图书馆。

    我必须为这些创建 Nifi处理器。我已经完成了第一个。

    我的一个想法是使用内联解析器来推导架构并创建一个大架构并将其用于任务,希望之后一切都能顺利运行。

    有关解决这些问题的好方法的任何建议。 其中一个架构是附加的。任何帮助将不胜感激。

    {
      "id": "/schemas/bi/events/identification/carrier",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "title": "Users Carrier Identified",
      "description": "A successfully identified carrier of a user",
      "type": "object",
      "definitions": {
        "carrier_identification_result": {
          "type": "object",
          "properties": {
            "mno": {
              "type": "string",
              "title": "Mobile network operator",
              "description": "The Mobile network operator",
              "example": "Telekom"
            },
            "mvno": {
              "type": "string",
              "title": " Mobile virtual network operator",
              "description": "The Mobile virtual network operator.",
              "example": "Mobilcom-Debitel"
            },
            "mcc": {
              "type": "string",
              "title": "Mobile Country Code",
              "description": "The Mobile Country Code as defined in the ITU-T Recommendation E.212",
              "example": "262"
            },
            "mnc": {
              "type": "string",
              "title": "Mobile Network Code",
              "description": "The Mobile Network Code as defined in the ITU-T Recommendation E.212",
              "example": "01"
            },
            "country": {
              "type": "string",
              "title": "The code ISO 3166-1 alpha 2 for the country",
              "example": "DE"
            }
          },
          "required": [
            "mno",
            "country"
          ]
        }
      },
      "allOf": [
        {
          "$ref": "../identification_service.json"
        },
        {
          "properties": {
            "type": {
              "constant": "identification.carrier",
              "example": "identification.carrier"
            },
            "event_data": {
              "allOf": [
                {
                  "$ref": "../identification_service.json#/definitions/event_data"
                },
                {
                  "type": "object",
                  "properties": {
                    "result": {
                      "$ref": "#/definitions/carrier_identification_result"
                    },
                    "required": [
                      "result"
                    ]
                  }
                }
              ]
            }
          }
        }
      ]
    }
    

0 个答案:

没有答案