Добавьте элемент remarks в документацию метода Создать действие.Он дополняет информацию, указанную в элементе summary , и предоставляет более надежный интерфейс Swagger.Содержимое элемента remarks может состоять из текста, JSON или XML.
Итак, чтобы исправить замечания и сгенерировать документацию Swagger в видеправильно, вы должны добавить текст после открытия тега remarks , добавить строку разрыва, а затем добавить пример запроса.
Еще одной важной деталью является отступ, вы должны применить правильный код отступа.
Ниже приведен текущий сценарий, исправление вашей проблемы и 2 примера.
До - Неправильно (ваш сценарий)
/// <remarks>
/// {
/// "your_val": "1a",
/// "member": "Test"
/// }
![enter image description here](https://i.stack.imgur.com/SOkSp.png)
После - Правильно
/// <remarks>
/// [Description]:
///
/// {
/// "your_val": "1a",
/// "member": "Test"
/// }
///</remarks>
![enter image description here](https://i.stack.imgur.com/KR5mO.png)
Пример 01:
/// <summary>
/// Creates a Item From Query (Default)
/// </summary>
/// <remarks>
/// Sample request:
///
/// POST /api/Items/CreateViaQuery
/// {
/// "code": "0001",
/// "description": "Item1"
/// }
///
/// </remarks>
/// <param cref="CreateItemViewModel" name="createItemViewModel">Create Item View Model</param>
/// <returns>A newly created Item</returns>
/// <response code="201">Returns the newly created item</response>
/// <response code="400">If the item is null</response>
[HttpPost("CreateViaQuery")]
[ProducesResponseType((int)HttpStatusCode.Created)]
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
public ActionResult<CreateItemViewModel> CreateViaQuery(CreateItemViewModel createItemViewModel)
{
if (!ModelState.IsValid)
{
return BadRequest();
}
return Created("", createItemViewModel);
}
![Example 01 Result](https://i.stack.imgur.com/lb5Wb.png)
Пример 02:
/// <summary>
/// Creates a Item From Body
/// </summary>
/// <remarks>
/// Sample request:
///
/// POST /api/Items/CreateViaBody
/// {
/// "code": "0001",
/// "description": "Item1"
/// }
///
/// </remarks>
/// <param cref="CreateItemViewModel" name="createItemViewModel">Create Item View Model</param>
/// <returns>A newly created Item</returns>
/// <response code="201" cref="CreateItemViewModel">Returns the newly created item</response>
/// <response code="400">If the item is null</response>
[HttpPost("CreateViaBody")]
[ProducesResponseType((int)HttpStatusCode.Created)]
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
public ActionResult<CreateItemViewModel> CreateViaBody([FromBody]CreateItemViewModel createItemViewModel)
{
if (!ModelState.IsValid)
{
return BadRequest();
}
return Created("", createItemViewModel);
}
![Example 02 Result](https://i.stack.imgur.com/20Yrq.png)
Для получения дополнительной информации ознакомьтесь со следующей статьей: Начало работы с Swashbuckle и ASP.NET Core
Iнадеюсь, это поможет вам.