Rystem.RepositoryFramework.Api.Server 3.0.10

There is a newer version of this package available.
See the version list below for details.
dotnet add package Rystem.RepositoryFramework.Api.Server --version 3.0.10                
NuGet\Install-Package Rystem.RepositoryFramework.Api.Server -Version 3.0.10                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rystem.RepositoryFramework.Api.Server" Version="3.0.10" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rystem.RepositoryFramework.Api.Server --version 3.0.10                
#r "nuget: Rystem.RepositoryFramework.Api.Server, 3.0.10"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Rystem.RepositoryFramework.Api.Server as a Cake Addin
#addin nuget:?package=Rystem.RepositoryFramework.Api.Server&version=3.0.10

// Install Rystem.RepositoryFramework.Api.Server as a Cake Tool
#tool nuget:?package=Rystem.RepositoryFramework.Api.Server&version=3.0.10                

What is Rystem?

Api auto-generated

In your web application you have only to add one row after service build.

builder.Services.AddApiFromRepositoryFramework(x =>
{
    x.Name = "Repository Api";
    x.HasSwagger = true;
    x.HasDocumentation = true;
    x.Identity.ConfigureAzureActiveDirectory(builder.Configuration);
});

var app = builder.Build();
app.UseApiFromRepositoryFramework()
   .WithNoAuthorization();

public static ApiAuthorizationBuilder UseApiFromRepositoryFramework<TEndpointRouteBuilder>(
    this TEndpointRouteBuilder app,
    string startingPath = "api")
    where TEndpointRouteBuilder : IEndpointRouteBuilder

You may add api for each service by

public static ApiAuthorizationBuilder UseApiForRepository<T>(this IEndpointRouteBuilder app,
    string startingPath = "api")

Startup example

In the example below you may find the DI for repository with string key for User model, populated with random data in memory, swagger to test the solution, the population method just after the build and the configuration of your API based on repository framework. Futhermore, we are adding a configuration for AAD to implement authentication on api.

var builder = WebApplication.CreateBuilder(args);
builder.Services
    .AddRepositoryInMemoryStorage<User>()
    .PopulateWithRandomData(x => x.Email!, 120, 5);
builder.Services.AddApiFromRepositoryFramework(x =>
{
    x.Name = "Repository Api";
    x.HasSwagger = true;
    x.HasDocumentation = true;
    x.Identity.ConfigureAzureActiveDirectory(builder.Configuration);
});    

var app = builder.Build();
app.Services.Populate();
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseApiForRepositoryFramework()
    .WithDefaultAuthorization();
app.Run();

No Authorization flow - default

var builder = WebApplication.CreateBuilder(args);
builder.Services
    .AddRepositoryInMemoryStorage<User>()
    .PopulateWithRandomData(x => x.Email!, 120, 5);
builder.Services.AddApiFromRepositoryFramework(x =>
{
    x.Name = "Repository Api";
    x.HasSwagger = true;
    x.HasDocumentation = true;
});    

var app = builder.Build();
app.Services.Populate();
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseApiForRepositoryFramework()
    .WithNoAuthorization();
app.Run();

Authorization flow - custom policies

You may configure the scoper for each method of your repository and for each repository, as you wish.

var builder = WebApplication.CreateBuilder(args);
builder.Services
    .AddRepositoryInMemoryStorage<User>()
    .PopulateWithRandomData(x => x.Email!, 120, 5);
builder.Services.AddApiFromRepositoryFramework(x =>
{
    x.Name = "Repository Api";
    x.HasSwagger = true;
    x.HasDocumentation = true;
    x.Identity.ConfigureAzureActiveDirectory(builder.Configuration);
});    

var app = builder.Build();
app.Services.Populate();
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseApiForRepositoryFramework()
    .SetPolicyForAll()
    .With("Normal User")
    .And()
    .SetPolicy(RepositoryMethod.Insert)
    .With("Admin")
    .And()
    .SetPolicy(RepositoryMethod.Update)
    .With("Admin")
    .And()
    .Finalize();

app.Run();

In this example, I'm configuring a policy named "Normal User" for all methods and all repositories, and a policy named "Admin" for the methods Insert and Update for all repositories. You can customize it repository for repository, using AddApiForRepository<T>() method.

Sample of filter usage when you use the api directly

All the requests are basic requests, the strangest request is only the query and you must use the Linq query. You may find some examples down below:

ƒ => (((ƒ.X == "dasda") AndAlso ƒ.X.Contains("dasda")) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32)))
ƒ => ((((ƒ.X == "dasda") AndAlso ƒ.Sol) AndAlso ƒ.X.Contains("dasda")) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32)))
ƒ => (((((ƒ.X == "dasda") AndAlso ƒ.Sol) AndAlso ƒ.X.Contains("dasda")) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32))) AndAlso ((ƒ.Type == 1) OrElse (ƒ.Type == 2)))
ƒ => (ƒ.Type == 2)
ƒ => (((((ƒ.X == "dasda") AndAlso ƒ.Sol) AndAlso (ƒ.X.Contains("dasda") OrElse ƒ.Sol.Equals(True))) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32))) AndAlso ((ƒ.Type == 1) OrElse (ƒ.Type == 2)))
ƒ => ((((((ƒ.X == "dasda") AndAlso ƒ.Samules.Any(x => (x == "ccccde"))) AndAlso ƒ.Sol) AndAlso (ƒ.X.Contains("dasda") OrElse ƒ.Sol.Equals(True))) AndAlso ((ƒ.E == Guid.Parse("bf46510b-b7e6-4ba2-88da-cef208aa81f2")) Or (ƒ.Id == 32))) AndAlso ((ƒ.Type == 1) OrElse (ƒ.Type == 2)))
ƒ => (ƒ.ExpirationTime > Convert.ToDateTime("7/6/2022 9:48:56 AM"))
ƒ => (ƒ.TimeSpan > new TimeSpan(1000 as long))
ƒ => Not(ƒ.Inside.Inside.A.Equals("dasdad"))
ƒ => Not(String.IsNullOrWhiteSpace(ƒ.Inside.Inside.A))
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.1.0 34 9/29/2024
6.0.24 116 9/11/2024
6.0.23 328,342 7/18/2024
6.0.21 111 6/18/2024
6.0.20 727,722 6/16/2024
6.0.19 30,343 6/14/2024
6.0.18 119 6/14/2024
6.0.17 96 6/14/2024
6.0.16 49,959 6/10/2024
6.0.15 109 6/9/2024
6.0.14 94,231 5/24/2024
6.0.13 115 5/23/2024
6.0.12 95 5/23/2024
6.0.11 108 5/20/2024
6.0.9 81 5/20/2024
6.0.7 76 5/18/2024
6.0.6 124 5/10/2024
6.0.5 126 5/10/2024
6.0.4 549,783 4/3/2024
6.0.3 919 3/25/2024
6.0.2 393,556 3/11/2024
6.0.0 1,171,121 11/21/2023
6.0.0-rc.6 103 10/25/2023
6.0.0-rc.5 76 10/25/2023
6.0.0-rc.4 74 10/23/2023
6.0.0-rc.3 61 10/19/2023
6.0.0-rc.2 75 10/18/2023
6.0.0-rc.1 70 10/16/2023
5.0.20 638,574 9/25/2023
5.0.19 915 9/10/2023
5.0.18 899 9/6/2023
5.0.17 880 9/6/2023
5.0.16 948 9/5/2023
5.0.15 890 9/5/2023
5.0.14 863 9/5/2023
5.0.13 859 9/1/2023
5.0.12 892 8/31/2023
5.0.11 867 8/30/2023
5.0.10 878 8/29/2023
5.0.9 899 8/24/2023
5.0.8 919 8/24/2023
5.0.7 450,383 8/23/2023
5.0.6 18,240 8/21/2023
5.0.5 5,055 8/21/2023
5.0.4 912 8/16/2023
5.0.3 213,306 8/2/2023
5.0.2 2,578 8/2/2023
5.0.1 12,378 8/1/2023
5.0.0 12,659 7/31/2023
4.1.26 141,437 7/20/2023
4.1.25 25,424 7/16/2023
4.1.24 398,499 6/13/2023
4.1.23 46,464 6/13/2023
4.1.22 130,274 5/30/2023
4.1.21 56,205 5/20/2023
4.1.20 405,388 4/19/2023
4.1.19 96,205 3/20/2023
4.1.18 1,097 3/20/2023
4.1.17 1,080 3/16/2023
4.1.16 1,084 3/16/2023
4.1.15 1,040 3/15/2023
4.1.14 1,628 3/9/2023
4.1.13 1,069 3/7/2023
4.1.12 1,269 2/10/2023
4.1.11 1,150 1/26/2023
4.1.10 1,138 1/22/2023
4.1.9 1,121 1/20/2023
4.1.8 1,088 1/18/2023
4.1.7 1,292 1/18/2023
4.1.6 1,154 1/17/2023
4.1.1 1,151 1/4/2023
4.1.0 1,205 1/1/2023
3.1.5 1,133 12/21/2022
3.1.3 1,167 12/12/2022
3.1.2 1,120 12/7/2022
3.1.1 1,122 12/7/2022
3.1.0 1,180 12/2/2022
3.0.29 1,153 12/1/2022
3.0.28 1,151 12/1/2022
3.0.27 1,351 11/23/2022
3.0.25 1,197 11/23/2022
3.0.24 1,178 11/18/2022
3.0.23 1,166 11/18/2022
3.0.22 1,211 11/15/2022
3.0.21 1,215 11/14/2022
3.0.20 1,195 11/13/2022
3.0.19 1,426 11/2/2022
3.0.18 1,197 11/2/2022
3.0.17 1,199 10/29/2022
3.0.16 1,214 10/29/2022
3.0.15 1,178 10/29/2022
3.0.14 1,285 10/24/2022
3.0.13 1,259 10/24/2022
3.0.12 1,277 10/17/2022
3.0.11 1,263 10/10/2022
3.0.10 1,292 10/6/2022
3.0.9 1,233 10/6/2022
3.0.8 1,214 10/6/2022
3.0.7 1,242 10/6/2022
3.0.6 1,214 10/5/2022
3.0.5 1,228 10/5/2022
3.0.4 1,186 10/5/2022
3.0.3 1,235 10/3/2022
3.0.2 1,238 9/30/2022
3.0.1 1,227 9/29/2022
2.0.17 1,224 9/29/2022
2.0.16 1,219 9/27/2022
2.0.15 1,336 9/27/2022
2.0.14 1,265 9/26/2022
2.0.13 1,302 9/26/2022
2.0.12 1,285 9/26/2022
2.0.11 1,224 9/25/2022
2.0.10 1,299 9/25/2022
2.0.9 1,304 9/22/2022
2.0.8 1,282 9/22/2022
2.0.6 1,225 9/20/2022
2.0.5 1,256 9/20/2022
2.0.4 1,255 9/20/2022
2.0.2 1,269 9/20/2022
2.0.1 1,341 9/13/2022
2.0.0 1,261 8/19/2022
1.1.24 1,290 7/30/2022
1.1.23 1,259 7/29/2022
1.1.22 1,256 7/29/2022
1.1.21 1,324 7/29/2022
1.1.20 1,289 7/29/2022
1.1.19 1,350 7/27/2022
1.1.17 1,245 7/27/2022
1.1.16 1,294 7/26/2022
1.1.15 1,313 7/25/2022
1.1.14 1,301 7/25/2022
1.1.13 1,249 7/22/2022
1.1.12 1,337 7/19/2022
1.1.11 1,314 7/19/2022
1.1.10 1,282 7/19/2022
1.1.9 1,288 7/19/2022
1.1.8 1,312 7/18/2022
1.1.7 1,290 7/18/2022
1.1.6 1,292 7/18/2022
1.1.5 1,279 7/17/2022
1.1.4 1,307 7/17/2022
1.1.3 1,309 7/17/2022
1.1.2 1,321 7/17/2022
1.1.0 1,309 7/17/2022
1.0.2 1,273 7/15/2022
1.0.1 1,237 7/15/2022
1.0.0 1,288 7/8/2022
0.10.7 1,311 7/7/2022
0.10.2 1,329 7/2/2022
0.10.1 1,257 7/1/2022
0.10.0 1,257 7/1/2022
0.9.11 1,306 6/29/2022
0.9.10 1,306 6/20/2022
0.9.9 1,271 6/11/2022
0.9.7 1,324 6/9/2022
0.9.6 1,276 6/5/2022
0.9.5 1,295 6/3/2022
0.9.4 1,289 6/3/2022
0.9.3 1,263 6/3/2022
0.9.2 1,277 5/31/2022
0.9.1 1,257 5/31/2022
0.9.0 1,255 5/31/2022