C# 在web API中公开由多个客户端使用的枚举是否是一个错误的设计决策?

C# 在web API中公开由多个客户端使用的枚举是否是一个错误的设计决策?,c#,web-services,asp.net-web-api,C#,Web Services,Asp.net Web Api,我目前正在开发一个restful API(使用web API),供多个客户使用。向消费者公开枚举可以吗?比如 public enum StatusType{Open,Closed} 然后,当客户机调用GetOrder时,我会将此返回给他们: public class Order { public StatusType CurrentStatus{get;set;} public int OrderId{get;set;} } public

我目前正在开发一个restful API(使用web API),供多个客户使用。向消费者公开枚举可以吗?比如

   public enum StatusType{Open,Closed}
然后,当客户机调用GetOrder时,我会将此返回给他们:

   public class Order
    {
      public StatusType CurrentStatus{get;set;}
      public int OrderId{get;set;}
    }
public class Order
{
  public OrderStatus CurrentStatus { get; set; }
  public int OrderId { get; set; }
}
一位开发人员说,不应该这样做,因为我们不应该向客户机使用者公开内部类型,而应该在表单中为此创建一个类

   public class OrderStatus
    {
     public string Status{get;set;}
     public int Id{get;set;}
    }
然后,当客户机调用GetOrder时,我会将此返回给他们:

   public class Order
    {
      public StatusType CurrentStatus{get;set;}
      public int OrderId{get;set;}
    }
public class Order
{
  public OrderStatus CurrentStatus { get; set; }
  public int OrderId { get; set; }
}
请你告诉我我该选哪一个,为什么

谢谢
尼尔

我认为,只要你不暴露内部机制,比如订单可能处于的其他状态,比如等待经理批准,或者你的客户不必担心或根本不应该知道你的其他状态,你就可以了


在我看来,公开一组枚举将允许您的客户机使用标准化的方式与您的应用程序交互

我认为,只要你不暴露内部机制,比如订单可能处于的其他状态,比如等待经理批准,或者你的客户不必担心或者根本不应该知道你的其他状态,你就可以了

在我看来,公开一组枚举将允许您的客户机使用标准化的方式与您的应用程序交互

可能的重复可能的重复