Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 4ea8de7

Browse files
committed
more explicit json, start of support for Continuation Token
1 parent 9776888 commit 4ea8de7

28 files changed

+156
-14
lines changed

src/MediatR.CommandQuery.Audit/AuditRecord.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Diagnostics.CodeAnalysis;
2+
using System.Text.Json.Serialization;
23

34
using EntityChange;
45

@@ -16,14 +17,17 @@ public class AuditRecord<TKey>
1617
/// <value>
1718
/// The key for the entity.
1819
/// </value>
19-
[NotNull] public TKey Key { get; set; } = default!;
20+
[NotNull]
21+
[JsonPropertyName("key")]
22+
public TKey Key { get; set; } = default!;
2023

2124
/// <summary>
2225
/// Gets or sets the entity name.
2326
/// </summary>
2427
/// <value>
2528
/// The entity name.
2629
/// </value>
30+
[JsonPropertyName("entity")]
2731
public string Entity { get; set; } = null!;
2832

2933
/// <summary>
@@ -32,6 +36,8 @@ public class AuditRecord<TKey>
3236
/// <value>
3337
/// The entity display name.
3438
/// </value>
39+
[JsonPropertyName("displayName")]
40+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3541
public string? DisplayName { get; set; }
3642

3743
/// <summary>
@@ -40,22 +46,27 @@ public class AuditRecord<TKey>
4046
/// <value>
4147
/// The description of the entity.
4248
/// </value>
49+
[JsonPropertyName("description")]
50+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4351
public string? Description { get; set; }
4452

4553
/// <summary>
46-
/// Gets or sets the date the change activity occured.
54+
/// Gets or sets the date the change activity occurred.
4755
/// </summary>
4856
/// <value>
49-
/// The date the change activity occured.
57+
/// The date the change activity occurred.
5058
/// </value>
59+
[JsonPropertyName("activityDate")]
5160
public DateTimeOffset ActivityDate { get; set; }
5261

5362
/// <summary>
54-
/// Gets or sets the username that initiated the activity.
63+
/// Gets or sets the user name that initiated the activity.
5564
/// </summary>
5665
/// <value>
57-
/// The username that initiated the activity.
66+
/// The user name that initiated the activity.
5867
/// </value>
68+
[JsonPropertyName("activityBy")]
69+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
5970
public string? ActivityBy { get; set; }
6071

6172
/// <summary>
@@ -64,6 +75,8 @@ public class AuditRecord<TKey>
6475
/// <value>
6576
/// The type of operation.
6677
/// </value>
78+
[JsonPropertyName("operation")]
79+
[JsonConverter(typeof(JsonStringEnumConverter<AuditOperation>))]
6780
public AuditOperation Operation { get; set; }
6881

6982
/// <summary>
@@ -72,6 +85,7 @@ public class AuditRecord<TKey>
7285
/// <value>
7386
/// The list of changes.
7487
/// </value>
88+
[JsonPropertyName("changes")]
89+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
7590
public IReadOnlyCollection<ChangeRecord>? Changes { get; set; }
76-
7791
}

src/MediatR.CommandQuery/Commands/EntityIdentifierCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Security.Claims;
3+
using System.Text.Json.Serialization;
34

45
namespace MediatR.CommandQuery.Commands;
56

@@ -32,5 +33,6 @@ protected EntityIdentifierCommand(ClaimsPrincipal? principal, [NotNull] TKey id)
3233
/// The identifier for this command.
3334
/// </value>
3435
[NotNull]
36+
[JsonPropertyName("id")]
3537
public TKey Id { get; }
3638
}

src/MediatR.CommandQuery/Commands/EntityIdentifiersCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Security.Claims;
3+
using System.Text.Json.Serialization;
34

45
namespace MediatR.CommandQuery.Commands;
56

@@ -31,5 +32,6 @@ protected EntityIdentifiersCommand(ClaimsPrincipal? principal, [NotNull] IReadOn
3132
/// <value>
3233
/// The list of identifiers for this command.
3334
/// </value>
35+
[JsonPropertyName("ids")]
3436
public IReadOnlyCollection<TKey> Ids { get; }
3537
}

src/MediatR.CommandQuery/Commands/EntityModelCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Security.Claims;
3+
using System.Text.Json.Serialization;
34

45
namespace MediatR.CommandQuery.Commands;
56

@@ -34,5 +35,6 @@ protected EntityModelCommand(ClaimsPrincipal? principal, [NotNull] TEntityModel
3435
/// The view model to use for this command.
3536
/// </value>
3637
[NotNull]
38+
[JsonPropertyName("model")]
3739
public TEntityModel Model { get; }
3840
}

src/MediatR.CommandQuery/Commands/EntityPatchCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Security.Claims;
3+
using System.Text.Json.Serialization;
34

45
using MediatR.CommandQuery.Definitions;
56
using MediatR.CommandQuery.Services;
@@ -38,6 +39,7 @@ public EntityPatchCommand(ClaimsPrincipal? principal, [NotNull] TKey id, [NotNul
3839
/// <value>
3940
/// The patch.
4041
/// </value>
42+
[JsonPropertyName("patch")]
4143
public JsonPatchDocument Patch { get; }
4244

4345
/// <inheritdoc />

src/MediatR.CommandQuery/Commands/EntityUpdateCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Security.Claims;
3+
using System.Text.Json.Serialization;
34

45
using MediatR.CommandQuery.Definitions;
56
using MediatR.CommandQuery.Services;
@@ -36,6 +37,7 @@ public EntityUpdateCommand(ClaimsPrincipal? principal, [NotNull] TKey id, TUpdat
3637
/// The identifier for entity to update.
3738
/// </value>
3839
[NotNull]
40+
[JsonPropertyName("id")]
3941
public TKey Id { get; }
4042

4143
/// <inheritdoc />

src/MediatR.CommandQuery/Commands/EntityUpsertCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Security.Claims;
3+
using System.Text.Json.Serialization;
34

45
using MediatR.CommandQuery.Definitions;
56
using MediatR.CommandQuery.Services;
@@ -36,6 +37,7 @@ public EntityUpsertCommand(ClaimsPrincipal? principal, [NotNull] TKey id, TUpdat
3637
/// The identifier for entity to update.
3738
/// </value>
3839
[NotNull]
40+
[JsonPropertyName("id")]
3941
public TKey Id { get; }
4042

4143
/// <inheritdoc />

src/MediatR.CommandQuery/Commands/PrincipalCommandBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ protected PrincipalCommandBase(ClaimsPrincipal? principal)
3131
/// <value>
3232
/// The <see cref="ClaimsPrincipal"/> this command is run for.
3333
/// </value>
34+
[JsonPropertyName("principal")]
3435
[JsonConverter(typeof(ClaimsPrincipalConverter))]
36+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3537
public ClaimsPrincipal? Principal { get; }
3638

3739
/// <summary>

src/MediatR.CommandQuery/MediatorJsonContext.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
namespace MediatR.CommandQuery;
77

8-
[JsonSourceGenerationOptions(
9-
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
10-
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase
11-
)]
128
[JsonSerializable(typeof(DispatchRequest))]
139
[JsonSerializable(typeof(ProblemDetails))]
1410
public partial class MediatorJsonContext : JsonSerializerContext;

src/MediatR.CommandQuery/Models/CompleteModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Text.Json.Serialization;
2+
13
namespace MediatR.CommandQuery.Models;
24

35
/// <summary>
@@ -11,6 +13,7 @@ public class CompleteModel
1113
/// <value>
1214
/// <c>true</c> if was successful; otherwise, <c>false</c>.
1315
/// </value>
16+
[JsonPropertyName("successful")]
1417
public bool Successful { get; set; }
1518

1619
/// <summary>
@@ -19,6 +22,8 @@ public class CompleteModel
1922
/// <value>
2023
/// The operation result message.
2124
/// </value>
25+
[JsonPropertyName("message")]
26+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2227
public string? Message { get; set; }
2328

2429
/// <summary>

0 commit comments

Comments
 (0)