-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from Research-Institute/feature/client-generat…
…ed-ids Feature/client generated ids
- Loading branch information
Showing
5 changed files
with
170 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/JsonApiDotNetCoreExampleTests/Startups/ClientGeneratedIdsStartup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using JsonApiDotNetCoreExample.Data; | ||
using Microsoft.EntityFrameworkCore; | ||
using JsonApiDotNetCore.Extensions; | ||
using DotNetCoreDocs.Configuration; | ||
using System; | ||
using JsonApiDotNetCoreExample; | ||
|
||
namespace JsonApiDotNetCoreExampleTests.Startups | ||
{ | ||
public class ClientGeneratedIdsStartup : Startup | ||
{ | ||
public ClientGeneratedIdsStartup(IHostingEnvironment env) | ||
: base (env) | ||
{ } | ||
|
||
public override IServiceProvider ConfigureServices(IServiceCollection services) | ||
{ | ||
var loggerFactory = new LoggerFactory(); | ||
|
||
loggerFactory | ||
.AddConsole(LogLevel.Trace); | ||
|
||
services.AddSingleton<ILoggerFactory>(loggerFactory); | ||
|
||
services.AddDbContext<AppDbContext>(options => | ||
{ | ||
options.UseNpgsql(GetDbConnectionString()); | ||
}, ServiceLifetime.Transient); | ||
|
||
services.AddJsonApi<AppDbContext>(opt => | ||
{ | ||
opt.Namespace = "api/v1"; | ||
opt.DefaultPageSize = 5; | ||
opt.IncludeTotalRecordCount = true; | ||
opt.AllowClientGeneratedIds = true; | ||
}); | ||
|
||
services.AddDocumentationConfiguration(Config); | ||
|
||
return services.BuildServiceProvider(); | ||
} | ||
} | ||
} |