Array of json schema


I defined json schema. In the api i return an array of it. But i get

it is not allowed to use external types in component type definitions


Here is my raml:

 #%RAML 1.0
 title: Title
 mediaType: application/json
 baseUri: http://{domainName}
 version: 1.0
   User: |
       "type": "object",
       "$schema": "",
       "id": "",
       "required": true,
       "properties": {
         "name": {
           "type": "string",
           "required": true
         "age": {
           "type": "number",
           "required": true
             users: User[]


@n0tel: AFAICT, your RAML is invalid. It uses a JSON Schema in a type expression.

see the relevant section in the specs:

A RAML processor MUST NOT allow types that define an XML or JSON schema to participate in type inheritance or specialization, or effectively in any type expression.

The error message should be a little more descriptive though. Which tool are you using?



RAML defines its own type system while also supporting JSON Schema too, but you shouldn’t mix these. So you either replace your User type, or express the array with json schema, but to do so, you will probably have to move the User schema to an external file, so you can refer to it using a "$ref".

So the array definition you are looking for will be something like

  "type": "array",
  "items": {
    "$ref": "location-of-user-schema.json"

But in this case, the way how your tool will look up the location-of-user-schema.json can be varying (the question here is how does your tool determine your base URL).

One more note: you use JSON Schema draft-3 which is very old. The currently latest version is draft-7. I recommend using at least draft-4. To upgrade, you have to change how you define a property as required.


Thanks a lot