RAML 文件在 Anypoint Studio 中抛出无效的 Json 架构响应

RAML file is throwing invalid Json schema response in Anypoint Studio

我将 Anypoint Studio 6.2 与 Mule 3.8.1 一起使用,我添加了一个 raml 和 JSON 模式,它在 api-workbench 中没有显示错误,但显示 Json Anypoint Studio 中的架构无效错误。

我发现,如果我从链接到 raml(即 raml、特征和类型)的所有 Json 模式中删除必填字段,那么一切正常。有办法解决这个问题吗?

我使用的要求语法是:

"required": [
    "Organisation",
    "Address"
  ],

Updated

而且我还看到 org.mule.common.metadata.parser.json.SchemaException: java.net.MalformedURLException: no protocol: 在使用 JSON 模式创建要在 Dataweave 中使用的元数据类型时无法解析 $ref:

{
    "id": "http://localhost:8000/schemas/products.json#",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Products",
    "type": "object",
    "properties": {
        "Products": {
            "$ref": "common/text.json"
        }
    },
    "additionalProperties": false
}

谢谢

我也是这样,所以Studio肯定是支持的。在没有看到整个 JSON 模式文件的情况下,我不得不猜测原因,我的假设是您没有指定 JSON 模式版本,或者您指定了错误的版本(至少应该是v4,而不是 v3 才能工作)。以下对我有用:

{
  "$schema": "http://json-schema.org/draft-04/schema",
  "type": "object",
  "properties": {
    "Organisation": { "type": "string" },
    "Address": { "type": "string" }
  },
  "required": [ "Organisation", "Address" ]
}

关于新添加的 - $ref - 我们也使用它,它似乎被 APIKit 正确解析(即消息被正确验证)但是我不使用这些模式来创建 Dataweave 元数据所以我不能保证它会表现相同(我希望它使用相同的解析器,但不能肯定地说)。

Common.json:

{
    "$schema": "http://json-schema.org/draft-04/schema",
    "definitions": {
        "emailAddress": {
            "description": "Basic RegEx for an email address",
            "type": ["string","null"],
            "pattern": "^[a-zA-Z0-9'._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
        }
    }   
}

Sample.json:

{
    "$schema": "http://json-schema.org/draft-04/schema",
    "type": "object",
    "properties": {
        "email": {
            "$ref": "common.json#/definitions/emailAddress"
        }
    }
}