Defining Array in RAML

Suyog Sathe picture Suyog Sathe · Apr 6, 2017 · Viewed 11.9k times · Source

I have a requirement where we have to define one of the headers as an array in RAML 1.0. It works fine in anypoint API platform. But, I'm not able to supply input values to it.

Anyone have similar experience defining an array in raml 1.0 header?

#%RAML 1.0
baseUri: https://mocksvc.mulesoft.com/mocks/5b0f764c-844a-4a70-a188-d48a50bcc532
title: arraytest
version: v1
types:
  array1:
    type: object
    properties: 
      name:
        type: string
/arraycheck:
  get:
    headers: 
      x-arraynos:
        type: array
        items: array1
    responses: 
      200:
        body: 
          application/json:
            example: {"aa":"aa"}

Answer

Hemin picture Hemin · May 11, 2017

You can try following code, which is optimised.

#%RAML 1.0
baseUri: https://mocksvc.mulesoft.com/mocks/5b0f764c-844a-4a70-a188-d48a50bcc532
title: arraytest
version: v1
types:
  array1:
    type: object
    properties:
      name:
        type: string[]
/arraycheck:
  get:
    headers:
      x-arraynos:
        type: array1
    responses:
      200:
        body:
          application/json:
            example: {"aa":"aa"}