raml-java-parser
raml-java-parser copied to clipboard
Discriminator sub-datatype validates to anything
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 https://github.com/raml-org/raml-java-parser/pull/602
Aha! Link: https://mulesoft-roadmap.aha.io/features/APIRAML-39
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?
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.
@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.