webapiclientgen icon indicating copy to clipboard operation
webapiclientgen copied to clipboard

Add Refit Support

Open startewho opened this issue 2 years ago • 1 comments

This PR add the Refit Support. Refit is a library heavily inspired by Square's Retrofit library, and it turns your REST API into a live interface:

public interface IGitHubApi
{
    [Get("/users/{user}")]
    Task<User> GetUser(string user);
}

Add the Refit Client File by this setting

{
  "ApiSelections": {
    "ExcludedControllerNames": [
      "DemoWebApi.Controllers.Home"
    ],

    "DataModels": [
			{
				"AssemblyName": "DemoWebApi.DemoDataCore",
				"CherryPickingMethods": 3
			},

			{
				"AssemblyName": "DemoCoreWeb",
				"CherryPickingMethods": 1
			}
		],
    "CherryPickingMethods": 0
  },

  "ClientApiOutputs": {
    "FileName":"WebApiClientRefit.cs",
    "ContainerNameSuffix":"",
    "ClientLibraryProjectFolderName": "..\\..\\DemoCoreWeb.ClientApi",
    "CamelCase": true,
    "CSClientNamespaceSuffix": "Refit.Client",
    "UseEnsureSuccessStatusCodeEx": false,
    "DataAnnotationsEnabled": true,
    "DataAnnotationsToComments": true,
    "HandleHttpRequestHeaders": true,
    "GenerateBothAsyncAndSync ":false,
    "CancellationTokenEnabled": true,
    "DecorateDataModelWithDataContract": true,
    "DataContractNamespace": "http://fonlowdemo.com/2020/09",
    "DecorateDataModelWithSerializable": true,
    "IEnumerableToArray": false,
    "MaybeNullAttributeOnMethod": true,
    "NotNullAttributeOnMethod": true,
    "UseSystemTextJson": true,
    "UseRefit":true,
    "Plugins": [

    ]
  }
}

Btw, refit support upload files also。 It's the first time i use the codedom,it seems lack a lot skills with your great the source code.

startewho avatar Jan 13 '23 06:01 startewho

What are the benefits to client programmers to use refit and its httpClient construction?

zijianhuang avatar Apr 08 '24 12:04 zijianhuang