Skip to content

Commit 3fda100

Browse files
authored
Merge pull request #146 from Research-Institute/master
v2.1.1 hotfix back to develop
2 parents ad8787e + 4a9968a commit 3fda100

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

Build.ps1

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# Gets the version suffix from the repo tag
2+
# example: v1.0.0-preview1-final => preview1-final
3+
function Get-Version-Suffix-From-Tag
4+
{
5+
$tag=$env:APPVEYOR_REPO_TAG_NAME
6+
$split=$tag -split "-"
7+
$suffix=$split[1..2]
8+
$final=$suffix -join "-"
9+
return $final
10+
}
11+
112
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
213
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
314

@@ -10,13 +21,16 @@ dotnet test ./test/NoEntityFrameworkTests/NoEntityFrameworkTests.csproj
1021
dotnet build .\src\JsonApiDotNetCore -c Release
1122

1223
echo "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
13-
echo "VERSION-SUFFIX: alpha1-$revision"
24+
1425

1526
If($env:APPVEYOR_REPO_TAG -eq $true) {
16-
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts "
17-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
27+
$revision = Get-Version-Suffix-From-Tag
28+
echo "VERSION-SUFFIX: $revision"
29+
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
30+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision
1831
}
1932
Else {
33+
echo "VERSION-SUFFIX: alpha1-$revision"
2034
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision"
2135
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision
22-
}
36+
}

src/JsonApiDotNetCore/Formatters/JsonApiReader.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.IO;
3-
using System.Text;
43
using System.Threading.Tasks;
54
using JsonApiDotNetCore.Internal;
65
using JsonApiDotNetCore.Serialization;
@@ -16,7 +15,7 @@ public class JsonApiReader : IJsonApiReader
1615
private readonly IJsonApiDeSerializer _deSerializer;
1716
private readonly IJsonApiContext _jsonApiContext;
1817
private readonly ILogger<JsonApiReader> _logger;
19-
18+
2019

2120
public JsonApiReader(IJsonApiDeSerializer deSerializer, IJsonApiContext jsonApiContext, ILoggerFactory loggerFactory)
2221
{
@@ -37,26 +36,25 @@ public Task<InputFormatterResult> ReadAsync(InputFormatterContext context)
3736
try
3837
{
3938
var body = GetRequestBody(context.HttpContext.Request.Body);
40-
var model = _jsonApiContext.IsRelationshipPath ?
39+
var model = _jsonApiContext.IsRelationshipPath ?
4140
_deSerializer.DeserializeRelationship(body) :
4241
_deSerializer.Deserialize(body);
4342

44-
if(model == null)
43+
if (model == null)
4544
_logger?.LogError("An error occurred while de-serializing the payload");
4645

4746
return InputFormatterResult.SuccessAsync(model);
4847
}
4948
catch (JsonSerializationException ex)
5049
{
5150
_logger?.LogError(new EventId(), ex, "An error occurred while de-serializing the payload");
52-
context.HttpContext.Response.StatusCode = 422;
51+
context.ModelState.AddModelError(context.ModelName, ex, context.Metadata);
5352
return InputFormatterResult.FailureAsync();
5453
}
55-
catch(JsonApiException jex)
54+
catch (JsonApiException jex)
5655
{
5756
_logger?.LogError(new EventId(), jex, "An error occurred while de-serializing the payload");
58-
context.HttpContext.Response.StatusCode = jex.GetStatusCode();
59-
context.HttpContext.Response.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(jex.GetError())));
57+
context.ModelState.AddModelError(context.ModelName, jex, context.Metadata);
6058
return InputFormatterResult.FailureAsync();
6159
}
6260
}

src/JsonApiDotNetCore/JsonApiDotNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<VersionPrefix>2.1.0</VersionPrefix>
3+
<VersionPrefix>2.1.1</VersionPrefix>
44
<TargetFrameworks>netstandard1.6</TargetFrameworks>
55
<AssemblyName>JsonApiDotNetCore</AssemblyName>
66
<PackageId>JsonApiDotNetCore</PackageId>

0 commit comments

Comments
 (0)