zijianhuang / webapiclientgen

Strongly Typed Client API Generators generate strongly typed client APIs in C# .NET and in TypeScript for jQuery and Angular 2+ from ASP.NET Web API and .NET Core Web API
MIT License
167 stars 38 forks source link

Resolve generic classes #50

Closed jfantunes closed 6 years ago

jfantunes commented 6 years ago

Hi! I have several classes that are generic. One of this is the following one:

 public class MimsResult<T>
    {
        public T Result { get; set; }
        public DateTime GeneratedAt { get; set; } = DateTime.Now;
        public bool Success { get; set; } = true;
        public string Message { get; set; }
    }

For what im observing webapicodegen doesnt like it. When i pass the cherrypick option 1 or 8, he throws me an error 'System.ArgumentNullException: 'Value cannot be null.' Since has you stated before this is simillar to a template it's not a typed class, what can i make it to be more friendly to the codegen witout having major changes on code? Thanks.

zijianhuang commented 6 years ago

webapiclientgen has limited supports for generic types like IList<> and IDictionary<> etc., however, supporting generics overall will require significant changes however it seems that using custom generic in Web API is not popular, since this is the first requirement after 3 years since webapiclientgen is released.

Let's see how many people would use custom generic?

zijianhuang commented 6 years ago

@jfantunes , basically done. You may check out this repository and build then test with your .NET Core Web API project.

I had tested with ASP.NET Web API, .net client, jQuery and Angular2+.

If you find things are OK, I will be making a release.

jfantunes commented 6 years ago

Hi @zijianhuang, i've tested and works great. Thank you for your time. I'm sure many people would appreciate it, since sometimes generics are the best way to have less Dto's without the same information.

zijianhuang commented 6 years ago

released webapiclientgen 2.5.0 and webapiclientgen 2.5.1. tested in https://github.com/zijianhuang/DemoCoreWeb and https://github.com/zijianhuang/webapiclientgenexamples