Search code examples
arraysjsonapienumsraml

How to put an array of elements from enum values defined in RAML?


I'm stuck in one point developing this RAML thing. In my included JSON to test the hierarchy of the RAML objects I need to construct like this:

"communicationWays": [
   {
     "SMS": false,
     "EMAIL": true,
     "VOICE": false,
     "MAIL": false
   }
 ]

But my question is: how can I implement it on RAML part?? I think about something like this...

types:
  communicationWays:
    type: array
      items:
        enum:
        - "SMS"
        - "EMAIL"
        - "VOICE"
        - "MAIL"
          (empty type name?)
            type: boolean

But, obviously, this is incorrect. I'm just try to explain the structure with the code. I tried to find out in the official RAML documentation but I couldn't see this example case.

Can you help me, please, with this kind of structure?


Solution

  • RAML (1.0) for your requirement will be :

            body:
              application/json:
                type: object
                properties: 
                  communicationWays:
                    type: array
                    items:
                      type: object
                      properties:
                        SMS:
                          type: boolean
                          required: false
                        EMAIL:
                          type: boolean
                        VOICE:
                          type: boolean
                        MAIL:
                          type: boolean
    

    Instead of enum it will be an object which contains boolean elements.