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 |
|---|---|---|
| 36.1.0 | 31 | 3/12/2026 |
| 36.0.0 | 36 | 3/10/2026 |
| 35.2.0 | 86 | 2/10/2026 |
| 35.1.0 | 72 | 2/10/2026 |
| 35.0.0 | 70 | 2/9/2026 |
| 34.0.1 | 311 | 12/15/2025 |
| 34.0.0 | 571 | 11/20/2025 |
| 33.0.0 | 364 | 11/11/2025 |
| 32.0.0 | 222 | 11/9/2025 |
| 31.0.1 | 214 | 9/24/2025 |
| 31.0.0 | 259 | 9/19/2025 |
| 30.1.0 | 292 | 7/10/2025 |
| 30.0.0 | 267 | 6/19/2025 |
| 29.0.0 | 282 | 4/15/2025 |
| 28.2.0 | 302 | 3/17/2025 |
| 28.1.0 | 331 | 1/28/2025 |
| 28.0.0 | 186 | 1/26/2025 |
| 27.0.0 | 374 | 11/20/2024 |
| 26.3.3 | 385 | 11/7/2024 |
| 1.0.1 | 582 | 4/1/2021 |