Skip to content

Commit c67b602

Browse files
authored
Merge pull request #1512 from json-api-dotnet/openapi-endpoint-tests
Basic OpenAPI tests for all JSON:API endpoints
2 parents 2724d63 + 8556a30 commit c67b602

File tree

294 files changed

+24085
-754
lines changed

Some content is hidden

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

294 files changed

+24085
-754
lines changed

src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json

+61-40
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,18 @@
232232
}
233233
}
234234
},
235+
"404": {
236+
"description": "A related resource does not exist.",
237+
"content": {
238+
"application/vnd.api+json": {
239+
"schema": {
240+
"$ref": "#/components/schemas/errorResponseDocument"
241+
}
242+
}
243+
}
244+
},
235245
"409": {
236-
"description": "A resource type in the request body is incompatible.",
246+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
237247
"content": {
238248
"application/vnd.api+json": {
239249
"schema": {
@@ -957,7 +967,7 @@
957967
}
958968
},
959969
"404": {
960-
"description": "The person does not exist.",
970+
"description": "The person or a related resource does not exist.",
961971
"content": {
962972
"application/vnd.api+json": {
963973
"schema": {
@@ -967,7 +977,7 @@
967977
}
968978
},
969979
"409": {
970-
"description": "A resource type in the request body is incompatible.",
980+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
971981
"content": {
972982
"application/vnd.api+json": {
973983
"schema": {
@@ -1025,7 +1035,7 @@
10251035
}
10261036
},
10271037
"404": {
1028-
"description": "The person does not exist.",
1038+
"description": "The person or a related resource does not exist.",
10291039
"content": {
10301040
"application/vnd.api+json": {
10311041
"schema": {
@@ -1035,7 +1045,7 @@
10351045
}
10361046
},
10371047
"409": {
1038-
"description": "A resource type in the request body is incompatible.",
1048+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
10391049
"content": {
10401050
"application/vnd.api+json": {
10411051
"schema": {
@@ -1093,7 +1103,7 @@
10931103
}
10941104
},
10951105
"404": {
1096-
"description": "The person does not exist.",
1106+
"description": "The person or a related resource does not exist.",
10971107
"content": {
10981108
"application/vnd.api+json": {
10991109
"schema": {
@@ -1103,7 +1113,7 @@
11031113
}
11041114
},
11051115
"409": {
1106-
"description": "A resource type in the request body is incompatible.",
1116+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
11071117
"content": {
11081118
"application/vnd.api+json": {
11091119
"schema": {
@@ -1509,7 +1519,7 @@
15091519
}
15101520
},
15111521
"404": {
1512-
"description": "The person does not exist.",
1522+
"description": "The person or a related resource does not exist.",
15131523
"content": {
15141524
"application/vnd.api+json": {
15151525
"schema": {
@@ -1519,7 +1529,7 @@
15191529
}
15201530
},
15211531
"409": {
1522-
"description": "A resource type in the request body is incompatible.",
1532+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
15231533
"content": {
15241534
"application/vnd.api+json": {
15251535
"schema": {
@@ -1577,7 +1587,7 @@
15771587
}
15781588
},
15791589
"404": {
1580-
"description": "The person does not exist.",
1590+
"description": "The person or a related resource does not exist.",
15811591
"content": {
15821592
"application/vnd.api+json": {
15831593
"schema": {
@@ -1587,7 +1597,7 @@
15871597
}
15881598
},
15891599
"409": {
1590-
"description": "A resource type in the request body is incompatible.",
1600+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
15911601
"content": {
15921602
"application/vnd.api+json": {
15931603
"schema": {
@@ -1645,7 +1655,7 @@
16451655
}
16461656
},
16471657
"404": {
1648-
"description": "The person does not exist.",
1658+
"description": "The person or a related resource does not exist.",
16491659
"content": {
16501660
"application/vnd.api+json": {
16511661
"schema": {
@@ -1655,7 +1665,7 @@
16551665
}
16561666
},
16571667
"409": {
1658-
"description": "A resource type in the request body is incompatible.",
1668+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
16591669
"content": {
16601670
"application/vnd.api+json": {
16611671
"schema": {
@@ -1889,8 +1899,18 @@
18891899
}
18901900
}
18911901
},
1902+
"404": {
1903+
"description": "A related resource does not exist.",
1904+
"content": {
1905+
"application/vnd.api+json": {
1906+
"schema": {
1907+
"$ref": "#/components/schemas/errorResponseDocument"
1908+
}
1909+
}
1910+
}
1911+
},
18921912
"409": {
1893-
"description": "A resource type in the request body is incompatible.",
1913+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
18941914
"content": {
18951915
"application/vnd.api+json": {
18961916
"schema": {
@@ -2614,7 +2634,7 @@
26142634
}
26152635
},
26162636
"404": {
2617-
"description": "The tag does not exist.",
2637+
"description": "The tag or a related resource does not exist.",
26182638
"content": {
26192639
"application/vnd.api+json": {
26202640
"schema": {
@@ -2624,7 +2644,7 @@
26242644
}
26252645
},
26262646
"409": {
2627-
"description": "A resource type in the request body is incompatible.",
2647+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
26282648
"content": {
26292649
"application/vnd.api+json": {
26302650
"schema": {
@@ -2682,7 +2702,7 @@
26822702
}
26832703
},
26842704
"404": {
2685-
"description": "The tag does not exist.",
2705+
"description": "The tag or a related resource does not exist.",
26862706
"content": {
26872707
"application/vnd.api+json": {
26882708
"schema": {
@@ -2692,7 +2712,7 @@
26922712
}
26932713
},
26942714
"409": {
2695-
"description": "A resource type in the request body is incompatible.",
2715+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
26962716
"content": {
26972717
"application/vnd.api+json": {
26982718
"schema": {
@@ -2750,7 +2770,7 @@
27502770
}
27512771
},
27522772
"404": {
2753-
"description": "The tag does not exist.",
2773+
"description": "The tag or a related resource does not exist.",
27542774
"content": {
27552775
"application/vnd.api+json": {
27562776
"schema": {
@@ -2760,7 +2780,7 @@
27602780
}
27612781
},
27622782
"409": {
2763-
"description": "A resource type in the request body is incompatible.",
2783+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
27642784
"content": {
27652785
"application/vnd.api+json": {
27662786
"schema": {
@@ -2994,8 +3014,18 @@
29943014
}
29953015
}
29963016
},
3017+
"404": {
3018+
"description": "A related resource does not exist.",
3019+
"content": {
3020+
"application/vnd.api+json": {
3021+
"schema": {
3022+
"$ref": "#/components/schemas/errorResponseDocument"
3023+
}
3024+
}
3025+
}
3026+
},
29973027
"409": {
2998-
"description": "A resource type in the request body is incompatible.",
3028+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
29993029
"content": {
30003030
"application/vnd.api+json": {
30013031
"schema": {
@@ -3719,7 +3749,7 @@
37193749
}
37203750
},
37213751
"404": {
3722-
"description": "The todoItem does not exist.",
3752+
"description": "The todoItem or a related resource does not exist.",
37233753
"content": {
37243754
"application/vnd.api+json": {
37253755
"schema": {
@@ -3729,7 +3759,7 @@
37293759
}
37303760
},
37313761
"409": {
3732-
"description": "A resource type in the request body is incompatible.",
3762+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
37333763
"content": {
37343764
"application/vnd.api+json": {
37353765
"schema": {
@@ -4135,7 +4165,7 @@
41354165
}
41364166
},
41374167
"404": {
4138-
"description": "The todoItem does not exist.",
4168+
"description": "The todoItem or a related resource does not exist.",
41394169
"content": {
41404170
"application/vnd.api+json": {
41414171
"schema": {
@@ -4145,7 +4175,7 @@
41454175
}
41464176
},
41474177
"409": {
4148-
"description": "A resource type in the request body is incompatible.",
4178+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
41494179
"content": {
41504180
"application/vnd.api+json": {
41514181
"schema": {
@@ -4551,7 +4581,7 @@
45514581
}
45524582
},
45534583
"404": {
4554-
"description": "The todoItem does not exist.",
4584+
"description": "The todoItem or a related resource does not exist.",
45554585
"content": {
45564586
"application/vnd.api+json": {
45574587
"schema": {
@@ -4561,7 +4591,7 @@
45614591
}
45624592
},
45634593
"409": {
4564-
"description": "A resource type in the request body is incompatible.",
4594+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
45654595
"content": {
45664596
"application/vnd.api+json": {
45674597
"schema": {
@@ -4619,7 +4649,7 @@
46194649
}
46204650
},
46214651
"404": {
4622-
"description": "The todoItem does not exist.",
4652+
"description": "The todoItem or a related resource does not exist.",
46234653
"content": {
46244654
"application/vnd.api+json": {
46254655
"schema": {
@@ -4629,7 +4659,7 @@
46294659
}
46304660
},
46314661
"409": {
4632-
"description": "A resource type in the request body is incompatible.",
4662+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
46334663
"content": {
46344664
"application/vnd.api+json": {
46354665
"schema": {
@@ -4687,7 +4717,7 @@
46874717
}
46884718
},
46894719
"404": {
4690-
"description": "The todoItem does not exist.",
4720+
"description": "The todoItem or a related resource does not exist.",
46914721
"content": {
46924722
"application/vnd.api+json": {
46934723
"schema": {
@@ -4697,7 +4727,7 @@
46974727
}
46984728
},
46994729
"409": {
4700-
"description": "A resource type in the request body is incompatible.",
4730+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
47014731
"content": {
47024732
"application/vnd.api+json": {
47034733
"schema": {
@@ -5255,9 +5285,6 @@
52555285
"$ref": "#/components/schemas/dataInResponse"
52565286
},
52575287
{
5258-
"required": [
5259-
"links"
5260-
],
52615288
"type": "object",
52625289
"properties": {
52635290
"attributes": {
@@ -5647,9 +5674,6 @@
56475674
"$ref": "#/components/schemas/dataInResponse"
56485675
},
56495676
{
5650-
"required": [
5651-
"links"
5652-
],
56535677
"type": "object",
56545678
"properties": {
56555679
"attributes": {
@@ -6157,9 +6181,6 @@
61576181
"$ref": "#/components/schemas/dataInResponse"
61586182
},
61596183
{
6160-
"required": [
6161-
"links"
6162-
],
61636184
"type": "object",
61646185
"properties": {
61656186
"attributes": {

src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/PeopleRequestBuilder.cs

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public async Task<PersonPrimaryResponseDocument> PostAsync(PersonPostRequestDocu
8686
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
8787
{"400", ErrorResponseDocument.CreateFromDiscriminatorValue},
8888
{"403", ErrorResponseDocument.CreateFromDiscriminatorValue},
89+
{"404", ErrorResponseDocument.CreateFromDiscriminatorValue},
8990
{"409", ErrorResponseDocument.CreateFromDiscriminatorValue},
9091
{"422", ErrorResponseDocument.CreateFromDiscriminatorValue},
9192
};

src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/TagsRequestBuilder.cs

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public async Task<TagPrimaryResponseDocument> PostAsync(TagPostRequestDocument b
8686
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
8787
{"400", ErrorResponseDocument.CreateFromDiscriminatorValue},
8888
{"403", ErrorResponseDocument.CreateFromDiscriminatorValue},
89+
{"404", ErrorResponseDocument.CreateFromDiscriminatorValue},
8990
{"409", ErrorResponseDocument.CreateFromDiscriminatorValue},
9091
{"422", ErrorResponseDocument.CreateFromDiscriminatorValue},
9192
};

src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/TodoItemsRequestBuilder.cs

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public async Task<TodoItemPrimaryResponseDocument> PostAsync(TodoItemPostRequest
8686
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
8787
{"400", ErrorResponseDocument.CreateFromDiscriminatorValue},
8888
{"403", ErrorResponseDocument.CreateFromDiscriminatorValue},
89+
{"404", ErrorResponseDocument.CreateFromDiscriminatorValue},
8990
{"409", ErrorResponseDocument.CreateFromDiscriminatorValue},
9091
{"422", ErrorResponseDocument.CreateFromDiscriminatorValue},
9192
};

src/Examples/OpenApiNSwagClientExample/Worker.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
4545
private static Task<ApiResponse<PersonCollectionResponseDocument?>> GetPeopleAsync(ExampleApiClient apiClient, IDictionary<string, string?> queryString,
4646
string? ifNoneMatch, CancellationToken cancellationToken)
4747
{
48-
return ApiResponse.TranslateAsync(() => apiClient.GetPersonCollectionAsync(queryString, ifNoneMatch, cancellationToken));
48+
return ApiResponse.TranslateAsync(async () => await apiClient.GetPersonCollectionAsync(queryString, ifNoneMatch, cancellationToken));
4949
}
5050

5151
private async Task UpdatePersonAsync(CancellationToken cancellationToken)
@@ -66,7 +66,7 @@ private async Task UpdatePersonAsync(CancellationToken cancellationToken)
6666
using (_apiClient.WithPartialAttributeSerialization<PersonPatchRequestDocument, PersonAttributesInPatchRequest>(patchRequest,
6767
person => person.FirstName))
6868
{
69-
_ = await ApiResponse.TranslateAsync(() => _apiClient.PatchPersonAsync(patchRequest.Data.Id, null, patchRequest, cancellationToken));
69+
_ = await ApiResponse.TranslateAsync(async () => await _apiClient.PatchPersonAsync(patchRequest.Data.Id, null, patchRequest, cancellationToken));
7070
}
7171
}
7272
}

src/JsonApiDotNetCore.OpenApi/ActionDescriptorExtensions.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ public static MethodInfo GetActionMethod(this ActionDescriptor descriptor)
2020
{
2121
ArgumentGuard.NotNull(descriptor);
2222

23-
IFilterMetadata? filterMetadata = descriptor.FilterDescriptors.Select(filterDescriptor => filterDescriptor.Filter)
24-
.OfType<TFilterMetaData>().FirstOrDefault();
25-
26-
return (TFilterMetaData?)filterMetadata;
23+
return descriptor.FilterDescriptors.Select(filterDescriptor => filterDescriptor.Filter).OfType<TFilterMetaData>().FirstOrDefault();
2724
}
2825

2926
public static ControllerParameterDescriptor? GetBodyParameterDescriptor(this ActionDescriptor descriptor)

0 commit comments

Comments
 (0)