Getting Should have required property and Should be array Errors in RAML

I’m getting the below errors in RAML Specification.

should have required property 'avatar' should have required property 'email' should have required 
property 'first_name' should have required property 'last_name' at Examples/userexample.raml (2, 
1) 

should have required property 'avatar' should have required property 'email' should have required 
property 'first_name' should have required property 'last_name' at 
Examples/userexampleforpost.raml (2, 1) 

should be array at Examples/AllUserExample.raml (3, 1)

Below is my specification.

#%RAML 1.0
version: 1.00
title: DummyProjectFromApiSpecification

traits:
   client-required:
headers:
  client_id:
    type: string
  client_token:
    type: string

types:
     User: !include ../DataTypes/userDataType.raml
     Users: !include ../DataTypes/allUsersDataType.raml

/users:
   is: [client-required]
   get:
   queryParameters:
responses:
  200:
    body:
      application/json:
        type: Users
        examples:
          output: !include ../Examples/AllUserExample.raml
          
post:
  body: 
    application/json:
      type: User
        example: 
           !include ../Examples/userexampleforpost.raml
responses: 
  201:
    body: 
      application/json:
        example: 
          message: User added Successfully.......

/{ID}:
  is: [client-required]
  get:
    responses: 
      200:
        body: 
          application/json:
            type: User
             example:
               !include ../Examples/userexample.raml

userexample.raml

#%RAML 1.0 NamedExample
singleuserexample:
    id: 2
    email: 'janet.weaver@reqres.in'
    first_name: Janet
    last_name: Weaver
    avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jp'

userexampleforpost.raml
It is same as userexample.raml but without id

#%RAML 1.0 NamedExample
userexampleforpost:
     email: 'janet.weaver@reqres.in'
     first_name: Janet
     last_name: Weaver
     avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jpg'

AllUserExample.raml

#%RAML 1.0 NamedExample
AllUserExample:
  - id: 2
    email: 'janet.weaver@reqres.in'
    first_name: Janet
    last_name: Weaver
    avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/josephstein/128.jpg"

  - id: 7
    email: 'michael.lawson@reqres.in'
    first_name: Michael
    last_name: Lawson
    avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/follettkyle/128.jpg"

userDataType.raml

#%RAML 1.0 DataType
type: object
properties:
  id?: integer 
  email: string
  first_name: string
  last_name: string
  avatar: string

allUserDataType.raml

#%RAML 1.0 DataType
type: array
items: !include userDataType.raml

@M-Danish-Khan: what’s the tool that gives you those errors? Also, your NamedExample fragments don’t all seem properly defined. I.e. a NamedExample fragment can only be included as follow:

examples: !include path/to/namedExample.raml

Note the use of the examples (plural) key.

Thank you @jstoiko . The issue has been resolved.
The one point you mentioned it was the culprit and the second below examples/example i was using output or input tag after removing these the issue got resolve.

1 Like