From 725d4bdeaf0b1b178e0a94900e9d659ee5cfdb19 Mon Sep 17 00:00:00 2001 From: Tony Bark <35226681+tonytins@users.noreply.github.com> Date: Thu, 27 Nov 2025 12:28:19 -0500 Subject: [PATCH] Update Swagger UI paths and add POST /todo endpoint Changed Swagger UI configuration paths for improved clarity and consistency. Added a new POST /todo endpoint to allow creation of Todo items in the database. --- Program.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Program.cs b/Program.cs index 0f8e0ce..acfe535 100644 --- a/Program.cs +++ b/Program.cs @@ -16,8 +16,8 @@ if (app.Environment.IsDevelopment()) app.UseSwaggerUi(cfg => { cfg.DocumentTitle = "BarkAPI"; - cfg.Path = "/api"; - cfg.DocumentPath = "/api/{documentName}/swagger.json}"; + cfg.Path = "/swagger"; + cfg.DocumentPath = "/swagger/{documentName}/swagger.json}"; cfg.DocExpansion = "list"; }); } @@ -68,4 +68,12 @@ app.MapGet("/todo/{id}", async (int id, TodoDb db) => return Results.NotFound(); }); +app.MapPost("/todo", async (Todo todo, TodoDb db) => +{ + db.Todos.Add(todo); + await db.SaveChangesAsync(); + + return Results.Created($"/todo/{todo.Id}", todo); +}); + app.Run();