Strongly Typed Client API Generators generate strongly typed client API in C# codes and TypeScript codes. This repository contains code examples explained in the following CodeProject.com articles:
- Generate C# Client API for ASP.NET Web API
- Generate TypeScript Client API for ASP.NET Web API
- ASP.NET Web API, Angular2, TypeScript and WebApiClientGen
And this repository contains the following demo applications:
- DemoWebApi, ASP.NET Web API with HeroesController providing data to DemoAngular2 and Fonlow.Heroes.Android.
- DemoAngular2, an Angular 2+ applications based on the Heroes Tour example in Angular's tutorial Website.
- Fonlow.Heroes.Android, a Xamarin.Forms application mimicking the Heroes example in Angular's tutorial Website.
- axios, JEST test suite using the generated TypeScript codes for Axios which is recommended by React and Vue.js.
- vueTS, JEST test suite with Vue TypeScript and the generated TypeScript codes.
This VS solution was constructed using Visual Studio 2015-2017.
Server side:
- .NET Framework 4.8
- ASP.NET Web API 2.2
.NET client side:
- .NET Framework 4.6.2, or Universal Windows, or Xamarin.Android, or Xamarin.iOS
- ASP.NET Web API 2.2 Client Libraries
- Json.NET of Newtonsoft for Content-Type application/json
- Microsoft Build Tools 2015
TypeScript client side:
- TypeScript compiler 2.6
- Angular 2/4/5 and its dependencies in node_modules supported by Node.js and npm.
Remarks:
- tag "withWebApiClientGen22" is with WebApiClientGen v2.2 and Angular 4.3
- tag "NG522" is with WebapiClientGen v2.4.4 and Angular 5
- Current trunk is similar to tag "NG522
Hints:
- The Android mobile app is talking to the Web API, however the base URI http://192.168.1.100:9030/webapi/ is hard-coded in HeroesFunction. So you may need to alter the base URI in codes in order to run the app successfuly in either Android devices or emulators, after you have deployed the Web API to IIS of local dev machine (not IIS Express).
- iOS emulator is actually running in Mac.
Special thanks to the support of BrowserStack so real cross browser testing on multiple desktop and mobile platforms as well is possible. And App Live supports testing Android apps and iOS apps on rich collections of real Android and iOS devices.
To test Fonlow.Heroes.Android running on local Android Simulator against DemoWebApi hosted in IIS Express, do the following:
- Edit .vs\WebApiClientGenExamples\config\applicationhost.config and locate
site name="DemoWebApi"
- Replate
bindingInformation="*:10965:localhost"
withbindingInformation="*:10965:127.0.0.1"
, and save.
Then Andorid simulator accessing 10.0.2.2:10965 will be able to talk to http://127.0.0.1:10965