3

I am using Mule EE 3.5.2 and migrating to 3.6.2. I have a RAML Project with a json schema thats throwing an error mule invalid JSON schema error: value has incorrect type (found boolean, expected one of [array]). On further digging I found that the required attribute was the offending one as explained here https://github.com/mulesoft/raml-for-jax-rs/issues/81. But even after making the necessary changes I am still getting the same error. Again I am in Mule EE 3.6.2. Below is the json schema. Any help would be greatly appreciated.

Regards, Hari

{
  "$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 log is as below

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]
hpandalai
  • 438
  • 2
  • 13
  • 31

5 Answers5

5

Try removing the :

,
  "required": [
    "record"
  ]

So:

{
  "$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"
      ]
    }
  }
}
Ryan Carter
  • 11,441
  • 2
  • 20
  • 27
0

You cannot have JSON with required field condition for array of array, instead required can be used only for array of records

So, Please remove , "required": [ "record" ]

at the end

Sudha Ch
  • 127
  • 1
  • 7
0

I am not sure about this solution, I got the same issue, I changed the id of the properties as below, it worked for me: "ZIP": { "id": "/properties/ZIP",
"type": "string" }

0

I also came across the same error message, but with a different schema file generated with an online schema generator.

The problem for me turned out to be that the schema generated was the wrong version (see github issue that put me on the right track). So I had to change from:

"$schema": "http://json-schema.org/draft-07/schema#",

to:

"$schema": "http://json-schema.org/draft-04/schema#",

It seems like later versions are not supported and default back to draft-03 which produces a message about required and boolean (at least for me)

I know this does not solve the original posters questions, but I hope this helps someone else who stumbles across this question.

Rob Bird
  • 3,764
  • 2
  • 28
  • 38
-2

Remove the "required": [ "record" ] I have tested and works fine after removing it.

Rajesh
  • 19
  • 1