Cike.Abp.AutoApi 1.0.8

dotnet add package Cike.Abp.AutoApi --version 1.0.8
                    
NuGet\Install-Package Cike.Abp.AutoApi -Version 1.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cike.Abp.AutoApi" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cike.Abp.AutoApi" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Cike.Abp.AutoApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cike.Abp.AutoApi --version 1.0.8
                    
#r "nuget: Cike.Abp.AutoApi, 1.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cike.Abp.AutoApi@1.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cike.Abp.AutoApi&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Cike.Abp.AutoApi&version=1.0.8
                    
Install as a Cake Tool

Abp.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.net7
Installation
dotnet add package Cike.Abp.AutoApi
Instructions
  1. 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);
});
  1. Business layer code, just need to inherit IRemoteService interface
    public class TestService : IRemoteService
    {
        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 IRemoteStreamContent[] .
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public async Task<string> ImportAsync(IRemoteStreamContent file)
        {
            using var fileStream = file.GetStream();


            return file.FileName;
        }
    }
  1. Final effect

Final effect

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.8 285 6/5/2023