Explicitely state discriminator value


#1

Hi, I would like to ask whether I have to explicitely set the value of discriminator property.
Let’s say I have I have these type definitions

#%RAML 1.0 
title: My API With Types
types:
  Person:
    type: object
    discriminator: true
    properties:
      name: string
  Employee:
    type: Person
    properties:
      employeeId: string
  User:
    type: Person
    properties:
      userId: string

Are the following data valid? In other words, do I have to set the discriminator property explicitely or can the actual type be inferred from the properties available in my objects?

#%RAML 1.0 
data:
  - name: A User
    userId: 111
  - name: An Employee
    employeeId: 222

#2

Hi msamek, according to RC1 it is assumed that you have to state it explicitly, but at this moment it is one of the hot topics which we discuss in our attempts to finalise RAML 1.0.

Regards,
Pavel


#3

Hi Pavel,

thank you for your reply. One more question. How do you reference a discriminator field that is deeper in the object structure?

Lets say I have

Product:
    discriminator: ???
    properties:
      _meta: Meta
      id: string
      created: date
      attributes: ProductAttributes

ProductAttributes:
    properties:
      title: string
      contentType: string << this is the discriminating field

Shall the discriminator field have a value of attributes/contentType or is something else expected?

Thank you!

Best,
Michal