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

Discriminator sub-datatype validates to anything #620

Open
jam01 opened this issue Apr 14, 2019 · 3 comments
Open

Discriminator sub-datatype validates to anything #620

jam01 opened this issue Apr 14, 2019 · 3 comments

Comments

@jam01
Copy link

jam01 commented Apr 14, 2019

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

@jam01
Copy link
Author

jam01 commented Jun 11, 2019

Hey @jpbelang , sorry to pull you in but it seems you're the most active maintainer. If you could point me in the right direction I could probably throw in a PR to fix this defect. I appreciate your input.

Also, is the library really deprecated as the repo description states?

@haolinj
Copy link

haolinj commented Sep 16, 2019

Hi @jam01 , I've just bumped into this issue as well. I think @jpbelang has merged a PR not long ago: https://github.com/raml-org/raml-java-parser/pull/651/files, I think it will fix this issue, hope it gets released soon.

@jam01
Copy link
Author

jam01 commented Oct 2, 2019

@haolinj rebased my branch with the latest code that includes #650 and #651 but the tests still fail. I'm not sure they were related.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants