Skip to content

Commit 271693a

Browse files
authored
Merge pull request #330 from json-api-dotnet/develop
v2.3.4 Introduce ResourceDefinition
2 parents 1a14773 + d67a894 commit 271693a

File tree

51 files changed

+695
-92
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+695
-92
lines changed

Build.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ If($env:APPVEYOR_REPO_TAG -eq $true) {
4646

4747
IF ([string]::IsNullOrWhitespace($revision)){
4848
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
49-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
49+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --include-symbols
5050
CheckLastExitCode
5151
}
5252
Else {
5353
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
54-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision
54+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision --include-symbols
5555
CheckLastExitCode
5656
}
5757
}
5858
Else {
5959
Write-Output "VERSION-SUFFIX: alpha1-$revision"
6060
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision"
61-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision
61+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision --include-symbols
6262
CheckLastExitCode
6363
}

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ deploy:
4444
api_key:
4545
secure: 6CeYcZ4Ze+57gxfeuHzqP6ldbUkPtF6pfpVM1Gw/K2jExFrAz763gNAQ++tiacq3
4646
skip_symbols: false
47+
symbol_server: https://www.myget.org/F/research-institute/symbols/api/v2/package
4748
on:
4849
branch: develop
4950
- provider: NuGet
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using JsonApiDotNetCore.Controllers;
2+
using JsonApiDotNetCore.Services;
3+
using JsonApiDotNetCoreExample.Models;
4+
using Microsoft.Extensions.Logging;
5+
6+
namespace JsonApiDotNetCoreExample.Controllers
7+
{
8+
public class UsersController : JsonApiController<User>
9+
{
10+
public UsersController(
11+
IJsonApiContext jsonApiContext,
12+
IResourceService<User> resourceService,
13+
ILoggerFactory loggerFactory)
14+
: base(jsonApiContext, resourceService, loggerFactory)
15+
{ }
16+
}
17+
}

src/Examples/JsonApiDotNetCoreExample/Data/AppDbContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
3737

3838
public DbSet<Article> Articles { get; set; }
3939
public DbSet<Author> Authors { get; set; }
40-
4140
public DbSet<NonJsonApiResource> NonJsonApiResources { get; set; }
41+
public DbSet<User> Users { get; set; }
4242
}
4343
}

src/Examples/JsonApiDotNetCoreExample/Migrations/20180327120810_initial.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
using Microsoft.EntityFrameworkCore.Metadata;
21
using Microsoft.EntityFrameworkCore.Migrations;
32
using System;
4-
using System.Collections.Generic;
53
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
64

75
namespace JsonApiDotNetCoreExample.Migrations
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using JsonApiDotNetCore.Models;
2+
3+
namespace JsonApiDotNetCoreExample.Models
4+
{
5+
public class User : Identifiable
6+
{
7+
[Attr("username")] public string Username { get; set; }
8+
[Attr("password")] public string Password { get; set; }
9+
}
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Collections.Generic;
2+
using JsonApiDotNetCore.Models;
3+
using JsonApiDotNetCoreExample.Models;
4+
5+
namespace JsonApiDotNetCoreExample.Resources
6+
{
7+
public class UserResource : ResourceDefinition<User>
8+
{
9+
protected override List<AttrAttribute> OutputAttrs()
10+
=> Remove(user => user.Password);
11+
}
12+
}

src/Examples/JsonApiDotNetCoreExample/Startup.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
using Microsoft.EntityFrameworkCore;
88
using JsonApiDotNetCore.Extensions;
99
using System;
10+
using JsonApiDotNetCore.Models;
11+
using JsonApiDotNetCoreExample.Resources;
12+
using JsonApiDotNetCoreExample.Models;
1013

1114
namespace JsonApiDotNetCoreExample
1215
{
@@ -38,7 +41,9 @@ public virtual IServiceProvider ConfigureServices(IServiceCollection services)
3841
options.Namespace = "api/v1";
3942
options.DefaultPageSize = 5;
4043
options.IncludeTotalRecordCount = true;
41-
});
44+
})
45+
// TODO: this should be handled via auto-discovery
46+
.AddScoped<ResourceDefinition<User>, UserResource>();
4247

4348
var provider = services.BuildServiceProvider();
4449
var appContext = provider.GetRequiredService<AppDbContext>();

src/Examples/ReportsExample/Controllers/ReportsController.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
1+
using System.Threading.Tasks;
52
using Microsoft.AspNetCore.Mvc;
63
using JsonApiDotNetCore.Controllers;
74
using JsonApiDotNetCore.Services;

src/Examples/ReportsExample/Services/ReportService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Threading.Tasks;
43
using JsonApiDotNetCore.Services;

0 commit comments

Comments
 (0)