• Stars
    star
    167
  • Rank 225,631 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Strongly Typed Client API Generators generate strongly typed client API in C# codes and TypeScript codes. You may then provide or publish either the generated source codes or the compiled client API libraries to other developers for developing client programs.

This project delivers these products:

  1. Code generator for strongly typed client API in C# supporting .NET and Xamarin.Forms.
  2. Code generators for strongly typed client API in TypeScript for jQuery, Angular 2, Aurelia, Axios and Fetch API.
  3. TypeScript CodeDOM, a CodeDOM component for TypeScript, derived from CodeDOM of .NET.
  4. POCO2TS.exe, a command line program that generates TypeScript interfaces from POCO classes.
  5. Fonlow.Poco2Ts, a component that generates TypeScript interfaces from POCO classes.
  6. Fonlow.DataOnlyExtensions with JSON converters for handling date only scenarios between the clients and server which sit in different timezones. A .NET Framework package is also available.

Packages

Hints:

  • OpenApiClientGen based on key components of WebApiClientGen is a spin-off for generating client API codes in C# and TypeScript according to a definition file of Swagger/Open API Specification.

Remarks:

  • The development had started in year 2015 supporting .NET Framework, then .NET Core 2. And Tag "LastCore31" is to mark the last snapshot supporting .NET Framework 4.6.2 and .NET Core 3.1.
  • Starting from 2021-02-10, the development will support only .NET 5 and onward.
  • Wiki contents about .NET Framework will be kept in foreseeable future.

Key Features

  1. Client API codes generated are directly mapped from the Web API controller methods, .NET primitive types and POCO classes. This is similar to what svcutil.exe in WCF has offered.
  2. Doc comments of controller methods and POCO classes are copied.

Key Benefits

  1. WebApiClientGen is seamlessly integrated with ASP.NET Core Web API with very little steps/overheads to setup, maintain and synchronize between Web API and client APIs, during RAD or Agile Software Development.
  2. Support all .NET primitive types including decimal.
  3. Support DataTime, DataTimeOffset, DateOnly, Array, Tuple, Dynamic Object, Dictionary and KeyValuePair
  4. Strongly typed generated codes are subject to design time type checking and compile time type checking.
  5. Provide high level of abstraction, shielding application developers from repetitive technical details of RESTful practices and traditional codes of AJAX calls.
  6. Rich meta info including doc comments make IDE intellisense more helpful, so application developers have less need of reading separated API documents.

Examples

  1. POCO classes
  2. Web API
  3. Generated client API C# codes
  4. Client codes using the generated library in C#
  5. Generated client data models and API in TypeScript for jQuery, for Angular 2, for Aurelia and for Axios
  6. Client codes using the generated library in TypeScript
  7. Online Demo with Angular Heroes hosted in GitHub.IO talking to a real backend

Remarks:

  1. JavaScript codes compiled from generated TypeScript codes could be used in JS applications, however, obviously no type info will be available, while application programmers may still enjoy intellisense and abstraction from AJAX details.
  2. React and Vue.js applications typically use Axios for HTTP requests. Currently babel does not support namespaces. So you may not do React TSX programming with generated TypeScript codes. However, this may be changed in near future because of this pull request.

Downloads

  1. Strongly Typed Client API Generators for ASP.NET Core Web API.
  2. TypeScript CodeDOM
  3. Fonlow.Poco2TS

Plugins for TypeScript/JavaScript Frameworks/Libraries

  1. jQuery and HttpClient helper library
  2. Angular 6+
  3. AXIOS
  4. Aurelia
  5. Fetch API

Concepts

  1. Web API vendors / developers should provide client API libraries to developers of client programs, as Google and Amazon etc. would do in order to make the RESTful Web API reach wider consumers (internal and external) efficiently.
  2. To client developers, classic function prototypes like ReturnType DoSomething(Type1 t1, Type2 t2 ...) is the API function, and the rest is the technical implementation details of transportations: TCP/IP, HTTP, SOAP, resource-oriented, CRUD-based URIs, RESTful, XML and JSON etc. The function prototype and a piece of API document should be good enough for calling the API function.
  3. The better you have separation of concerns in your Web API design, the more you will benefit from the components of this project in order to deliver business values sooner, with less handcrafted codes , less repetitive tasks and less chances of human mistakes.

Prerequisites

Server side:

  1. .NET 6

And in the service startup codes, ensure the following:

services.AddControllers(
	options =>
	{
#if DEBUG
		options.Conventions.Add(new Fonlow.CodeDom.Web.ApiExplorerVisibilityEnabledConvention());
#endif
	}
)

.NET client side:

  1. .NET Framework 4.5.2, or Universal Windows, or Mono.Android, or Xamarin.iOS, or .NET Core 2.0/2.1/3 and .NET 5
  2. ASP.NET Web API 2.2 Client Libraries
  3. Json.NET of Newtonsoft for Content-Type application/json
  4. Microsoft Build Tools 2015

TypeScript client side:

  1. TypeScript compiler
  2. jQuery
  3. Angular 6-13
  4. Aurelia
  5. Axios
  6. Fetch API

For more details, please check WIKI, and codeproject.com articles at:

  1. Generate C# .NET Client API for ASP.NET Web API
  2. Generate TypeScript Client API for ASP.NET Web API
  3. ASP.NET Web API, Angular2, TypeScript and WebApiClientGen
  4. Generate C# Client API for ASP.NET Core Web API
  5. DateOnly in ASP.NET Core 6

Demo Applications

The Demo applications in this repository are mainly for testing WebApiClientGen during development. And there are other demo applications in the following repositories, demostrating how real world applications could utilize WebApiClientGen:

  1. WebApiClientGen Examples
  2. .NET Core Demo
  3. WebApiClientGen vs Swagger

These demo applications are actively maintained and kept up-to-date with the latest frameworks. If you are still staying with some older frameworks like Angular 4 or 5 or .NET Core 2.0, you may navigate to respective tags of the repositories and checkout.

More Repositories

1

openapiclientgen

Generate strongly typed C# and TypeScript client codes from Open API / Swagger definitions supporting jQuery, Angular, AXIOS, Fetch API, Aurelia and Angular Strictly Typed Forms
TypeScript
62
star
2

webapiclientgenexamples

Code Examples for using WebApiClientGen
JavaScript
43
star
3

TraceHub

Centralized and distributed logging for Web applications and services, extending System.Diagnostics and Essential.Diagnostics, providing structured tracing and logging withou needing to change 1 line of your application codes
JavaScript
24
star
4

DemoCoreWeb

.NET Core Web projects to demonstrate WebApiClientGen, with examples for vue, React, jQuery, Angular and MAUI
TypeScript
12
star
5

commandlinegui

Command line arguments parser library for constructing .NET command line programs with complex arguments. Better Robocopy GUI is included.
C#
9
star
6

WorkflowDemo

Working samples of Windows Workflow Foundation 4.5
JavaScript
6
star
7

AuthEF

Libraries for utilizing ASP.NET Identity and Entity Framework Core, neutral to database engines
C#
5
star
8

TraceSourceNetCore

Use Trace and TraceSource in .NET Core applications.
C#
5
star
9

SyncMLDotNet

.NET components for synchronizing meta data with a SyncML server such as Funambol DS server. SyncML Client for Open Contacts and Addin for MS Outlook are utilizing the API
HTML
5
star
10

TraceHubDemos

Demo projects for TraceHub
JavaScript
4
star
11

HelloWorldAuth

Demo source codes of Authentication and Authorization with ASP.NET Identity 2.0 for WCF Services
C#
4
star
12

CommonDelphi

Some Delphi 7 lib codes I wrote in 90s and early 2000s
Pascal
1
star
13

FonlowTesting

Helper functions for constructing unit testing and integration testing efficiently
C#
1
star
14

Fonlow.Diagnostics

Extensions of System.Diagnostics
C#
1
star
15

xamarinforms4bugs

demo some bugs in Xamarin.Forms 4 as reported at https://github.com/xamarin/Xamarin.Forms/issues/6327 and 10809
C#
1
star
16

OpenApiExamples

Compare OpenApiClientGen with others
C#
1
star
17

JsLargeIntegralDemo

Dealing with large integral numbers in JavaScript for integral types of ASP.NET Core Web API
TypeScript
1
star