From 176cfbf3534986e6f268830f02171b16e0be19f9 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 15 Sep 2023 09:01:38 +0800 Subject: [PATCH] Static C# API client proxy compatible ReplaceEmbeddedByPhysical --- .../ClientProxyApiDescriptionFinder.cs | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyApiDescriptionFinder.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyApiDescriptionFinder.cs index 9c54fe840e..f7b9b838b5 100644 --- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyApiDescriptionFinder.cs +++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxying/ClientProxyApiDescriptionFinder.cs @@ -1,8 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.FileProviders.Physical; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Modeling; using Volo.Abp.Json; @@ -92,15 +94,35 @@ public class ClientProxyApiDescriptionFinder : IClientProxyApiDescriptionFinder, { if (directoryContent.IsDirectory) { - GetGenerateProxyFileInfos(fileInfoList, directoryContent.PhysicalPath); + GetGenerateProxyFileInfos(fileInfoList, GetDirectoryContentPath(path, directoryContent)); } else { if (directoryContent.Name.EndsWith("generate-proxy.json")) { - fileInfoList.Add(VirtualFileProvider.GetFileInfo(directoryContent.GetVirtualOrPhysicalPathOrNull())); + fileInfoList.Add(VirtualFileProvider.GetFileInfo(GetProxyFileInfoPath(path, directoryContent))); } } } } + + private string GetDirectoryContentPath(string rootPath, IFileInfo fileInfo) + { + if (fileInfo is PhysicalDirectoryInfo physicalDirectoryInfo) + { + return rootPath + physicalDirectoryInfo.Name.EnsureStartsWith('/'); + } + + return fileInfo.PhysicalPath; + } + + private string GetProxyFileInfoPath(string rootPath, IFileInfo fileInfo) + { + if (fileInfo is PhysicalFileInfo physicalFileInfo) + { + return rootPath + physicalFileInfo.Name.EnsureStartsWith('/'); + } + + return fileInfo.GetVirtualOrPhysicalPathOrNull(); + } }