Search code examples
raml

RAML override required field or


I'd like to change the required field for a type that I am inheriting in another type. Is it possible to override that value or abstract it somehow? In the example below, I'd like to override the required field for Passenger.firstName:

 Description: "Passenger"
 type: object
    properties:
      firstName:
        type: string
        example: Sansa
        description: first name
      lastName:
        type: string
        example: Stark
        description: last name
      gender:
        .
        .
        . 
        .
    passengers:
      description: passenger details
      required: false
      type: array
      items:
        type: !include passenger.raml
          properties:
              firstName:
                required: false

My goal is to not have to create different types when I want to implement the Passenger object.


Solution

  • The solution in this scenario would be to declare the field as required false in the parent node. RAML does not allow you to change the required field for child nodes.