0

在 Mule 4 中,我只想使用 DataWeave 显示 JSONschema,但在 JSON 模式中引用 ID 或任何以“$”开头的字段时出现错误。mime/类型是应用程序/json。目标是显示架构,我将不胜感激任何建议。谢谢!

示例模式

{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://example.com/example.json",
  "type": "object",
  "title": "The Root Schema",
  "properties": {
    "checked": {
      "$id": "/properties/checked",
      "type": "boolean",
      "title": "The Checked Schema",
      "default": false,
      "examples": [
        false
      ]
    },
    "dimensions": {
      "$id": "/properties/dimensions",
      "type": "object",
      "title": "The Dimensions Schema",
      "required": [
        "width",
        "height"
      ],
      "properties": {
        "width": {
          "$id": "/properties/dimensions/properties/width",
          "type": "integer",
          "title": "The Width Schema",
          "default": 0,
          "examples": [
            5
          ]
        },
        "height": {
          "$id": "/properties/dimensions/properties/height",
          "type": "integer",
          "title": "The Height Schema",
          "default": 0,
          "examples": [
            10
          ]
        }
      }
    },
    "id": {
      "$id": "/properties/id",
      "type": "integer",
      "title": "The Id Schema",
      "default": 0,
      "examples": [
        1
      ]
    }
  }
}
4

1 回答 1

1

在 $ 之前使用黑斜线\,这将在列名中使用 $ 打印您的架构。不幸的是,作为前缀的 $ 在 Mule 中不被视为字符串的一部分

例子

"\$id": "/properties/dimensions/properties/width"

将打印

"$id": "/properties/dimensions/properties/width"
于 2019-09-23T11:24:26.953 回答