Add project files.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Adapter;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Ports;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Ports;
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Ports;
|
||||
using Core.Blueprint.Application.UsesCases.MongoStorage.Adapter;
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Adapter;
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Input;
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Ports;
|
||||
using Core.Cerberos.Application.UseCases.Blueprints;
|
||||
using Core.Cerberos.Application.UseCases.Blueprints.Validator;
|
||||
using Core.Cerberos.Application.UseCases.KeyVault;
|
||||
using Core.Cerberos.Application.UseCases.KeyVault.Validator;
|
||||
using Core.Cerberos.Application.UseCases.SQL.Validator;
|
||||
using Core.Cerberos.Application.UseCases.UserProjects;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Blueprint.Service.API.Extensions
|
||||
{
|
||||
public static class ServiceCollectionExtension
|
||||
{
|
||||
public static IServiceCollection AddServiceConfigurationLayer(this IServiceCollection services)
|
||||
{
|
||||
#region Mongo Services
|
||||
services.AddScoped<IMongoPort, MongoPort>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<CreateBlueprintValidator>();
|
||||
services.AddScoped<IValidator<CreateBlueprintRequest>, CreateBlueprintValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateBlueprintRequest>, MongoHandler>();
|
||||
|
||||
services.AddScoped<IComponentHandler<GetAllBlueprintsRequest>, MongoHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<GetBlueprintValidator>();
|
||||
services.AddScoped<IValidator<GetBlueprintRequest>, GetBlueprintValidator>();
|
||||
services.AddScoped<IComponentHandler<GetBlueprintRequest>, MongoHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateBlueprintValidator>();
|
||||
services.AddScoped<IValidator<UpdateBlueprintRequest>, UpdateBlueprintValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateBlueprintRequest>, MongoHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<DeleteBlueprintValidator>();
|
||||
services.AddScoped<IValidator<DeleteBlueprintRequest>, DeleteBlueprintValidator>();
|
||||
services.AddScoped<IComponentHandler<DeleteBlueprintRequest>, MongoHandler>();
|
||||
#endregion
|
||||
|
||||
#region SQL Services
|
||||
services.AddScoped<ISQLPort, SQLPort>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<CreateUserProjectValidator>();
|
||||
services.AddScoped<IValidator<CreateUserProjectRequest>, CreateUserProjectValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateUserProjectRequest>, SQLHandler>();
|
||||
|
||||
services.AddScoped<IComponentHandler<GetAllUserProjectsRequest>, SQLHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<GetUserProjectValidator>();
|
||||
services.AddScoped<IValidator<GetUserProjectRequest>, GetUserProjectValidator>();
|
||||
services.AddScoped<IComponentHandler<GetUserProjectRequest>, SQLHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateUserProjectValidator>();
|
||||
services.AddScoped<IValidator<UpdateUserProjectRequest>, UpdateUserProjectValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateUserProjectRequest>, SQLHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<DeleteUserProjectValidator>();
|
||||
services.AddScoped<IValidator<DeleteUserProjectRequest>, DeleteUserProjectValidator>();
|
||||
services.AddScoped<IComponentHandler<DeleteUserProjectRequest>, SQLHandler>();
|
||||
#endregion
|
||||
|
||||
#region KeyVault Services
|
||||
services.AddScoped<IKeyVaultPort, KeyVaultPort>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<CreateSecretValidator>();
|
||||
services.AddScoped<IValidator<CreateSecretRequest>, CreateSecretValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateSecretRequest>, KeyVaultHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<GetSecretValidator>();
|
||||
services.AddScoped<IValidator<GetSecretRequest>, GetSecretValidator>();
|
||||
services.AddScoped<IComponentHandler<GetSecretRequest>, KeyVaultHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateSecretValidator>();
|
||||
services.AddScoped<IValidator<UpdateSecretRequest>, UpdateSecretValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateSecretRequest>, KeyVaultHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<DeleteSecretValidator>();
|
||||
services.AddScoped<IValidator<DeleteSecretRequest>, DeleteSecretValidator>();
|
||||
services.AddScoped<IComponentHandler<DeleteSecretRequest>, KeyVaultHandler>();
|
||||
#endregion
|
||||
|
||||
#region Storage Services
|
||||
services.AddScoped<IStoragePort, StoragePort>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UploadBlobValidator>();
|
||||
services.AddScoped<IValidator<UploadBlobRequest>, UploadBlobValidator>();
|
||||
services.AddScoped<IComponentHandler<UploadBlobRequest>, StorageHandler>();
|
||||
|
||||
services.AddScoped<IComponentHandler<GetBlobListRequest>, StorageHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<DownloadBlobValidator>();
|
||||
services.AddScoped<IValidator<DownloadBlobRequest>, DownloadBlobValidator>();
|
||||
services.AddScoped<IComponentHandler<DownloadBlobRequest>, StorageHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<DeleteBlobValidator>();
|
||||
services.AddScoped<IValidator<DeleteBlobRequest>, DeleteBlobValidator>();
|
||||
services.AddScoped<IComponentHandler<DeleteBlobRequest>, StorageHandler>();
|
||||
#endregion
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
71
Core.Blueprint.Service.API/Extensions/SwaggerExtensions.cs
Normal file
71
Core.Blueprint.Service.API/Extensions/SwaggerExtensions.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Asp.Versioning.ApiExplorer;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
|
||||
namespace Core.Blueprint.Service.API.Extensions
|
||||
{
|
||||
public static class SwaggerExtensions
|
||||
{
|
||||
public static void AddSwagger(this IServiceCollection services)
|
||||
{
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddSwaggerGen();
|
||||
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
|
||||
}
|
||||
|
||||
public static void ConfigureSwagger(this WebApplication app)
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
foreach (var version in app.DescribeApiVersions().Select(version => version.GroupName))
|
||||
options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version);
|
||||
|
||||
options.DisplayRequestDuration();
|
||||
options.EnableTryItOutByDefault();
|
||||
options.DocExpansion(DocExpansion.None);
|
||||
});
|
||||
}
|
||||
public static IServiceCollection AddVersioning(this IServiceCollection services)
|
||||
{
|
||||
services.AddApiVersioning(options => options.ReportApiVersions = true)
|
||||
.AddApiExplorer(options =>
|
||||
{
|
||||
options.GroupNameFormat = "'v'VVV";
|
||||
options.SubstituteApiVersionInUrl = true;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
public class ConfigureSwaggerOptions : IConfigureOptions<SwaggerGenOptions>
|
||||
{
|
||||
private readonly IApiVersionDescriptionProvider _provider;
|
||||
|
||||
public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider)
|
||||
{
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
public void Configure(SwaggerGenOptions options)
|
||||
{
|
||||
foreach (var description in _provider.ApiVersionDescriptions)
|
||||
options.SwaggerDoc(description.GroupName, new()
|
||||
{
|
||||
Title = AppDomain.CurrentDomain.FriendlyName,
|
||||
Version = description.ApiVersion.ToString()
|
||||
});
|
||||
|
||||
//Map ALL Values Format TODO
|
||||
options.MapType<DateOnly>(() => new()
|
||||
{
|
||||
Format = "date",
|
||||
Example = new OpenApiString(DateOnly.MinValue.ToString())
|
||||
});
|
||||
|
||||
options.CustomSchemaIds(type => type.ToString().Replace("+", "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user