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
168 stars 38 forks source link

Generate interfaces for API clients #99

Closed yanxiaodi closed 3 years ago

yanxiaodi commented 4 years ago

Just a proposal. It would be better if webapiclientgen can generate interfaces for API clients because now we use Dependency Injection widely in .NET Core applications. Thanks.

zijianhuang commented 4 years ago

I would presume your idea was inspired by what generated by NSwag. If so, you may be interested in looking at https://github.com/zijianhuang/openapiclientgen particularly comparing what generated by OpenApiClientGen from pet.yaml and mcp.yaml with what generated by NSwag.

I don't really have strong opinion on whether generating interface is beneficial overall to application programmers. The priority probably depends how popular application programmers would utilize the interface.

I had grown up during the age when development framework like .NET framework did not provide built-in DI mechanisms, so we had used various design patterns for DI. These days, I would use the built-in DI of .NET Core as last resort for the sake of DI.

Nevertheless, I would keep this case open to see how many developers would love to see the interface in the generated codes.

yanxiaodi commented 4 years ago

Thanks. I think one possible option is to provide an switch to control if the interfaces would be generated. I'll try it. I checked openapiclientgen and it would be a good idea because I don't really like the code generated by NSwag.

zijianhuang commented 4 years ago

Good to hear, and you will have fun of using CodeDOM. :) And if you haven't, you may view my CodeProject articles some of which compare with Swagger and NSwag, so you may be understanding more about the functional scope and the business scope of WebApiClientGen and OpenApiClientGen.

zijianhuang commented 3 years ago

too old , no progress