General class to represent any API response, success or failure #64186
              
                Unanswered
              
          
                  
                    
                      The-Futurist
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 1 comment
-
| 
         Do you know How to create responses in Minimal API apps? Series: Working with the result pattern may also be worth a read. In your type I'd at least try to reduce the size of it. public class ApiResult<T>
{
-   public bool Success { get; set; }
+   public bool Success => Data is not null;
    public T? Data { get; set; }
    public ProblemDetails? Error { get; set; }
    public string TraceId { get; set; } = default!;
}or use a union like type where  But when you've read the above links, maybe you think different about the approach...  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm seeking to bring consistency to an API server I've developed. I have in various places stuff like:
and
I want to devise a general purpose class that can represent either success or failure (as well as any actual data).
Is something like this a reasonable start:
Beta Was this translation helpful? Give feedback.
All reactions