Search code examples
jsonmulejsonschemaanypoint-studioraml

RAML file is throwing invalid Json schema response in Anypoint Studio


I am using Anypoint Studio 6.2 with Mule 3.8.1 and I have added a raml and JSON schema which shows no errors in api-workbench but show Json schema invalid errors in Anypoint Studio.

I have found that if I remove the required field from all of my Json schemas linked to the raml (i.e. raml, traits and types) then everything works. Is there a way to fix this?

The required syntax I am using is:

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

Updated

and I am also seeing a org.mule.common.metadata.parser.json.SchemaException: java.net.MalformedURLException: no protocol: where the $ref cannot be resolved when using the JSON schema to create a metadata type to use in Dataweave:

{
    "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
}

Thanks


Solution

  • I do the same, so it is definitely supported in Studio. Without seeing your entire JSON schema file I have to guess at the cause, and my assumption is that you either don't specify a JSON schema version or you are specifying the wrong one (should be at least v4, not v3 for this to work). The following works for me:

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