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.

13.2.0.0 generating non-working C# client with ChangeType as a culprit

See original GitHub issue

Upgrading from 13.1.6.0 to 13.2.0.0 creates client, that compiles, but does not work (Can’t convert from System.String).

Problem is when client is generated, it tries to serialize json to types with ChangeType:

var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
var result_ = (System.Collections.Generic.ICollection<string>)System.Convert.ChangeType(responseData_, typeof(System.Collections.Generic.ICollection<string>));

Old version does this correctly:

var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<string>>(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;

Here is the bug repro for this issue: https://github.com/Enegia/NSwagGeneratorChangeTypeBugRepro

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
ghostcommented, Dec 31, 2019

@scberr thanks, that fixed problem for us too.

We have tons of controllers, so we end up using global filter (startup.cs):

services.AddControllers(options =>
{
	options.Filters.Add(new ProducesAttribute("application/json"));
});
3reactions
pantoniscommented, Dec 27, 2019

Have the same issue here. Just upgrades and the latest upgrade causes this problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

AMIS, Data Driven Blog - Oracle & Microsoft Azure - RSSing.com
Developers kick off the development process discussing the API with their potential customers, generate use cases, and mock up the API before even...
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