Optional types with multiple inheritance


#1

Hi there!

I am trying to create a response type combining a base type with core information and other optional types using inheritance. I need that my responses contains always the person related information, and the rest of the info if it exists.

Imagine I have declared some datatypes in datatypes files: Person, Address, PersonalId and Job. I include it in my API using !include and then I try to create my new type, but using ? in the types is not valid.

FullPersonInfo:
  type: [ Person, Address?, Id?, Job? ]

I also try to include the types using required false:

types:
  Person: !include person.raml
  Address: 
    type: !include person.raml
    required: false
  Id: 
    type: !include person.raml
    required: false
  Job: 
    type: !include person.raml
    required: false

I only make it working using union with inheritance and making all possible combinations…


#2

What about:

FullPersonInfo:
  type: Person
  properties:
    address?: Address 
    id?: Id
    job?: Job

#3

I want to inherit the properties of the datatypes directly in my type, but I am also considering add new properties.

I’m going to change my types, thanks!