autorest
autorest copied to clipboard
[bug] child classes are not recognized if discriminator type is defined in parent of base class
Before filling a bug
- [x] have you checked the faq for known issues.
- [x] have you checked existing issues
Describe the bug
Some services will adopt the following pattern of defining discriminator:
- Base type has a
discriminator
property - However, the
discriminator
property is defined in the parent class of the base type - An example is
SecurityCenter
which has a ExternalSecuritySolution type.ExternalSecuritySolution
has akind
property as discriminator, butkind
is actually defined in one of its parent class ExternalSecuritySolutionKind.
In such cases, autorest could not correctly deduce the child classes. I've written a test case Discriminator.zip. In it:
-
Discriminator.json
provides a base type with inline discriminator property -
Discriminator2.json
provides a base type of which the discriminator property is defined in its parent class
Expected behavior
Autorest should deduce the child classes when discriminator property is defined in the parent class of the base type. Or it should report error if such pattern is not supported.
Additional context Add any other context about the problem here.
Another example is LocalSearch. It contains a type definition Action
which has a very deep inheritance path from ResponseBase
which contains the discriminator property.
I can repro this with the latest Go code generator for ExternalSecuritySolution