ASP.Net Core的 JSONAPI 框架

网友投稿 819 2022-10-17 08:07:00

ASP.Net Core的 JSONAPI 框架

JSON API .Net Core

A framework for building json:api compliant web APIs. The ultimate goal of this library is to eliminate as much boilerplate as possible by offering out-of-the-box features such as sorting, filtering and pagination. You just need to focus on defining the resources and implementing your custom business logic. This library has been designed around dependency injection making extensibility incredibly easy.

Getting Started

These are some steps you can take to help you understand what this project is and how you can use it:

What is json:api and why should I use it?The json:api specificationDemo [Video]Our documentationCheck out the example projectsEmbercasts: Full Stack Ember with ASP .NET Core

Related Projects

Performance ReportsJsonApiDotNetCore.MongoDbJsonApiDotNetCore.MartenTodo List App

Examples

See the examples directory for up-to-date sample applications. There is also a Todo List App that includes a JADNC API and an EmberJs client.

Installation And Usage

See our documentation for detailed usage.

Models

public class Article : Identifiable{ [Attr("name")] public string Name { get; set; }}

Controllers

public class ArticlesController : JsonApiController

{ public ArticlesController( IJsonApiOptions jsonApiOptions, IResourceService
resourceService, ILoggerFactory loggerFactory) : base(jsonApiOptions, resourceService, loggerFactory) { }}

Middleware

public class Startup{ public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddJsonApi(); // ... } public void Configure(IApplicationBuilder app) { app.UseJsonApi() // ... }}

Development

Restore all NuGet packages with:

dotnet restore

Testing

Running tests locally requires access to a PostgreSQL database. If you have docker installed, this can be propped up via:

docker run --rm --name jsonapi-dotnet-core-testing -e POSTGRES_DB=JsonApiDotNetCoreExample -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:12.0

And then to run the tests:

dotnet test

Cleaning

Sometimes the compiled files can be dirty / corrupt from other branches / failed builds.

dotnet clean

Compiler warnings

The Release build configuration is set to fail on warnings. That means when submitting a PR there shouldn't be any compiler warnings because the CI build it set to Release.

Compatibility

A lot of changes were introduced in v4.0.0, the following chart should help you with compatibility issues between .NET Core versions

.NET Core VersionJADNC Version
2.*v3.*
3.*v4.*

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Elasticsearch Search流程
下一篇:Netty分布式pipeline管道传播事件的逻辑总结分析
相关文章