Skip to content

Spec for collections inside polymorphic objects inside polymorphic objects are not generated correctly #2823

@stijn-o-ispnext

Description

@stijn-o-ispnext

Describe the bug
I have a polymorphic object that has collection properties (List) that is used inside another polymorphic object. This results in the library generating stuff like:

 "$ref": "#/components/schemas/polymorphicClass/anyOf/0/properties/polymorphicClassThatIsAProperty/anyOf/8/properties/intList"

Instead of

"type": [
  "null",
  "array"
],
"items": {
  "type": "number",
  "format": "int32"
}

OpenApi File To Reproduce
I cannot share the file. Simply create this structure:

[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
[JsonDerivedType(typeof(B), typeDiscriminator: "test")]
public abstract class A
{
    public C TestProperty { get; set; }
}

public class B : A
{
}

[JsonPolymorphic(TypeDiscriminatorPropertyName = "otherType")]
[JsonDerivedType(typeof(D), typeDiscriminator: "test1")]
public abstract class C
{
}

public class D : C
{
    public List<int> TestInts { get; set; }
}

Expected behavior
Correct array spec should be generated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions