NetCoreForce icon indicating copy to clipboard operation
NetCoreForce copied to clipboard

Request: Extend ErrorResponse model

Open asleire opened this issue 2 years ago • 0 comments

The current ErrorResponse model contains a limited number of properties and is specifically missing the duplicateResut property (no - not a typo)

Since there are likely to be a number of other possible error properties I'd like it if a "catch-all" dictionary property was added to include any unknown properties. This can be achieved using the Newtonsoft.Json JsonExtensionDataAttribute, e.g. by extending the model like this:

  public class ErrorResponse
  {
    /// <summary>Fields related to the error</summary>
    [JsonProperty(PropertyName = "fields")]
    public List<string> Fields { get; set; }

    /// <summary>Error message</summary>
    [JsonProperty(PropertyName = "message")]
    public string Message { get; set; }

    /// <summary>Error code</summary>
    [JsonProperty(PropertyName = "errorCode")]
    public string ErrorCode { get; set; }
    
    /// <summary>Additional error data</summary>
    [JsonExtensionData]
    public Dictionary<string, JToken> AdditionalData { get; set; }
  }

asleire avatar May 02 '23 09:05 asleire