We have a problem with code generation and polymorphism :
We are using a REST micro service achitecture with BFF pattern, so we have resource oriented service (producing C#/TS generated client) and some front end aggregator using these resources services (producing C#/TS generated client).
Our ressource has some polymorph data, and for historical reason, we don't use the default discriminator but "$type".
Ex :
Resource service :
Produce "Human" resource with an Animal property which can be Cat or Dog
Generate a client with Human/Dog/Cat classes, Animal class with [JsonConverter(typeof(JsonInheritanceConverter), new[] { "$type" })] attribute, and an internal JsonInheritanceConverter class used by the previous attribute
Aggregator service :
Use the generated client from the resource service
Produce HumanEx class which extend Human class from the generated client (to add some members from other services)
Generate a client with HumanEx/Human/Dog/Cat classes, Animal class with [Newtonsoft.Json.JsonConverter(typeof(JsonInheritanceConverter), "discriminator")] attribute, and an internal JsonInheritanceConverter class used by the previous attribute.
The problem is the json data produced by the aggregator service use "$type" as a discriminator (uses the attribute defined by the resource service client) while the client waits for a "discriminator" discriminator (doesnt use the values of the attribute defined by the resource service client).
Are we missing something ? (we would like to avoid to redefine our resources).
Hi,
We have a problem with code generation and polymorphism :
We are using a REST micro service achitecture with BFF pattern, so we have resource oriented service (producing C#/TS generated client) and some front end aggregator using these resources services (producing C#/TS generated client).
Our ressource has some polymorph data, and for historical reason, we don't use the default discriminator but "$type".
Ex :
Resource service :
Aggregator service :
The problem is the json data produced by the aggregator service use "$type" as a discriminator (uses the attribute defined by the resource service client) while the client waits for a "discriminator" discriminator (doesnt use the values of the attribute defined by the resource service client).
Are we missing something ? (we would like to avoid to redefine our resources).
Thanks for help.