Make sure that the /v1/command endpoint actually ignores the parameter default value during json serialization if its null, instead of making it an empty string

This commit is contained in:
Daan Boerlage 2021-11-09 01:44:31 +01:00
parent 4d97201319
commit 09af445436
Signed by: daan
GPG key ID: FCE070E1E4956606
2 changed files with 3 additions and 2 deletions

View file

@ -27,7 +27,7 @@ public class CommandController : ControllerBase
Params = cmd.Parameters.Select(dict => new ResponseCommandParam()
{
Summary = dict.Value.Summary,
Default = dict.Value.DefaultValue,
Default = string.IsNullOrEmpty(dict.Value.DefaultValue) ? null : dict.Value.DefaultValue,
Type = dict.Value.Type
}).ToList()
});

View file

@ -8,7 +8,8 @@ public record ResponseCommandParam
public string Summary { get; set; }
[JsonPropertyName("default")]
public string Default { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Default { get; set; }
[JsonPropertyName("type")]
public string Type { get; set; }