Skip to content

Commit 4d078ba

Browse files
authored
feat: Swap Swagger UI with Scalar UI docs for Chapters 2, 3, and 4 (#245)
1 parent 24930d1 commit 4d078ba

File tree

28 files changed

+50
-123
lines changed

28 files changed

+50
-123
lines changed

Chapter-2-modules-separation/Src/Common/Fitnet.Common.Api/Documentation/SwaggerDocumentationExtensions.cs renamed to Chapter-2-modules-separation/Src/Common/Fitnet.Common.Api/Documentation/ApiDocumentationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
public static class ApiDocumentationExtensions
88
{
99
public static void UseApiDocumentation(this IEndpointRouteBuilder app) =>
10-
app.MapGet("/", () => Results.Redirect("/swagger"))
10+
app.MapGet("/", () => Results.Redirect("/docs/v1"))
1111
.Produces(StatusCodes.Status200OK)
1212
.WithTags("Documentation");
1313
}

Chapter-2-modules-separation/Src/Common/Tests/Fitnet.Common.Infrastructure.IntegrationTests/Events/EventBus/InMemory/InMemoryEventBusTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal async Task Given_valid_event_published_Then_event_should_be_consumed()
1919
var fakeEvent = FakeEvent.Create();
2020

2121
// Act
22-
await eventBus!.PublishAsync(fakeEvent, CancellationToken.None);
22+
await eventBus.PublishAsync(fakeEvent, CancellationToken.None);
2323

2424
// Assert
2525
fakeEvent.Consumed.ShouldBeTrue();

Chapter-2-modules-separation/Src/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<Nullable>enable</Nullable>
1212
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1313
<GenerateDocumentationFile>true</GenerateDocumentationFile>
14+
<InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated</InterceptorsNamespaces>
1415
</PropertyGroup>
1516

1617
<ItemGroup>

Chapter-2-modules-separation/Src/Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageVersion Include="KubernetesClient" Version="17.0.14" />
1313
<PackageVersion Include="MediatR" Version="12.5.0" />
1414
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
15-
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
15+
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
1616
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
1717
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
1818
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.0" />
@@ -22,7 +22,7 @@
2222
<PackageVersion Include="Microsoft.OpenApi" Version="2.3.0" />
2323
<PackageVersion Include="Npgsql" Version="10.0.0" />
2424
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
25-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.0.1" />
25+
<PackageVersion Include="Scalar.AspNetCore" Version="2.12.17" />
2626
</ItemGroup>
2727
<ItemGroup Label="Tests">
2828
<PackageVersion Include="Bogus" Version="35.6.3" />

Chapter-2-modules-separation/Src/Fitnet/Fitnet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<ItemGroup>
88
<PackageReference Include="JetBrains.Annotations" />
9-
<PackageReference Include="Swashbuckle.AspNetCore" />
9+
<PackageReference Include="Scalar.AspNetCore" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

Chapter-2-modules-separation/Src/Fitnet/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
using EvolutionaryArchitecture.Fitnet.Common.Api.ErrorHandling;
33
using EvolutionaryArchitecture.Fitnet.Common.Infrastructure;
44
using EvolutionaryArchitecture.Fitnet.Modules;
5+
using Scalar.AspNetCore;
56

67
var builder = WebApplication.CreateBuilder(args);
78
builder.Services.AddControllers();
8-
builder.Services.AddEndpointsApiExplorer();
9-
builder.Services.AddSwaggerGen();
9+
builder.Services.AddOpenApi();
1010

1111
builder.Services.AddExceptionHandling();
1212
builder.Services.AddCommonInfrastructure();
@@ -16,8 +16,8 @@
1616

1717
if (app.Environment.IsDevelopment())
1818
{
19-
app.UseSwagger();
20-
app.UseSwaggerUI();
19+
app.MapOpenApi();
20+
app.MapScalarApiReference("/docs/v1");
2121
}
2222

2323
app.UseApiDocumentation();
Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
{
22
"$schema": "https://json.schemastore.org/launchsettings.json",
3-
"iisSettings": {
4-
"windowsAuthentication": false,
5-
"anonymousAuthentication": true,
6-
"iisExpress": {
7-
"applicationUrl": "http://localhost:62425",
8-
"sslPort": 44354
9-
}
10-
},
113
"profiles": {
124
"http": {
135
"commandName": "Project",
146
"dotnetRunMessages": true,
157
"launchBrowser": true,
16-
"launchUrl": "swagger",
8+
"launchUrl": "docs/v1",
179
"applicationUrl": "http://localhost:5013",
1810
"environmentVariables": {
1911
"ASPNETCORE_ENVIRONMENT": "Development"
@@ -23,19 +15,11 @@
2315
"commandName": "Project",
2416
"dotnetRunMessages": true,
2517
"launchBrowser": true,
26-
"launchUrl": "swagger",
18+
"launchUrl": "docs/v1",
2719
"applicationUrl": "https://localhost:7097;http://localhost:5013",
2820
"environmentVariables": {
2921
"ASPNETCORE_ENVIRONMENT": "Development"
3022
}
31-
},
32-
"IIS Express": {
33-
"commandName": "IISExpress",
34-
"launchBrowser": true,
35-
"launchUrl": "swagger",
36-
"environmentVariables": {
37-
"ASPNETCORE_ENVIRONMENT": "Development"
38-
}
3923
}
4024
}
4125
}

Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<Nullable>enable</Nullable>
1212
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1313
<GenerateDocumentationFile>true</GenerateDocumentationFile>
14+
<InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated</InterceptorsNamespaces>
1415
</PropertyGroup>
1516

1617
<ItemGroup>

Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
2121
<PackageVersion Include="Microsoft.OpenApi" Version="2.3.0" />
2222
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
23-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.0.1" />
23+
<PackageVersion Include="Scalar.AspNetCore" Version="2.12.17" />
2424
</ItemGroup>
2525
<ItemGroup Label="Tests">
2626
<PackageVersion Include="Bogus" Version="35.6.3" />

Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts/Fitnet.Contracts.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ItemGroup>
88
<PackageReference Include="EvolutionaryArchitecture.Fitnet.Common.Api" />
99
<PackageReference Include="JetBrains.Annotations" />
10-
<PackageReference Include="Swashbuckle.AspNetCore" />
10+
<PackageReference Include="Scalar.AspNetCore" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

0 commit comments

Comments
 (0)