Skip to content

Commit 240608e

Browse files
authored
0.2.0 Release Prep, Dependency and Documentation Clean-up (#13)
- Bump version to 0.2.0 - Remove JetBrains Annotations dependency - Upgrade dependencies including F23.Hateoas to 2.0.0 (breaking change - removes Newtonsoft.Json dependency) - Fix Swagger docs for response status codes and types - Run tests on .NET 9 - Remove OpenAPI dependency from examples since we already have Swashbuckle; just use that
1 parent 4265228 commit 240608e

File tree

13 files changed

+105
-62
lines changed

13 files changed

+105
-62
lines changed

.github/workflows/ci_build.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,41 @@ on:
1010
- 'releases/**'
1111
pull_request:
1212
branches: [ main ]
13-
paths:
14-
- '**/*.cs'
15-
- '**/*.csproj'
1613

1714
jobs:
1815
build:
1916

20-
name: build-${{matrix.os}}-${{matrix.dotnet}}
17+
name: build-${{matrix.os}}
2118
runs-on: ${{ matrix.os }}
2219
defaults:
2320
run:
2421
working-directory: src
2522
strategy:
2623
matrix:
2724
os: [ubuntu-latest, windows-latest, macOS-latest]
28-
dotnet: ['8.x'] # Just a single target for now
2925

3026
steps:
3127
- uses: actions/checkout@v3
32-
- name: Setup .NET Core
28+
29+
- name: Setup .NET 8
3330
uses: actions/setup-dotnet@v3
3431
with:
35-
dotnet-version: ${{ matrix.dotnet }}
32+
dotnet-version: 8.x
33+
34+
- name: Setup .NET 9
35+
uses: actions/setup-dotnet@v3
36+
with:
37+
dotnet-version: 9.x
3638

3739
- name: Install dependencies
3840
run: dotnet restore
39-
41+
4042
- name: Build
4143
run: dotnet build --configuration Release --no-restore
4244

4345
- name: Test
44-
run: dotnet test --no-restore --verbosity normal --logger trx --collect:"XPlat Code Coverage"
45-
46+
run: dotnet test --no-build --configuration Release --verbosity normal --logger trx --collect:"XPlat Code Coverage"
47+
4648
- name: Combine Coverage Reports # This is because one report is produced per project, and we want one result for all of them.
4749
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.4
4850
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' # Skip if running locally with act
@@ -55,15 +57,15 @@ jobs:
5557
tag: "${{ github.run_number }}_${{ github.run_id }}" # Optional tag or build version.
5658
customSettings: "" # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
5759
toolpath: "reportgeneratortool" # Default directory for installing the dotnet tool.
58-
60+
5961
- name: Upload Combined Coverage XML
6062
uses: actions/upload-artifact@v4
6163
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' # Skip if running locally with act
6264
with:
6365
name: coverage
6466
path: ${{ github.workspace }}/Cobertura.xml
6567
retention-days: 5
66-
68+
6769
- name: Publish Code Coverage Report
6870
uses: irongut/CodeCoverageSummary@v1.3.0
6971
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' # Skip if running locally with act
@@ -77,7 +79,7 @@ jobs:
7779
indicators: true
7880
output: both
7981
thresholds: "10 30" # Red, Yellow
80-
82+
8183
- name: Add Coverage PR Comment
8284
uses: marocchino/sticky-pull-request-comment@v2
8385
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request' # Skip if running locally with act, or if not a pull request
@@ -92,10 +94,9 @@ jobs:
9294
name: test-results
9395
path: ${{ github.workspace }}/**/TestResults/**/*
9496
retention-days: 5
95-
97+
9698
- name: Publish Test Results
9799
uses: EnricoMi/publish-unit-test-result-action@v2.16.1
98100
if: github.actor != 'nektos/act' && matrix.os == 'ubuntu-latest' && always() # Skip if running locally with act
99101
with:
100102
trx_files: "${{ github.workspace }}/**/*.trx"
101-

.github/workflows/publish.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ name: publish
44

55
on:
66
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
7-
push:
8-
branches:
9-
- main # Run the workflow when pushing to the main branch
10-
- 'releases/**' # Run the workflow when pushing to a release branch
11-
pull_request:
12-
branches:
13-
- '*' # Run the workflow for all pull requests
147
release:
158
types:
169
- published # Run the workflow when a new GitHub release is published
@@ -32,8 +25,15 @@ jobs:
3225
with:
3326
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
3427

35-
- name: Setup .NET
28+
- name: Setup .NET 8
3629
uses: actions/setup-dotnet@v4
30+
with:
31+
dotnet-version: 8.x
32+
33+
- name: Setup .NET 9
34+
uses: actions/setup-dotnet@v4
35+
with:
36+
dotnet-version: 9.x
3737

3838
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
3939

@@ -52,8 +52,17 @@ jobs:
5252
working-directory: src
5353
steps:
5454
- uses: actions/checkout@v3
55-
- name: Setup .NET
55+
56+
- name: Setup .NET 8
57+
uses: actions/setup-dotnet@v4
58+
with:
59+
dotnet-version: 8.x
60+
61+
- name: Setup .NET 9
5662
uses: actions/setup-dotnet@v4
63+
with:
64+
dotnet-version: 9.x
65+
5766
- name: Run tests
5867
run: dotnet test --configuration Release
5968

@@ -74,8 +83,15 @@ jobs:
7483
name: nuget
7584
path: ${{ env.NuGetDirectory }}
7685

77-
- name: Setup .NET Core
86+
- name: Setup .NET 8
7887
uses: actions/setup-dotnet@v4
88+
with:
89+
dotnet-version: 8.x
90+
91+
- name: Setup .NET 9
92+
uses: actions/setup-dotnet@v4
93+
with:
94+
dotnet-version: 9.x
7995

8096
# Publish all NuGet packages to NuGet.org
8197
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
@@ -84,4 +100,4 @@ jobs:
84100
run: |
85101
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
86102
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
87-
}
103+
}

src/F23.Kernel.AspNetCore/F23.Kernel.AspNetCore.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<Version>0.1.0</Version>
7+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
8+
<Version>0.2.0</Version>
89
<Authors>feature[23]</Authors>
910
<Copyright>feature[23]</Copyright>
1011
<PackageProjectUrl>https://github.com/feature23/kernel</PackageProjectUrl>
@@ -23,18 +24,17 @@
2324
<ItemGroup>
2425
<InternalsVisibleTo Include="F23.Kernel.Tests" />
2526
</ItemGroup>
26-
27+
2728
<ItemGroup>
2829
<FrameworkReference Include="Microsoft.AspNetCore.App" />
2930
</ItemGroup>
30-
31+
3132
<ItemGroup>
3233
<ProjectReference Include="..\F23.Kernel\F23.Kernel.csproj" />
3334
</ItemGroup>
3435

3536
<ItemGroup>
36-
<PackageReference Include="F23.Hateoas" Version="1.0.0" />
37-
<!-- <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.3.0" />-->
37+
<PackageReference Include="F23.Hateoas" Version="2.0.0" />
3838
</ItemGroup>
3939

4040
</Project>

src/F23.Kernel.AspNetCore/MinimalApiResultExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static IResult ToMinimalApiResult<T>(this Result<T> result, Func<T, IResu
9797
SuccessResult<T> success when successMap != null
9898
=> successMap(success.Value),
9999
SuccessResult<T> success
100-
=> HttpResults.Ok(new HypermediaResponse(success.Value)),
100+
=> HttpResults.Ok(new HypermediaResponse(success.Value!)), // [!]: TODO: Fix nullability issue in F23.Hateoas
101101
PreconditionFailedResult<T> { Reason: PreconditionFailedReason.NotFound } when useProblemDetails
102102
=> result.ToProblemHttpResult(HttpStatusCode.NotFound),
103103
PreconditionFailedResult<T> { Reason: PreconditionFailedReason.NotFound } when !useProblemDetails

src/F23.Kernel.AspNetCore/MvcResultExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static IActionResult ToActionResult<T>(this Result<T> result, Func<T, IAc
104104
SuccessResult<T> success when successMap != null
105105
=> successMap(success.Value),
106106
SuccessResult<T> success
107-
=> new OkObjectResult(new HypermediaResponse(success.Value)),
107+
=> new OkObjectResult(new HypermediaResponse(success.Value!)), // [!]: TODO: Fix nullability issue in F23.Hateoas
108108
PreconditionFailedResult<T> { Reason: PreconditionFailedReason.NotFound } when useProblemDetails
109109
=> result.ToProblemDetailsResult(HttpStatusCode.NotFound),
110110
PreconditionFailedResult<T> { Reason: PreconditionFailedReason.NotFound } when !useProblemDetails

src/F23.Kernel.Examples.AspNetCore/Core/ResultsEndpoints.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using F23.Kernel;
21
using F23.Kernel.AspNetCore;
32
using F23.Kernel.Results;
4-
using Microsoft.AspNetCore.Builder;
5-
using Microsoft.AspNetCore.Routing;
3+
using Microsoft.AspNetCore.Mvc;
64

75
namespace F23.Kernel.Examples.AspNetCore.Core;
86

@@ -18,43 +16,49 @@ public static class ResultsEndpoints
1816
public static void MapResultsEndpoints(this WebApplication app)
1917
{
2018
var group = app.MapGroup("/minimal-apis/results")
21-
.WithTags("Results - Minimal APIs")
22-
.WithOpenApi();
19+
.WithTags("Results - Minimal APIs");
2320

2421
group.MapGet("/success-no-value", SuccessNoValue)
2522
.WithName("MinimalApiSuccessNoValue")
2623
.WithSummary("Demonstrates a successful result with no value")
27-
.WithDescription("Returns 204 No Content");
24+
.WithDescription("Returns 204 No Content")
25+
.Produces(StatusCodes.Status204NoContent);
2826

2927
group.MapGet("/success-with-value", SuccessWithValue)
3028
.WithName("MinimalApiSuccessWithValue")
3129
.WithSummary("Demonstrates a successful result with a value")
32-
.WithDescription("Returns 200 OK with the value in the response body");
30+
.WithDescription("Returns 200 OK with the value in the response body")
31+
.Produces(StatusCodes.Status200OK);
3332

3433
group.MapGet("/validation-failed", ValidationFailed)
3534
.WithName("MinimalApiValidationFailed")
3635
.WithSummary("Demonstrates a validation failed result")
37-
.WithDescription("Returns 400 Bad Request with validation errors");
36+
.WithDescription("Returns 400 Bad Request with validation errors")
37+
.Produces<HttpValidationProblemDetails>(StatusCodes.Status400BadRequest);
3838

3939
group.MapGet("/unauthorized", Unauthorized)
4040
.WithName("MinimalApiUnauthorized")
4141
.WithSummary("Demonstrates an unauthorized result")
42-
.WithDescription("Returns 403 Forbidden");
42+
.WithDescription("Returns 403 Forbidden")
43+
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden);
4344

4445
group.MapGet("/not-found", NotFound)
4546
.WithName("MinimalApiNotFound")
4647
.WithSummary("Demonstrates a precondition failed result (not found)")
47-
.WithDescription("Returns 404 Not Found");
48+
.WithDescription("Returns 404 Not Found")
49+
.Produces<ProblemDetails>(StatusCodes.Status404NotFound);
4850

4951
group.MapGet("/concurrency-mismatch", ConcurrencyMismatch)
5052
.WithName("MinimalApiConcurrencyMismatch")
5153
.WithSummary("Demonstrates a precondition failed result (concurrency mismatch)")
52-
.WithDescription("Returns 412 Precondition Failed");
54+
.WithDescription("Returns 412 Precondition Failed")
55+
.Produces<ProblemDetails>(StatusCodes.Status412PreconditionFailed);
5356

5457
group.MapGet("/conflict", Conflict)
5558
.WithName("MinimalApiConflict")
5659
.WithSummary("Demonstrates a precondition failed result (conflict)")
57-
.WithDescription("Returns 409 Conflict");
60+
.WithDescription("Returns 409 Conflict")
61+
.Produces<ProblemDetails>(StatusCodes.Status409Conflict);
5862
}
5963

6064
private static IResult SuccessNoValue()

src/F23.Kernel.Examples.AspNetCore/F23.Kernel.Examples.AspNetCore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10"/>
11-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2"/>
10+
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
1211
</ItemGroup>
1312

1413
<ItemGroup>

src/F23.Kernel.Examples.AspNetCore/Infrastructure/ResultsController.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using F23.Kernel;
21
using F23.Kernel.AspNetCore;
32
using F23.Kernel.Results;
43
using Microsoft.AspNetCore.Mvc;
@@ -18,6 +17,7 @@ public class ResultsController : ControllerBase
1817
/// </summary>
1918
/// <returns>204 No Content</returns>
2019
[HttpGet("success-no-value")]
20+
[ProducesResponseType(StatusCodes.Status204NoContent)]
2121
public IActionResult SuccessNoValue()
2222
{
2323
var result = Result.Success();
@@ -29,6 +29,7 @@ public IActionResult SuccessNoValue()
2929
/// </summary>
3030
/// <returns>200 OK with the value in the response body</returns>
3131
[HttpGet("success-with-value")]
32+
[ProducesResponseType(StatusCodes.Status200OK)]
3233
public IActionResult SuccessWithValue()
3334
{
3435
var data = new { message = "Operation completed successfully", timestamp = DateTime.UtcNow };
@@ -41,6 +42,7 @@ public IActionResult SuccessWithValue()
4142
/// </summary>
4243
/// <returns>400 Bad Request with validation errors</returns>
4344
[HttpGet("validation-failed")]
45+
[ProducesResponseType<ValidationProblemDetails>(StatusCodes.Status400BadRequest)]
4446
public IActionResult ValidationFailed()
4547
{
4648
var errors = new[]
@@ -58,6 +60,7 @@ public IActionResult ValidationFailed()
5860
/// </summary>
5961
/// <returns>403 Forbidden</returns>
6062
[HttpGet("unauthorized")]
63+
[ProducesResponseType<ProblemDetails>(StatusCodes.Status403Forbidden)]
6164
public IActionResult UnauthorizedDemo()
6265
{
6366
var result = Result.Unauthorized("User does not have permission to access this resource");
@@ -69,6 +72,7 @@ public IActionResult UnauthorizedDemo()
6972
/// </summary>
7073
/// <returns>404 Not Found</returns>
7174
[HttpGet("not-found")]
75+
[ProducesResponseType<ProblemDetails>(StatusCodes.Status404NotFound)]
7276
public IActionResult NotFoundDemo()
7377
{
7478
var result = Result.PreconditionFailed(
@@ -83,6 +87,7 @@ public IActionResult NotFoundDemo()
8387
/// </summary>
8488
/// <returns>412 Precondition Failed</returns>
8589
[HttpGet("concurrency-mismatch")]
90+
[ProducesResponseType<ProblemDetails>(StatusCodes.Status412PreconditionFailed)]
8691
public IActionResult ConcurrencyMismatch()
8792
{
8893
var result = Result.PreconditionFailed(
@@ -97,6 +102,7 @@ public IActionResult ConcurrencyMismatch()
97102
/// </summary>
98103
/// <returns>409 Conflict</returns>
99104
[HttpGet("conflict")]
105+
[ProducesResponseType<ProblemDetails>(StatusCodes.Status409Conflict)]
100106
public IActionResult ConflictDemo()
101107
{
102108
var result = Result.PreconditionFailed(

0 commit comments

Comments
 (0)