From fba272ba6efb64e27c1d15112ae0b1b4af8db808 Mon Sep 17 00:00:00 2001 From: undrcrxwn <69521267+undrcrxwn@users.noreply.github.com> Date: Tue, 24 Jun 2025 16:22:34 +0300 Subject: [PATCH 1/2] fix(openapi): configure Swagger to treat SortingStrategy as enum of strings --- .../Swagger/ConfigureSwaggerOptions.cs | 13 ++++++++++++- .../v1/Controllers/UsersController.cs | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/CrowdParlay.Users.Api/Swagger/ConfigureSwaggerOptions.cs b/src/CrowdParlay.Users.Api/Swagger/ConfigureSwaggerOptions.cs index 6adda34..59ce796 100644 --- a/src/CrowdParlay.Users.Api/Swagger/ConfigureSwaggerOptions.cs +++ b/src/CrowdParlay.Users.Api/Swagger/ConfigureSwaggerOptions.cs @@ -1,5 +1,7 @@ +using CrowdParlay.Users.Domain; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; @@ -21,9 +23,18 @@ public void Configure(SwaggerGenOptions options) { foreach (var description in _provider.ApiVersionDescriptions) options.SwaggerDoc(description.GroupName, CreateInfoForApiVersion(description)); - + options.SupportNonNullableReferenceTypes(); options.UseAllOfToExtendReferenceSchemas(); + options.MapType(() => new OpenApiSchema + { + Type = "string", + Enum = Enum.GetNames(typeof(SortingStrategy)) + .Select(name => char.ToLowerInvariant(name[0]) + name[1..]) + .Select(name => new OpenApiString(name)) + .Cast() + .ToList() + }); } private static OpenApiInfo CreateInfoForApiVersion(ApiVersionDescription versionDescription) diff --git a/src/CrowdParlay.Users.Api/v1/Controllers/UsersController.cs b/src/CrowdParlay.Users.Api/v1/Controllers/UsersController.cs index bec1a8c..7726ed2 100644 --- a/src/CrowdParlay.Users.Api/v1/Controllers/UsersController.cs +++ b/src/CrowdParlay.Users.Api/v1/Controllers/UsersController.cs @@ -1,3 +1,4 @@ +using System.ComponentModel.DataAnnotations; using System.Net; using System.Net.Mime; using System.Text.Json; @@ -15,6 +16,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Mvc; +using ValidationException = CrowdParlay.Users.Application.Exceptions.ValidationException; namespace CrowdParlay.Users.Api.v1.Controllers; From 1f01c9e1ef9957821a4b0e6e8863a48e0479c466 Mon Sep 17 00:00:00 2001 From: undrcrxwn <69521267+undrcrxwn@users.noreply.github.com> Date: Tue, 24 Jun 2025 16:24:54 +0300 Subject: [PATCH 2/2] fix(ci): replace wrong DLL path in OpenAPI workflow --- .config/dotnet-tools.json | 5 +++-- .github/workflows/openapi.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index fe723f0..80e0e99 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,10 +3,11 @@ "isRoot": true, "tools": { "swashbuckle.aspnetcore.cli": { - "version": "6.6.2", + "version": "9.0.1", "commands": [ "swagger" - ] + ], + "rollForward": false } } } \ No newline at end of file diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml index 20c1e0d..e25482f 100644 --- a/.github/workflows/openapi.yml +++ b/.github/workflows/openapi.yml @@ -25,7 +25,7 @@ jobs: - name: ⚙️ Restore .NET tools run: dotnet tool restore - name: 📝 Produce OpenAPI specification - run: dotnet swagger tofile --output openapi.yaml --yaml ./src/CrowdParlay.Social.Api/bin/Debug/net9.0/CrowdParlay.Social.Api.dll v1 + run: dotnet swagger tofile --output openapi.yaml --yaml ./src/CrowdParlay.Users.Api/bin/Debug/net9.0/CrowdParlay.Users.Api.dll v1 - name: 🔗 Upload OpenAPI specification as release asset uses: actions/upload-release-asset@v1 env: