Skip to content

feat: Swap Swagger UI with Scalar UI docs for Chapters 2, 3, and 4#245

Merged
kamilbaczek merged 7 commits intomainfrom
copilot/update-chapter-2-3-4-contracts-monolith
Apr 11, 2026
Merged

feat: Swap Swagger UI with Scalar UI docs for Chapters 2, 3, and 4#245
kamilbaczek merged 7 commits intomainfrom
copilot/update-chapter-2-3-4-contracts-monolith

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 29, 2026

📋 Description

Extends the Scalar API documentation integration from Chapter 1 (PR #236) to Chapters 2, 3, and 4 — covering both the Fitnet monolith and Fitnet.Contracts microservice where applicable.

Changes across all 5 affected projects (Ch2/Fitnet, Ch3/Fitnet, Ch3/Fitnet.Contracts, Ch4/Fitnet, Ch4/Fitnet.Contracts):

  • Directory.Packages.props — replace Swashbuckle.AspNetCore with Scalar.AspNetCore v2.12.17; bump Microsoft.AspNetCore.OpenApi to 10.0.1; add FluentAssertions v6.12.2 to Ch3 Fitnet test packages
  • Directory.Build.props — add <InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated</InterceptorsNamespaces> to enable the C# interceptors feature required by the Microsoft.AspNetCore.OpenApi source generator (XML doc comment support)
  • .csproj — update package references; add explicit FluentAssertions reference to Ch3 Reports integration tests
  • Program.cs — migrate to native OpenAPI + Scalar:
    // Before
    builder.Services.AddEndpointsApiExplorer();
    builder.Services.AddSwaggerGen();
    // ...
    app.UseSwagger();
    app.UseSwaggerUI();
    
    // After
    builder.Services.AddOpenApi();
    // ...
    app.MapOpenApi();
    app.MapScalarApiReference("/docs/v1");
  • launchSettings.jsonlaunchUrl: swaggerdocs/v1; remove IIS Express profile
  • ApiDocumentationExtensions.cs (Ch2 only) — root redirect updated from /swagger/docs/v1; file renamed from SwaggerDocumentationExtensions.cs to ApiDocumentationExtensions.cs to match the class name
  • InMemoryEventBusTests.cs (Ch2) — removed unnecessary null-forgiving operator (!) to resolve IDE0370 build error

📦 PR Includes

  • Feature added 🆕
  • Bug fix 🐛
  • Code refactor 🔄
  • Documentation update 📚
  • Tests added/updated 🧪
  • Other: (describe)

🚫 PR Does Not Include

  • Breaking changes ❌
  • Major architectural changes 🏗️
  • Unrelated features/tasks 🚫

💡 Additional Notes

API docs available at /docs/v1 in development mode. Consistent with the Chapter 1 implementation.

The Microsoft.AspNetCore.OpenApi source generator (introduced in .NET 10) emits C# interceptor code to support XML doc comments in OpenAPI specs. This requires explicitly opting in via InterceptorsNamespaces in each chapter's Directory.Build.props; without it the build fails with CS9137.

FluentAssertions was referenced in Ch3 Reports integration tests' GlobalUsings.cs but was not declared as an explicit package reference. Added the package declaration (v6.12.2, matching Ch4) to resolve the CS0246 build error.

InMemoryEventBusTests.cs used a null-forgiving operator (!) on a non-nullable IEventBus return value, which was flagged as IDE0370 (unnecessary suppression) and treated as an error due to TreatWarningsAsErrors=true and EnforceCodeStyleInBuild=true in Directory.Build.props. The suppression has been removed.


⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI changed the title [WIP] Update chapter 2 and 3 contracts and monolith for chapter 4 feat: Swap Swagger UI with Scalar UI docs for Chapters 2, 3, and 4 Mar 29, 2026
Copilot AI requested a review from kamilbaczek March 29, 2026 21:36
@kamilbaczek kamilbaczek marked this pull request as ready for review March 30, 2026 05:17
@@ -7,7 +7,7 @@
public static class ApiDocumentationExtensions
{
public static void UseApiDocumentation(this IEndpointRouteBuilder app) =>
app.MapGet("/", () => Results.Redirect("/swagger"))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename file to ApiDocumentationExtensions @copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5f897c1.

@kamilbaczek
Copy link
Copy Markdown
Collaborator

@copilot Error: /home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-2-modules-separation/Src/Fitnet/obj/Debug/net10.0/Microsoft.AspNetCore.OpenApi.SourceGenerators/Microsoft.AspNetCore.OpenApi.SourceGenerators.XmlCommentGenerator/OpenApiXmlCommentSupport.generated.cs(596,10): error CS9137: The 'interceptors' feature is not enabled in this namespace. Add '$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated' to your project. [/home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-2-modules-separation/Src/Fitnet/Fitnet.csproj]

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 11, 2026

@copilot Error: /home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-2-modules-separation/Src/Fitnet/obj/Debug/net10.0/Microsoft.AspNetCore.OpenApi.Sourc...

Fixed in 5ea6d71. The Microsoft.AspNetCore.OpenApi source generator produces code using C# interceptors (for XML doc comment support), but the interceptors feature requires explicit opt-in. Added <InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated</InterceptorsNamespaces> to Directory.Build.props for Chapters 2, 3, and 4 (all five Directory.Build.props files). Also bumped Microsoft.AspNetCore.OpenApi from 10.0.010.0.1 in Chapter 2's Directory.Packages.props to align with Chapters 3 and 4.

@kamilbaczek
Copy link
Copy Markdown
Collaborator

@copilot Error: /home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-3-microservice-extraction/Fitnet/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/GlobalUsings.cs(5,14): error CS0246: The type or namespace name 'FluentAssertions' could not be found (are you missing a using directive or an assembly reference?) [/home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-3-microservice-extraction/Fitnet/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/Fitnet.Reports.IntegrationTests.csproj]

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 11, 2026

@copilot Error: /home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-3-microservice-extraction/Fitnet/Src/Reports/Tests/Fitnet.Reports.IntegrationTests/...

Fixed in 17035ec. FluentAssertions was referenced in GlobalUsings.cs but not declared as an explicit package. Added FluentAssertions v6.12.2 (matching Chapter 4) to Chapter-3-microservice-extraction/Fitnet/Src/Directory.Packages.props and added the <PackageReference> to Fitnet.Reports.IntegrationTests.csproj.

@kamilbaczek
Copy link
Copy Markdown
Collaborator

@copilot Error: /home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-2-modules-separation/Src/Common/Tests/Fitnet.Common.Infrastructure.IntegrationTests/Events/EventBus/InMemory/InMemoryEventBusTests.cs(22,23): error IDE0370: Suppression is unnecessary (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0370) [/home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-2-modules-separation/Src/Common/Tests/Fitnet.Common.Infrastructure.IntegrationTests/Fitnet.Common.Infrastructure.IntegrationTests.csproj]

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 11, 2026

@copilot Error: /home/runner/work/evolutionary-architecture-by-example/evolutionary-architecture-by-example/Chapter-2-modules-separation/Src/Common/Tests/Fitnet.Common.Infrastructure.IntegrationTests/...

Fixed in 1e6d3e3. The ! null-forgiving operator on eventBus was unnecessary since GetEventBus() returns a non-nullable IEventBus. Removed the suppression.

@kamilbaczek kamilbaczek merged commit 4d078ba into main Apr 11, 2026
10 checks passed
@kamilbaczek kamilbaczek deleted the copilot/update-chapter-2-3-4-contracts-monolith branch April 11, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants