Skip to content
Closed
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
2 changes: 1 addition & 1 deletion App/Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<ProjectReference Include="..\Services\Services.csproj" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<PackageReference Include="Scalar.AspNetCore" />
<PackageReference Include="Serilog"/>
<PackageReference Include="Serilog.Extensions.Hosting" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Swashbuckle.AspNetCore" />
</ItemGroup>
</Project>
22 changes: 7 additions & 15 deletions App/Api/Setup/Middleware.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Scalar.AspNetCore;

public static class Middleware
{
public static void ConfigureMiddleware(this WebApplication app)
Expand All @@ -13,21 +15,12 @@ public static void ConfigureMiddleware(this WebApplication app)

app.UseOutputCache();

app.UseStaticFiles();

app.UseSwagger();
app.UseSwaggerUI(opt =>
app.MapOpenApi();
app.MapScalarApiReference(opt =>
{
var descriptions = app.DescribeApiVersions();
foreach (var desc in descriptions)
{
var url = $"/swagger/{desc.GroupName}/swagger.json";
var name = desc.GroupName.ToUpperInvariant();
opt.SwaggerEndpoint(url, name);
}
opt.RoutePrefix = string.Empty;
var indexPath = Path.Combine(env.WebRootPath, "swagger-ui", "index.html");
opt.IndexStream = () => new FileStream(indexPath, FileMode.Open, FileAccess.Read);
opt.Title = "Bitcoin Web API";
opt.ShowSidebar = true;
opt.DarkMode = true;
});

app.MapHealthChecks("health");
Expand All @@ -41,7 +34,6 @@ public static void ConfigureMiddleware(this WebApplication app)

app.Use(async (context, next) =>
{
context.Response.Headers.Append("Content-Security-Policy", "default-src 'self'");
context.Response.Headers.Append("X-Content-Type-Options", "nosniff");
context.Response.Headers.Append("X-Frame-Options", "DENY");
context.Response.Headers.Append("Referrer-Policy", "no-referrer");
Expand Down
3 changes: 1 addition & 2 deletions App/Api/Setup/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public static void ConfigureServices(this IServiceCollection services)
opt.SubstituteApiVersionInUrl = true;
});

services.AddSwaggerGen();
services.ConfigureOptions<ConfigureSwaggerOptions>();
services.AddOpenApi();

services.Configure<JsonOptions>(opt =>
{
Expand Down
34 changes: 0 additions & 34 deletions App/Api/Setup/Swagger.cs

This file was deleted.

19 changes: 0 additions & 19 deletions App/Api/wwwroot/swagger-ui/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion App/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<PackageVersion Include="Asp.Versioning.Http" Version="8.1.0" />
<PackageVersion Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageVersion Include="Scalar.AspNetCore" Version="1.2.41" />
<PackageVersion Include="Serilog" Version="4.1.0" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="7.0.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions Tests/IntegrationTests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public async Task BuyAndSell(string? fromDate, string? toDate, HttpStatusCode st
}

[Fact]
public async Task Swagger()
public async Task OpenApi()
{
var result = await _fixture.Client.GetAsync("/");
var result = await _fixture.Client.GetAsync("/openapi/v1.json");
result.StatusCode.Should().Be(HttpStatusCode.OK);
}

Expand Down
Loading