Skip to content

Commit ae81441

Browse files
authored
Merge pull request #1150 from json-api-dotnet/merge-v5-into-openapi
Merge v5 into openapi
2 parents 3e01136 + c73c2ad commit ae81441

File tree

331 files changed

+11853
-2677
lines changed

Some content is hidden

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

331 files changed

+11853
-2677
lines changed

.config/dotnet-tools.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"isRoot": true,
44
"tools": {
55
"jetbrains.resharper.globaltools": {
6-
"version": "2021.3.0",
6+
"version": "2021.3.4",
77
"commands": [
88
"jb"
99
]
1010
},
1111
"regitlint": {
12-
"version": "6.0.6",
12+
"version": "6.0.8",
1313
"commands": [
1414
"regitlint"
1515
]
@@ -21,7 +21,7 @@
2121
]
2222
},
2323
"dotnet-reportgenerator-globaltool": {
24-
"version": "5.0.0",
24+
"version": "5.1.3",
2525
"commands": [
2626
"reportgenerator"
2727
]

.github/CONTRIBUTING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,23 @@ public sealed class AppDbContext : DbContext
8888
}
8989
```
9090

91+
## Creating a release (for maintainers)
92+
93+
- Verify documentation is up-to-date
94+
- Bump the package version in Directory.Build.props
95+
- Create a GitHub release
96+
- Update https://github.com/json-api-dotnet/JsonApiDotNetCore.MongoDb to consume the new version and release
97+
- Create a new branch in https://github.com/json-api-dotnet/MigrationGuide and update README.md in master
98+
9199
## Backporting and hotfixes (for maintainers)
92100

93101
- Checkout the version you want to apply the feature on top of and create a new branch to release the new version:
94102
```
95103
git checkout tags/v2.5.1 -b release/2.5.2
96104
```
97105
- Cherrypick the merge commit: `git cherry-pick {git commit SHA}`
98-
- Bump the package version in the csproj
99-
- Make any other compatibility, documentation or tooling related changes
106+
- Bump the package version in Directory.Build.props
107+
- Make any other compatibility, documentation, or tooling related changes
100108
- Push the branch to origin and verify the build
101109
- Once the build is verified, create a GitHub release, tagging the release branch
102110
- Open a PR back to master with any other additions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ Closes #{ISSUE_NUMBER}
77
- [ ] Complies with our [contributing guidelines](./.github/CONTRIBUTING.md)
88
- [ ] Adapted tests
99
- [ ] Documentation updated
10-
- [ ] Created issue to update [Templates](https://github.com/json-api-dotnet/Templates/issues/new): {ISSUE_NUMBER}

CodingGuidelines.ruleset

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
<Rule Id="AV1555" Action="Warning" />
1515
<Rule Id="AV1564" Action="Info" />
1616
<Rule Id="AV1568" Action="Warning" />
17+
<Rule Id="AV1580" Action="None" />
1718
<Rule Id="AV1706" Action="Warning" />
1819
<Rule Id="AV1710" Action="Info" />
1920
<Rule Id="AV1711" Action="Info" />
2021
<Rule Id="AV1738" Action="Warning" />
2122
<Rule Id="AV1739" Action="Warning" />
2223
<Rule Id="AV1745" Action="Warning" />
2324
<Rule Id="AV1755" Action="Warning" />
24-
<Rule Id="AV2210" Action="None" />
25+
<Rule Id="AV2210" Action="Warning" />
2526
<Rule Id="AV2220" Action="Warning" />
2627
<Rule Id="AV2230" Action="Info" />
2728
<Rule Id="AV2305" Action="None" />

Directory.Build.props

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<AspNetVersion>6.0.*</AspNetVersion>
55
<EFCoreVersion>6.0.*</EFCoreVersion>
66
<EFCorePostgresVersion>6.0.*</EFCorePostgresVersion>
7-
<MicrosoftCodeAnalysisVersion>4.*</MicrosoftCodeAnalysisVersion>
8-
<HumanizerVersion>2.*</HumanizerVersion>
7+
<MicrosoftCodeAnalysisVersion>4.1.*</MicrosoftCodeAnalysisVersion>
8+
<HumanizerVersion>2.14.1</HumanizerVersion>
99
<SwashbuckleVersion>6.2.*</SwashbuckleVersion>
10-
<JsonApiDotNetCoreVersionPrefix>5.0.0</JsonApiDotNetCoreVersionPrefix>
10+
<JsonApiDotNetCoreVersionPrefix>5.0.2</JsonApiDotNetCoreVersionPrefix>
1111
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
1212
<WarningLevel>9999</WarningLevel>
1313
<Nullable>enable</Nullable>
@@ -18,7 +18,7 @@
1818

1919
<ItemGroup>
2020
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" PrivateAssets="All" />
21-
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.7.1" PrivateAssets="All" />
21+
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.0" PrivateAssets="All" />
2222
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CSharpGuidelinesAnalyzer.config" Visible="False" />
2323
</ItemGroup>
2424

@@ -28,10 +28,14 @@
2828
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2929
</PropertyGroup>
3030

31+
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
32+
<NoWarn>$(NoWarn);AV2210</NoWarn>
33+
</PropertyGroup>
34+
3135
<!-- Test Project Dependencies -->
3236
<PropertyGroup>
33-
<CoverletVersion>3.1.0</CoverletVersion>
34-
<MoqVersion>4.16.1</MoqVersion>
35-
<TestSdkVersion>17.0.0</TestSdkVersion>
37+
<CoverletVersion>3.1.2</CoverletVersion>
38+
<MoqVersion>4.17.2</MoqVersion>
39+
<TestSdkVersion>17.1.0</TestSdkVersion>
3640
</PropertyGroup>
3741
</Project>

JsonApiDotNetCore.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceGeneratorTests", "tes
5252
EndProject
5353
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.Annotations", "src\JsonApiDotNetCore.Annotations\JsonApiDotNetCore.Annotations.csproj", "{83FF097C-C8C6-477B-9FAB-DF99B84978B5}"
5454
EndProject
55+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabasePerTenantExample", "src\Examples\DatabasePerTenantExample\DatabasePerTenantExample.csproj", "{60334658-BE51-43B3-9C4D-F2BBF56C89CE}"
56+
EndProject
5557
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.OpenApi", "src\JsonApiDotNetCore.OpenApi\JsonApiDotNetCore.OpenApi.csproj", "{71287D6F-6C3B-44B4-9FCA-E78FE3F02289}"
5658
EndProject
5759
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApiTests", "test\OpenApiTests\OpenApiTests.csproj", "{B693DE14-BB28-496F-AB39-B4E674ABCA80}"
@@ -276,6 +278,18 @@ Global
276278
{83FF097C-C8C6-477B-9FAB-DF99B84978B5}.Release|x64.Build.0 = Release|Any CPU
277279
{83FF097C-C8C6-477B-9FAB-DF99B84978B5}.Release|x86.ActiveCfg = Release|Any CPU
278280
{83FF097C-C8C6-477B-9FAB-DF99B84978B5}.Release|x86.Build.0 = Release|Any CPU
281+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
282+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
283+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Debug|x64.ActiveCfg = Debug|Any CPU
284+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Debug|x64.Build.0 = Debug|Any CPU
285+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Debug|x86.ActiveCfg = Debug|Any CPU
286+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Debug|x86.Build.0 = Debug|Any CPU
287+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
288+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Release|Any CPU.Build.0 = Release|Any CPU
289+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Release|x64.ActiveCfg = Release|Any CPU
290+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Release|x64.Build.0 = Release|Any CPU
291+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Release|x86.ActiveCfg = Release|Any CPU
292+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE}.Release|x86.Build.0 = Release|Any CPU
279293
{71287D6F-6C3B-44B4-9FCA-E78FE3F02289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
280294
{71287D6F-6C3B-44B4-9FCA-E78FE3F02289}.Debug|Any CPU.Build.0 = Debug|Any CPU
281295
{71287D6F-6C3B-44B4-9FCA-E78FE3F02289}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -358,6 +372,7 @@ Global
358372
{87D066F9-3540-4AC7-A748-134900969EE5} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
359373
{0E0B5C51-F7E2-4F40-A4E4-DED0E9731DC9} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
360374
{83FF097C-C8C6-477B-9FAB-DF99B84978B5} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}
375+
{60334658-BE51-43B3-9C4D-F2BBF56C89CE} = {026FBC6C-AF76-4568-9B87-EC73457899FD}
361376
{71287D6F-6C3B-44B4-9FCA-E78FE3F02289} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}
362377
{B693DE14-BB28-496F-AB39-B4E674ABCA80} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
363378
{5ADAA902-5A75-4ECB-B4B4-03291D63CE9C} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}

JsonApiDotNetCore.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,10 @@ $left$ = $right$;</s:String>
632632
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=B3D9EE6B4EC62A4F961EB15F9ADEC2C6/ReplacePattern/@EntryValue">$collection$.IsNullOrEmpty()</s:String>
633633
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=B3D9EE6B4EC62A4F961EB15F9ADEC2C6/SearchPattern/@EntryValue">$collection$ == null || !$collection$.Any()</s:String>
634634
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=B3D9EE6B4EC62A4F961EB15F9ADEC2C6/Severity/@EntryValue">WARNING</s:String>
635+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Accurize/@EntryIndexedValue">True</s:Boolean>
635636
<s:Boolean x:Key="/Default/UserDictionary/Words/=appsettings/@EntryIndexedValue">True</s:Boolean>
636637
<s:Boolean x:Key="/Default/UserDictionary/Words/=Assignee/@EntryIndexedValue">True</s:Boolean>
638+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Contoso/@EntryIndexedValue">True</s:Boolean>
637639
<s:Boolean x:Key="/Default/UserDictionary/Words/=Injectables/@EntryIndexedValue">True</s:Boolean>
638640
<s:Boolean x:Key="/Default/UserDictionary/Words/=jsonapi/@EntryIndexedValue">True</s:Boolean>
639641
<s:Boolean x:Key="/Default/UserDictionary/Words/=linebreaks/@EntryIndexedValue">True</s:Boolean>

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ The ultimate goal of this library is to eliminate as much boilerplate as possibl
1717

1818
These are some steps you can take to help you understand what this project is and how you can use it:
1919

20-
- [What is JSON:API and why should I use it?](https://nordicapis.com/the-benefits-of-using-json-api/)
21-
- [The JSON:API specification](http://jsonapi.org/format/)
22-
- Demo [Video](https://youtu.be/KAMuo6K7VcE), [Blog](https://dev.to/wunki/getting-started-5dkl)
23-
- [Our documentation](https://www.jsonapi.net/)
24-
- [Check out the example projects](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/master/src/Examples)
25-
- [Embercasts: Full Stack Ember with ASP.NET Core](https://www.embercasts.com/course/full-stack-ember-with-dotnet/watch/whats-in-this-course-cs)
20+
### About
21+
- [What is JSON:API and why should I use it?](https://nordicapis.com/the-benefits-of-using-json-api/) (blog, 2017)
22+
- [Pragmatic JSON:API Design](https://www.youtube.com/watch?v=3jBJOga4e2Y) (video, 2017)
23+
- [JSON:API and JsonApiDotNetCore](https://www.youtube.com/watch?v=79Oq0HOxyeI) (video, 2021)
24+
- [JsonApiDotNetCore Release 4.0](https://dev.to/wunki/getting-started-5dkl) (blog, 2020)
25+
- [JSON:API, .Net Core, EmberJS](https://youtu.be/KAMuo6K7VcE) (video, 2017)
26+
- [Embercasts: Full Stack Ember with ASP.NET Core](https://www.embercasts.com/course/full-stack-ember-with-dotnet/watch/whats-in-this-course-cs) (paid course, 2017)
27+
28+
### Official documentation
29+
- [The JSON:API specification](https://jsonapi.org/format/1.1/)
30+
- [JsonApiDotNetCore website](https://www.jsonapi.net/)
2631
- [Roadmap](ROADMAP.md)
2732

2833
## Related Projects
@@ -79,7 +84,7 @@ See also our [versioning policy](./VERSIONING_POLICY.md).
7984
| | | Core 3.1 | 5 |
8085
| | | 5 | 5 |
8186
| | | 6 | 5 |
82-
| v5.x | Pre-release | 6 | 6 |
87+
| v5.x | Stable | 6 | 6 |
8388

8489
## Contributing
8590

ROADMAP.md

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,12 @@ This document provides an overview of the direction this project is heading and
44

55
> Disclaimer: This is an open source project. The available time of our contributors varies and therefore we do not plan release dates. This document expresses our current intent, which may change over time.
66
7-
## v4.x
7+
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.
88

9-
We've completed active development on v4.x, but we'll still fix important bugs or add small enhancements on request that don't require breaking changes nor lots of testing.
10-
11-
## v5.x
12-
13-
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.
14-
15-
- [x] Remove Resource Hooks [#1025](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1025)
16-
- [x] Update to .NET 5 with EF Core 5 [#1026](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1026)
17-
- [x] Native many-to-many [#935](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/935)
18-
- [x] Refactorings [#1027](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1027) [#944](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/944)
19-
- [x] Tweak trace logging [#1033](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1033)
20-
- [x] Instrumentation [#1032](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1032)
21-
- [x] Optimized delete to-many [#1030](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1030)
22-
- [x] Support System.Text.Json [#664](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/664) [#999](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/999) [1077](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1077) [1078](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1078)
23-
- [x] Optimize IIdentifiable to ResourceObject conversion [#1028](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1028) [#1024](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1024) [#233](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/233)
24-
- [x] Nullable reference types [#1029](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1029)
25-
- [x] Improved paging links [#1010](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1010)
26-
- [x] Configuration validation [#170](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/170)
27-
- [x] Auto-generated controllers [#732](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/732) [#365](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/365)
28-
- [x] Support .NET 6 with EF Core 6 [#1109](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1109)
29-
- [x] Extract annotations into separate package [#730](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/730)
30-
31-
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.
32-
33-
- Optimistic concurrency [#1004](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1004)
9+
- Optimistic concurrency [#1119](https://github.com/json-api-dotnet/JsonApiDotNetCore/pull/1119)
3410
- OpenAPI (Swagger) [#1046](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/1046)
3511
- Fluent API [#776](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/776)
36-
- Resource inheritance [#844](https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/844)
37-
- Idempotency
12+
- Idempotency [#1132](https://github.com/json-api-dotnet/JsonApiDotNetCore/pull/1132)
3813

3914
## Feedback
4015

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ for:
8383
- provider: NuGet
8484
skip_symbols: false
8585
api_key:
86-
secure: OBYPCgp3WCuwkDRMuZ9a4QcBdTja/lqlUwZ+Yl5VHqooSJRVTYKP5y15XK0fuHsZ
86+
secure: S9fkLwmhi7w+DGouXYqYq/1PGocnYo8UBUKwv+BGpWHnzE6yHZEYth3j/XJ9Ydsa
8787
on:
8888
branch: master
8989
appveyor_repo_tag: true
9090
- provider: NuGet
9191
skip_symbols: false
9292
api_key:
93-
secure: OBYPCgp3WCuwkDRMuZ9a4QcBdTja/lqlUwZ+Yl5VHqooSJRVTYKP5y15XK0fuHsZ
93+
secure: S9fkLwmhi7w+DGouXYqYq/1PGocnYo8UBUKwv+BGpWHnzE6yHZEYth3j/XJ9Ydsa
9494
on:
9595
branch: /release\/.+/
9696
appveyor_repo_tag: true

benchmarks/Serialization/ResourceSerializationBenchmarks.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,19 @@ protected override IEvaluatedIncludeCache CreateEvaluatedIncludeCache(IResourceG
127127
RelationshipAttribute multi4 = resourceAType.GetRelationshipByPropertyName(nameof(OutgoingResource.Multi4));
128128
RelationshipAttribute multi5 = resourceAType.GetRelationshipByPropertyName(nameof(OutgoingResource.Multi5));
129129

130-
ImmutableArray<ResourceFieldAttribute> chain = ImmutableArray.Create<ResourceFieldAttribute>(single2, single3, multi4, multi5);
131-
IEnumerable<ResourceFieldChainExpression> chains = new ResourceFieldChainExpression(chain).AsEnumerable();
132-
133-
var converter = new IncludeChainConverter();
134-
IncludeExpression include = converter.FromRelationshipChains(chains);
130+
var include = new IncludeExpression(new HashSet<IncludeElementExpression>
131+
{
132+
new(single2, new HashSet<IncludeElementExpression>
133+
{
134+
new(single3, new HashSet<IncludeElementExpression>
135+
{
136+
new(multi4, new HashSet<IncludeElementExpression>
137+
{
138+
new(multi5)
139+
}.ToImmutableHashSet())
140+
}.ToImmutableHashSet())
141+
}.ToImmutableHashSet())
142+
}.ToImmutableHashSet());
135143

136144
var cache = new EvaluatedIncludeCache();
137145
cache.Set(include);

benchmarks/Serialization/SerializationBenchmarkBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ public Task OnSetToManyRelationshipAsync<TResource>(TResource leftResource, HasM
180180
return Task.CompletedTask;
181181
}
182182

183-
public Task OnAddToRelationshipAsync<TResource, TId>(TId leftResourceId, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds,
183+
public Task OnAddToRelationshipAsync<TResource>(TResource leftResource, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds,
184184
CancellationToken cancellationToken)
185-
where TResource : class, IIdentifiable<TId>
185+
where TResource : class, IIdentifiable
186186
{
187187
return Task.CompletedTask;
188188
}
@@ -245,7 +245,7 @@ public RelationshipLinks GetRelationshipLinks(RelationshipAttribute relationship
245245

246246
private sealed class FakeMetaBuilder : IMetaBuilder
247247
{
248-
public void Add(IReadOnlyDictionary<string, object?> values)
248+
public void Add(IDictionary<string, object?> values)
249249
{
250250
}
251251

docs/docfx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"src": [
55
{
6-
"files": [ "**/JsonApiDotNetCore.csproj" ],
6+
"files": [ "**/JsonApiDotNetCore.csproj","**/JsonApiDotNetCore.Annotations.csproj" ],
77
"src": "../"
88
}
99
],

docs/usage/errors.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Errors
22

3-
Errors returned will contain only the properties that are set on the `Error` class. Custom fields can be added through `Error.Meta`.
4-
You can create a custom error by throwing a `JsonApiException` (which accepts an `Error` instance), or returning an `Error` instance from an `ActionResult` in a controller.
5-
Please keep in mind that JSON:API requires Title to be a generic message, while Detail should contain information about the specific problem occurence.
3+
Errors returned will contain only the properties that are set on the `ErrorObject` class. Custom fields can be added through `ErrorObject.Meta`.
4+
You can create a custom error by throwing a `JsonApiException` (which accepts an `ErrorObject` instance), or returning an `ErrorObject` instance from an `ActionResult` in a controller.
5+
Please keep in mind that JSON:API requires `Title` to be a generic message, while `Detail` should contain information about the specific problem occurence.
66

77
From a controller method:
88

99
```c#
10-
return Conflict(new Error(HttpStatusCode.Conflict)
10+
return Conflict(new ErrorObject(HttpStatusCode.Conflict)
1111
{
1212
Title = "Target resource was modified by another user.",
1313
Detail = $"User {userName} changed the {resourceField} field on {resourceName} resource."
@@ -17,7 +17,7 @@ return Conflict(new Error(HttpStatusCode.Conflict)
1717
From other code:
1818

1919
```c#
20-
throw new JsonApiException(new Error(HttpStatusCode.Conflict)
20+
throw new JsonApiException(new ErrorObject(HttpStatusCode.Conflict)
2121
{
2222
Title = "Target resource was modified by another user.",
2323
Detail = $"User {userName} changed the {resourceField} field on {resourceName} resource."
@@ -75,7 +75,7 @@ public class CustomExceptionHandler : ExceptionHandler
7575
{
7676
return new[]
7777
{
78-
new Error(HttpStatusCode.Conflict)
78+
new ErrorObject(HttpStatusCode.Conflict)
7979
{
8080
Title = "Product is temporarily available.",
8181
Detail = $"Product {productOutOfStock.ProductId} " +

docs/usage/extensibility/resource-definitions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public class EmployeeDefinition : JsonApiResourceDefinition<Employee, int>
200200
if (existingIncludes.Any(include =>
201201
include.Relationship.Property.Name == nameof(Employee.Manager)))
202202
{
203-
throw new JsonApiException(new Error(HttpStatusCode.BadRequest)
203+
throw new JsonApiException(new ErrorObject(HttpStatusCode.BadRequest)
204204
{
205205
Title = "Including the manager of employees is not permitted."
206206
});

0 commit comments

Comments
 (0)