diff --git a/TeachingRecordSystem/.config/dotnet-tools.json b/TeachingRecordSystem/.config/dotnet-tools.json index 335011edc2..9cae982acf 100644 --- a/TeachingRecordSystem/.config/dotnet-tools.json +++ b/TeachingRecordSystem/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-format": { - "version": "7.4.441804", + "version": "8.0.453106", "commands": [ "dotnet-format" ] diff --git a/TeachingRecordSystem/Directory.Packages.props b/TeachingRecordSystem/Directory.Packages.props index ba07bbc81f..599612d7ba 100644 --- a/TeachingRecordSystem/Directory.Packages.props +++ b/TeachingRecordSystem/Directory.Packages.props @@ -13,7 +13,7 @@ - + @@ -29,24 +29,24 @@ - - - - + + + + - - + + - - - - - + + + + + - - - - + + + + @@ -55,8 +55,8 @@ - - + + @@ -72,11 +72,11 @@ - + - \ No newline at end of file + diff --git a/TeachingRecordSystem/nuget.config b/TeachingRecordSystem/nuget.config index a75b3acd55..e9658ed5f8 100644 --- a/TeachingRecordSystem/nuget.config +++ b/TeachingRecordSystem/nuget.config @@ -1,13 +1,13 @@ - + - + diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Dockerfile b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Dockerfile index 5adea936d2..d5c56d6759 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Dockerfile +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Dockerfile @@ -1,9 +1,10 @@ # syntax=docker/dockerfile:1 -FROM mcr.microsoft.com/dotnet/aspnet:7.0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0 ARG GIT_SHA ENV GitSha ${GIT_SHA} -COPY src/TeachingRecordSystem.Api/bin/Release/net7.0/publish/ App/ -COPY src/TeachingRecordSystem.Cli/bin/Release/net7.0/publish/ TrsCli/ +ENV ASPNETCORE_HTTP_PORTS 80 +COPY src/TeachingRecordSystem.Api/bin/Release/net8.0/publish/ App/ +COPY src/TeachingRecordSystem.Cli/bin/Release/net8.0/publish/ TrsCli/ WORKDIR /App # install required fonts for PdfSharpCore diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/GeneratedCrmTypeNameGenerator.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/GeneratedCrmTypeNameGenerator.cs index 0e673bc5f6..5e3f08d71e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/GeneratedCrmTypeNameGenerator.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/GeneratedCrmTypeNameGenerator.cs @@ -11,7 +11,7 @@ public GeneratedCrmTypeNameGenerator(ITypeNameGenerator innerGenerator) _innerGenerator = innerGenerator; } - public string Generate(JsonSchema schema, string typeNameHint, IEnumerable reservedTypeNames) + public string Generate(JsonSchema schema, string? typeNameHint, IEnumerable reservedTypeNames) { var name = _innerGenerator.Generate(schema, typeNameHint, reservedTypeNames); @@ -19,7 +19,7 @@ public string Generate(JsonSchema schema, string typeNameHint, IEnumerable( - ContextualType contextualType, - bool isNullable, - JsonSchemaResolver schemaResolver, - Action? transformation = null) - { - if (contextualType.Type.IsGenericType && contextualType.Type.GetGenericTypeDefinition() == typeof(Option<>)) - { - contextualType = contextualType.Type.GetGenericArguments()[0].ToContextualType(); - } - - var schema = base.GenerateWithReferenceAndNullability(contextualType, isNullable, schemaResolver, transformation); - - return schema; - } -} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/OpenApiEndpointsStartupFilter.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/OpenApiEndpointsStartupFilter.cs index 034064f526..1302fc141a 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/OpenApiEndpointsStartupFilter.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/OpenApiEndpointsStartupFilter.cs @@ -34,7 +34,7 @@ public Action Configure(Action next) = }); } - app.UseSwaggerUi3(settings => + app.UseSwaggerUi(settings => { foreach (var version in Api.Constants.Versions) { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/ServiceCollectionExtensions.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/ServiceCollectionExtensions.cs index 1dee59527b..13e98466e1 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/ServiceCollectionExtensions.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/ServiceCollectionExtensions.cs @@ -16,19 +16,19 @@ public static IServiceCollection AddOpenApi(this IServiceCollection services, IC settings.Version = OpenApiDocumentHelper.GetVersionName(version); settings.Title = "Teaching Record System API"; settings.ApiGroupNames = new[] { OpenApiDocumentHelper.GetVersionName(version) }; - settings.AddExamples(provider); - settings.TypeNameGenerator = new GeneratedCrmTypeNameGenerator(settings.TypeNameGenerator); + //settings.AddExamples(provider); // Broken with the current NSwag.Examples library + settings.SchemaSettings.TypeNameGenerator = new GeneratedCrmTypeNameGenerator(settings.SchemaSettings.TypeNameGenerator); settings.DocumentProcessors.Add(new PopulateResponseDescriptionOperationProcessor()); - settings.SchemaProcessors.Add(new RemoveCompositeValuesFromFlagsEnumSchemaProcessor()); - settings.SchemaProcessors.Add(new RemoveExcludedEnumOptionsSchemaProcessor()); + settings.SchemaSettings.SchemaProcessors.Add(new RemoveCompositeValuesFromFlagsEnumSchemaProcessor()); + settings.SchemaSettings.SchemaProcessors.Add(new RemoveExcludedEnumOptionsSchemaProcessor()); settings.OperationProcessors.Add(new ResponseContentTypeOperationProcessor()); settings.OperationProcessors.Add(new PopulateResponseDescriptionOperationProcessor()); settings.OperationProcessors.Add(new AssignBinaryContentTypeFromProducesOperationProcessor()); - settings.SchemaGenerator = new HandleOptionJsonSchemaGenerator(settings); + settings.SchemaSettings.ReflectionService = new UnwrapOptionTypesReflectionService(); settings.AddSecurity(SecuritySchemes.ApiKey, new NSwag.OpenApiSecurityScheme() { diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/UnwrapOptionTypesReflectionService.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/UnwrapOptionTypesReflectionService.cs new file mode 100644 index 0000000000..5cd220fe57 --- /dev/null +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/OpenApi/UnwrapOptionTypesReflectionService.cs @@ -0,0 +1,24 @@ +using Namotion.Reflection; +using NJsonSchema.Generation; +using Optional; + +namespace TeachingRecordSystem.Api.Infrastructure.OpenApi; + +public class UnwrapOptionTypesReflectionService : SystemTextJsonReflectionService +{ + protected override JsonTypeDescription GetDescription( + ContextualType contextualType, + SystemTextJsonSchemaGeneratorSettings settings, + Type originalType, + bool isNullable, + ReferenceTypeNullHandling defaultReferenceTypeNullHandling) + { + if (contextualType.Type.IsGenericType && contextualType.Type.GetGenericTypeDefinition() == typeof(Option<>)) + { + originalType = contextualType.Type.GetGenericArguments()[0]; + contextualType = originalType.ToContextualType(); + } + + return base.GetDescription(contextualType, settings, originalType, isNullable, defaultReferenceTypeNullHandling); + } +} diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Security/ApiKeyAuthenticationHandler.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Security/ApiKeyAuthenticationHandler.cs index a9332d2a05..0e3567951d 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Security/ApiKeyAuthenticationHandler.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Infrastructure/Security/ApiKeyAuthenticationHandler.cs @@ -17,9 +17,8 @@ public ApiKeyAuthenticationHandler( IApiClientRepository clientRepository, IOptionsMonitor options, ILoggerFactory logger, - UrlEncoder encoder, - ISystemClock clock) - : base(options, logger, encoder, clock) + UrlEncoder encoder) + : base(options, logger, encoder) { _clientRepository = clientRepository; } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs index 7ddf25f2bf..4c0405494a 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs @@ -329,9 +329,9 @@ public static void Main(string[] args) app.Use((ctx, next) => { - ctx.Response.Headers.Add("X-Frame-Options", "deny"); - ctx.Response.Headers.Add("X-Content-Type-Options", "nosniff"); - ctx.Response.Headers.Add("X-XSS-Protection", "0"); + ctx.Response.Headers.Append("X-Frame-Options", "deny"); + ctx.Response.Headers.Append("X-Content-Type-Options", "nosniff"); + ctx.Response.Headers.Append("X-XSS-Protection", "0"); return next(); }); diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/TeachingRecordSystem.Api.csproj b/TeachingRecordSystem/src/TeachingRecordSystem.Api/TeachingRecordSystem.Api.csproj index a103bc0552..e65485d141 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/TeachingRecordSystem.Api.csproj +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/TeachingRecordSystem.Api.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 TeachingRecordSystemApi diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Cli/Dockerfile b/TeachingRecordSystem/src/TeachingRecordSystem.Cli/Dockerfile index 0e10ccf705..6eed8c82aa 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Cli/Dockerfile +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Cli/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM mcr.microsoft.com/dotnet/sdk:7.0 -COPY src/TeachingRecordSystem.Cli/bin/Release/net7.0/publish/ TrsCli/ +FROM mcr.microsoft.com/dotnet/sdk:8.0 +COPY src/TeachingRecordSystem.Cli/bin/Release/net8.0/publish/ TrsCli/ WORKDIR /TrsCli ENV PATH="${PATH}:/TrsCli" diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Cli/TeachingRecordSystem.Cli.csproj b/TeachingRecordSystem/src/TeachingRecordSystem.Cli/TeachingRecordSystem.Cli.csproj index d634925f81..523a20cd9e 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Cli/TeachingRecordSystem.Cli.csproj +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Cli/TeachingRecordSystem.Cli.csproj @@ -2,9 +2,7 @@ Exe - net7.0 - enable - enable + net8.0 trscli diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Core/TeachingRecordSystem.Core.csproj b/TeachingRecordSystem/src/TeachingRecordSystem.Core/TeachingRecordSystem.Core.csproj index 445fa20f5d..b65d04c4c4 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Core/TeachingRecordSystem.Core.csproj +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Core/TeachingRecordSystem.Core.csproj @@ -1,8 +1,7 @@ - net7.0 - enable + net8.0 TeachingRecordSystemCore diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Dockerfile b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Dockerfile index b3eb806af1..221743d5b3 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Dockerfile +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Dockerfile @@ -1,8 +1,9 @@ # syntax=docker/dockerfile:1 -FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine3.18 +FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.18 ARG GIT_SHA ENV GitSha ${GIT_SHA} -COPY src/TeachingRecordSystem.SupportUi/bin/Release/net7.0/publish/ App/ +ENV ASPNETCORE_HTTP_PORTS 80 +COPY src/TeachingRecordSystem.SupportUi/bin/Release/net8.0/publish/ App/ WORKDIR /App # Install Culture prerequisities diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TeachingRecordSystem.SupportUi.csproj b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TeachingRecordSystem.SupportUi.csproj index 311a300335..e88bd56c34 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TeachingRecordSystem.SupportUi.csproj +++ b/TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/TeachingRecordSystem.SupportUi.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 TeachingRecordSystemSupportUi diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/Infrastructure/Security/TestAuthentication.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/Infrastructure/Security/TestAuthentication.cs index 0684b8edb4..e178a7f1c8 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/Infrastructure/Security/TestAuthentication.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/Infrastructure/Security/TestAuthentication.cs @@ -14,9 +14,8 @@ public TestAuthenticationHandler( CurrentApiClientProvider currentApiClientProvider, IOptionsMonitor options, ILoggerFactory logger, - UrlEncoder encoder, - ISystemClock clock) : - base(options, logger, encoder, clock) + UrlEncoder encoder) : + base(options, logger, encoder) { _currentApiClientProvider = currentApiClientProvider; } diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/TeachingRecordSystem.Api.Tests.csproj b/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/TeachingRecordSystem.Api.Tests.csproj index ec273865f9..51755297dc 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/TeachingRecordSystem.Api.Tests.csproj +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/TeachingRecordSystem.Api.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false true diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.Core.Dqt.Tests/TeachingRecordSystem.Core.Dqt.Tests.csproj b/TeachingRecordSystem/tests/TeachingRecordSystem.Core.Dqt.Tests/TeachingRecordSystem.Core.Dqt.Tests.csproj index 97f193043a..10a8ff7de9 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.Core.Dqt.Tests/TeachingRecordSystem.Core.Dqt.Tests.csproj +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.Core.Dqt.Tests/TeachingRecordSystem.Core.Dqt.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false true diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.Core.Tests/TeachingRecordSystem.Core.Tests.csproj b/TeachingRecordSystem/tests/TeachingRecordSystem.Core.Tests/TeachingRecordSystem.Core.Tests.csproj index 54e70c7901..fc7fabadd0 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.Core.Tests/TeachingRecordSystem.Core.Tests.csproj +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.Core.Tests/TeachingRecordSystem.Core.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false true diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/TeachingRecordSystem.SupportUi.EndToEndTests.csproj b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/TeachingRecordSystem.SupportUi.EndToEndTests.csproj index 9b6366049b..5779719165 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/TeachingRecordSystem.SupportUi.EndToEndTests.csproj +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.EndToEndTests/TeachingRecordSystem.SupportUi.EndToEndTests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false true diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/TeachingRecordSystem.SupportUi.Tests.csproj b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/TeachingRecordSystem.SupportUi.Tests.csproj index 59a5f796bd..85824737bf 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/TeachingRecordSystem.SupportUi.Tests.csproj +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.SupportUi.Tests/TeachingRecordSystem.SupportUi.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false true diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.TestCommon/TeachingRecordSystem.TestCommon.csproj b/TeachingRecordSystem/tests/TeachingRecordSystem.TestCommon/TeachingRecordSystem.TestCommon.csproj index a4a65bfebf..9a70aa2d4c 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.TestCommon/TeachingRecordSystem.TestCommon.csproj +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.TestCommon/TeachingRecordSystem.TestCommon.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 false diff --git a/justfile b/justfile index 61bbabab4e..df5f1f9d9c 100644 --- a/justfile +++ b/justfile @@ -12,7 +12,7 @@ install-tools: # Run the trscli cli *ARGS: - @cd {{solution-root / "src" / "TeachingRecordSystem.Cli"}} && dotnet {{"bin" / "Debug" / "net7.0" / "trscli.dll"}} {{ARGS}} + @cd {{solution-root / "src" / "TeachingRecordSystem.Cli"}} && dotnet {{"bin" / "Debug" / "net8.0" / "trscli.dll"}} {{ARGS}} # Build the .NET solution build: @@ -112,7 +112,7 @@ set-ui-e2e-tests-secret key value: @cd {{solution-root / "tests" / "TeachingRecordSystem.SupportUi.EndToEndTests"}} && dotnet user-secrets set "{{key}}" "{{value}}" create-admin email name: - @cd {{solution-root / "src" / "TeachingRecordSystem.Cli"}} && dotnet {{"bin" / "Debug" / "net7.0" / "trscli.dll"}} create-admin --email {{email}} --name {{quote(name)}} + @cd {{solution-root / "src" / "TeachingRecordSystem.Cli"}} && dotnet {{"bin" / "Debug" / "net8.0" / "trscli.dll"}} create-admin --email {{email}} --name {{quote(name)}} make *ARGS: @make {{ARGS}}