Magicalizer是一个小型,超级简单且轻巧的库,可让您创建一个具有最小例程代码的完整特色的REST API ASP.NET CORE WEB应用程序。
在大多数情况下,您需要编写的只是为其编写的DTO/模型/实体类,过滤器和验证器。就是这样。 Your web application will automatically support complex filtering (including multiple nested object properties, ranges, etc.), complex sorting (multiple nested object properties with different directions), pagination, complex inclusions (nested object properties), flexible and powerful validation at both the DTO and model levels (using FluentValidation), and policy-based authorization for GET, POST, PUT, PATCH, and DELETE requests (yes, PATCH requests are supported too).
重要的一点是:虽然Magicalizer处理繁重的工作,但您仍然可以在需要时自行替换任何默认实现。为任何模型创建自定义服务实现后,它将自动替换默认的服务。同样适用于控制器。将DTO/模型/实体类,验证器,服务或控制器放置在何处,它们会自动发现和解决。这使得重复使用代码并创建解耦软件变得非常容易。
运行Web应用程序并尝试以下请求(您可以使用此项目中的测试数据库)。
GET: /v1/categories GET: /v1/categories?name.contains=izza GET: /v1/categories?products.any.photos.any.filename.contains=.jpg&fields=products.photos GET: /v1/categories/1 GET: /v1/categories/5?fields=products.photos GET: /v1/products GET: /v1/products?id.in=1&id.in=2 GET: /v1/products?category.id=5&sorting=+name&offset=0&limit=5 GET: /v1/products?category.id=5&sorting=-name&offset=0&limit=5 GET: /v1/products?category.name.equals=Pizza&name.contains=ana&fields=category POST: /v1/categories { "name" : " Sushi " } PUT: /v1/categories { "id" : 1 , "name" : " Not sushi " } PATCH: /v1/categories/1 [{ "op" : " replace " , "path" : " name " , "value" : " Sushi again o_O " }] DELETE: /v1/categories/1 github上的资料:https://github.com/magicalizer/magicalizer
作者:http://sikorsky.pro/