Skip to content

Commit 9ce7e55

Browse files
committed
Fixed: Another cause for 409 Conflict is that another resource with the same ID already exists on post resource request
1 parent d47dd5b commit 9ce7e55

File tree

15 files changed

+147
-147
lines changed

15 files changed

+147
-147
lines changed

src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
}
234234
},
235235
"409": {
236-
"description": "A resource type in the request body is incompatible.",
236+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
237237
"content": {
238238
"application/vnd.api+json": {
239239
"schema": {
@@ -967,7 +967,7 @@
967967
}
968968
},
969969
"409": {
970-
"description": "A resource type in the request body is incompatible.",
970+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
971971
"content": {
972972
"application/vnd.api+json": {
973973
"schema": {
@@ -1035,7 +1035,7 @@
10351035
}
10361036
},
10371037
"409": {
1038-
"description": "A resource type in the request body is incompatible.",
1038+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
10391039
"content": {
10401040
"application/vnd.api+json": {
10411041
"schema": {
@@ -1103,7 +1103,7 @@
11031103
}
11041104
},
11051105
"409": {
1106-
"description": "A resource type in the request body is incompatible.",
1106+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
11071107
"content": {
11081108
"application/vnd.api+json": {
11091109
"schema": {
@@ -1519,7 +1519,7 @@
15191519
}
15201520
},
15211521
"409": {
1522-
"description": "A resource type in the request body is incompatible.",
1522+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
15231523
"content": {
15241524
"application/vnd.api+json": {
15251525
"schema": {
@@ -1587,7 +1587,7 @@
15871587
}
15881588
},
15891589
"409": {
1590-
"description": "A resource type in the request body is incompatible.",
1590+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
15911591
"content": {
15921592
"application/vnd.api+json": {
15931593
"schema": {
@@ -1655,7 +1655,7 @@
16551655
}
16561656
},
16571657
"409": {
1658-
"description": "A resource type in the request body is incompatible.",
1658+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
16591659
"content": {
16601660
"application/vnd.api+json": {
16611661
"schema": {
@@ -1890,7 +1890,7 @@
18901890
}
18911891
},
18921892
"409": {
1893-
"description": "A resource type in the request body is incompatible.",
1893+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
18941894
"content": {
18951895
"application/vnd.api+json": {
18961896
"schema": {
@@ -2624,7 +2624,7 @@
26242624
}
26252625
},
26262626
"409": {
2627-
"description": "A resource type in the request body is incompatible.",
2627+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
26282628
"content": {
26292629
"application/vnd.api+json": {
26302630
"schema": {
@@ -2692,7 +2692,7 @@
26922692
}
26932693
},
26942694
"409": {
2695-
"description": "A resource type in the request body is incompatible.",
2695+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
26962696
"content": {
26972697
"application/vnd.api+json": {
26982698
"schema": {
@@ -2760,7 +2760,7 @@
27602760
}
27612761
},
27622762
"409": {
2763-
"description": "A resource type in the request body is incompatible.",
2763+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
27642764
"content": {
27652765
"application/vnd.api+json": {
27662766
"schema": {
@@ -2995,7 +2995,7 @@
29952995
}
29962996
},
29972997
"409": {
2998-
"description": "A resource type in the request body is incompatible.",
2998+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
29992999
"content": {
30003000
"application/vnd.api+json": {
30013001
"schema": {
@@ -3729,7 +3729,7 @@
37293729
}
37303730
},
37313731
"409": {
3732-
"description": "A resource type in the request body is incompatible.",
3732+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
37333733
"content": {
37343734
"application/vnd.api+json": {
37353735
"schema": {
@@ -4145,7 +4145,7 @@
41454145
}
41464146
},
41474147
"409": {
4148-
"description": "A resource type in the request body is incompatible.",
4148+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
41494149
"content": {
41504150
"application/vnd.api+json": {
41514151
"schema": {
@@ -4561,7 +4561,7 @@
45614561
}
45624562
},
45634563
"409": {
4564-
"description": "A resource type in the request body is incompatible.",
4564+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
45654565
"content": {
45664566
"application/vnd.api+json": {
45674567
"schema": {
@@ -4629,7 +4629,7 @@
46294629
}
46304630
},
46314631
"409": {
4632-
"description": "A resource type in the request body is incompatible.",
4632+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
46334633
"content": {
46344634
"application/vnd.api+json": {
46354635
"schema": {
@@ -4697,7 +4697,7 @@
46974697
}
46984698
},
46994699
"409": {
4700-
"description": "A resource type in the request body is incompatible.",
4700+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
47014701
"content": {
47024702
"application/vnd.api+json": {
47034703
"schema": {

src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiOperationDocumentationFilter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ internal sealed class JsonApiOperationDocumentationFilter : IOperationFilter
3535
private const string TextQueryStringBad = "The query string is invalid.";
3636
private const string TextRequestBodyBad = "The request body is missing or malformed.";
3737
private const string TextQueryStringOrRequestBodyBad = "The query string is invalid or the request body is missing or malformed.";
38-
private const string TextRequestBodyIncompatibleType = "A resource type in the request body is incompatible.";
38+
private const string TextConflict = "The request body contains conflicting information or another resource with the same ID already exists.";
3939
private const string TextRequestBodyIncompatibleIdOrType = "A resource type or identifier in the request body is incompatible.";
4040
private const string TextRequestBodyValidationFailed = "Validation of the request body failed.";
4141
private const string TextRequestBodyClientId = "Client-generated IDs cannot be used at this endpoint.";
@@ -241,7 +241,7 @@ private void ApplyPostResource(OpenApiOperation operation, ResourceType resource
241241
SetResponseDescription(operation.Responses, HttpStatusCode.Forbidden, TextRequestBodyClientId);
242242
}
243243

244-
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextRequestBodyIncompatibleType);
244+
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict);
245245
SetResponseDescription(operation.Responses, HttpStatusCode.UnprocessableEntity, TextRequestBodyValidationFailed);
246246
}
247247

@@ -374,7 +374,7 @@ private void ApplyPostRelationship(OpenApiOperation operation, RelationshipAttri
374374

375375
SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad);
376376
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} does not exist.");
377-
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextRequestBodyIncompatibleType);
377+
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict);
378378
}
379379

380380
private void ApplyPatchRelationship(OpenApiOperation operation, RelationshipAttribute relationship)
@@ -407,7 +407,7 @@ relationship is HasOneAttribute
407407

408408
SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad);
409409
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} does not exist.");
410-
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextRequestBodyIncompatibleType);
410+
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict);
411411
}
412412

413413
private void ApplyDeleteRelationship(OpenApiOperation operation, RelationshipAttribute relationship)
@@ -424,7 +424,7 @@ private void ApplyDeleteRelationship(OpenApiOperation operation, RelationshipAtt
424424

425425
SetResponseDescription(operation.Responses, HttpStatusCode.BadRequest, TextRequestBodyBad);
426426
SetResponseDescription(operation.Responses, HttpStatusCode.NotFound, $"The {singularLeftName} does not exist.");
427-
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextRequestBodyIncompatibleType);
427+
SetResponseDescription(operation.Responses, HttpStatusCode.Conflict, TextConflict);
428428
}
429429

430430
private static RelationshipAttribute GetRelationshipFromRoute(ApiDescription apiDescription, ResourceType resourceType)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
}
8383
},
8484
"409": {
85-
"description": "A resource type in the request body is incompatible.",
85+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
8686
"content": {
8787
"application/vnd.api+json": {
8888
"schema": {
@@ -186,7 +186,7 @@
186186
}
187187
},
188188
"409": {
189-
"description": "A resource type in the request body is incompatible.",
189+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
190190
"content": {
191191
"application/vnd.api+json": {
192192
"schema": {
@@ -280,7 +280,7 @@
280280
}
281281
},
282282
"409": {
283-
"description": "A resource type in the request body is incompatible.",
283+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
284284
"content": {
285285
"application/vnd.api+json": {
286286
"schema": {

test/OpenApiTests/DocComments/DocCommentTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public async Task Endpoints_are_documented()
131131
responsesElement.Should().HaveProperty("201.headers.Location.description", "The URL at which the newly created skyscraper can be retrieved.");
132132
responsesElement.Should().HaveProperty("204.description", "The skyscraper was successfully created, which did not result in additional changes.");
133133
responsesElement.Should().HaveProperty("400.description", "The query string is invalid or the request body is missing or malformed.");
134-
responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible.");
134+
responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists.");
135135
responsesElement.Should().HaveProperty("422.description", "Validation of the request body failed.");
136136
});
137137
});
@@ -384,7 +384,7 @@ public async Task Endpoints_are_documented()
384384
responsesElement.Should().HaveProperty("204.description", "The elevator relationship was successfully updated, which did not result in additional changes.");
385385
responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed.");
386386
responsesElement.Should().HaveProperty("404.description", "The skyscraper does not exist.");
387-
responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible.");
387+
responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists.");
388388
});
389389
});
390390
});
@@ -529,7 +529,7 @@ public async Task Endpoints_are_documented()
529529
responsesElement.Should().HaveProperty("204.description", "The spaces were successfully added, which did not result in additional changes.");
530530
responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed.");
531531
responsesElement.Should().HaveProperty("404.description", "The skyscraper does not exist.");
532-
responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible.");
532+
responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists.");
533533
});
534534
});
535535

@@ -552,7 +552,7 @@ public async Task Endpoints_are_documented()
552552
responsesElement.Should().HaveProperty("204.description", "The spaces relationship was successfully updated, which did not result in additional changes.");
553553
responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed.");
554554
responsesElement.Should().HaveProperty("404.description", "The skyscraper does not exist.");
555-
responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible.");
555+
responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists.");
556556
});
557557
});
558558

@@ -575,7 +575,7 @@ public async Task Endpoints_are_documented()
575575
responsesElement.Should().HaveProperty("204.description", "The spaces were successfully removed, which did not result in additional changes.");
576576
responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed.");
577577
responsesElement.Should().HaveProperty("404.description", "The skyscraper does not exist.");
578-
responsesElement.Should().HaveProperty("409.description", "A resource type in the request body is incompatible.");
578+
responsesElement.Should().HaveProperty("409.description", "The request body contains conflicting information or another resource with the same ID already exists.");
579579
});
580580
});
581581
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
}
234234
},
235235
"409": {
236-
"description": "A resource type in the request body is incompatible.",
236+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
237237
"content": {
238238
"application/vnd.api+json": {
239239
"schema": {
@@ -967,7 +967,7 @@
967967
}
968968
},
969969
"409": {
970-
"description": "A resource type in the request body is incompatible.",
970+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
971971
"content": {
972972
"application/vnd.api+json": {
973973
"schema": {
@@ -1035,7 +1035,7 @@
10351035
}
10361036
},
10371037
"409": {
1038-
"description": "A resource type in the request body is incompatible.",
1038+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
10391039
"content": {
10401040
"application/vnd.api+json": {
10411041
"schema": {
@@ -1103,7 +1103,7 @@
11031103
}
11041104
},
11051105
"409": {
1106-
"description": "A resource type in the request body is incompatible.",
1106+
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
11071107
"content": {
11081108
"application/vnd.api+json": {
11091109
"schema": {

0 commit comments

Comments
 (0)