Skip to content

Migration 28 30

fonlow edited this page Nov 10, 2019 · 3 revisions

WebApiClientGen v2.8 has built-in supports for jQuery, Angular 2+, AXIOS and Aurelia. V3.0 has the supports being moved to plugins. If you are using v2.8 for your Web API projects, please walk through this change log in order to adjust in existing developments.

Changes:

  1. WebApiClientGen packages are built on .NET Framework 4.6.2 while prior releases were built on 4 and 4.5.2.
  2. WebApiClientGenCore packages are built on .NET Core 3.0 while prior releases were built on 2.0, 2.1 and 2.2.
  3. Support for only Angular 6+. Dropped supports for what below 6, and switch "NGVersion" is removed so backward compatibility with Angular 2, 3, 4 and 5 is dropped.
  4. In CodeGen.json, these settings are removed: TypeScriptJQFolder/TypeScriptJQFile, TypeScriptNG2Folder/TypeScriptNG2File, TypeScriptAxiosFolder/TypeScriptAxiosFile, and TypeScriptAureliaFolder/TypeScriptAureliaFile. Instead, settings for new plugin structure are added. And you need to download and install extra NuGet packages for generating TypeScript client API codes for respective TypeScript/JavaScript frameworks/libraries.

A typical JSON payload for generating client API codes:

{
	"ApiSelections": {
		"ExcludedControllerNames": [
			"DemoWebApi.Controllers.Account",
			"DemoWebApi.Controllers.FileUpload"
		],

		"DataModelAssemblyNames": [
			"DemoWebApi.DemoData",
			"DemoWebApi"
		],
		"CherryPickingMethods": 3
	},

	"ClientApiOutputs": {
		"ClientLibraryProjectFolderName": "..\\DemoWebApi.ClientApi",
		"GenerateBothAsyncAndSync": true,

		"Plugins": [
			{
				"AssemblyName": "Fonlow.WebApiClientGen.jQuery",
				"TargetDir": "Scripts\\ClientApi",
				"TSFile": "WebApiJQClientAuto.ts",
				"AsModule": false,
				"ContentType": "application/json;charset=UTF-8",
				"CamelCase": true
			},

			{
				"AssemblyName": "Fonlow.WebApiClientGen.NG2",
				"TargetDir": "..\\DemoNGCli\\NGSource\\src\\ClientApi",
				"TSFile": "WebApiNG2ClientAuto.ts",
				"AsModule": true,
				"ContentType": "application/json;charset=UTF-8",
				"CamelCase": true
			},

			{
				"AssemblyName": "Fonlow.WebApiClientGen.Axios",
				"TargetDir": "..\\axios\\src\\clientapi",
				"TSFile": "WebApiAxiosClientAuto.ts",
				"AsModule": true,
				"ContentType": "application/json;charset=UTF-8",
				"CamelCase": true
			},

			{
				"AssemblyName": "Fonlow.WebApiClientGen.Aurelia",
				"TargetDir": "..\\aurelia\\src\\clientapi",
				"TSFile": "WebApiAureliaClientAuto.ts",
				"AsModule": true,
				"ContentType": "application/json;charset=UTF-8",
				"CamelCase": true
			}

		]


	}
}

Remarks:

Now you need to explicitly define the TypeScript file name in setting TSFile.

Hints:

The outputs of client API codes remain the same, thus there won't be any change to existing deployments on both the server side and the client side. WebApiClientGen is to be used during development, thus the breaking changes impact only on existing developments.

Clone this wiki locally