Abp Vnext 的 Vue3 实现版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
1.0 KiB

namespace Swagger;
/// <summary>
/// swagger注释加载慢,把文档添加到缓存
/// </summary>
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(ISwaggerProvider))]
public class CachingSwaggerProvider : ISwaggerProvider, ITransientDependency
{
private static readonly ConcurrentDictionary<string, OpenApiDocument> _cache = new ConcurrentDictionary<string, OpenApiDocument>();
private readonly SwaggerGenerator _swaggerGenerator;
public CachingSwaggerProvider(
IOptions<SwaggerGeneratorOptions> optionsAccessor,
IApiDescriptionGroupCollectionProvider apiDescriptionsProvider,
ISchemaGenerator schemaGenerator)
{
_swaggerGenerator = new SwaggerGenerator(optionsAccessor.Value, apiDescriptionsProvider, schemaGenerator);
}
public OpenApiDocument GetSwagger(string documentName, string host = null, string basePath = null)
{
return _cache.GetOrAdd(documentName, (_) => _swaggerGenerator.GetSwagger(documentName, host, basePath));
}
}