无效 JSON 架构错误
Invalid JSON Schema Error
我正在使用 Mule EE 3.5.2 并迁移到 3.6.2。我有一个带有 json 模式的 RAML 项目,它抛出一个错误 mule invalid JSON 模式错误:值的类型不正确(找到布尔值,预期是 [array] 之一)。在进一步的挖掘中,我发现所需的属性是有问题的属性,如这里所解释的 https://github.com/mulesoft/raml-for-jax-rs/issues/81。但即使在进行了必要的更改之后,我仍然遇到同样的错误。我再次进入 Mule EE 3.6.2。
下面是 json 架构。任何帮助将不胜感激。
此致,
哈里
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://example.com",
"type": "object",
"properties": {
"record": {
"id": "http://example.com/record",
"type": "array",
"items": {
"id": "http://example.com/record/0",
"type": "object",
"properties": {
"Account": {
"id": "http://example.com/record/0/Account",
"type": "string"
},
"DeptID": {
"id": "http://example.com/record/0/DeptID",
"type": "string"
},
"ProjectID": {
"id": "http://example.com/record/0/ProjectID",
"type": "string"
},
"ProjectDescription": {
"id": "http://example.com/record/0/ProjectDescription",
"type": "string"
},
"Amount": {
"id": "http://example.com/record/0/Amount",
"type": "number"
},
"CheckNo": {
"id": "http://example.com/record/0/CheckNo",
"type": "integer"
},
"Reference": {
"id": "http://example.com/record/0/Reference",
"type": "string"
},
"BudgetRef": {
"id": "http://example.com/record/0/BudgetRef",
"type": "string"
},
"Description": {
"id": "http://example.com/record/0/Description",
"type": "string"
},
"Oprid": {
"id": "http://example.com/record/0/Oprid",
"type": "string"
},
"Date": {
"id": "http://example.com/record/0/Date",
"type": "string"
}
},
"required": [
"Account",
"DeptID",
"ProjectID",
"ProjectDescription",
"Amount",
"CheckNo",
"Reference",
"BudgetRef",
"Description",
"Oprid",
"Date"
]
},
"required": [
"0"
]
}
},
"required": [
"record"
]
}
错误日志如下
ERROR 2015-09-23 14:04:57,797 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
org.mule.module.apikit.exception.ApikitRuntimeException: Invalid API descriptor -- errors found: 1
invalid JSON schema (schemas/ip_revenue_management_input.json):
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Account"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Amount"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/BudgetRef"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/CheckNo"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Date"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/DeptID"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Description"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Oprid"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/ProjectDescription"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/ProjectID"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Reference"}
keyword: "required"
found: "boolean"
expected: ["array"]
-- file: schemas/ip_revenue_management_input.json
at org.mule.module.apikit.AbstractConfiguration.validateRaml(AbstractConfiguration.java:199) ~[?:?]
at org.mule.module.apikit.AbstractConfiguration.initialise(AbstractConfiguration.java:97) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_45]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_45]
尝试删除 :
,
"required": [
"record"
]
所以:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://example.com",
"type": "object",
"properties": {
"record": {
"id": "http://example.com/record",
"type": "array",
"items": {
"id": "http://example.com/record/0",
"type": "object",
"properties": {
"Account": {
"id": "http://example.com/record/0/Account",
"type": "string"
},
"DeptID": {
"id": "http://example.com/record/0/DeptID",
"type": "string"
},
"ProjectID": {
"id": "http://example.com/record/0/ProjectID",
"type": "string"
},
"ProjectDescription": {
"id": "http://example.com/record/0/ProjectDescription",
"type": "string"
},
"Amount": {
"id": "http://example.com/record/0/Amount",
"type": "number"
},
"CheckNo": {
"id": "http://example.com/record/0/CheckNo",
"type": "integer"
},
"Reference": {
"id": "http://example.com/record/0/Reference",
"type": "string"
},
"BudgetRef": {
"id": "http://example.com/record/0/BudgetRef",
"type": "string"
},
"Description": {
"id": "http://example.com/record/0/Description",
"type": "string"
},
"Oprid": {
"id": "http://example.com/record/0/Oprid",
"type": "string"
},
"Date": {
"id": "http://example.com/record/0/Date",
"type": "string"
}
},
"required": [
"Account",
"DeptID",
"ProjectID",
"ProjectDescription",
"Amount",
"CheckNo",
"Reference",
"BudgetRef",
"Description",
"Oprid",
"Date"
]
}, "required": [
"items"
]
}
}
}
你不能让 JSON 具有数组数组的必填字段条件,相反,required 只能用于记录数组
所以,请删除
,
"required": [
"record"
]
最后
删除 "required":[
"record"
]
我已经测试过,删除后工作正常。
我不确定这个解决方案,我遇到了同样的问题,我更改了 properties 的 id 如下,它为我工作:
"ZIP": {
"id": "/properties/ZIP",<br>
"type": "string"
}
我也遇到了相同的错误消息,但使用在线模式生成器生成了不同的模式文件。
我的问题原来是生成的模式版本错误(参见 github issue 让我走上正轨)。所以我不得不改变:
"$schema": "http://json-schema.org/draft-07/schema#",
至:
"$schema": "http://json-schema.org/draft-04/schema#",
似乎不支持更高版本,默认返回 draft-03,它会生成一条关于 required 和 boolean 的消息(至少对我而言)
我知道这并不能解决最初发布者的问题,但我希望这能帮助其他偶然发现这个问题的人。
我正在使用 Mule EE 3.5.2 并迁移到 3.6.2。我有一个带有 json 模式的 RAML 项目,它抛出一个错误 mule invalid JSON 模式错误:值的类型不正确(找到布尔值,预期是 [array] 之一)。在进一步的挖掘中,我发现所需的属性是有问题的属性,如这里所解释的 https://github.com/mulesoft/raml-for-jax-rs/issues/81。但即使在进行了必要的更改之后,我仍然遇到同样的错误。我再次进入 Mule EE 3.6.2。 下面是 json 架构。任何帮助将不胜感激。
此致, 哈里
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://example.com",
"type": "object",
"properties": {
"record": {
"id": "http://example.com/record",
"type": "array",
"items": {
"id": "http://example.com/record/0",
"type": "object",
"properties": {
"Account": {
"id": "http://example.com/record/0/Account",
"type": "string"
},
"DeptID": {
"id": "http://example.com/record/0/DeptID",
"type": "string"
},
"ProjectID": {
"id": "http://example.com/record/0/ProjectID",
"type": "string"
},
"ProjectDescription": {
"id": "http://example.com/record/0/ProjectDescription",
"type": "string"
},
"Amount": {
"id": "http://example.com/record/0/Amount",
"type": "number"
},
"CheckNo": {
"id": "http://example.com/record/0/CheckNo",
"type": "integer"
},
"Reference": {
"id": "http://example.com/record/0/Reference",
"type": "string"
},
"BudgetRef": {
"id": "http://example.com/record/0/BudgetRef",
"type": "string"
},
"Description": {
"id": "http://example.com/record/0/Description",
"type": "string"
},
"Oprid": {
"id": "http://example.com/record/0/Oprid",
"type": "string"
},
"Date": {
"id": "http://example.com/record/0/Date",
"type": "string"
}
},
"required": [
"Account",
"DeptID",
"ProjectID",
"ProjectDescription",
"Amount",
"CheckNo",
"Reference",
"BudgetRef",
"Description",
"Oprid",
"Date"
]
},
"required": [
"0"
]
}
},
"required": [
"record"
]
}
错误日志如下
ERROR 2015-09-23 14:04:57,797 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
org.mule.module.apikit.exception.ApikitRuntimeException: Invalid API descriptor -- errors found: 1
invalid JSON schema (schemas/ip_revenue_management_input.json):
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Account"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Amount"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/BudgetRef"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/CheckNo"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Date"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/DeptID"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Description"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Oprid"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/ProjectDescription"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/ProjectID"}
keyword: "required"
found: "boolean"
expected: ["array"]
error: value has incorrect type (found boolean, expected one of [array])
level: "error"
domain: "syntax"
schema: {"loadingURI":"#","pointer":"/properties/record/items/properties/Reference"}
keyword: "required"
found: "boolean"
expected: ["array"]
-- file: schemas/ip_revenue_management_input.json
at org.mule.module.apikit.AbstractConfiguration.validateRaml(AbstractConfiguration.java:199) ~[?:?]
at org.mule.module.apikit.AbstractConfiguration.initialise(AbstractConfiguration.java:97) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_45]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_45]
尝试删除 :
,
"required": [
"record"
]
所以:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://example.com",
"type": "object",
"properties": {
"record": {
"id": "http://example.com/record",
"type": "array",
"items": {
"id": "http://example.com/record/0",
"type": "object",
"properties": {
"Account": {
"id": "http://example.com/record/0/Account",
"type": "string"
},
"DeptID": {
"id": "http://example.com/record/0/DeptID",
"type": "string"
},
"ProjectID": {
"id": "http://example.com/record/0/ProjectID",
"type": "string"
},
"ProjectDescription": {
"id": "http://example.com/record/0/ProjectDescription",
"type": "string"
},
"Amount": {
"id": "http://example.com/record/0/Amount",
"type": "number"
},
"CheckNo": {
"id": "http://example.com/record/0/CheckNo",
"type": "integer"
},
"Reference": {
"id": "http://example.com/record/0/Reference",
"type": "string"
},
"BudgetRef": {
"id": "http://example.com/record/0/BudgetRef",
"type": "string"
},
"Description": {
"id": "http://example.com/record/0/Description",
"type": "string"
},
"Oprid": {
"id": "http://example.com/record/0/Oprid",
"type": "string"
},
"Date": {
"id": "http://example.com/record/0/Date",
"type": "string"
}
},
"required": [
"Account",
"DeptID",
"ProjectID",
"ProjectDescription",
"Amount",
"CheckNo",
"Reference",
"BudgetRef",
"Description",
"Oprid",
"Date"
]
}, "required": [
"items"
]
}
}
}
你不能让 JSON 具有数组数组的必填字段条件,相反,required 只能用于记录数组
所以,请删除 , "required": [ "record" ]
最后
删除 "required":[ "record" ] 我已经测试过,删除后工作正常。
我不确定这个解决方案,我遇到了同样的问题,我更改了 properties 的 id 如下,它为我工作:
"ZIP": {
"id": "/properties/ZIP",<br>
"type": "string"
}
我也遇到了相同的错误消息,但使用在线模式生成器生成了不同的模式文件。
我的问题原来是生成的模式版本错误(参见 github issue 让我走上正轨)。所以我不得不改变:
"$schema": "http://json-schema.org/draft-07/schema#",
至:
"$schema": "http://json-schema.org/draft-04/schema#",
似乎不支持更高版本,默认返回 draft-03,它会生成一条关于 required 和 boolean 的消息(至少对我而言)
我知道这并不能解决最初发布者的问题,但我希望这能帮助其他偶然发现这个问题的人。