RESTworld.AspNetCore
1.0.1
See the version list below for details.
dotnet add package RESTworld.AspNetCore --version 1.0.1
NuGet\Install-Package RESTworld.AspNetCore -Version 1.0.1
<PackageReference Include="RESTworld.AspNetCore" Version="1.0.1" />
<PackageVersion Include="RESTworld.AspNetCore" Version="1.0.1" />
<PackageReference Include="RESTworld.AspNetCore" />
paket add RESTworld.AspNetCore --version 1.0.1
#r "nuget: RESTworld.AspNetCore, 1.0.1"
#:package RESTworld.AspNetCore@1.0.1
#addin nuget:?package=RESTworld.AspNetCore&version=1.0.1
#tool nuget:?package=RESTworld.AspNetCore&version=1.0.1
RESTworld
RESTworld is a framework which utilizes other common frameworks and patterns alltogether to enable easy and fast creation of a truly RESTful API.
Used frameworks and patterns
- Entity Framework Core for data access
- ASP.Net Core for hosting
- HAL for providing hyperlinks between resources
- OData for query support on list endpoints
- AutoMapper for mapping between Entities and DTOs
Pipeline
The most basic pipeline has the following data flow for a request on a list endpoint:
- Request
- Controller selection through ASP.Net Core
- Query parsing through OData
- Controller method calls business service method
- Service gets the data through Entity Framework Core
- Entity Framework Core translates the query into SQL and gets the data from the database
- Business service translates Entities into DTOs through Automapper
- Controller wraps the result in a HAL response
- Result
Usage
Solution structure
If your API gets the name MyApi, structure your Solution with the following Projects:
- MyApi (ASP.Net Core Web API)
- References RESTworld.AspNetCore, MyApi.Business
- Contains your startup logic and your custom controllers
- MyApi.Business
- References RESTworld.Business, MyApi.Data
- Contains your AutoMapperConfiguration and your custom services
- MyApi.Data
- References RESTworld.EntityFrameworkCore, MyApi.Common
- Contains your Entity Framework Core Database Model including Entities and Migrations
- MyApi.Common
- References RESTworld.Common
- Contains your DTOs and Enums
Startup configuration
Add the following to your appsettings.json
"RESTworld": {
"MaxNumberForListEndpoint": <whatever is an appropriate number of resources for one page>
}
Change your Program.cs to the following
namespace MyApi
{
public class Program
{
public static void Main(string[] args)
{
RESTworld.AspNetCore.Program<Startup>.Main(args);
}
}
}
Change or add your Startup class
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using RESTworld.Business.Abstractions;
using MyApi.Common.Dtos;
using MyApi.Data;
using MyApi.Data.Models;
using MyApi.Business;
namespace MyApi
{
public class Startup : RESTworld.AspNetCore.StartupBase
{
public Startup(IConfiguration configuration)
: base(configuration)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
base.Configure(app, env);
// Optionally migrate your database to the latest version during startup
MigrateDatabase<TDbContext>(app);
}
// This method gets called by the runtime. Use this method to add services to the container.
public override void ConfigureServices(IServiceCollection services)
{
// Database
services.AddDbContextFactoryWithDefaults<MyDatabase>(Configuration);
services.AddODataModelForDbContext<MyDatabase>();
// Default pipeline
services.AddRestPipeline<TContext, TEntity, TCreateDto, TGetListDto, TGetFullDto, TUpdateDto>();
// With custom service
services.AddRestPipelineWithCustomService<TContext, TEntity, TCreateDto, TGetListDto, TGetFullDto, TUpdateDto, TService>();
// With custom controller
services.AddRestPipelineWithCustomController<TContext, TEntity, TCreateDto, TGetListDto, TGetFullDto, TUpdateDto, TController>();
base.ConfigureServices(services);
}
protected override void ConfigureAutomapper(IMapperConfigurationExpression config)
=> new AutoMapperConfiguration().ConfigureAutomapper(config);
}
}
Add an AutoMapperConfiguration to your MyApi.Business project
using AutoMapper;
using MyApi.Common.Dtos;
using MyApi.Common.Enums;
using MyApi.Data.Models;
namespace MyApi.Business
{
public class AutoMapperConfiguration
{
public void ConfigureAutomapper(IMapperConfigurationExpression config)
{
config.CreateMap<TEntity, TDto>();
// Add more mappings
}
}
}
That's it. Now you can start your API and use a HAL browser like https://chatty42.herokuapp.com/hal-explorer/index.html#uri=https://localhost:5001 to browse your API.
If you are using a launchSettings.json, I suggest to use this as your "launchUrl".
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net5.0
- AutoMapper.Extensions.Microsoft.DependencyInjection (>= 8.1.1)
- HAL.AspNetCore.OData (>= 1.0.1)
- Microsoft.AspNetCore.OData.Versioning.ApiExplorer (>= 5.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore (>= 5.0.4)
- RESTworld.Business (>= 1.0.0)
- Serilog.AspNetCore (>= 4.1.0)
- Serilog.Sinks.Async (>= 1.4.0)
- Swashbuckle.AspNetCore (>= 6.1.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on RESTworld.AspNetCore:
| Package | Downloads |
|---|---|
|
RESTworld.Client.AspNetCore
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 33.0.0 | 211 | 11/11/2025 |
| 32.0.0 | 149 | 11/9/2025 |
| 31.0.1 | 172 | 9/24/2025 |
| 31.0.0 | 223 | 9/19/2025 |
| 30.1.0 | 240 | 7/10/2025 |
| 30.0.0 | 232 | 6/19/2025 |
| 29.0.0 | 250 | 4/15/2025 |
| 28.2.0 | 275 | 3/17/2025 |
| 28.1.0 | 294 | 1/28/2025 |
| 28.0.0 | 150 | 1/26/2025 |
| 27.0.0 | 332 | 11/20/2024 |
| 26.3.3 | 359 | 11/7/2024 |
| 26.3.2 | 146 | 11/6/2024 |
| 26.3.1 | 192 | 10/30/2024 |
| 26.3.0 | 160 | 10/30/2024 |
| 26.2.0 | 504 | 10/11/2024 |
| 26.1.2 | 242 | 10/1/2024 |
| 26.1.1 | 189 | 10/1/2024 |
| 26.1.0 | 169 | 9/27/2024 |
| 26.0.0 | 170 | 9/20/2024 |
| 25.2.0 | 425 | 7/30/2024 |
| 25.1.2 | 199 | 7/18/2024 |
| 25.1.1 | 147 | 7/12/2024 |
| 25.1.0 | 344 | 7/10/2024 |
| 25.0.0 | 195 | 7/3/2024 |
| 24.1.0 | 196 | 6/10/2024 |
| 24.0.0 | 198 | 6/4/2024 |
| 23.0.0 | 154 | 6/4/2024 |
| 22.2.0 | 785 | 1/9/2024 |
| 22.0.0 | 248 | 12/22/2023 |
| 21.1.0 | 400 | 11/27/2023 |
| 21.0.1 | 196 | 11/27/2023 |
| 21.0.0 | 269 | 11/15/2023 |
| 20.1.0 | 383 | 10/23/2023 |
| 20.0.0 | 375 | 9/27/2023 |
| 19.2.2 | 296 | 9/11/2023 |
| 19.2.1 | 504 | 7/17/2023 |
| 19.2.0 | 342 | 7/3/2023 |
| 19.1.0 | 272 | 6/29/2023 |
| 19.0.0 | 302 | 6/28/2023 |
| 18.1.0 | 524 | 6/14/2023 |
| 18.0.2 | 486 | 5/25/2023 |
| 18.0.1 | 336 | 5/16/2023 |
| 18.0.0 | 387 | 5/10/2023 |
| 17.1.1 | 312 | 5/2/2023 |
| 17.1.0 | 352 | 4/30/2023 |
| 17.0.0 | 358 | 4/19/2023 |
| 16.0.0 | 396 | 3/12/2023 |
| 15.1.1 | 691 | 2/22/2023 |
| 15.1.0 | 426 | 2/9/2023 |
| 15.0.0 | 568 | 1/24/2023 |
| 14.1.0 | 472 | 1/24/2023 |
| 14.0.2 | 618 | 1/5/2023 |
| 14.0.1 | 438 | 1/5/2023 |
| 14.0.0 | 534 | 12/21/2022 |
| 13.0.0 | 678 | 11/9/2022 |
| 12.1.0 | 761 | 10/20/2022 |
| 12.0.0 | 651 | 10/20/2022 |
| 11.10.0 | 780 | 9/27/2022 |
| 11.9.0 | 958 | 6/28/2022 |
| 11.8.0 | 823 | 6/27/2022 |
| 11.7.0 | 753 | 6/23/2022 |
| 11.6.1 | 796 | 6/8/2022 |
| 11.6.0 | 791 | 6/7/2022 |
| 11.5.1 | 854 | 5/13/2022 |
| 11.5.0 | 1,113 | 4/1/2022 |
| 11.4.0 | 845 | 3/30/2022 |
| 11.3.1 | 1,005 | 3/16/2022 |
| 11.3.0 | 927 | 3/15/2022 |
| 11.2.4 | 907 | 3/13/2022 |
| 11.2.3 | 883 | 3/10/2022 |
| 11.2.2 | 894 | 3/9/2022 |
| 11.2.1 | 881 | 3/8/2022 |
| 11.1.3 | 1,064 | 3/7/2022 |
| 11.1.2 | 935 | 2/24/2022 |
| 11.1.1 | 913 | 2/22/2022 |
| 11.1.0 | 881 | 2/22/2022 |
| 11.0.0 | 917 | 2/21/2022 |
| 10.0.0 | 776 | 1/14/2022 |
| 9.0.4 | 539 | 1/6/2022 |
| 9.0.3 | 615 | 12/16/2021 |
| 9.0.2 | 566 | 12/9/2021 |
| 9.0.1 | 624 | 12/9/2021 |
| 9.0.0 | 471 | 12/3/2021 |
| 8.2.0 | 3,180 | 11/25/2021 |
| 8.1.1 | 742 | 11/4/2021 |
| 8.1.0 | 750 | 11/4/2021 |
| 8.0.0 | 799 | 10/28/2021 |
| 7.0.1 | 565 | 10/12/2021 |
| 7.0.0 | 602 | 10/6/2021 |
| 6.0.1 | 637 | 10/6/2021 |
| 6.0.0 | 588 | 10/6/2021 |
| 5.2.0 | 608 | 9/29/2021 |
| 5.1.0 | 584 | 9/27/2021 |
| 5.0.2 | 577 | 9/13/2021 |
| 5.0.1 | 526 | 9/8/2021 |
| 5.0.0 | 619 | 9/7/2021 |
| 4.1.0 | 536 | 8/18/2021 |
| 4.0.0 | 569 | 7/7/2021 |
| 3.0.0 | 590 | 7/5/2021 |
| 2.0.0 | 585 | 6/29/2021 |
| 1.2.0 | 568 | 5/11/2021 |
| 1.1.0 | 600 | 4/22/2021 |
| 1.0.3 | 558 | 4/1/2021 |
| 1.0.2 | 567 | 4/1/2021 |
| 1.0.1 | 532 | 4/1/2021 |
| 1.0.0 | 541 | 3/31/2021 |