Microsoft Web API Help page - how to create annotations for parameters
Asked Answered
W

1

7

Recently I've start playing with new web API help page functionality, that was recently added to web API project template, and I have a notice that some "Additional information" column is always 'none'.

enter image description here

After some looking at markup I found that this info should arrive from attributes

 <td class="parameter-annotations">
                    @if (parameter.Annotations.Count > 0)
                    {
                        foreach (var annotation in parameter.Annotations)
                        {
                            <p>@annotation.Documentation</p>
                        }
                    }
                    else
                    {
                        <p>None.</p>
                    }
                </td>

But what kind of attribute I should use, to populate additional information?

Wildermuth answered 29/9, 2014 at 10:47 Comment(0)
K
16

See this site for an example of how to add additional information.

It's basically annotating your model, so in your case it would be something like:-

public class Product
{
    /// <summary>
    ///  The id of the product
    /// </summary>
    [Required]
    public int Id { get; set; }

    /// <summary>
    /// The name of the product
    /// </summary>
    [MaxLength(50)]
    public string Name { get; set; }
}

Which would give you an output like this:-

example output

Kansu answered 24/10, 2014 at 17:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.