Skip to content

v2.1.1 hotfix back to develop #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Gets the version suffix from the repo tag
# example: v1.0.0-preview1-final => preview1-final
function Get-Version-Suffix-From-Tag
{
$tag=$env:APPVEYOR_REPO_TAG_NAME
$split=$tag -split "-"
$suffix=$split[1..2]
$final=$suffix -join "-"
return $final
}

$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)

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

echo "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
echo "VERSION-SUFFIX: alpha1-$revision"


If($env:APPVEYOR_REPO_TAG -eq $true) {
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts "
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
$revision = Get-Version-Suffix-From-Tag
echo "VERSION-SUFFIX: $revision"
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision
}
Else {
echo "VERSION-SUFFIX: alpha1-$revision"
echo "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision"
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=alpha1-$revision
}
}
14 changes: 6 additions & 8 deletions src/JsonApiDotNetCore/Formatters/JsonApiReader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using JsonApiDotNetCore.Internal;
using JsonApiDotNetCore.Serialization;
Expand All @@ -16,7 +15,7 @@ public class JsonApiReader : IJsonApiReader
private readonly IJsonApiDeSerializer _deSerializer;
private readonly IJsonApiContext _jsonApiContext;
private readonly ILogger<JsonApiReader> _logger;


public JsonApiReader(IJsonApiDeSerializer deSerializer, IJsonApiContext jsonApiContext, ILoggerFactory loggerFactory)
{
Expand All @@ -37,26 +36,25 @@ public Task<InputFormatterResult> ReadAsync(InputFormatterContext context)
try
{
var body = GetRequestBody(context.HttpContext.Request.Body);
var model = _jsonApiContext.IsRelationshipPath ?
var model = _jsonApiContext.IsRelationshipPath ?
_deSerializer.DeserializeRelationship(body) :
_deSerializer.Deserialize(body);

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

return InputFormatterResult.SuccessAsync(model);
}
catch (JsonSerializationException ex)
{
_logger?.LogError(new EventId(), ex, "An error occurred while de-serializing the payload");
context.HttpContext.Response.StatusCode = 422;
context.ModelState.AddModelError(context.ModelName, ex, context.Metadata);
return InputFormatterResult.FailureAsync();
}
catch(JsonApiException jex)
catch (JsonApiException jex)
{
_logger?.LogError(new EventId(), jex, "An error occurred while de-serializing the payload");
context.HttpContext.Response.StatusCode = jex.GetStatusCode();
context.HttpContext.Response.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(jex.GetError())));
context.ModelState.AddModelError(context.ModelName, jex, context.Metadata);
return InputFormatterResult.FailureAsync();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/JsonApiDotNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>2.1.0</VersionPrefix>
<VersionPrefix>2.1.1</VersionPrefix>
<TargetFrameworks>netstandard1.6</TargetFrameworks>
<AssemblyName>JsonApiDotNetCore</AssemblyName>
<PackageId>JsonApiDotNetCore</PackageId>
Expand Down