From 0213e44f553b115b87e6d957e100892c3065583f Mon Sep 17 00:00:00 2001 From: Fabricio Catae Date: Thu, 2 Feb 2017 00:21:36 -0200 Subject: [PATCH] Add Swagger to Arda.Kanban --- src/Arda.Kanban/Controllers/AppointmentController.cs | 6 +++--- src/Arda.Kanban/Controllers/FiscalYearController.cs | 4 ++-- src/Arda.Kanban/Controllers/MetricController.cs | 6 +++--- src/Arda.Kanban/Controllers/ReportController.cs | 6 +++--- src/Arda.Kanban/Controllers/UserController.cs | 2 +- src/Arda.Kanban/Controllers/WorkloadController.cs | 4 ++-- src/Arda.Kanban/Startup.cs | 12 ++++++++++++ src/Arda.Kanban/project.json | 3 ++- 8 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/Arda.Kanban/Controllers/AppointmentController.cs b/src/Arda.Kanban/Controllers/AppointmentController.cs index 1bb2474..09e0dab 100644 --- a/src/Arda.Kanban/Controllers/AppointmentController.cs +++ b/src/Arda.Kanban/Controllers/AppointmentController.cs @@ -72,7 +72,7 @@ public IEnumerable List() [HttpGet] [Route("listfromuser")] - public IEnumerable ListFromUser(string user) + public IEnumerable ListFromUser([FromQuery]string user) { try { @@ -95,7 +95,7 @@ public IEnumerable ListFromUser(string user) [HttpGet] [Route("getappointmentbyid")] - public AppointmentViewModel GetAppointmentByID(Guid id) + public AppointmentViewModel GetAppointmentByID([FromQuery]Guid id) { try { @@ -146,7 +146,7 @@ public HttpResponseMessage EditAppointmentByID() [HttpDelete] [Route("deleteappointmentbyid")] - public HttpResponseMessage DeleteAppointmentByID(Guid id) + public HttpResponseMessage DeleteAppointmentByID([FromQuery]Guid id) { try { diff --git a/src/Arda.Kanban/Controllers/FiscalYearController.cs b/src/Arda.Kanban/Controllers/FiscalYearController.cs index 50d314c..260754c 100644 --- a/src/Arda.Kanban/Controllers/FiscalYearController.cs +++ b/src/Arda.Kanban/Controllers/FiscalYearController.cs @@ -72,7 +72,7 @@ public IEnumerable List() [HttpGet] [Route("getfiscalyearbyid")] - public FiscalYearViewModel GetFiscalYearByID(Guid id) + public FiscalYearViewModel GetFiscalYearByID([FromQuery]Guid id) { try { @@ -123,7 +123,7 @@ public HttpResponseMessage EditFiscalYearByID() [HttpDelete] [Route("deletefiscalyearbyid")] - public HttpResponseMessage DeleteFiscalYearByID(Guid id) + public HttpResponseMessage DeleteFiscalYearByID([FromQuery]Guid id) { try { diff --git a/src/Arda.Kanban/Controllers/MetricController.cs b/src/Arda.Kanban/Controllers/MetricController.cs index 77fdedd..535db16 100644 --- a/src/Arda.Kanban/Controllers/MetricController.cs +++ b/src/Arda.Kanban/Controllers/MetricController.cs @@ -72,7 +72,7 @@ public IEnumerable List() [HttpGet] [Route("listbyyear")] - public IEnumerable List(int year) + public IEnumerable List([FromQuery]int year) { try { @@ -95,7 +95,7 @@ public IEnumerable List(int year) [HttpGet] [Route("getmetricbyid")] - public MetricViewModel GetMetricByID(Guid id) + public MetricViewModel GetMetricByID([FromQuery]Guid id) { try { @@ -146,7 +146,7 @@ public HttpResponseMessage EditMetricByID() [HttpDelete] [Route("deletemetricbyid")] - public HttpResponseMessage DeleteMetricByID(Guid id) + public HttpResponseMessage DeleteMetricByID([FromQuery]Guid id) { try { diff --git a/src/Arda.Kanban/Controllers/ReportController.cs b/src/Arda.Kanban/Controllers/ReportController.cs index aae2dae..b267dec 100644 --- a/src/Arda.Kanban/Controllers/ReportController.cs +++ b/src/Arda.Kanban/Controllers/ReportController.cs @@ -20,7 +20,7 @@ public ReportController(IReportRepository repository) [HttpGet] [Route("getactivityconsumingdata")] - public IEnumerable GetActivityConsumingData(DateTime startDate, DateTime endDate, string user = "All") + public IEnumerable GetActivityConsumingData([FromQuery]DateTime startDate, [FromQuery] DateTime endDate, [FromQuery]string user = "All") { try { @@ -43,7 +43,7 @@ public IEnumerable GetActivityConsumingData(DateTime [HttpGet] [Route("getexpertiseconsumingdata")] - public IEnumerable GetExpertiseConsumingData(DateTime startDate, DateTime endDate, string user = "All") + public IEnumerable GetExpertiseConsumingData([FromQuery]DateTime startDate, [FromQuery]DateTime endDate, [FromQuery]string user = "All") { try { @@ -66,7 +66,7 @@ public IEnumerable GetExpertiseConsumingData(DateTi [HttpGet] [Route("getmetricconsumingdata")] - public IEnumerable GetMetricConsumingData(DateTime startDate, DateTime endDate, string user = "All") + public IEnumerable GetMetricConsumingData([FromQuery]DateTime startDate, [FromQuery]DateTime endDate, [FromQuery]string user = "All") { try { diff --git a/src/Arda.Kanban/Controllers/UserController.cs b/src/Arda.Kanban/Controllers/UserController.cs index 45a92b0..d7c66c0 100644 --- a/src/Arda.Kanban/Controllers/UserController.cs +++ b/src/Arda.Kanban/Controllers/UserController.cs @@ -51,7 +51,7 @@ public HttpResponseMessage AddUser() [HttpDelete] [Route("delete")] - public HttpResponseMessage DeleteUser(string userID) + public HttpResponseMessage DeleteUser([FromQuery]string userID) { if (userID != null) { diff --git a/src/Arda.Kanban/Controllers/WorkloadController.cs b/src/Arda.Kanban/Controllers/WorkloadController.cs index 1ec0054..867322e 100644 --- a/src/Arda.Kanban/Controllers/WorkloadController.cs +++ b/src/Arda.Kanban/Controllers/WorkloadController.cs @@ -69,7 +69,7 @@ public IEnumerable List() [HttpGet] [Route("details")] - public WorkloadViewModel Details(Guid workloadID) + public WorkloadViewModel Details([FromQuery]Guid workloadID) { try { @@ -173,7 +173,7 @@ public HttpResponseMessage Edit() [HttpDelete] [Route("delete")] - public HttpResponseMessage Delete(Guid workloadID) + public HttpResponseMessage Delete([FromQuery]Guid workloadID) { try { diff --git a/src/Arda.Kanban/Startup.cs b/src/Arda.Kanban/Startup.cs index fd305bf..693d8c2 100644 --- a/src/Arda.Kanban/Startup.cs +++ b/src/Arda.Kanban/Startup.cs @@ -9,6 +9,7 @@ using Arda.Kanban.Models; using Arda.Common.Interfaces.Kanban; using Arda.Kanban.Repositories; +using Swashbuckle.AspNetCore.Swagger; namespace Arda.Kanban { @@ -73,6 +74,11 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); + + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new Info { Title = "Arda.Kanban", Version = "v1" }); + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline @@ -91,6 +97,12 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF app.UseCors("AllowAll"); + app.UseSwagger(); + app.UseSwaggerUi(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Arda.Kanban v1"); + }); + app.UseMvc(); } diff --git a/src/Arda.Kanban/project.json b/src/Arda.Kanban/project.json index 3cce2d3..663a905 100644 --- a/src/Arda.Kanban/project.json +++ b/src/Arda.Kanban/project.json @@ -26,7 +26,8 @@ "Microsoft.Extensions.Caching.Redis": "1.1.0-preview1-final", "Newtonsoft.Json": "9.0.1", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", - "Arda.Common": "1.0.0-*" + "Arda.Common": "1.0.0-*", + "Swashbuckle.AspNetCore": "1.0.0-rc1" }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*"