Awesome
<a href="https://www.jsonapi.net"><img src="docs/home/assets/img/logo.svg" style="height: 345px; width: 345px"/></a>
JsonApiDotNetCore
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.
Getting Started
These are some steps you can take to help you understand what this project is and how you can use it:
About
- What is JSON:API and why should I use it? (blog, 2017)
- Pragmatic JSON:API Design (video, 2017)
- JSON:API and JsonApiDotNetCore (video, 2021)
- JsonApiDotNetCore Release 4.0 (blog, 2020)
- JSON:API, .Net Core, EmberJS (video, 2017)
- Embercasts: Full Stack Ember with ASP.NET Core (paid course, 2017)
Official documentation
Related Projects
Examples
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.
Installation and Usage
See our documentation for detailed usage.
Models
#nullable enable
[Resource]
public class Article : Identifiable<int>
{
[Attr]
public string Name { get; set; } = null!;
}
Middleware
// Program.cs
builder.Services.AddJsonApi<AppDbContext>();
// ...
app.UseRouting();
app.UseJsonApi();
app.MapControllers();
Compatibility
The following chart should help you pick the best version, based on your environment. See also our versioning policy.
JsonApiDotNetCore | Status | .NET | Entity Framework Core |
---|---|---|---|
3.x | Stable | Core 2.x | 2.x |
4.x | Stable | Core 3.1 | 3.1, 5 |
5 | 5 | ||
6 | 5 | ||
5.0.0-5.0.2 | Stable | 6 | 6 |
5.0.3-5.4.0 | Stable | 6 | 6, 7 |
7 | 7 | ||
5.5+ | Stable | 6 | 6, 7 |
7 | 7 | ||
8 | 8 | ||
master | Preview | 6 | 6, 7 |
7 | 7 | ||
8 | 8 | ||
openapi | Experimental | 6 | 6, 7 |
7 | 7 | ||
8 | 8 |
Contributing
Have a question, found a bug or want to submit code changes? See our contributing guidelines.
Trying out the latest build
After each commit to the master branch, a new pre-release NuGet package is automatically published to GitHub Packages. To try it out, follow the steps below:
- Create a Personal Access Token (classic) with at least
read:packages
scope. - Add our package source to your local user-specific
nuget.config
file by running:
In the command above:dotnet nuget add source https://nuget.pkg.github.com/json-api-dotnet/index.json --name github-json-api --username YOUR-GITHUB-USERNAME --password YOUR-PAT-CLASSIC
- Replace YOUR-GITHUB-USERNAME with the username you use to login your GitHub account.
- Replace YOUR-PAT-CLASSIC with the token your created above.
and retry with thedotnet nuget remove source github-json-api
--store-password-in-clear-text
switch added. - Restart your IDE, open your project, and browse the list of packages from the github-json-api feed (make sure pre-release packages are included).
Development
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:
pwsh run-docker-postgres.ps1
And then to run the tests:
dotnet test
Alternatively, to build, run all tests, generate code coverage and NuGet packages:
pwsh Build.ps1
Sponsors
<a href="https://jb.gg/OpenSourceSupport"><img align="middle" src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg" alt="JetBrains Logo" style="width:150px"></a> <a href="https://www.araxis.com/buy/open-source"><img align="middle" src="https://www.araxis.com/theme/37/img/araxis-logo-lg.svg" alt="Araxis Logo" style="width:150px"></a>