(feature): improve patch operation details
This commit is contained in:
parent
eaa610a853
commit
9982ee3a8e
@ -1997,7 +1997,7 @@ var patch = new SomePatchRequestModel {
|
|||||||
Username = "Updated Name"
|
Username = "Updated Name"
|
||||||
|
|
||||||
Operations = new Dictionary<string, PatchOperation> {
|
Operations = new Dictionary<string, PatchOperation> {
|
||||||
{ "Username", PartchOperation.Replace }
|
{ "Username", PartchOperation.SetField }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -23,5 +23,11 @@ public abstract class PatchRequestModelBase : RequestModelBase {
|
|||||||
if (!HasNonNullPatchField) {
|
if (!HasNonNullPatchField) {
|
||||||
yield return new ValidationResult("At least one patch field must be provided", new string[] { "PatchField" });
|
yield return new ValidationResult("At least one patch field must be provided", new string[] { "PatchField" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var operation in Operations) {
|
||||||
|
if (!Enum.IsDefined(typeof(PatchOperation), operation.Value)) {
|
||||||
|
yield return new ValidationResult($"Invalid patch operation '{operation.Value}' for property '{operation.Key}'", new string[] { operation.Key });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<!-- NuGet package metadata -->
|
<!-- NuGet package metadata -->
|
||||||
<PackageId>MaksIT.Core</PackageId>
|
<PackageId>MaksIT.Core</PackageId>
|
||||||
<Version>1.2.3</Version>
|
<Version>1.2.4</Version>
|
||||||
<Authors>Maksym Sadovnychyy</Authors>
|
<Authors>Maksym Sadovnychyy</Authors>
|
||||||
<Company>MAKS-IT</Company>
|
<Company>MAKS-IT</Company>
|
||||||
<Product>MaksIT.Core</Product>
|
<Product>MaksIT.Core</Product>
|
||||||
|
|||||||
@ -3,22 +3,37 @@
|
|||||||
public enum PatchOperation {
|
public enum PatchOperation {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When you need to replace some field, or relpace item in collection
|
/// When you need to set or replace a normal field
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Replace,
|
SetField,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When you need to set some field, or add item to collection
|
/// When you need to set a normal field to null
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Add,
|
RemoveField,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When you need to set some field to null, or remove item from collection
|
/// When you need to add an item to a collection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Remove,
|
AddToCollection,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When you need to clear collection
|
/// When you need to remove an item from a collection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Clear
|
RemoveFromCollection,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When you need to replace a collection
|
||||||
|
/// </summary>
|
||||||
|
ReplaceCollection,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When you need to clear a collection
|
||||||
|
/// </summary>
|
||||||
|
ClearCollection,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When you need to set a collection to null
|
||||||
|
/// </summary>
|
||||||
|
RemoveCollection
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user