Add workflow and document APIs, middleware, and Swagger

Introduced `CloseWorkflowRequest` for closing workflows.
Added `DocumentsController` for document downloads and
`WorkflowsController` for workflow retrieval and closing.

Implemented `ExceptionHandlingMiddleware` for global exception
handling with structured API responses.

Enhanced Swagger configuration with metadata and production
support. Added `Scalar.AspNetCore` for API reference mapping.

Updated project dependencies and improved API documentation.
This commit is contained in:
2026-10-10 13:50:26 +02:00
parent b44be4f9e2
commit 3126f025be
6 changed files with 227 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
using DigitalData.TaskFlow.Application.Features.Documents.Queries.GetDocument;
using DigitalData.TaskFlow.Domain.Common;
using DigitalData.TaskFlow.Domain.Documents;
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace DigitalData.TaskFlow.API.Controllers;
/// <summary>
/// Provides document binary download endpoints.
/// </summary>
[ApiController]
[Route("api/documents")]
public sealed class DocumentsController(ISender sender) : ControllerBase
{
/// <summary>
/// Returns binary document content by document identifier.
/// </summary>
/// <param name="id">Document identifier.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Binary stream when available.</returns>
[HttpGet("{id}")]
[ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiEnvelope<object>), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ApiEnvelope<object>), StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken)
{
var response = await sender.Send(new GetDocumentQuery(id), cancellationToken);
var data = response.Data;
if (data is null)
{
return NotFound(response);
}
return File(data.Content, data.ContentType, data.FileName);
}
}