Skip to content

Commit e018317

Browse files
feat: update OpenAPI integration and improve documentation for Scalar usage
1 parent 352a655 commit e018317

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"serverReadyAction": {
2727
"action": "openExternally",
2828
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
29-
"uriFormat": "%s/swagger"
29+
"uriFormat": "%s/scalar"
3030
},
3131
"env": {
3232
"ASPNETCORE_ENVIRONMENT": "Development"

SampleApp/BackEnd/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
using Microsoft.AspNetCore.OpenApi;
12
using Scalar.AspNetCore;
23

34
var builder = WebApplication.CreateBuilder(args);
45

56
// Add services to the container.
67
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
7-
builder.Services.AddOpenApi();
8+
builder.Services.AddOpenApi(options =>
9+
{
10+
options.AddDocumentTransformer((document, context, ct) =>
11+
{
12+
document.Servers = [];
13+
return Task.CompletedTask;
14+
});
15+
});
816

917
var app = builder.Build();
1018

images/scalar.png

167 KB
Loading

readme.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# GitHub Codespaces ♥️ .NET
22

3-
Want to try out the latest performance improvements coming with .NET 8 for web development?
3+
Want to try out the latest performance improvements coming with .NET for web development?
44

5-
This repo builds a Weather API and displays the data in a web application using Blazor with .NET.
5+
This repo builds a Weather API, OpenAPI integration to test with [Scalar](https://learn.microsoft.com/aspnet/core/fundamentals/openapi/using-openapi-documents?view=aspnetcore-9.0#use-scalar-for-interactive-api-documentation), and displays the data in a web application using Blazor with .NET.
66

77
We've given you both a frontend and backend to play around with and where you go from here is up to you!
88

@@ -22,18 +22,20 @@ You can also run this repository locally by following these instructions:
2222
1. **📤 One-click setup**: [Open a new Codespace](https://codespaces.new/github/dotnet-codespaces), giving you a fully configured cloud developer environment.
2323
2. **▶️ Run all, one-click again**: Use VS Code's built-in *Run* command and open the forwarded ports *8080* and *8081* in your browser.
2424

25-
![](images/RunAll.png)
25+
![Debug menu in VS Code showing Run All](images/RunAll.png)
2626

27-
3. The Blazor web app and Swagger tabs should now be open on your browser. On Swagger, click "Try it out" and "Execute" to call and test the API.
27+
3. The Blazor web app and Scalar can be open by heading to **/scalar** in your browser. On Scalar, head to the backend API and click "Test Request" to call and test the API.
2828

29-
![](images/BlazorApp.png)
29+
![A website showing weather](images/BlazorApp.png)
30+
31+
!["UI showing testing an API"](images/scalar.png)
3032

3133

3234
4. **🔄 Iterate quickly:** Codespaces updates the server on each save, and VS Code's debugger lets you dig into the code execution.
3335

3436
5. To stop running, return to VS Code, and click Stop twice in the debug toolbar.
3537

36-
![](images/StopRun.png)
38+
![VS Code stop debuggin on both backend and frontend](images/StopRun.png)
3739

3840

3941
## Contributing

0 commit comments

Comments
 (0)