WSO2 EI,从 属性 加载验证模式

WSO2 EI, loading validation schemas from property

我有一个序列将从注册表中加载特定的 JSON 验证模式,具体取决于请求正文的值:

<switch description="" source="get-property('uri.var.service')">
    <case regex="1">
        <property expression="base64Decode(get-property('registry', 'conf:/schemas/1'))" name="schema" scope="default" type="STRING"/>
    </case>
    <case regex="2">
        <property expression="base64Decode(get-property('registry', 'conf:/schemas/2'))" name="schema" scope="default" type="STRING"/>
    </case>
</switch>

然后我尝试从中验证:

<validate cache-schema="true" source="json-eval($)">
    <schema key="{get-property('schema')}"/>
</validate>

但是,这会抛出这个错误:

 ValidateMediator Can not find JSON Schema {
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "uin": {
      "type": "string"
    }
  },
  "required": [
    "uin"
  ]
}

为什么我无法从 属性 加载正确的架构?此外,在 WSO2 EI 的文档中没有关于 JSON 验证的动态密钥的示例。

根据验证中介实现 [1],只能从注册表中加载模式键,而不是整个模式。在您的情况下,加载整个架构以代替架构键。作为一种解决方案,您可以将架构 属性 定义为字符串值。

<property name="schema" scope="default" type="STRING" value="conf:/schema.json"/>