Commit 02b758d8 authored by Ariel Piñeiro's avatar Ariel Piñeiro

Merge branch 'master' into master-github

parents a0ff6f97 dd6987c1
......@@ -39,7 +39,8 @@ namespace CleanArchitecture.Web.Api
}
// POST: api/ToDoItems
public async Task<IActionResult> Post([FromBody] ToDoItemDTO item)
[HttpPost]
public IActionResult Post([FromBody] ToDoItemDTO item)
{
var todoItem = new ToDoItem()
{
......
......@@ -27,6 +27,7 @@
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
......
......@@ -9,6 +9,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using StructureMap;
using Swashbuckle.AspNetCore.Swagger;
namespace CleanArchitecture.Web
{
......@@ -32,6 +33,11 @@ namespace CleanArchitecture.Web
services.AddMvc()
.AddControllersAsServices();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
});
var container = new Container();
container.Configure(config =>
......@@ -83,6 +89,15 @@ namespace CleanArchitecture.Web
app.UseStaticFiles();
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
app.UseMvc(routes =>
{
routes.MapRoute(
......
......@@ -8,6 +8,7 @@
<ul>
<li><a asp-area="" asp-controller="ToDo" asp-action="Populate">Load Sample To Do Items</a></li>
<li><a asp-area="" asp-controller="ToDo" asp-action="Index">List To Do Items</a></li>
<li><a href="/swagger">API Documentation (Swagger)</a></li>
</ul>
</div>
<div class="col-md-6">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment