From a25b4eff1725297c1046293cecf2b03294fa48fd Mon Sep 17 00:00:00 2001 From: Hamed Shirbandi Date: Wed, 20 Dec 2023 21:31:49 +0100 Subject: [PATCH] fix: Swagger and DNTCaptcha conflict --- .../Web.MVC/Controllers/BaseApiController.cs | 2 +- src/3-ApiGateways/UserPanel/ApiGateway/ApiGateway.csproj | 2 +- .../UserPanel/ApiGateway/Configuration/HostingExtensions.cs | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/1-BuildingBlocks/Web.MVC/Controllers/BaseApiController.cs b/src/1-BuildingBlocks/Web.MVC/Controllers/BaseApiController.cs index 68e5f307c..dbcea949d 100644 --- a/src/1-BuildingBlocks/Web.MVC/Controllers/BaseApiController.cs +++ b/src/1-BuildingBlocks/Web.MVC/Controllers/BaseApiController.cs @@ -4,7 +4,7 @@ namespace TaskoMask.BuildingBlocks.Web.MVC.Controllers; -public class BaseApiController : Controller +public abstract class BaseApiController : Controller { #region Fields diff --git a/src/3-ApiGateways/UserPanel/ApiGateway/ApiGateway.csproj b/src/3-ApiGateways/UserPanel/ApiGateway/ApiGateway.csproj index c92376c64..83ee1761c 100644 --- a/src/3-ApiGateways/UserPanel/ApiGateway/ApiGateway.csproj +++ b/src/3-ApiGateways/UserPanel/ApiGateway/ApiGateway.csproj @@ -1,4 +1,4 @@ - + net6.0 diff --git a/src/3-ApiGateways/UserPanel/ApiGateway/Configuration/HostingExtensions.cs b/src/3-ApiGateways/UserPanel/ApiGateway/Configuration/HostingExtensions.cs index 5cd9d9621..d153855a5 100644 --- a/src/3-ApiGateways/UserPanel/ApiGateway/Configuration/HostingExtensions.cs +++ b/src/3-ApiGateways/UserPanel/ApiGateway/Configuration/HostingExtensions.cs @@ -2,6 +2,7 @@ using Ocelot.DependencyInjection; using Ocelot.Middleware; using Serilog; +using TaskoMask.BuildingBlocks.Web.MVC.Configuration.Captcha; using TaskoMask.BuildingBlocks.Web.MVC.Configuration.Metric; using TaskoMask.BuildingBlocks.Web.MVC.Configuration.Serilog; @@ -16,6 +17,11 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde { builder.AddCustomSerilog(); + //TODO : Swagger tries to initialize DNTCaptcha.Core built-in controller and throws an error if we remove the bellow lines + // We need to ignore DNTCaptcha.Core during generating swagger docs + builder.Services.AddControllers(); + builder.Services.AddCaptcha(); + builder.Configuration.AddOcelotWithSwaggerSupport( (o) => {