Reputation: 246
I'm using Swashbuckle to generate swagger documentation. Unfortunately I can't find how to add the implementation notes, as per attached pictures.
This is a sample picture of swagger generated documentation
Bellow is excerpt from my code to generate some tags.
/// <summary>
/// User login for given application
/// </summary>
/// <description>
/// Test description
/// </description>
/// <remarks>
/// Sample request:
///
/// POST /login
/// {
/// "email": "[email protected]",
/// "password": "jonLov3sDaenarys"
/// "productId": "5e7en-k1ngd0m5"
/// }
///
/// </remarks>
/// <param name="model">Login model</param>
/// <returns>JWT Token</returns>
/// <response code="200">Returns the newly created auth response, containing token with user information</response>
/// <response code="400">If the request is invalid or productId doesn't exist</response>
/// <response code="403">If the account is locked out or role is inactive</response>
[HttpPost]
[Produces("application/json")]
[Consumes("application/json")]
[ProducesResponseType(typeof(AuthResponseModel), 200)]
[ProducesResponseType(400)]
[ProducesResponseType(403)]
[Route("login")]
public async Task<IActionResult> Login([FromBody]LoginModel model)
{
if (ModelState.IsValid)
{
Any idea what I'm doing wrong?
Thank you,
Upvotes: 2
Views: 777
Reputation: 3073
You have to generate the XML documentation file.
Project Properties > Build > Output => Check XML Documentation file
. Example: bin\netcoreapp2.1\MyProject.xml
In ConfigureServices
, where you do services.AddSwaggerGen(...)
, include the generated file:
services.AddSwaggerGen(options =>
{
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MyProject.xml");
options.IncludeXmlComments(filePath);
});
If these two things are in place, the xml comments should be included in the documentation.
Upvotes: 1
Reputation: 131
Did you miss the attributes for swagger?
[SwaggerOperation("Get_Whatever")]
[SwaggerResponse(StatusCodes.Status200OK, typeof(List<string>), "An array of strings.")]
[SwaggerResponse(StatusCodes.Status403Forbidden, null, "Forbidden")]
public async Task<IActionResult> Login([FromBody]LoginModel model){
Upvotes: 0