Polymorphic lists do not have correct type
See original GitHub issueWhen I have a polymorphic list like in the example below, the generated C# client defines the list as of the first type (in this case Dog
). Dog
and Snake
in this example are both derived from the same model.
"friends": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#/components/schemas/Dog"
},
{
"$ref": "#/components/schemas/Snake"
}
]
}
}
public System.Collections.Generic.ICollection<Dog> Friends { get; set; }
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13 (1 by maintainers)
Top Results From Across the Web
java - why polymorphism doesn't treat generic collections ...
Now, the problem with Java generic types is that the type information is discarded by the compiler and it is not available at...
Read more >Recitation 4: Datatype pitfalls, polymorphism, lists
We have to be careful: If id is a data constructor (e.g., Penny), then we're comparing e to see if it has the...
Read more >Can't wrap my head around how to use Polymorphic ...
I'm trying to extract the data from a xml file produced by the Tiled2D map editor. I originally had an untyped function that...
Read more >Is return-type-(only)-polymorphism in Haskell a good thing?
I actually think that return type polymorphism is one of the best features of type classes. After having used it for a while,...
Read more >Chapter 6 Polymorphism and its limitations
1.1 Weakly polymorphic types ... Therefore, after placing an int in store, we cannot use it to store any value other than an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just wanted to note that this is also an issue for TypeScript generation as well. I’m not sure if the output would be entirely the same, and I can provide a sample input/output if that helps? Many thanks.
Both models
Dog
andSnake
have the same base class in C# which is expressed viain each of those models. In my case all $refs in the list have the same base class so it would be possible to infere the base class and pick it as the collection’s type. But I don’t know what to do in other cases where the is a mixed $refs list with no common base model.