-
Notifications
You must be signed in to change notification settings - Fork 181
Discriminator field is 'null' in subtype #295
Comments
I did the first half of the bug. I'll look at the second half. Could you look at the raml-defined example: the Human type doesn't seem to have your problem. And that error message is not from our code (probably the parser...) Thanks :-) |
Hey @jpbelang, Not sure about the second part: for me, the solution without Regards |
Do you mean in the discriminator value ? I get the discriminator which is the interface class. |
Alright, I finally had time to try it again. It works now as you described, not sure what made it not working as expected on the first go. |
When I tested it right now, the String |
Alright, probably this issue won't find any more recognition, so for me it's fine to declare the discriminatorValue explicitly within the RAML. |
Hey there,
I tried using the
discriminator
property in a type like that (shortened example):When I tried generating code from this, the generated field
animalType
was alwaysnull
in both,Animal
andCat
.The default
discriminatorValue
should be the type name (see RAML doku).This behavior would be helpful here.
In a second step, I tried to add the
discriminatorValue
manually toCat
like this:As you can see, the value is the lower-cased type name
"cat"
. Reasonably, I expected this to be used in the class. However, during generation an exception was thrown:org.raml.jaxrs.generator.GenerationException: [Error validating JSON. Error: - Invalid type name: Cat
When I changed the
discriminatorValue
to upper-casedCat
(like the name of the type), it finally worked and the fieldanimalType
has the value"Cat"
in the classCat
.However, I expected to be able to use whatever name and not, that the
discriminatorValue
has to match the class name exactly.Thanks already for having a look at this issue.
Regards
The text was updated successfully, but these errors were encountered: