Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"isRoot": true,
"tools": {
"swashbuckle.aspnetcore.cli": {
"version": "6.6.2",
"version": "9.0.1",
"commands": [
"swagger"
]
],
"rollForward": false
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.Social.Api/bin/Debug/net9.0/CrowdParlay.Users.Api.dll v1
- name: 🔗 Upload OpenAPI specification as release asset
uses: actions/upload-release-asset@v1
env:
Expand Down
13 changes: 12 additions & 1 deletion src/CrowdParlay.Users.Api/Swagger/ConfigureSwaggerOptions.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<SortingStrategy>(() => new OpenApiSchema
{
Type = "string",
Enum = Enum.GetNames(typeof(SortingStrategy))
.Select(name => char.ToLowerInvariant(name[0]) + name[1..])
.Select(name => new OpenApiString(name))
.Cast<IOpenApiAny>()
.ToList()
});
}

private static OpenApiInfo CreateInfoForApiVersion(ApiVersionDescription versionDescription)
Expand Down
2 changes: 2 additions & 0 deletions src/CrowdParlay.Users.Api/v1/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Net.Mime;
using System.Text.Json;
Expand All @@ -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;

Expand Down
Loading