Skip to content

Commit 7c40384

Browse files
author
Bart Koelman
committed
Fixed: broke dependency between action results and json:api error document structure
1 parent a99cc59 commit 7c40384

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/JsonApiDotNetCore/Controllers/JsonApiControllerMixin.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ protected IActionResult Error(Error error)
2323
protected IActionResult Errors(IEnumerable<Error> errors)
2424
{
2525
var document = new ErrorDocument(errors.ToList());
26-
return document.AsActionResult();
26+
27+
return new ObjectResult(document)
28+
{
29+
StatusCode = (int) document.GetErrorStatusCode()
30+
};
2731
}
2832
}
2933
}

src/JsonApiDotNetCore/Models/JsonApiDocuments/ErrorDocument.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using System.Net;
4-
using Microsoft.AspNetCore.Mvc;
54

65
namespace JsonApiDotNetCore.Models.JsonApiDocuments
76
{
@@ -37,13 +36,5 @@ public HttpStatusCode GetErrorStatusCode()
3736
var statusCode = int.Parse(statusCodes.Max().ToString()[0] + "00");
3837
return (HttpStatusCode)statusCode;
3938
}
40-
41-
public IActionResult AsActionResult()
42-
{
43-
return new ObjectResult(this)
44-
{
45-
StatusCode = (int)GetErrorStatusCode()
46-
};
47-
}
4839
}
4940
}

0 commit comments

Comments
 (0)