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();