Skip to content

Commit 6682d27

Browse files
committed
Fixed: Add missing 404 status from post resource request
1 parent 30a7e0b commit 6682d27

File tree

26 files changed

+409
-124
lines changed

26 files changed

+409
-124
lines changed

src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@
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": {
236246
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
237247
"content": {
@@ -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": {
@@ -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": {
@@ -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": {
@@ -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": {
@@ -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": {
@@ -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": {
@@ -1889,6 +1899,16 @@
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": {
18931913
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
18941914
"content": {
@@ -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": {
@@ -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": {
@@ -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": {
@@ -2994,6 +3014,16 @@
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": {
29983028
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
29993029
"content": {
@@ -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": {
@@ -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": {
@@ -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": {
@@ -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": {
@@ -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": {

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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/JsonApiDotNetCore.OpenApi/OpenApiEndpointConvention.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,14 @@ private IEnumerable<HttpStatusCode> GetErrorStatusCodesForEndpoint(JsonApiEndpoi
186186
[
187187
HttpStatusCode.BadRequest,
188188
HttpStatusCode.Forbidden,
189+
HttpStatusCode.NotFound,
189190
HttpStatusCode.Conflict,
190191
HttpStatusCode.UnprocessableEntity
191192
],
192193
JsonApiEndpoint.Post =>
193194
[
194195
HttpStatusCode.BadRequest,
196+
HttpStatusCode.NotFound,
195197
HttpStatusCode.Conflict,
196198
HttpStatusCode.UnprocessableEntity
197199
],

src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiOperationDocumentationFilter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ private void ApplyPostResource(OpenApiOperation operation, ResourceType resource
241241
SetResponseDescription(operation.Responses, HttpStatusCode.Forbidden, TextRequestBodyClientId);
242242
}
243243

244+
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, "A related resource does not exist.");
244245
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict);
245246
SetResponseDescription(operation.Responses, HttpStatusCode.UnprocessableEntity, TextRequestBodyValidationFailed);
246247
}
@@ -373,7 +374,7 @@ private void ApplyPostRelationship(OpenApiOperation operation, RelationshipAttri
373374
$"The {rightName} were successfully added, which did not result in additional changes.");
374375

375376
SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad);
376-
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} does not exist.");
377+
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} or a related resource does not exist.");
377378
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict);
378379
}
379380

@@ -406,7 +407,7 @@ relationship is HasOneAttribute
406407
$"The {relationship} relationship was successfully updated, which did not result in additional changes.");
407408

408409
SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad);
409-
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} does not exist.");
410+
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} or a related resource does not exist.");
410411
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict);
411412
}
412413

@@ -423,7 +424,7 @@ private void ApplyDeleteRelationship(OpenApiOperation operation, RelationshipAtt
423424
$"The {rightName} were successfully removed, which did not result in additional changes.");
424425

425426
SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad);
426-
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} does not exist.");
427+
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} or a related resource does not exist.");
427428
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict);
428429
}
429430

test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Games/GamesRequestBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public async Task<GamePrimaryResponseDocument> PostAsync(GamePostRequestDocument
4444
var requestInfo = ToPostRequestInformation(body, requestConfiguration);
4545
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
4646
{"400", ErrorResponseDocument.CreateFromDiscriminatorValue},
47+
{"404", ErrorResponseDocument.CreateFromDiscriminatorValue},
4748
{"409", ErrorResponseDocument.CreateFromDiscriminatorValue},
4849
{"422", ErrorResponseDocument.CreateFromDiscriminatorValue},
4950
};

test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/PlayerGroups/PlayerGroupsRequestBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public async Task<PlayerGroupPrimaryResponseDocument> PostAsync(PlayerGroupPostR
4545
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
4646
{"400", ErrorResponseDocument.CreateFromDiscriminatorValue},
4747
{"403", ErrorResponseDocument.CreateFromDiscriminatorValue},
48+
{"404", ErrorResponseDocument.CreateFromDiscriminatorValue},
4849
{"409", ErrorResponseDocument.CreateFromDiscriminatorValue},
4950
{"422", ErrorResponseDocument.CreateFromDiscriminatorValue},
5051
};

test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/GeneratedCode/Players/PlayersRequestBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public async Task<PlayerPrimaryResponseDocument> PostAsync(PlayerPostRequestDocu
4444
var requestInfo = ToPostRequestInformation(body, requestConfiguration);
4545
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
4646
{"400", ErrorResponseDocument.CreateFromDiscriminatorValue},
47+
{"404", ErrorResponseDocument.CreateFromDiscriminatorValue},
4748
{"409", ErrorResponseDocument.CreateFromDiscriminatorValue},
4849
{"422", ErrorResponseDocument.CreateFromDiscriminatorValue},
4950
};

test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/CountriesRequestBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public async Task<CountryPrimaryResponseDocument> PostAsync(CountryPostRequestDo
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
};

test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/NameValuePairsRequestBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public async Task<NameValuePairPrimaryResponseDocument> PostAsync(NameValuePairP
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
};

test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/NodesRequestBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public async Task<NodePrimaryResponseDocument> PostAsync(NodePostRequestDocument
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
};

test/OpenApiTests/ClientIdGenerationModes/GeneratedSwagger/swagger.g.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@
8181
}
8282
}
8383
},
84+
"404": {
85+
"description": "A related resource does not exist.",
86+
"content": {
87+
"application/vnd.api+json": {
88+
"schema": {
89+
"$ref": "#/components/schemas/errorResponseDocument"
90+
}
91+
}
92+
}
93+
},
8494
"409": {
8595
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
8696
"content": {
@@ -185,6 +195,16 @@
185195
}
186196
}
187197
},
198+
"404": {
199+
"description": "A related resource does not exist.",
200+
"content": {
201+
"application/vnd.api+json": {
202+
"schema": {
203+
"$ref": "#/components/schemas/errorResponseDocument"
204+
}
205+
}
206+
}
207+
},
188208
"409": {
189209
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
190210
"content": {
@@ -279,6 +299,16 @@
279299
}
280300
}
281301
},
302+
"404": {
303+
"description": "A related resource does not exist.",
304+
"content": {
305+
"application/vnd.api+json": {
306+
"schema": {
307+
"$ref": "#/components/schemas/errorResponseDocument"
308+
}
309+
}
310+
}
311+
},
282312
"409": {
283313
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
284314
"content": {

0 commit comments

Comments
 (0)