Home > Back-end >  How do I add description to FromHeaderAttribute
How do I add description to FromHeaderAttribute

Time:12-20

FromHeader only has a Name property and doesn't have description. How do I change the description?

public async Task<IActionResult> Test([FromHeader] string Authorization)
{
}

enter image description here

CodePudding user response:

You should include the using System.ComponentModel then add an annotation to the controller method like this:

[Description("This description will appear in docs")]
[HttpPost]
public async Task<IActionResult> Test([FromHeader] string Authorization)
        {
       }

Hope help you.

CodePudding user response:

Updated your csproj to use xml documentation: enter image description here

Update your program.cs enter image description here

Then your xml comments will show, like mine: enter image description here

enter image description here

  • Related