Skip to content

Commit

Permalink
Explore making responses required and nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Feb 9, 2024
1 parent 0766806 commit dfd1c22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
33 changes: 16 additions & 17 deletions src/Api/SecretsManager/Models/Response/BaseSecretResponseModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Bit.Core.Models.Api;
#nullable enable

using System.ComponentModel.DataAnnotations;
using Bit.Core.Models.Api;
using Bit.Core.SecretsManager.Entities;

namespace Bit.Api.SecretsManager.Models.Response;
Expand All @@ -24,29 +27,25 @@ public BaseSecretResponseModel(Secret secret, string objectName = _objectName) :
Projects = secret.Projects?.Select(p => new SecretResponseInnerProject(p));
}

public BaseSecretResponseModel(string objectName = _objectName) : base(objectName)
{
}

public BaseSecretResponseModel() : base(_objectName)
{
}

public Guid Id { get; set; }
[Required]
public Guid Id { get; }

public Guid OrganizationId { get; set; }
[Required]
public Guid OrganizationId { get; }

public string Key { get; set; }
public string? Key { get; }

public string Value { get; set; }
public string? Value { get; }

public string Note { get; set; }
public string? Note { get; }

public DateTime CreationDate { get; set; }
[Required]
public DateTime CreationDate { get; }

public DateTime RevisionDate { get; set; }
[Required]
public DateTime RevisionDate { get; }

public IEnumerable<SecretResponseInnerProject> Projects { get; set; }
public IEnumerable<SecretResponseInnerProject>? Projects { get; init; }

public class SecretResponseInnerProject
{
Expand Down
4 changes: 0 additions & 4 deletions src/Api/SecretsManager/Models/Response/SecretResponseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ public SecretResponseModel(Secret secret, bool read, bool write) : base(secret,
Write = write;
}

public SecretResponseModel() : base(_objectName)
{
}

public bool Read { get; set; }

public bool Write { get; set; }
Expand Down

0 comments on commit dfd1c22

Please sign in to comment.