Web API帮助页面不显示扩展对象的文档

时间:2017-01-11 21:40:51

标签: c# asp.net-web-api asp.net-web-api2 xml-documentation asp.net-web-api-helppages

Tldr;

我有一个从另一个对象扩展的对象。

/// <summary>
/// Represents the result of an operation
/// </summary>
[DataContract]
public class ApiResult<T> : ApiResult
{
    /// <summary>
    /// The requested data
    /// </summary>
    [DataMember]
    public T Data { get; private set; }

    /// <summary>
    /// Test
    /// </summary>
    [DataMember]
    public string Test { get; private set; }

ApiResult的每个属性都会被记录,但不会记录ApiResult<T>的属性:

Documentation

为什么扩展对象的文档说明是空白的?我希望我的<summary>在这里使用。我怎样才能展示它?

更多详情

以下是完整代码:

/// <summary>
/// Represents the result of an operation
/// </summary>
//[DataContract(Name = "ApiResult")]
public class ApiResult
{
    /// <summary>
    /// Indicates if the operation was performed successfull. If an error occured more Information are available in ErrorCode and Message.
    /// </summary>
    [DataMember]
    public bool IsSuccess { get; private set; }

    /// <summary>
    /// A programmable static reason, if the operation was not successfull. This can be ignored on successfull state.
    /// </summary>
    [DataMember]
    public int ErrorCode { get; private set; }

    /// <summary>
    /// Additional information about the error, if the operation was not successfull. This is only for Information purpose. Use the ErrorCode for business conditions instead.
    /// </summary>
    [DataMember]
    public string Message { get; private set; }

    /// <summary>
    /// Creates a Success Result
    /// </summary>
    public ApiResult()
    {
        IsSuccess = true;
        ErrorCode = 0;
        Message = "ok";
    }

    /// <summary>
    /// Creates a Error Result
    /// </summary>
    /// <param name="errorCode">The error code</param>
    /// <param name="message">The message</param>
    public ApiResult(int errorCode, string message)
    {
        IsSuccess = false;
        ErrorCode = errorCode;
        Message = message;
    }
}

/// <summary>
/// Represents the result of an operation
/// </summary>
//[DataContract(Name = "ApiResult")]
public class ApiResult<T> : ApiResult
{
    /// <summary>
    /// The requested data
    /// </summary>
    [DataMember]
    public T Data { get; private set; }

    /// <summary>
    /// Test
    /// </summary>
    [DataMember]
    public string Test { get; private set; }

    /// <summary>
    /// Creates a Success Result without having an actualy Result
    /// <remarks>This constructor should not be used. A parameterless constructor is needed for the automatic generation of a Documentation Example.</remarks>
    /// </summary>
    //[EditorBrowsable(EditorBrowsableState.Never)]
    //[Obsolete("Use the nongeneric version of ApiResult instead. This CTOR is only to support XmlSerialization.")]
    public ApiResult()
    {
    }

    /// <summary>
    /// Creates a Success Result
    /// </summary>
    /// <param name="data">The data</param>
    public ApiResult(T data)
    {
        Data = data;
    }

    /// <summary>
    /// Creates a Error Result
    /// </summary>
    /// <param name="errorCode">The error code</param>
    /// <param name="message">The message</param>
    public ApiResult(int errorCode, string message) : base(errorCode, message)
    {
    }

}

这是我的方法签名:

public ApiResult<CardInfo> GetCardInfo(string cardNumber)

以防万一,这是我的CardInfo - 班级:

/// <summary>
/// Information about a card
/// </summary>
public class CardInfo
{
    /// <summary>
    /// Card Type
    /// </summary>
    public string CardType { get; set; }

    /// <summary>
    /// Represents the current credit on card.
    /// Prepaid cards: CurrentValue represents the current credit on card.
    /// Postpaid: CurrentValue represents the monthly available credit amount.
    /// </summary>
    public decimal CurrentValue { get; set; }
}

我的问题是关于Web API 2中自动生成的帮助页面。如果扩展了Class,则在helppage上忽略<summary>

0 个答案:

没有答案
相关问题