RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.61k stars 1.22k forks source link

"Chaining" generated clients (C# or TS) #3287

Open pierre-seiitra opened 3 years ago

pierre-seiitra commented 3 years ago

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.

RicoSuter commented 3 years ago

How does the generated spec look like in the inheritance mapping part? There you should find the correct discriminator property name..