All Projects → pda-team → Panda.dynamicwebapi

pda-team / Panda.dynamicwebapi

Licence: apache-2.0
ASP.NET Core Dynamic Restful WebApi. Generating WebApi from Classes. Such as: Direct Generation of WebApi Based on Business Logic Layer.

Projects that are alternatives of or similar to Panda.dynamicwebapi

Plato
Plato helps software teams connect & stay engaged with users to gather feedback, provide support & deliver better software.
Stars: ✭ 293 (-28.54%)
Mutual labels:  asp-net-core
Blog.identityserver
🥗 打造一个功能强大的通用型Ids4用户认证授权服务中心,配合之前的所有开源项目
Stars: ✭ 315 (-23.17%)
Mutual labels:  asp-net-core
Exceptionless.net
Exceptionless clients for the .NET platform
Stars: ✭ 362 (-11.71%)
Mutual labels:  asp-net-core
Jpproject.identityserver4.sso
🔒 ASP.NET Core 3.1 Open Source SSO. Built within IdentityServer4 🔑
Stars: ✭ 298 (-27.32%)
Mutual labels:  asp-net-core
Simplcommerce
A simple, cross platform, modularized ecommerce system built on .NET Core
Stars: ✭ 3,474 (+747.32%)
Mutual labels:  asp-net-core
Umbraco Cms
The simple, flexible and friendly ASP.NET CMS used by more than 730.000 websites
Stars: ✭ 3,484 (+749.76%)
Mutual labels:  asp-net-core
Nucleus
Vue startup application template that uses ASP.NET Core API layered architecture at the back-end and JWT based authentication
Stars: ✭ 276 (-32.68%)
Mutual labels:  asp-net-core
Framework
.NET Core Extensions and Helper NuGet packages.
Stars: ✭ 399 (-2.68%)
Mutual labels:  asp-net-core
Aspnetcore Webapi Sample
This is a sample ASP.NET Core WebAPI
Stars: ✭ 310 (-24.39%)
Mutual labels:  asp-net-core
Epplus.core
EPPlus.Core is an unofficial port of the EPPlus library to .NET Core
Stars: ✭ 354 (-13.66%)
Mutual labels:  asp-net-core
Asp.net Core Inventory Order Management System
Project example Asp.Net Core Mvc implementation of inventory order management system. warehouse, product, vendor, customer, purchase order, sales order, shipment, goods receive and more.
Stars: ✭ 301 (-26.59%)
Mutual labels:  asp-net-core
Mix.core
🚀 Mixcore CMS is an open source CMS that support both headless and decoupled to easily build any kinds of app/web app/customisable APIs built on top of ASP.NET Core / Dotnet Core. It is a completely open source ASP.NET Core (Dotnet Core) CMS solution. https://mixcore.org
Stars: ✭ 304 (-25.85%)
Mutual labels:  asp-net-core
Itextsharp.lgplv2.core
iTextSharp.LGPLv2.Core is an unofficial port of the last LGPL version of the iTextSharp (V4.1.6) to .NET Core
Stars: ✭ 322 (-21.46%)
Mutual labels:  asp-net-core
Live.asp.net
Code for live.asp.net, which hosts the ASP.NET Community Stand-up
Stars: ✭ 295 (-28.05%)
Mutual labels:  asp-net-core
Comcms core
COMCMS_Core 版本
Stars: ✭ 377 (-8.05%)
Mutual labels:  asp-net-core
React Aspnet Boilerplate
A starting point for building isomorphic React applications with ASP.NET Core, leveraging existing techniques.
Stars: ✭ 285 (-30.49%)
Mutual labels:  asp-net-core
Microsoft Identity Web
Helps creating protected web apps and web APIs with Microsoft identity platform and Azure AD B2C
Stars: ✭ 321 (-21.71%)
Mutual labels:  asp-net-core
Professionalcsharp7
Code samples for the book Professional C# 7 and .NET Core 2.0 (with updates for 2.1), Wrox Press
Stars: ✭ 403 (-1.71%)
Mutual labels:  asp-net-core
Chartjs.blazor
Brings Chart.js charts to Blazor
Stars: ✭ 402 (-1.95%)
Mutual labels:  asp-net-core
Grid.blazor
Grid component with CRUD for Blazor (client-side and server-side) and ASP.NET Core MVC
Stars: ✭ 335 (-18.29%)
Mutual labels:  asp-net-core

Panda.DynamicWebApi

Language: English | 中文

Panda.DynamicWebApi is a component that dynamically generates WebApi. The generated API conforms to the Restful style and is inspired by ABP. It can generate WebApi based on qualified classes. The logic is directly called by the MVC framework. There is no performance problem. It is perfectly compatible with Swagger to build the API documentation. There is no difference compared with manually writing the Controller.

Application Scenario: The application logic layer in the DDD architecture, which can be used to directly generate WebApi without using the Controller.

Latest version

1.Quick Start

(1)Create a new ASP.NET Core WebApi (or MVC) project

(2)Install Package

Install-Package Panda.DynamicWebApi

(3)Create a class named AppleAppService, implement the IDynamicWebApi interface, and add the attribute [DynamicWebApi]

[DynamicWebApi]
public class AppleAppService: IDynamicWebApi
{
    private static readonly Dictionary<int,string> Apples=new Dictionary<int, string>()
    {
        [1]="Big Apple",
        [2]="Small Apple"
    };

    /// <summary>
    /// Get An Apple.
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpGet("{id:int}")]
    public string Get(int id)
    {
        if (Apples.ContainsKey(id))
        {
            return Apples[id];
        }
        else
        {
            return "No Apple!";
        }
    }

    /// <summary>
    /// Get All Apple.
    /// </summary>
    /// <returns></returns>
    public IEnumerable<string> Get()
    {
        return Apples.Values;
    }

    public void Update(UpdateAppleDto dto)
    {
        if (Apples.ContainsKey(dto.Id))
        {
            Apples[dto.Id] =dto.Name;
        }
    }

    /// <summary>
    /// Delete Apple
    /// </summary>
    /// <param name="id">Apple Id</param>
    [HttpDelete("{id:int}")]
    public void Delete(int id)
    {
        if (Apples.ContainsKey(id))
        {
            Apples.Remove(id);
        }
    }

}

(4)Register DynamicWebApi in Startup

public void ConfigureServices(IServiceCollection services)
{
    services.AddDynamicWebApi();
}

(5)Add Swagger

(6)Run

After running the browser, visit <your project address>/swagger/index.html and you will see the WebApi generated for our AppleAppService.

1560265120580

This quick start Demo Address: link

2.Advanced

(1)There are two conditions that need to be met for a class to generate a dynamic API. One is that the class direct or indirect implements IDynamicWebApi, and the class itself or parent abstract class or Implemented interface has the property DynamicWebApi

(2)Adding the attribute [NonDynamicWebApi] allows a class or a method to not generate an API, and [NonDynamicWebApi] has the highest priority.

(3)The suffix of the dynamic API class name that conforms to the rule is deleted. For example, our quick start AppleAppService will delete the AppService suffix. This rule can be dynamically configured.

(4)The API route prefix is automatically added, and the api prefix is added by default for all APIs.

(5)The default HTTP verb is POST, which can be understood as the Http Method of the API. But it can be overridden by HttpGet/HttpPost/HttpDelete and other ASP.NET Core built-in attribute.

(6)You can override the default route with built-in attribute such as HttpGet/HttpPost/HttpDelete

(7)By default, HTTP verbs are set according to your method name. For example, the API verb generated by CreateApple or Create is POST. The comparison table is as follows. If you hit (ignore uppercase) the comparison table, then this part of the API name will be Omitted, such as CreateApple will become Apple, if not in the following comparison table, will use the default verb POST

MethodName Start With Http Verb
create POST
add POST
post POST
get GET
find GET
fetch GET
query GET
update PUT
put PUT
delete DELETE
remove DELETE

(8)It is highly recommended that the method name use the PascalCase specification and use the verbs from the above table. Such as:

Create Apple Info-> Add/AddApple/Create/CreateApple

Update Apple Info -> Update/UpdateApple

...

(9)The [DynamicWebApi] attribute can be inherited, so it is forbidden to be placed on a parent class other than an abstract class or interface for the parent class to be misidentified.

3.Configuration

All configurations are in the object DynamicWebApiOptions, as explained below:

Property Require 说明
DefaultHttpVerb False Default:POST.
DefaultAreaName False Default:Empty.
DefaultApiPrefix False Default:api. Web API route prefix.
RemoveControllerPostfixes False Default:AppService/ApplicationService. The suffix of the class name that needs to be removed.
RemoveActionPostfixes False Default:Async. Method name needs to be removed from the suffix.
FormBodyBindingIgnoredTypes False Default:IFormFile。Ignore type for MVC Form Binding.

4.Q&A

If you encounter problems, you can use Issues to ask questions.

5.Reference project

This project directly or indirectly refers to the following items

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].