如何在 Mule 4 中使用 Dataweave 显示 json 模式?

How to display json schema using Dataweave in Mule 4?

在 Mule 4 中,我只想使用 DataWeave 显示 JSON 模式,但在 JSON 模式中出现引用 ID 或任何以“$”开头的字段的错误。 mime/type 是 application/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
      ]
    }
  }
}

在 $ 之前使用黑斜杠 \,这将在列名称中打印带有 $ 的模式。不幸的是,$ 作为前缀在 Mule

中不被视为字符串的一部分

示例

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

将打印

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