BUG generated code fails with runtime error
Closed this issue · 3 comments
Describe the bug
the generated code at line 1493 var dictionary_ = in attached file fails with error below
var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(parameterValues, settings.Value);
var dictionary = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Collections.Generic.Dictionary<string, string>>(json_, _settings.Value);
Assemblies affected
Which assemblies and versions are known to be affected?
Steps to reproduce
using .net core 3.1
add the attached class UnchaseIssueDemo.cs.txt to a console app or other host app.
Run the code
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
...
Expected result
A clear and concise description of what you expected to happen.
expect generated code to work
Actual result
What is actually happening.
UnchaseIssueDemo.cs.txt
ContentAccessAPIClient.cs.txt
get error
Message=Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary`2[System.String,System.String]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
ContentAccessAPIClient.cs.txt
If applicable, add screenshots to help explain your problem.
Additional detail
Add any other context about the problem here.
Optional, details of the root cause if known.
This issue occurs on the side of the NSwag.Commands library that the Connected service depends on.
Therefore, the timing of the fix depends on the maintainer of the NSwag project.