Merged PR 36: swagger mediatr fix

- .
- fix
master
Tudor Stanciu 2022-03-15 16:37:13 +00:00
parent 53c6ad4a46
commit 77e58181f6
5 changed files with 9 additions and 35 deletions

View File

@ -6,12 +6,12 @@
<NewtonsoftJsonPackageVersion>5.0.7</NewtonsoftJsonPackageVersion> <NewtonsoftJsonPackageVersion>5.0.7</NewtonsoftJsonPackageVersion>
<SerilogAspNetCorePackageVersion>4.1.0</SerilogAspNetCorePackageVersion> <SerilogAspNetCorePackageVersion>4.1.0</SerilogAspNetCorePackageVersion>
<SerilogSinksSQLitePackageVersion>5.0.0</SerilogSinksSQLitePackageVersion> <SerilogSinksSQLitePackageVersion>5.0.0</SerilogSinksSQLitePackageVersion>
<NDBExtensionsSwaggerPackageVersion>1.0.2</NDBExtensionsSwaggerPackageVersion> <NDBExtensionsSwaggerPackageVersion>1.0.4</NDBExtensionsSwaggerPackageVersion>
<NDBSecurityAuthenticationIdentityPackageVersion>1.0.7</NDBSecurityAuthenticationIdentityPackageVersion> <NDBSecurityAuthenticationIdentityPackageVersion>1.0.7</NDBSecurityAuthenticationIdentityPackageVersion>
<NDBDatabaseMigrationPackageVersion>1.1.3</NDBDatabaseMigrationPackageVersion> <NDBDatabaseMigrationPackageVersion>1.1.3</NDBDatabaseMigrationPackageVersion>
<AutoMapperPackageVersion>10.1.1</AutoMapperPackageVersion> <AutoMapperPackageVersion>10.1.1</AutoMapperPackageVersion>
<ScrutorPackageVersion>3.3.0</ScrutorPackageVersion> <ScrutorPackageVersion>3.3.0</ScrutorPackageVersion>
<MicrosoftAspNetCorePackageVersion>5.0.7</MicrosoftAspNetCorePackageVersion> <MicrosoftAspNetCorePackageVersion>5.0.7</MicrosoftAspNetCorePackageVersion>
<MediatRPackageVersion>6.0.0</MediatRPackageVersion> <MediatRPackageVersion>9.0.0</MediatRPackageVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -1,8 +0,0 @@
using MediatR;
namespace ProxmoxConnector.Server.Application.Queries
{
public abstract class Query<TResponse> : IRequest<TResponse>, IBaseRequest
{
}
}

View File

@ -7,16 +7,11 @@ namespace ProxmoxConnector.Server.Application.Queries.System
{ {
public class GetSystemVersion public class GetSystemVersion
{ {
public class Query : Query<Model> public record Query : IRequest<Model> { }
{
public Query()
{
}
}
public class Model public record Model
{ {
public string Version { get; set; } public string Version { get; init; }
} }
public class QueryHandler : IRequestHandler<Query, Model> public class QueryHandler : IRequestHandler<Query, Model>

View File

@ -8,16 +8,13 @@ namespace ProxmoxConnector.Server.Application.Queries
{ {
public class TestQ public class TestQ
{ {
public class Query : Query<Model> public record Query : IRequest<Model>
{ {
public Query()
{
}
} }
public class Model public record Model
{ {
public string Msg { get; set; } public string Msg { get; init; }
} }
public class QueryHandler : IRequestHandler<Query, Model> public class QueryHandler : IRequestHandler<Query, Model>
@ -29,10 +26,6 @@ namespace ProxmoxConnector.Server.Application.Queries
_pveConnector=pveConnector; _pveConnector=pveConnector;
} }
public QueryHandler()
{
}
public async Task<Model> Handle(Query request, CancellationToken cancellationToken) public async Task<Model> Handle(Query request, CancellationToken cancellationToken)
{ {
await _pveConnector.TestWithLogin(); await _pveConnector.TestWithLogin();

View File

@ -34,7 +34,7 @@ namespace ProxmoxConnector.Server
services.AddIdentityAuthentication(_configuration.GetSection("IdentityServer")["BaseAddress"]); services.AddIdentityAuthentication(_configuration.GetSection("IdentityServer")["BaseAddress"]);
// MediatR // MediatR
services.AddMediatR(GetMediatRAssemblies()); services.AddMediatR(typeof(Application.Queries.System.GetSystemVersion).Assembly);
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPreProcessorBehavior<,>)); services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPreProcessorBehavior<,>));
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPostProcessorBehavior<,>)); services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPostProcessorBehavior<,>));
@ -69,11 +69,5 @@ namespace ProxmoxConnector.Server
app.UseMigration(); app.UseMigration();
} }
private Assembly[] GetMediatRAssemblies()
{
var assembly = typeof(Application.Queries.System.GetSystemVersion).Assembly;
return new Assembly[] { assembly };
}
} }
} }