Skip to content

Commit 9d0f574

Browse files
committed
Replaced Swagger with Scalar in the example project
1 parent 1e1bb4b commit 9d0f574

4 files changed

Lines changed: 18 additions & 83 deletions

File tree

example/OwaspHeaders.Core.Example/OwaspHeaders.Core.Example.csproj

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

1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.8"/>
13-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
13+
<PackageReference Include="Scalar.AspNetCore" Version="2.14.14"/>
1414
</ItemGroup>
1515

1616
<ItemGroup>

example/OwaspHeaders.Core.Example/Program.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
using OwaspHeaders.Core.Enums;
2-
// the above using statement is required for example 4, which is commented
3-
// out by default. As such, Rider (and linting tools) will likely complain
4-
// about the fact that it is unnecessary.
2+
using Scalar.AspNetCore;
3+
// the OwaspHeaders.Core.Enums using statement is required for example 4,
4+
// which is commented out by default. As such, Rider (and linting tools)
5+
// will likely complain about the fact that it is unnecessary.
56

67
var builder = WebApplication.CreateBuilder(args);
78

89
// Add services to the container.
910
builder.Services.AddControllers();
10-
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
11-
builder.Services.AddEndpointsApiExplorer();
12-
builder.Services.AddSwaggerGen();
11+
builder.Services.AddOpenApi();
1312

1413
// Configure logging - this shows how to see SecureHeaders logs in console output
1514
builder.Logging.ClearProviders();
@@ -21,15 +20,15 @@
2120
// Configure the HTTP request pipeline.
2221
if (app.Environment.IsDevelopment())
2322
{
24-
app.UseSwagger();
25-
app.UseSwaggerUI();
23+
app.MapOpenApi();
24+
app.MapScalarApiReference();
2625
}
2726

2827
app.UseHttpsRedirection();
2928
app.UseAuthorization();
3029

3130
// Example 1: Basic SecureHeaders with default logging (uses default Event IDs 1000-3999)
32-
var listOfUrlsToIgnore = new List<string> { "/skipthis" };
31+
var listOfUrlsToIgnore = new List<string> { "/skipthis", "/scalar/v1" };
3332
app.UseSecureHeadersMiddleware(urlIgnoreList: listOfUrlsToIgnore);
3433

3534
// Example 2 (commented): Custom configuration with custom Event IDs

example/OwaspHeaders.Core.Example/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dotnet run
1212

1313
2. Open your browser to the displayed URL (typically `https://localhost:7xxx`, check the `launchSettings.json` file for the exact port)
1414

15-
3. Navigate to the Swagger UI to explore the available endpoints
15+
3. Navigate to `/scalar/v1` in your browser to explore the available endpoints via the Scalar API reference UI. The raw OpenAPI document is served at `/openapi/v1.json`.
1616

1717
## Available Endpoints
1818

example/OwaspHeaders.Core.Example/packages.lock.json

Lines changed: 8 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,17 @@
1111
"Microsoft.OpenApi": "2.0.0"
1212
}
1313
},
14-
"Swashbuckle.AspNetCore": {
14+
"Scalar.AspNetCore": {
1515
"type": "Direct",
16-
"requested": "[6.4.0, )",
17-
"resolved": "6.4.0",
18-
"contentHash": "eUBr4TW0up6oKDA5Xwkul289uqSMgY0xGN4pnbOIBqCcN9VKGGaPvHX3vWaG/hvocfGDP+MGzMA0bBBKz2fkmQ==",
19-
"dependencies": {
20-
"Microsoft.Extensions.ApiDescription.Server": "6.0.5",
21-
"Swashbuckle.AspNetCore.Swagger": "6.4.0",
22-
"Swashbuckle.AspNetCore.SwaggerGen": "6.4.0",
23-
"Swashbuckle.AspNetCore.SwaggerUI": "6.4.0"
24-
}
25-
},
26-
"Microsoft.Extensions.ApiDescription.Server": {
27-
"type": "Transitive",
28-
"resolved": "6.0.5",
29-
"contentHash": "Ckb5EDBUNJdFWyajfXzUIMRkhf52fHZOQuuZg/oiu8y7zDCVwD0iHhew6MnThjHmevanpxL3f5ci2TtHQEN6bw=="
16+
"requested": "[2.14.14, )",
17+
"resolved": "2.14.14",
18+
"contentHash": "xNa3MadDudKk7y+0gQPBQihVL+JxGP3KNZHB4Zl2W42ATFIffHHHBjsuyKJ4YPUnnA7NUiHR/diqV/FTZC9dkg=="
3019
},
3120
"Microsoft.OpenApi": {
3221
"type": "Transitive",
3322
"resolved": "2.0.0",
3423
"contentHash": "GGYLfzV/G/ct80OZ45JxnWP7NvMX1BCugn/lX7TH5o0lcVaviavsLMTxmFV2AybXWjbi3h6FF1vgZiTK6PXndw=="
3524
},
36-
"Swashbuckle.AspNetCore.Swagger": {
37-
"type": "Transitive",
38-
"resolved": "6.4.0",
39-
"contentHash": "nl4SBgGM+cmthUcpwO/w1lUjevdDHAqRvfUoe4Xp/Uvuzt9mzGUwyFCqa3ODBAcZYBiFoKvrYwz0rabslJvSmQ==",
40-
"dependencies": {
41-
"Microsoft.OpenApi": "1.2.3"
42-
}
43-
},
44-
"Swashbuckle.AspNetCore.SwaggerGen": {
45-
"type": "Transitive",
46-
"resolved": "6.4.0",
47-
"contentHash": "lXhcUBVqKrPFAQF7e/ZeDfb5PMgE8n5t6L5B6/BQSpiwxgHzmBcx8Msu42zLYFTvR5PIqE9Q9lZvSQAcwCxJjw==",
48-
"dependencies": {
49-
"Swashbuckle.AspNetCore.Swagger": "6.4.0"
50-
}
51-
},
52-
"Swashbuckle.AspNetCore.SwaggerUI": {
53-
"type": "Transitive",
54-
"resolved": "6.4.0",
55-
"contentHash": "1Hh3atb3pi8c+v7n4/3N80Jj8RvLOXgWxzix6w3OZhB7zBGRwsy7FWr4e3hwgPweSBpwfElqj4V4nkjYabH9nQ=="
56-
},
5725
"owaspheaders.core": {
5826
"type": "Project"
5927
}
@@ -68,49 +36,17 @@
6836
"Microsoft.OpenApi": "2.0.0"
6937
}
7038
},
71-
"Swashbuckle.AspNetCore": {
39+
"Scalar.AspNetCore": {
7240
"type": "Direct",
73-
"requested": "[6.4.0, )",
74-
"resolved": "6.4.0",
75-
"contentHash": "eUBr4TW0up6oKDA5Xwkul289uqSMgY0xGN4pnbOIBqCcN9VKGGaPvHX3vWaG/hvocfGDP+MGzMA0bBBKz2fkmQ==",
76-
"dependencies": {
77-
"Microsoft.Extensions.ApiDescription.Server": "6.0.5",
78-
"Swashbuckle.AspNetCore.Swagger": "6.4.0",
79-
"Swashbuckle.AspNetCore.SwaggerGen": "6.4.0",
80-
"Swashbuckle.AspNetCore.SwaggerUI": "6.4.0"
81-
}
82-
},
83-
"Microsoft.Extensions.ApiDescription.Server": {
84-
"type": "Transitive",
85-
"resolved": "6.0.5",
86-
"contentHash": "Ckb5EDBUNJdFWyajfXzUIMRkhf52fHZOQuuZg/oiu8y7zDCVwD0iHhew6MnThjHmevanpxL3f5ci2TtHQEN6bw=="
41+
"requested": "[2.14.14, )",
42+
"resolved": "2.14.14",
43+
"contentHash": "xNa3MadDudKk7y+0gQPBQihVL+JxGP3KNZHB4Zl2W42ATFIffHHHBjsuyKJ4YPUnnA7NUiHR/diqV/FTZC9dkg=="
8744
},
8845
"Microsoft.OpenApi": {
8946
"type": "Transitive",
9047
"resolved": "2.0.0",
9148
"contentHash": "GGYLfzV/G/ct80OZ45JxnWP7NvMX1BCugn/lX7TH5o0lcVaviavsLMTxmFV2AybXWjbi3h6FF1vgZiTK6PXndw=="
9249
},
93-
"Swashbuckle.AspNetCore.Swagger": {
94-
"type": "Transitive",
95-
"resolved": "6.4.0",
96-
"contentHash": "nl4SBgGM+cmthUcpwO/w1lUjevdDHAqRvfUoe4Xp/Uvuzt9mzGUwyFCqa3ODBAcZYBiFoKvrYwz0rabslJvSmQ==",
97-
"dependencies": {
98-
"Microsoft.OpenApi": "1.2.3"
99-
}
100-
},
101-
"Swashbuckle.AspNetCore.SwaggerGen": {
102-
"type": "Transitive",
103-
"resolved": "6.4.0",
104-
"contentHash": "lXhcUBVqKrPFAQF7e/ZeDfb5PMgE8n5t6L5B6/BQSpiwxgHzmBcx8Msu42zLYFTvR5PIqE9Q9lZvSQAcwCxJjw==",
105-
"dependencies": {
106-
"Swashbuckle.AspNetCore.Swagger": "6.4.0"
107-
}
108-
},
109-
"Swashbuckle.AspNetCore.SwaggerUI": {
110-
"type": "Transitive",
111-
"resolved": "6.4.0",
112-
"contentHash": "1Hh3atb3pi8c+v7n4/3N80Jj8RvLOXgWxzix6w3OZhB7zBGRwsy7FWr4e3hwgPweSBpwfElqj4V4nkjYabH9nQ=="
113-
},
11450
"owaspheaders.core": {
11551
"type": "Project"
11652
}

0 commit comments

Comments
 (0)