From 985d2e427cf1068dee7ef4915e96b919e0b38f6d Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Wed, 21 Feb 2024 16:47:39 -0500 Subject: [PATCH] Added request-interceptor to remove RequestVerificationToken --- .../EShopOnAbp.WebPublicGateway.csproj | 5 ++++ .../wwwroot/swagger/ui/requestinterceptor.js | 9 +++++++ .../EShopOnAbp.WebGateway.csproj | 5 ++++ .../wwwroot/swagger/ui/requestinterceptor.js | 9 +++++++ .../AdministrationServiceHttpApiHostModule.cs | 16 ++++------- ....AdministrationService.HttpApi.Host.csproj | 5 ++++ .../wwwroot/swagger/ui/requestinterceptor.js | 9 +++++++ .../BasketServiceModule.cs | 2 +- .../EShopOnAbp.BasketService.csproj | 5 ++++ .../wwwroot/swagger/ui/requestinterceptor.js | 9 +++++++ .../CatalogServiceHttpApiHostModule.cs | 2 +- ...opOnAbp.CatalogService.HttpApi.Host.csproj | 5 ++++ .../wwwroot/swagger/ui/requestinterceptor.js | 9 +++++++ .../CmskitServiceHttpApiHostModule.cs | 2 +- ...hopOnAbp.CmskitService.HttpApi.Host.csproj | 5 ++++ .../wwwroot/swagger/ui/requestinterceptor.js | 9 +++++++ ...pOnAbp.IdentityService.HttpApi.Host.csproj | 6 +++++ .../IdentityServiceHttpApiHostModule.cs | 5 ++-- .../wwwroot/swagger/ui/requestinterceptor.js | 9 +++++++ ...pOnAbp.OrderingService.HttpApi.Host.csproj | 5 ++++ .../OrderingServiceHttpApiHostModule.cs | 2 +- .../wwwroot/swagger/ui/requestinterceptor.js | 9 +++++++ ...opOnAbp.PaymentService.HttpApi.Host.csproj | 5 ++++ .../PaymentServiceHttpApiHostModule.cs | 2 +- .../wwwroot/swagger/ui/requestinterceptor.js | 9 +++++++ .../AbpSwaggerUIBuilderExtensions.cs | 27 +++++++++++++++++++ ...ShopOnAbp.Shared.Hosting.AspNetCore.csproj | 4 +++ ...EShopOnAbpSharedHostingAspNetCoreModule.cs | 3 --- .../YarpSwaggerUIBuilderExtensions.cs | 3 ++- 29 files changed, 172 insertions(+), 23 deletions(-) create mode 100644 gateways/web-public/src/EShopOnAbp.WebPublicGateway/wwwroot/swagger/ui/requestinterceptor.js create mode 100644 gateways/web/src/EShopOnAbp.WebGateway/wwwroot/swagger/ui/requestinterceptor.js create mode 100644 services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js create mode 100644 services/basket/src/EShopOnAbp.BasketService/wwwroot/swagger/ui/requestinterceptor.js create mode 100644 services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js create mode 100644 services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js create mode 100644 services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js create mode 100644 services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js create mode 100644 services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js create mode 100644 shared/EShopOnAbp.Shared.Hosting.AspNetCore/AbpSwaggerUIBuilderExtensions.cs diff --git a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbp.WebPublicGateway.csproj b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbp.WebPublicGateway.csproj index b5f35155..5c6e4325 100644 --- a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbp.WebPublicGateway.csproj +++ b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbp.WebPublicGateway.csproj @@ -15,4 +15,9 @@ + + + + + diff --git a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/wwwroot/swagger/ui/requestinterceptor.js b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj b/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj index b5f35155..5c6e4325 100644 --- a/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj +++ b/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj @@ -15,4 +15,9 @@ + + + + + diff --git a/gateways/web/src/EShopOnAbp.WebGateway/wwwroot/swagger/ui/requestinterceptor.js b/gateways/web/src/EShopOnAbp.WebGateway/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/gateways/web/src/EShopOnAbp.WebGateway/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs index bc61eb04..d823f511 100644 --- a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs +++ b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs @@ -59,17 +59,11 @@ public class AdministrationServiceHttpApiHostModule : AbpModule .AllowCredentials(); }); }); - - Configure(options => - { - options.IsDynamicPermissionStoreEnabled = true; - }); - Configure(options => - { - options.IsDynamicSettingStoreEnabled = true; - }); - + Configure(options => { options.IsDynamicPermissionStoreEnabled = true; }); + + Configure(options => { options.IsDynamicSettingStoreEnabled = true; }); + // Configure(options => // { // options.ValueProviders.Clear(); @@ -99,7 +93,7 @@ public class AdministrationServiceHttpApiHostModule : AbpModule app.UseUnitOfWork(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Administration Service API"); diff --git a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/EShopOnAbp.AdministrationService.HttpApi.Host.csproj b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/EShopOnAbp.AdministrationService.HttpApi.Host.csproj index 394141c4..140fcc02 100644 --- a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/EShopOnAbp.AdministrationService.HttpApi.Host.csproj +++ b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/EShopOnAbp.AdministrationService.HttpApi.Host.csproj @@ -33,4 +33,9 @@ + + + + + diff --git a/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs index 92adfd78..29c769df 100644 --- a/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs +++ b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs @@ -95,7 +95,7 @@ public class BasketServiceModule : AbpModule app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Basket Service API"); diff --git a/services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj b/services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj index 866a430d..fce71f6c 100644 --- a/services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj +++ b/services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj @@ -44,4 +44,9 @@ + + + + + diff --git a/services/basket/src/EShopOnAbp.BasketService/wwwroot/swagger/ui/requestinterceptor.js b/services/basket/src/EShopOnAbp.BasketService/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs index 410e55aa..cd0e3cba 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs @@ -101,7 +101,7 @@ public class CatalogServiceHttpApiHostModule : AbpModule app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Catalog Service API"); diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/EShopOnAbp.CatalogService.HttpApi.Host.csproj b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/EShopOnAbp.CatalogService.HttpApi.Host.csproj index 706f800e..4228481b 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/EShopOnAbp.CatalogService.HttpApi.Host.csproj +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/EShopOnAbp.CatalogService.HttpApi.Host.csproj @@ -30,6 +30,11 @@ + + + + + diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/CmskitServiceHttpApiHostModule.cs b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/CmskitServiceHttpApiHostModule.cs index 120af667..9a21f3ae 100644 --- a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/CmskitServiceHttpApiHostModule.cs +++ b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/CmskitServiceHttpApiHostModule.cs @@ -111,7 +111,7 @@ public class CmskitServiceHttpApiHostModule : AbpModule app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Cmskit Service API"); diff --git a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/EShopOnAbp.CmskitService.HttpApi.Host.csproj b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/EShopOnAbp.CmskitService.HttpApi.Host.csproj index 856c7143..7f715491 100644 --- a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/EShopOnAbp.CmskitService.HttpApi.Host.csproj +++ b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/EShopOnAbp.CmskitService.HttpApi.Host.csproj @@ -32,4 +32,9 @@ + + + + + diff --git a/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/services/cmskit/src/EShopOnAbp.CmskitService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj index df7b860b..5de66493 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj @@ -3,6 +3,7 @@ net8.0 EShopOnAbp.IdentityService + true @@ -26,5 +27,10 @@ + + + + + diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs index 66bd0070..489741fe 100644 --- a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs @@ -22,8 +22,7 @@ namespace EShopOnAbp.IdentityService; typeof(EShopOnAbpSharedHostingMicroservicesModule), typeof(IdentityServiceHttpApiModule), typeof(IdentityServiceApplicationModule), - typeof(IdentityServiceEntityFrameworkCoreModule), - typeof(EShopOnAbpSharedHostingGatewaysModule) + typeof(IdentityServiceEntityFrameworkCoreModule) )] public class IdentityServiceHttpApiHostModule : AbpModule { @@ -91,7 +90,7 @@ public class IdentityServiceHttpApiHostModule : AbpModule app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API"); diff --git a/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/EShopOnAbp.OrderingService.HttpApi.Host.csproj b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/EShopOnAbp.OrderingService.HttpApi.Host.csproj index 5415c2bd..19f80c0e 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/EShopOnAbp.OrderingService.HttpApi.Host.csproj +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/EShopOnAbp.OrderingService.HttpApi.Host.csproj @@ -31,4 +31,9 @@ + + + + + diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs index be9910c9..1ba22f30 100644 --- a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs @@ -88,7 +88,7 @@ public class OrderingServiceHttpApiHostModule : AbpModule app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Ordering Service API"); diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/EShopOnAbp.PaymentService.HttpApi.Host.csproj b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/EShopOnAbp.PaymentService.HttpApi.Host.csproj index b4607f89..7ac859a9 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/EShopOnAbp.PaymentService.HttpApi.Host.csproj +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/EShopOnAbp.PaymentService.HttpApi.Host.csproj @@ -26,4 +26,9 @@ + + + + + diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs index 953d02cf..59767643 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs @@ -81,7 +81,7 @@ public class PaymentServiceHttpApiHostModule : AbpModule app.UseAbpClaimsMap(); app.UseAuthorization(); app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); options.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment Service API"); diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js new file mode 100644 index 00000000..963782ee --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/wwwroot/swagger/ui/requestinterceptor.js @@ -0,0 +1,9 @@ +const originalFetch = window.fetch; + +window.fetch = function (input, init) { + if (init !== undefined && init.headers['RequestVerificationToken'] !== undefined) { + delete init.headers['RequestVerificationToken']; + } + + return originalFetch.apply(this, arguments); +}; \ No newline at end of file diff --git a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/AbpSwaggerUIBuilderExtensions.cs b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/AbpSwaggerUIBuilderExtensions.cs new file mode 100644 index 00000000..0cf25f81 --- /dev/null +++ b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/AbpSwaggerUIBuilderExtensions.cs @@ -0,0 +1,27 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Swashbuckle.AspNetCore.SwaggerUI; +using Volo.Abp.Swashbuckle; + +namespace EShopOnAbp.Shared.Hosting.AspNetCore; + +public static class AbpSwaggerUIBuilderExtensions +{ + public static IApplicationBuilder UseAbpSwaggerWithCustomScriptUI( + this IApplicationBuilder app, + Action? setupAction = null) + { + var resolver = app.ApplicationServices.GetService(); + + return app.UseSwaggerUI(options => + { + options.InjectJavascript("ui/abp.js"); + options.InjectJavascript("ui/abp.swagger.js"); + options.InjectJavascript("ui/requestinterceptor.js"); + options.IndexStream = () => resolver?.Resolver(); + + setupAction?.Invoke(options); + }); + } +} \ No newline at end of file diff --git a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj index 65802e99..8a0b5e53 100644 --- a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj +++ b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbp.Shared.Hosting.AspNetCore.csproj @@ -17,4 +17,8 @@ + + + + diff --git a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbpSharedHostingAspNetCoreModule.cs b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbpSharedHostingAspNetCoreModule.cs index 0c71d886..7e3b8d8d 100644 --- a/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbpSharedHostingAspNetCoreModule.cs +++ b/shared/EShopOnAbp.Shared.Hosting.AspNetCore/EShopOnAbpSharedHostingAspNetCoreModule.cs @@ -12,7 +12,4 @@ namespace EShopOnAbp.Shared.Hosting.AspNetCore; )] public class EShopOnAbpSharedHostingAspNetCoreModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) - { - } } \ No newline at end of file diff --git a/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs b/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs index ad54e1da..9dab2860 100644 --- a/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs +++ b/shared/EShopOnAbp.Shared.Hosting.Gateways/YarpSwaggerUIBuilderExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using EShopOnAbp.Shared.Hosting.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -15,7 +16,7 @@ public static class YarpSwaggerUIBuilderExtensions ApplicationInitializationContext context) { app.UseSwagger(); - app.UseAbpSwaggerUI(options => + app.UseAbpSwaggerWithCustomScriptUI(options => { var configuration = context.ServiceProvider.GetRequiredService(); var logger = context.ServiceProvider.GetRequiredService>();