Loading

How to Add Arrays in NamedExample in RAML

Publish Date: Mar 2, 2024
Task

GOAL

When developing API specification, you may want to use NamedExample in RAML. This can be achieved as mentioned in this documentation.
api.raml

#%RAML 1.0
title: test
types:
  A:
    properties:
      givenName: string
      familyName: string
    examples: !include fragment.raml
fragment.raml
#%RAML 1.0 NamedExample
fullName:
  givenName: ”Chiaki”
  familyName: "Mukai"
However, you may want to specify an array of items within NamedExample. 
Steps

In order to specify an array of items within NamedExamples, you can achieve it as shown below.
api.raml

#%RAML 1.0
title: test

types:
  A:
    type: array
    items:
      type: object
      properties: 
        Names?:
          properties:
            givenName: string
            familyNameCode: string
    examples: 
      test: !include fragment.raml
fragment.raml
#%RAML 1.0 NamedExample
[
{
"name": "TestName1",
"code": "1234"
},
{
"name": "TestName2",
"code": "5678"
}
]

 

Knowledge Article Number

001115794

 
Loading
Salesforce Help | Article