A framework for building JSON:API compliant REST APIs using .NET Core and Entity Framework Core. Includes support for Atomic Operations.
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.
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 specification
- Demo Video, Blog
- Our documentation
- Check out the example projects
- Embercasts: Full Stack Ember with ASP.NET Core
- Roadmap
See the examples directory for up-to-date sample applications. There is also a Todo List App that includes a JsonApiDotNetCore API and an EmberJs client.
See our documentation for detailed usage.
public class Article : Identifiable
{
[Attr]
public string Name { get; set; }
}
public class ArticlesController : JsonApiController<Article>
{
public ArticlesController(IJsonApiOptions options, ILoggerFactory loggerFactory,
IResourceService<Article> resourceService,)
: base(options, loggerFactory, resourceService)
{
}
}
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddJsonApi<AppDbContext>();
}
public void Configure(IApplicationBuilder app)
{
app.UseRouting();
app.UseJsonApi();
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}
A lot of changes were introduced in v4. The following chart should help you pick the best version, based on your environment.
.NET Version | EF Core Version | JsonApiDotNetCore Version |
---|---|---|
.NET Core 2.x | 2.x | v3.x |
.NET Core 3.1 | 3.1, 5 | v4 |
.NET 5 | 5 | v4 |
Have a question, found a bug or want to submit code changes? See our contributing guidelines.
After each commit to the master branch, a new prerelease NuGet package is automatically published to AppVeyor at https://ci.appveyor.com/nuget/jsonapidotnetcore. To try it out, follow the next steps:
- In Visual Studio: Tools, NuGet Package Manager, Package Manager Settings, Package Sources
- Click +
- Name: AppVeyor JADNC, Source: https://ci.appveyor.com/nuget/jsonapidotnetcore
- Click Update, Ok
- Open the NuGet package manager console (Tools, NuGet Package Manager, Package Manager Console)
- Select AppVeyor JADNC as package source
- Run command:
Install-Package JonApiDotNetCore -pre
To build the code from this repository locally, run:
dotnet build
Running tests locally requires access to a PostgreSQL database. If you have docker installed, this can be propped up via:
run-docker-postgres.ps1
And then to run the tests:
dotnet test
Alternatively, to build and validate the code, run all tests, generate code coverage and produce the NuGet package:
Build.ps1