Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Refit Support #128

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

startewho
Copy link

@startewho startewho commented Jan 13, 2023

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.

@zijianhuang
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants