Skip to content

Commit 4d028f2

Browse files
committed
1 parent b3b9091 commit 4d028f2

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

JixMinApi/Features/Todo/TodoEndpoints.cs

+18
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public static async Task<Ok<TodoDto[]>> GetAllTodosAsync(IMediator mediator)
5858
return TypedResults.Ok(todos?.ToArray());
5959
}
6060

61+
/// <summary>
62+
/// Fetches a todo by Id
63+
/// </summary>
6164
public static async Task<Results<BadRequest<ValidationErrorDto>, NotFound, Ok<TodoDto>>> GetTodoByIdAsync(Guid id, IMediator mediator)
6265
{
6366
if (id == Guid.Empty)
@@ -79,6 +82,21 @@ public static async Task<Results<BadRequest<ValidationErrorDto>, NotFound, Ok<To
7982
return TypedResults.Ok(todo);
8083
}
8184

85+
/// <summary>
86+
/// Creates a new todo
87+
/// </summary>
88+
/// <remarks>
89+
/// Sample request:
90+
///
91+
/// POST /Todo
92+
/// {
93+
/// "name": "Item #1",
94+
/// "isComplete": true
95+
/// }
96+
///
97+
/// </remarks>
98+
/// <response code="201">Returns the newly created item</response>
99+
/// <response code="400">Invalid payload</response>
82100
public static async Task<Results<Created<TodoDto>, BadRequest>> CreateTodoAsync(TodoCreateDto input, IMediator mediator)
83101
{
84102
var result = await mediator.Send(new CreateTodoCommand(input));

JixMinApi/JixMinApi.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8+
<NoWarn>$(NoWarn);1591</NoWarn>
79
<UserSecretsId>d4957f71-7a37-4e19-a3a2-7d24ed38f9c4</UserSecretsId>
810
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
911
</PropertyGroup>

JixMinApi/Program.cs

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using JixMinApi.Features.Todo;
22
using Microsoft.OpenApi.Models;
3+
using System.Reflection;
34

45
var builder = WebApplication.CreateBuilder(args);
56

@@ -13,6 +14,10 @@
1314
Title = "JixMinApi Demo",
1415
Description = "A simple minimal API Demo that uses vertical slice architecture.",
1516
});
17+
18+
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
19+
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
20+
options.IncludeXmlComments(xmlPath);
1621
});
1722

1823
builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Program).Assembly));

0 commit comments

Comments
 (0)