Use ContractResolver instead of forcing to lower case (#112)
Addresses #90
This commit is contained in:
parent
e4a412e164
commit
f1efb29b18
|
|
@ -691,12 +691,13 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
{
|
{
|
||||||
foreach (var op in Operations)
|
foreach (var op in Operations)
|
||||||
{
|
{
|
||||||
var untypedOp = new Operation();
|
var untypedOp = new Operation
|
||||||
|
{
|
||||||
untypedOp.op = op.op;
|
op = op.op,
|
||||||
untypedOp.value = op.value;
|
value = op.value,
|
||||||
untypedOp.path = op.path;
|
path = op.path,
|
||||||
untypedOp.from = op.from;
|
from = op.from
|
||||||
|
};
|
||||||
|
|
||||||
allOps.Add(untypedOp);
|
allOps.Add(untypedOp);
|
||||||
}
|
}
|
||||||
|
|
@ -715,11 +716,11 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
path += "/" + position;
|
path += "/" + position;
|
||||||
if (segments.Count == 0)
|
if (segments.Count == 0)
|
||||||
{
|
{
|
||||||
return path.ToLowerInvariant();
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "/" + path.ToLowerInvariant();
|
return "/" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> GetPathSegments(Expression expr)
|
private List<string> GetPathSegments(Expression expr)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
var path = patchDocument.GetPath(p => p.SimpleObject.IntegerList, "-");
|
var path = patchDocument.GetPath(p => p.SimpleObject.IntegerList, "-");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal("/simpleobject/integerlist/-", path);
|
Assert.Equal("/SimpleObject/IntegerList/-", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
var path = patchDocument.GetPath(p => (BaseClass)p.DerivedObject, null);
|
var path = patchDocument.GetPath(p => (BaseClass)p.DerivedObject, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal("/derivedobject", path);
|
Assert.Equal("/DerivedObject", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
|
|
||||||
// get path
|
// get path
|
||||||
var pathToCheck = deserialized.Operations.First().path;
|
var pathToCheck = deserialized.Operations.First().path;
|
||||||
Assert.Equal("/anothername", pathToCheck);
|
Assert.Equal("/AnotherName", pathToCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var pathToCheck = deserialized.Operations.First().path;
|
var pathToCheck = deserialized.Operations.First().path;
|
||||||
Assert.Equal("/stringproperty", pathToCheck);
|
Assert.Equal("/StringProperty", pathToCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var pathToCheck = deserialized.Operations.First().path;
|
var pathToCheck = deserialized.Operations.First().path;
|
||||||
Assert.Equal("/arrayproperty/-", pathToCheck);
|
Assert.Equal("/ArrayProperty/-", pathToCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -209,7 +209,7 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
|
|
||||||
// get path
|
// get path
|
||||||
var pathToCheck = deserialized.Operations.First().path;
|
var pathToCheck = deserialized.Operations.First().path;
|
||||||
Assert.Equal("/anothername", pathToCheck);
|
Assert.Equal("/AnotherName", pathToCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -249,9 +249,9 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var fromPath = deserialized.Operations.First().from;
|
var fromPath = deserialized.Operations.First().from;
|
||||||
Assert.Equal("/stringproperty", fromPath);
|
Assert.Equal("/StringProperty", fromPath);
|
||||||
var toPath = deserialized.Operations.First().path;
|
var toPath = deserialized.Operations.First().path;
|
||||||
Assert.Equal("/stringproperty2", toPath);
|
Assert.Equal("/StringProperty2", toPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -269,7 +269,7 @@ namespace Microsoft.AspNetCore.JsonPatch
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var path = deserialized.Operations.First().path;
|
var path = deserialized.Operations.First().path;
|
||||||
Assert.Equal("/socialsecuritynumber", path);
|
Assert.Equal("/SocialSecurityNumber", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class JsonPropertyWithNoPropertyName
|
private class JsonPropertyWithNoPropertyName
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue