mirror of
https://git.tonybark.com/tonytins/bark.api.git
synced 2026-02-10 16:24:47 -05:00
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.
This commit is contained in:
parent
dc4af28f97
commit
725d4bdeaf
1 changed files with 10 additions and 2 deletions
12
Program.cs
12
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue