question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG][csharp] [csharp-netcore] producing invalid Dictionary

See original GitHub issue

Bug 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:open
  • Created 2 years ago
  • Reactions:3
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Blackclawscommented, Dec 29, 2021

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.

2reactions
InTheCloudDancommented, Jun 16, 2021

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 just Dictionary

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found