I have created my WebAPI controllers' documentation using HelpPage. I have following model in my web api.

public class InfoModel
{
    [Required]
    public int id { get; set; }

    [Required]
    public string title { get; set; }

    public string status { get; set; }

    public string created_at { get; set; }
}

HelpPage renders InfoModel on help page like this:

{
   "id": 1,
   "title": "Sample string 2",
   "status": "Sample string 3",
   "created_at": "Sample string 4"
}

Using [Required] attribute from Model Validation and I want to highlight properties having [Required] attribute. How can I customize HelpPage MVC plugin to bold "id" and "title", so that user may know that these attributes are REQUIRED:

{

"id": 1,

"title": "Sample string 2",

"status": "Sample string 3",

"created_at": "Sample string 4"

}

I understand Jquery/CSS but for that HelpPage MVC should render HTML contents with some marking for [Required] attributes so that JS/CSS may style them differently on client side. I am expecting some modifications in Areas.HelpPage.ObjectGenerator class that is responsible for generating HTML for InfoModel.

有帮助吗?

解决方案

if you are using latest version of Web API, then you get helpful information regarding data annotation attributes like Required etc.

Example: enter image description here

其他提示

Use jQuery to apply css to the id and title:

$('foo').css("font-weight","Bold");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top