Reputation: 114
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"}
Upvotes: 1
Views: 20802
Reputation: 752
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"}
Upvotes: 1
Reputation: 617
I got this example by the RAML 1.0 spec.
This ilustrate the problem that you are having:
#%RAML 1.0
title: Example with headers
traits:
chargeable:
headers:
X-Dept:
type: array
description: |
A department code to be charged.
Multiple of such headers are allowed.
items:
pattern: ^\d+\-\w+$
example: 230-OCTO
traceable:
headers:
X-Tracker:
description: A code to track API calls end to end
pattern: ^\w{16}$
example: abcdefghijklmnop
/users:
get:
is: [ chargeable, traceable ]
description: |
The HTTP interaction will look like
GET /users HTTP/1.1
X-Dept: 18-FINANCE
X-Dept: 200-MISC
X-Tracker: gfr456d03ygh38s2
headers:
X-Dept:
example: [ 18-FINANCE, 200-MISC ]
X-Tracker:
example: gfr456d03ygh38s2
Upvotes: 0