[BUG] [C#] Polymorphism with 2 level derived classes generates invalid client
Created by: scavarda
Generated client is invalid for this example: Using latest version 5.0.1
public class BaseClass1
{
public int Number { get; set; }
}
public class DerivedClass_A : BaseClass1
{
public int Number2 { get; set; }
}
public class DerivedClass_B : DerivedClass_A
{
public int Number3 { get; set; }
}
document
{
"openapi": "3.0.1",
"info": {
"title": "Test",
"description": "Test",
"contact": {
"name": "John Doe",
"url": "https://mydomain.com",
"email": "johndoe@hotmail.com"
},
"license": {
"name": "-"
},
"version": "1.0.0.0"
},
"servers": [
{
"url": "http://127.0.0.1:5000"
}
],
"paths": {
"/poly1": {
"get": {
"tags": [
"Test"
],
"operationId": "TestPolymorphism1",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/BaseClass1"
},
{
"$ref": "#/components/schemas/DerivedClass_A"
},
{
"$ref": "#/components/schemas/DerivedClass_B"
}
]
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"BaseClass1": {
"required": [
"discriminator"
],
"type": "object",
"properties": {
"discriminator": {
"type": "string"
},
"number": {
"type": "integer",
"format": "int32"
}
},
"additionalProperties": false,
"discriminator": {
"propertyName": "discriminator",
"mapping": {
"BaseClass1": "#/components/schemas/BaseClass1",
"DerivedClass_A": "#/components/schemas/DerivedClass_A",
"DerivedClass_B": "#/components/schemas/DerivedClass_B"
}
}
},
"DerivedClass_A": {
"required": [
"discriminator"
],
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/BaseClass1"
}
],
"properties": {
"discriminator": {
"type": "string"
},
"number2": {
"type": "integer",
"format": "int32"
}
},
"additionalProperties": false,
"discriminator": {
"propertyName": "discriminator",
"mapping": {
"DerivedClass_A": "#/components/schemas/DerivedClass_A",
"DerivedClass_B": "#/components/schemas/DerivedClass_B"
}
}
},
"DerivedClass_B": {
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/DerivedClass_A"
}
],
"properties": {
"number3": {
"type": "integer",
"format": "int32"
}
},
"additionalProperties": false
}
}
}
}
The error is in the constructor of DerivedClass_A when calling base(....), discriminator is missing in the arguments