Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Discriminator sub-datatype validates to anything #620

@jam01

Description

@jam01

Consider the following RAML

types:
  event:
    type: object
    discriminator: eventType
    properties:
      eventType: string

  fooEvent:
    type: event
    discriminatorValue: foo
    properties:
      bar: string

/resource:
   post:
     body:
       application/json:
         type: fooEvent

Expected behavior
resource/ should accept a value such as:
{"eventType":"foo", "bar":"val"}

and reject a value such as:
{"not":"acceptable"}

Current behavior
Both are considered valid.

Seems to me the issue is that unless the discriminator field is present there's no validation at all and everything is valid.

There should be a validation that the discriminator field exists and then check for valid values of that field and validate accordingly, otherwise it should fail.

I added test cases in this PR #602

Aha! Link: https://mulesoft-roadmap.aha.io/features/APIRAML-39

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions