asp.net-core.net-coreswashbuckle.aspnetcore

Why swashbuckle example value does not work?


Here I added XML doc parameter example="this does not work" for swashbuckle framework.

/// <summary>Gets a user by id.</summary>
/// <param name="id" example="this does not work">The id of user.</param>
/// <returns>got user.</returns>
[HttpGet("Get")]
[ProducesResponseType(typeof(UserDTO), 200)]
[ProducesResponseType(typeof(AppException), StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> Get(string id)
{
    return HandleResult(await _userServices.GetUserAsync(id));
}

But example value does not appear in Swagger UI.

enter image description here

Where I should look for the problem?


Solution

  • Found why it didn't worked. I changed in my project this setting: app.UseSwagger(c => c.SerializeAsV2 = true) to app.UseSwagger() and everything works now.