Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG generated code fails with runtime error #51

Closed
johnpfmg opened this issue Apr 29, 2021 · 3 comments
Closed

BUG generated code fails with runtime error #51

johnpfmg opened this issue Apr 29, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@johnpfmg
Copy link

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

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. 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.

@johnpfmg johnpfmg added the bug Something isn't working label Apr 29, 2021
@unchase
Copy link
Owner

unchase commented Apr 29, 2021

Hi, @johnpfmg

See RicoSuter/NSwag#3414

@johnpfmg
Copy link
Author

johnpfmg commented Apr 30, 2021 via email

@unchase
Copy link
Owner

unchase commented Apr 30, 2021

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.

@unchase unchase closed this as completed Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants