From 64b3f94a4c5fb7b231681320d5cd0d9f34d99de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 12 Sep 2017 16:10:23 +0300 Subject: [PATCH] Integrated swagger UI to Identity.HttpApi.Host. --- .../AbpIdentityHttpApiHostModule.cs | 18 +++++++++++++++++- .../Controllers/HomeController.cs | 13 +++++++++++++ .../Volo.Abp.Identity.HttpApi.Host.csproj | 3 +++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/Controllers/HomeController.cs diff --git a/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs b/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs index 3859f51180..aca4f8ca56 100644 --- a/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs +++ b/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Swashbuckle.AspNetCore.Swagger; using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.Autofac; using Volo.Abp.Data; @@ -33,6 +34,13 @@ namespace Volo.Abp.Identity.HttpApi.Host }); services.AddMvc(); + + services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new Info { Title = "Volo.Abp.Identity API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + }); + services.AddAssemblyOf(); } @@ -47,7 +55,15 @@ namespace Volo.Abp.Identity.HttpApi.Host app.UseDeveloperExceptionPage(); } - app.UseMvc(); //No need to a default route + app.UseStaticFiles(); + + app.UseSwagger(); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Volo.Abp.Identity API"); + }); + + app.UseMvcWithDefaultRoute(); } private static IConfigurationRoot BuildConfiguration(IHostingEnvironment env) diff --git a/src/Volo.Abp.Identity.HttpApi.Host/Controllers/HomeController.cs b/src/Volo.Abp.Identity.HttpApi.Host/Controllers/HomeController.cs new file mode 100644 index 0000000000..34283e4d36 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/Controllers/HomeController.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; + +namespace Volo.Abp.Identity.HttpApi.Host.Controllers +{ + public class HomeController : AbpController + { + public IActionResult Index() + { + return Redirect("/swagger"); + } + } +} diff --git a/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.csproj b/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.csproj index cb52e807b0..291fc63e8d 100644 --- a/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.csproj +++ b/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.csproj @@ -23,6 +23,8 @@ + + @@ -34,6 +36,7 @@ +