NET.AutoApi
1.0.5
The NET.AutoApi rename to Cike.AutoApi.Please install Cike.AutoApi
dotnet add package NET.AutoApi --version 1.0.5
NuGet\Install-Package NET.AutoApi -Version 1.0.5
<PackageReference Include="NET.AutoApi" Version="1.0.5" />
<PackageVersion Include="NET.AutoApi" Version="1.0.5" />
<PackageReference Include="NET.AutoApi" />
paket add NET.AutoApi --version 1.0.5
#r "nuget: NET.AutoApi, 1.0.5"
#:package NET.AutoApi@1.0.5
#addin nuget:?package=NET.AutoApi&version=1.0.5
#tool nuget:?package=NET.AutoApi&version=1.0.5
AutoWebApi
The NET.AutoApi rename to Cike.AutoApi.Please install Cike.AutoApi
Description
🔥Automatic api to make your code more concise 🔥. If your controller layer simply relays code from the business layer, like the following, then the automated api is a great fit for your project. The automated api dynamically generates controllers directly based on your business-layer methods, combined with restful specifications.
The controller just forwards and doesn't do anything, creating a lot of redundant code
public class UserController:ControllerBase
{
private readonly IUserAppService _userAppService;
public UserController(IUserAppService userAppService)
{
_userAppService=userAppService;
}
[HttpGet]
public async Task<PageResult<List<xxxDto>>> GetListAsync(xxxDto input)
{
return await _userAppService.GetListAsync(input);
}
[HttpPost]
public async Task<xxxDto> CreateAsync(xxxDto input)
{
return await _userAppService.CreateAsync(input);
}
[HttpPost]
public async Task<xxxDto> UpdateAsync(Guid id,xxxDto input)
{
return await _userAppService.UpdateAsync(id,input);
}
}
Software Architecture
- This project relies on.net6
Installation
dotnet add package NET.AutoApi
Instructions
- Add the following two pieces of code in
Program.cs
//The 'AddAutoApiService' method must be placed after the 'AddControllers' or 'AddMvc' method.
builder.Services.AddAutoApiService(opt =>
{
//Add dynamic api configuration to the assembly where NETServiceTest resides
opt.CreateConventional(typeof(NETServiceTest).Assembly);
});
- Business layer code, just need to inherit
IAutoApiServiceinterface
public class TestService : IAutoApiService
{
public async Task<List<string>> CreateAsync(TestCreateUpdateInput input)
{
return new List<string>
{
$"{input.Code}|{input.Name}"
};
}
public async Task<string> GetListAsync(string keyword)
{
return keyword;
}
public async Task<List<string>> UpdateAsync(Guid id, TestCreateUpdateInput input)
{
return new List<string>
{
$"{id}|{input.Code}|{input.Name}"
};
}
/// <summary>
/// Upload file. If you upload files,Please use IAutoApiStreamContent[] .
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public async Task<string> ImportAsync(IAutoApiStreamContent file)
{
using var fileStream = file.GetStream();
return file.FileName;
}
}
- Final effect
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.