Skip to content

Commit 8694e6a

Browse files
author
Bart Koelman
committed
Merge branch 'master' into master-into-openapi
2 parents 17fed9b + 15f5923 commit 8694e6a

File tree

115 files changed

+1839
-1952
lines changed

Some content is hidden

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

115 files changed

+1839
-1952
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
]
1010
},
1111
"regitlint": {
12-
"version": "2.1.4",
12+
"version": "6.0.6",
1313
"commands": [
1414
"regitlint"
1515
]

Build.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function CheckLastExitCode {
88

99
function RunInspectCode {
1010
$outputPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'jetbrains-inspectcode-results.xml')
11-
dotnet jb inspectcode JsonApiDotNetCore.sln --no-build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=SolutionPersonal -dsl=ProjectPersonal
11+
dotnet jb inspectcode JsonApiDotNetCore.sln --no-build --output="$outputPath" --profile=WarningSeverities.DotSettings --properties:Configuration=Release --severity=WARNING --verbosity=WARN -dsl=GlobalAll -dsl=GlobalPerProduct -dsl=SolutionPersonal -dsl=ProjectPersonal
1212
CheckLastExitCode
1313

1414
[xml]$xml = Get-Content "$outputPath"
@@ -47,7 +47,7 @@ function RunCleanupCode {
4747
$mergeCommitHash = git rev-parse "HEAD"
4848
$targetCommitHash = git rev-parse "$env:APPVEYOR_REPO_BRANCH"
4949

50-
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $mergeCommitHash -b $targetCommitHash --fail-on-diff --print-diff
50+
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --disable-jb-path-hack --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN -f commits -a $mergeCommitHash -b $targetCommitHash --fail-on-diff --print-diff
5151
CheckLastExitCode
5252
}
5353
}
@@ -73,10 +73,10 @@ function CreateNuGetPackage {
7373
$versionSuffix = $suffixSegments -join "-"
7474
}
7575
else {
76-
# Get the version suffix from the auto-incrementing build number. Example: "123" => "pre-0123".
76+
# Get the version suffix from the auto-incrementing build number. Example: "123" => "master-0123".
7777
if ($env:APPVEYOR_BUILD_NUMBER) {
7878
$revision = "{0:D4}" -f [convert]::ToInt32($env:APPVEYOR_BUILD_NUMBER, 10)
79-
$versionSuffix = "pre-$revision"
79+
$versionSuffix = "$($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH ?? $env:APPVEYOR_REPO_BRANCH)-$revision"
8080
}
8181
else {
8282
$versionSuffix = "pre-0001"

README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,23 @@ See [our documentation](https://www.jsonapi.net/) for detailed usage.
4343
### Models
4444

4545
```c#
46-
public class Article : Identifiable
46+
#nullable enable
47+
48+
public class Article : Identifiable<int>
4749
{
4850
[Attr]
49-
public string Name { get; set; }
51+
public string Name { get; set; } = null!;
5052
}
5153
```
5254

5355
### Controllers
5456

5557
```c#
56-
public class ArticlesController : JsonApiController<Article>
58+
public class ArticlesController : JsonApiController<Article, int>
5759
{
58-
public ArticlesController(IJsonApiOptions options, ILoggerFactory loggerFactory,
59-
IResourceService<Article> resourceService,)
60-
: base(options, loggerFactory, resourceService)
60+
public ArticlesController(IJsonApiOptions options, IResourceGraph resourceGraph,
61+
ILoggerFactory loggerFactory, IResourceService<Article, int> resourceService)
62+
: base(options, resourceGraph, loggerFactory, resourceService)
6163
{
6264
}
6365
}
@@ -87,13 +89,16 @@ public class Startup
8789
The following chart should help you pick the best version, based on your environment.
8890
See also our [versioning policy](./VERSIONING_POLICY.md).
8991

90-
| .NET version | Entity Framework Core version | JsonApiDotNetCore version |
91-
| ------------ | ----------------------------- | ------------------------- |
92-
| Core 2.x | 2.x | 3.x |
93-
| Core 3.1 | 3.1 | 4.x |
94-
| Core 3.1 | 5 | 4.x |
95-
| 5 | 5 | 4.x or 5.x |
96-
| 6 | 6 | 5.x |
92+
| JsonApiDotNetCore | .NET | Entity Framework Core | Status |
93+
| ----------------- | -------- | --------------------- | -------------------------- |
94+
| 3.x | Core 2.x | 2.x | Released |
95+
| 4.x | Core 3.1 | 3.1 | Released |
96+
| | Core 3.1 | 5 | |
97+
| | 5 | 5 | |
98+
| | 6 | 5 | |
99+
| v5.x (pending) | 5 | 5 | On AppVeyor, to-be-dropped |
100+
| | 6 | 5 | On AppVeyor, to-be-dropped |
101+
| | 6 | 6 | Requires build from master |
97102

98103
## Contributing
99104

ROADMAP.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ We've completed active development on v4.x, but we'll still fix important bugs o
1313
The need for breaking changes has blocked several efforts in the v4.x release, so now that we're starting work on v5, we're going to catch up.
1414

1515
- [x] Remove Resource Hooks [#1025](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1025)
16-
- [x] Update to .NET/EFCORE 5 [#1026](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1026)
16+
- [x] Update to .NET 5 with EF Core 5 [#1026](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1026)
1717
- [x] Native many-to-many [#935](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/935)
1818
- [x] Refactorings [#1027](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1027) [#944](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/944)
1919
- [x] Tweak trace logging [#1033](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1033)
@@ -24,6 +24,7 @@ The need for breaking changes has blocked several efforts in the v4.x release, s
2424
- [x] Nullable reference types [#1029](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1029)
2525
- [x] Improved paging links [#1010](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1010)
2626
- [x] Configuration validation [#170](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/170)
27+
- [ ] Support .NET 6 with EF Core 6 [#1109](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1109)
2728

2829
Aside from the list above, we have interest in the following topics. It's too soon yet to decide whether they'll make it into v5.x or in a later major version.
2930

appveyor.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
image:
22
- Ubuntu
3-
- Visual Studio 2019
3+
- Visual Studio 2022
44

55
version: '{build}'
66

@@ -33,7 +33,7 @@ for:
3333
-
3434
matrix:
3535
only:
36-
- image: Visual Studio 2019
36+
- image: Visual Studio 2022
3737
services:
3838
- postgresql13
3939
# REF: https://github.com/docascode/docfx-seed/blob/master/appveyor.yml
@@ -43,9 +43,7 @@ for:
4343
# https://dotnet.github.io/docfx/tutorial/docfx_getting_started.html
4444
git checkout $env:APPVEYOR_REPO_BRANCH -q
4545
}
46-
# Pinning to previous version, because zip of v2.58.8 (released 2d ago) is corrupt.
47-
# Tracked at https://github.com/dotnet/docfx/issues/7689
48-
choco install docfx -y --version 2.58.5
46+
choco install docfx -y
4947
if ($lastexitcode -ne 0) {
5048
throw "docfx install failed with exit code $lastexitcode."
5149
}

benchmarks/Deserialization/DeserializationBenchmarkBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public abstract class DeserializationBenchmarkBase
2121
protected DeserializationBenchmarkBase()
2222
{
2323
var options = new JsonApiOptions();
24-
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<IncomingResource>().Build();
24+
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<IncomingResource, int>().Build();
2525
options.SerializerOptions.Converters.Add(new ResourceObjectConverter(resourceGraph));
2626
SerializerReadOptions = ((IJsonApiOptions)options).SerializerReadOptions;
2727

benchmarks/QueryString/QueryStringParserBenchmarks.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public QueryStringParserBenchmarks()
2929
EnableLegacyFilterNotation = true
3030
};
3131

32-
IResourceGraph resourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<QueryableResource>("alt-resource-name").Build();
32+
IResourceGraph resourceGraph =
33+
new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<QueryableResource, int>("alt-resource-name").Build();
3334

3435
var request = new JsonApiRequest
3536
{

benchmarks/Serialization/SerializationBenchmarkBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected SerializationBenchmarkBase()
4040
}
4141
};
4242

43-
ResourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<OutgoingResource>().Build();
43+
ResourceGraph = new ResourceGraphBuilder(options, NullLoggerFactory.Instance).Add<OutgoingResource, int>().Build();
4444
SerializerWriteOptions = ((IJsonApiOptions)options).SerializerWriteOptions;
4545

4646
// ReSharper disable VirtualMemberCallInConstructor
@@ -229,15 +229,15 @@ public TopLevelLinks GetTopLevelLinks()
229229
};
230230
}
231231

232-
public ResourceLinks GetResourceLinks(ResourceType resourceType, string id)
232+
public ResourceLinks GetResourceLinks(ResourceType resourceType, IIdentifiable resource)
233233
{
234234
return new ResourceLinks
235235
{
236236
Self = "Resource:Self"
237237
};
238238
}
239239

240-
public RelationshipLinks GetRelationshipLinks(RelationshipAttribute relationship, string leftId)
240+
public RelationshipLinks GetRelationshipLinks(RelationshipAttribute relationship, IIdentifiable leftResource)
241241
{
242242
return new RelationshipLinks
243243
{

cleanupcode.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ if ($LASTEXITCODE -ne 0) {
1414
throw "Package restore failed with exit code $LASTEXITCODE"
1515
}
1616

17-
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --jb --profile --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN
17+
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --disable-jb-path-hack --jb --profile='\"JADNC Full Cleanup\"' --jb --properties:Configuration=Release --jb --verbosity=WARN

docs/getting-started/step-by-step.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ Define your domain models such that they implement `IIdentifiable<TId>`.
3838
The easiest way to do this is to inherit from `Identifiable<TId>`.
3939

4040
```c#
41+
#nullable enable
42+
4143
public class Person : Identifiable<int>
4244
{
4345
[Attr]
44-
public string Name { get; set; }
46+
public string Name { get; set; } = null!;
4547
}
4648
```
4749

@@ -52,12 +54,12 @@ Nothing special here, just an ordinary `DbContext`.
5254
```
5355
public class AppDbContext : DbContext
5456
{
57+
public DbSet<Person> People => Set<Person>();
58+
5559
public AppDbContext(DbContextOptions<AppDbContext> options)
5660
: base(options)
5761
{
5862
}
59-
60-
public DbSet<Person> People { get; set; }
6163
}
6264
```
6365

docs/home/index.html

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,31 +142,35 @@ <h2>Example usage</h2>
142142
<div class="icon"><i class='bx bx-detail'></i></div>
143143
<h4 class="title">Resource</h4>
144144
<pre>
145-
<code>public class Article : Identifiable
145+
<code>#nullable enable
146+
147+
public class Article : Identifiable&lt;long&gt;
146148
{
147149
[Attr]
148-
[Required, MaxLength(30)]
149-
public string Title { get; set; }
150+
[MaxLength(30)]
151+
public string Title { get; set; } = null!;
150152

151153
[Attr(Capabilities = AttrCapabilities.AllowFilter)]
152-
public string Summary { get; set; }
154+
public string? Summary { get; set; }
153155

154156
[Attr(PublicName = "websiteUrl")]
155-
public string Url { get; set; }
157+
public string? Url { get; set; }
158+
159+
[Attr]
160+
[Required]
161+
public int? WordCount { get; set; }
156162

157163
[Attr(Capabilities = AttrCapabilities.AllowView)]
158164
public DateTimeOffset LastModifiedAt { get; set; }
159165

160166
[HasOne]
161-
public Person Author { get; set; }
167+
public Person Author { get; set; } = null!;
162168

163-
[HasMany]
164-
public ICollection&lt;Revision&gt; Revisions { get; set; }
169+
[HasOne]
170+
public Person? Reviewer { get; set; }
165171

166-
[HasManyThrough(nameof(ArticleTags))]
167-
[NotMapped]
168-
public ICollection&lt;Tag&gt; Tags { get; set; }
169-
public ICollection&lt;ArticleTag&gt; ArticleTags { get; set; }
172+
[HasMany]
173+
public ICollection&lt;Tag&gt; Tags { get; set; } = new HashSet&lt;Tag&gt;();
170174
}</code>
171175
</pre>
172176
</div>
@@ -179,7 +183,7 @@ <h4 class="title">Resource</h4>
179183
<h4 class="title">Request</h4>
180184
<pre>
181185
<code>
182-
GET /articles?filter=contains(summary,'web')&sort=-lastModifiedAt&fields=title,summary&include=author HTTP/1.1
186+
GET /articles?filter=contains(summary,'web')&sort=-lastModifiedAt&fields[articles]=title,summary&include=author HTTP/1.1
183187
</code>
184188
</pre>
185189
</div>
@@ -197,9 +201,9 @@ <h4 class="title">Response</h4>
197201
"totalResources": 1
198202
},
199203
"links": {
200-
"self": "/articles?filter=contains(summary,'web')&sort=-lastModifiedAt&fields=title,summary&include=author",
201-
"first": "/articles?filter=contains(summary,'web')&sort=-lastModifiedAt&fields=title,summary&include=author",
202-
"last": "/articles?filter=contains(summary,'web')&sort=-lastModifiedAt&fields=title,summary&include=author"
204+
"self": "/articles?filter=contains(summary,'web')&sort=-lastModifiedAt&fields%5Barticles%5D=title,summary&include=author",
205+
"first": "/articles?filter=contains(summary,'web')&sort=-lastModifiedAt&fields%5Barticles%5D=title,summary&include=author",
206+
"last": "/articles?filter=contains(summary,'web')&sort=-lastModifiedAt&fields%5Barticles%5D=title,summary&include=author"
203207
},
204208
"data": [
205209
{

docs/usage/errors.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ From a controller method:
1010
return Conflict(new Error(HttpStatusCode.Conflict)
1111
{
1212
Title = "Target resource was modified by another user.",
13-
Detail = $"User {userName} changed the {resourceField} field on the {resourceName} resource."
13+
Detail = $"User {userName} changed the {resourceField} field on {resourceName} resource."
1414
});
1515
```
1616

@@ -20,7 +20,7 @@ From other code:
2020
throw new JsonApiException(new Error(HttpStatusCode.Conflict)
2121
{
2222
Title = "Target resource was modified by another user.",
23-
Detail = $"User {userName} changed the {resourceField} field on the {resourceName} resource."
23+
Detail = $"User {userName} changed the {resourceField} field on {resourceName} resource."
2424
});
2525
```
2626

@@ -69,18 +69,22 @@ public class CustomExceptionHandler : ExceptionHandler
6969
return base.GetLogMessage(exception);
7070
}
7171

72-
protected override ErrorDocument CreateErrorDocument(Exception exception)
72+
protected override IReadOnlyList<ErrorObject> CreateErrorResponse(Exception exception)
7373
{
7474
if (exception is ProductOutOfStockException productOutOfStock)
7575
{
76-
return new ErrorDocument(new Error(HttpStatusCode.Conflict)
76+
return new[]
7777
{
78-
Title = "Product is temporarily available.",
79-
Detail = $"Product {productOutOfStock.ProductId} cannot be ordered at the moment."
80-
});
78+
new Error(HttpStatusCode.Conflict)
79+
{
80+
Title = "Product is temporarily available.",
81+
Detail = $"Product {productOutOfStock.ProductId} " +
82+
"cannot be ordered at the moment."
83+
}
84+
};
8185
}
8286

83-
return base.CreateErrorDocument(exception);
87+
return base.CreateErrorResponse(exception);
8488
}
8589
}
8690

0 commit comments

Comments
 (0)