From 9bda262b25c8b456beb79a6dd99b4447087868a8 Mon Sep 17 00:00:00 2001 From: Mirko Sekulic Date: Thu, 14 Nov 2024 09:02:06 +0100 Subject: [PATCH] chore: .net8 -> .net9 (#14043) --- .github/workflows/codeql.yml | 5 ++++ .github/workflows/designer-dotnet-test.yaml | 2 +- .github/workflows/dotnet-format.yaml | 2 +- .../gitea-designer-integration-tests.yaml | 2 +- Dockerfile | 4 +-- backend/Directory.Build.props | 2 +- backend/Migrations.Dockerfile | 2 +- backend/packagegroups/NuGet.props | 12 ++++----- backend/src/Designer/Designer.csproj | 2 +- backend/src/Designer/Program.cs | 25 ++----------------- .../Designer/wwwroot/designer/openapi.html | 23 +++++++++++++++++ .../Utils/RandomObjectModelGenerator.cs | 13 +++++++++- 12 files changed, 56 insertions(+), 38 deletions(-) create mode 100644 backend/src/Designer/wwwroot/designer/openapi.html diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 49ae99b7f8b..93bf788caa1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -30,6 +30,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: diff --git a/.github/workflows/designer-dotnet-test.yaml b/.github/workflows/designer-dotnet-test.yaml index 7f0df1bc60b..7e91e2bb1fb 100644 --- a/.github/workflows/designer-dotnet-test.yaml +++ b/.github/workflows/designer-dotnet-test.yaml @@ -27,7 +27,7 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 8.0.x + 9.0.x - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis diff --git a/.github/workflows/dotnet-format.yaml b/.github/workflows/dotnet-format.yaml index 6f2ff345f56..bcff1afad91 100644 --- a/.github/workflows/dotnet-format.yaml +++ b/.github/workflows/dotnet-format.yaml @@ -20,7 +20,7 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 8.0.x + 9.0.x - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis diff --git a/.github/workflows/gitea-designer-integration-tests.yaml b/.github/workflows/gitea-designer-integration-tests.yaml index d7cc63e5667..a792c66655b 100644 --- a/.github/workflows/gitea-designer-integration-tests.yaml +++ b/.github/workflows/gitea-designer-integration-tests.yaml @@ -25,7 +25,7 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 8.0.x + 9.0.x - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis diff --git a/Dockerfile b/Dockerfile index d5d8ca10c3f..e4d36091075 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ COPY . . RUN yarn build # Building the backend -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS generate-studio-backend +FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS generate-studio-backend ARG DESIGNER_VERSION='' WORKDIR /build COPY backend . @@ -52,7 +52,7 @@ WORKDIR /version RUN echo "{\"designerVersion\":\"$DESIGNER_VERSION\",\"appTemplateVersion\":\"$(curl -s https://api.github.com/repos/Altinn/app-template-dotnet/releases/latest | jq -r .tag_name)\"}" > version.json # Building the final image -FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final +FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine AS final EXPOSE 80 WORKDIR /app ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ diff --git a/backend/Directory.Build.props b/backend/Directory.Build.props index 29f8cbdfd70..b81d75c4147 100644 --- a/backend/Directory.Build.props +++ b/backend/Directory.Build.props @@ -1,6 +1,6 @@ - net8.0 + net9.0 Altinn Altinn Studio diff --git a/backend/Migrations.Dockerfile b/backend/Migrations.Dockerfile index bd314773319..6523121e42b 100644 --- a/backend/Migrations.Dockerfile +++ b/backend/Migrations.Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build WORKDIR /app diff --git a/backend/packagegroups/NuGet.props b/backend/packagegroups/NuGet.props index 5b7d4b031da..389193bbd30 100644 --- a/backend/packagegroups/NuGet.props +++ b/backend/packagegroups/NuGet.props @@ -19,20 +19,20 @@ - + - + + - @@ -45,7 +45,7 @@ - + @@ -59,8 +59,8 @@ - - + + diff --git a/backend/src/Designer/Designer.csproj b/backend/src/Designer/Designer.csproj index 5c1a057d3e8..341117518d1 100644 --- a/backend/src/Designer/Designer.csproj +++ b/backend/src/Designer/Designer.csproj @@ -41,6 +41,7 @@ + @@ -58,7 +59,6 @@ - diff --git a/backend/src/Designer/Program.cs b/backend/src/Designer/Program.cs index b90669b0706..e989dacb740 100644 --- a/backend/src/Designer/Program.cs +++ b/backend/src/Designer/Program.cs @@ -38,7 +38,6 @@ using Microsoft.Extensions.Logging; using Microsoft.FeatureManagement; using Microsoft.Net.Http.Headers; -using Microsoft.OpenApi.Models; ILogger logger; @@ -243,18 +242,7 @@ void ConfigureServices(IServiceCollection services, IConfiguration configuration services.ConfigureLocalization(); services.AddPolicyBasedAuthorization(); - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "Altinn Designer API", Version = "v1" }); - try - { - c.IncludeXmlComments(GetXmlCommentsPathForControllers()); - } - catch - { - // Catch swashbuckle exception if it doesn't find the generated XML documentation file - } - }); + services.AddOpenApi("v1"); // Auto register all settings classes services.RegisterSettingsByBaseType(configuration); @@ -320,16 +308,7 @@ void Configure(IConfiguration configuration) } }); - const string swaggerRoutePrefix = "designer/swagger"; - app.UseSwagger(c => - { - c.RouteTemplate = swaggerRoutePrefix + "/{documentName}/swagger.json"; - }); - app.UseSwaggerUI(c => - { - c.RoutePrefix = swaggerRoutePrefix; - c.SwaggerEndpoint($"/{swaggerRoutePrefix}/v1/swagger.json", "Altinn Designer API V1"); - }); + app.MapOpenApi("/designer/openapi/{documentName}/openapi.json"); if (!app.Environment.IsDevelopment()) { diff --git a/backend/src/Designer/wwwroot/designer/openapi.html b/backend/src/Designer/wwwroot/designer/openapi.html new file mode 100644 index 00000000000..d285d64b159 --- /dev/null +++ b/backend/src/Designer/wwwroot/designer/openapi.html @@ -0,0 +1,23 @@ + + + + + + Elements in HTML + + + + + + + + + + + + + diff --git a/backend/tests/DataModeling.Tests/Utils/RandomObjectModelGenerator.cs b/backend/tests/DataModeling.Tests/Utils/RandomObjectModelGenerator.cs index e3b25304ede..c0f2ab9d5e3 100644 --- a/backend/tests/DataModeling.Tests/Utils/RandomObjectModelGenerator.cs +++ b/backend/tests/DataModeling.Tests/Utils/RandomObjectModelGenerator.cs @@ -78,6 +78,12 @@ private static void PopulatePrimitiveProperty(object obj, PropertyInfo property) return; } + // Do not generate AltinnRowId + if (property.PropertyType == typeof(Guid) && property.Name.Equals("AltinnRowId")) + { + return; + } + property.SetValue(obj, GeneratePrimitiveType(property.PropertyType, property.CustomAttributes)); } @@ -126,6 +132,11 @@ private static object GeneratePrimitiveType(Type type, IEnumerable