[BUG][csharp] [csharp-netcore] producing invalid Dictionary
See original GitHub issueBug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What’s the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version
5.1.1
and
5.2.0-20210607.065944-108
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
"example": {
"type": "object",
"additionalProperties": true
}
or additionalProperties: {}
Create a spec with the model above and use csharp
or csharp-netcore
to generate a client. It errors with error CS0305: Using the generic type 'Dictionary<TKey, TValue>' requires 2 type arguments
The property in code shows as Dictionary
without any additional type information
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:9 (6 by maintainers)
Top Results From Across the Web
The given key was not present in the dictionary. Which key?
NET Core, .Net 5 finally tells us the name of the offending key: class Program { static void Main(string[] args) { Dictionary<string, ...
Read more >The 10 Most Common Mistakes in C# Programming - Toptal
Common C# Programming Mistake #2: Misunderstanding default values for uninitialized variables. In C#, value types can't be null. By definition, value types ...
Read more >Model validation in ASP.NET Core MVC | Microsoft Learn
Error messages. Validation attributes let you specify the error message to be displayed for invalid input. For example: C#
Read more >Different Ways to Iterate Through a Dictionary in C#
There are several ways we can iterate through the dictionary. We're going to implement some of the and compare the execution speed.
Read more >Common .NET Software Errors and How to Fix Them - Stackify
We've aggregated the 50 top .NET software errors. It includes exceptions, broken data bindings, memory leaks, etc. Find solutions on ways to ...
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 FreeTop 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
Top GitHub Comments
Yeah ok, that is a weird issue. Additional properties in general are a bit of a mixed bag. We’re just throwing the bunch of them into a dictionary that should be string, object. I have no clue why it generates a List object type here or a dictionary without any types whatsoever. I’ll take a look after the holiday season is over.
The one I’m running into seems like it originating from here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/csharp/modelGeneric.mustache#L113
But with the same root cause, I found one that was also a
List
not justDictionary