How to describe tested type ( schema )


I’m stuck on describing structure in RAML type ( schema ) and can’t figure out by my own how to resolve it.
There’is my RAML:

#%RAML 1.0
title: Encoder API
version: v2
mediaType: application/vnd.api+json
/jobs: # its fully-resolved URI is{version}/jobs
  displayName: Jobs
  description: A collection of jobs
            type: object
     # wrong :/
                description: Unique ID
                type: number
            example: |
                "data" : [{
                  "id" : 204,
                  "calling_code" : [ 211 ],
                  "country" : "South Sudan",
                  "type": "countries"

As you can see in example JSON is nested and i can’t figure out how to describe it in schema ( type since RAML 1.0 ).
Following format: seems doesn’t work.


What about

  type: object
      type: array
        type: object
            description: Unique ID
            type: number


Awesome, thanks @christian_vogel! Saved my day. :slightly_smiling:


Perfect! Always good to hear to save someones day :smiley:


RAML 1.0 supporting data-type reminds me of YAML & Swagger, describing the data elements with data types :slight_smile:

Great to use these as an alternate of JSON examples :slight_smile:


Taking the opportunity to bump this thread with a related question… :slight_smile:

I am trying to create examples using the RAML schema instead of JSON, but my type has a nested structure. How do I provide an instance of a nested structure within an example facet? Much like @christian_vogel points out, but not an inline declaration of a type but instead an instantiation. Using JSON, this is not a problem off course, but I cannot find any examples of this using RAML schema.


Can you post your RAML type? I will try to help you :slight_smile:


Actually, I just found the answer myself:

Under “RAML vs Swagger” a nested example is shown. Problem solved!


That was easy :stuck_out_tongue: Love that!