Skip to content

Commit 45d8b22

Browse files
committed
update blog post
1 parent 8a4b413 commit 45d8b22

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
title: .NET 10's new OpenAPI Scalar + Swagger UIs
3+
summary: ServiceStack v10 adds first-class .NET 10 support and new OpenAPI for Swagger and Scalar UIs.
4+
tags: [.net10,openapi,swagger,scalar]
5+
author: Demis Bellot
6+
image: https://servicestack.net/img/posts/openapi-net10/bg.webp
7+
---
8+
9+
# .NET 10 LTS
10+
11+
We're excited to announce **ServiceStack v10** - a major release aligned with Microsoft's newly released .NET 10!
12+
13+
This milestone release brings first-class .NET 10 support across the entire ServiceStack ecosystem, with all packages now shipping native .NET 10 builds optimized for the latest runtime.
14+
15+
As part of this major version upgrade, we've modernized our tooling and streamlined our package offerings:
16+
17+
- **All project templates upgraded to .NET 10** - Start new projects on the latest LTS framework
18+
- **Adopted the new `.slnx` solution format** - Embracing .NET's modern, simplified solution file format
19+
- **Enhanced Kamal GitHub Action deployments** - Streamlined CI/CD that intelligently derives configuration from your repository name and GitHub Action context
20+
21+
## .NET 10 OpenAPI Support
22+
23+
.NET 10 has added support for generating OpenAPI schemas and API Explorer UIs with there now being multiple ways to generate OpenAPI schemas and multiple ways to view them.
24+
25+
Assuming the trend of Microsoft's defaults having a determinant influence on the wider .NET ecosystem, we expect Microsoft's new [Microsoft.AspNetCore.OpenApi](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/overview) to become the defacto default and Swashbuckle to suffer a slow death as a result, until then it's still the simpler and more popular combination that we've added .NET 10 support for in the new NuGet package:
26+
27+
### ServiceStack.OpenApi.Swashbuckle
28+
29+
Depends on:
30+
- Microsoft.OpenApi v2.x
31+
- Swashbuckle.AspNetCore v10.x
32+
33+
<div class="not-prose">
34+
<img class="mx-auto my-8 max-w-2xl border" src="https://docs.servicestack.net/img/pages/openapi/v3/swagger.webp">
35+
</div>
36+
37+
Which can be added to .NET 10 Project with:
38+
39+
:::sh
40+
npx add-in openapi-swagger
41+
:::
42+
43+
Which uses `Swashbuckle.AspNetCore` for generating OpenAPI schemas and displaying the Swagger UI.
44+
45+
## Microsoft.AspNetCore.OpenApi
46+
47+
This was a more frustrating package to support starting with trying to use the latest **Microsoft.OpenApi v3.x**
48+
results in failures at runtime since its latest version is limited to **Microsoft.OpenApi v2.x**.
49+
50+
In addition **Microsoft.OpenApi v2.x** use of Analyzers/Interceptors made it impossible to add support for the **Microsoft.OpenApi v2.x** in .NET 10 builds whilst preserving **Microsoft.OpenApi v1.x** for NET 8.0 builds.
51+
As a result we've had to publish .NET 10 support in the new NuGet package:
52+
53+
### ServiceStack.OpenApi.Microsoft
54+
55+
Depends on:
56+
- Microsoft.OpenApi v2.x
57+
- Microsoft.AspNetCore.OpenApi v10.x
58+
59+
<div class="not-prose">
60+
<img class="mx-auto my-8 max-w-2xl border" src="https://docs.servicestack.net/img/pages/openapi/v3/scalar.webp">
61+
</div>
62+
63+
Which can be added to .NET 10 Project with:
64+
65+
:::sh
66+
npx add-in openapi-scalar
67+
:::
68+
69+
Which uses `Microsoft.AspNetCore.OpenApi` to generate OpenAPI schemas and is configured to use `Scalar.AspNetCore`
70+
to display the newer Scalar UI from the VC-backed [scalar.com](https://scalar.com).
71+
72+
Unfortunately `Microsoft.AspNetCore.OpenApi` has issues that we're surprised to find its complexity leaking into end-user projects which requires adding an `<InterceptorsNamespaces>` configuration to your **MyApp.csproj**:
73+
74+
```xml
75+
<PropertyGroup>
76+
<InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated</InterceptorsNamespaces>
77+
</PropertyGroup>
78+
```
79+
80+
Another alternative we've discovered to avoid build issues is to disable its XML Comment source generator:
81+
82+
```xml
83+
<!-- Disable the XML comment source generator to avoid compatibility issues with Microsoft.OpenApi -->
84+
<Target Name="DisableCompileTimeOpenApiXmlGenerator" BeforeTargets="CoreCompile">
85+
<ItemGroup>
86+
<Analyzer Remove="$(PkgMicrosoft_AspNetCore_OpenApi)\analyzers\dotnet\cs\Microsoft.AspNetCore.OpenApi.SourceGenerators.dll"/>
87+
</ItemGroup>
88+
</Target>
89+
```
90+
91+
92+
## npx scripts
93+
94+
A new **v10.0.0** version of the **x** dotnet tool is now available with.NET 10 support:
95+
96+
```bash
97+
dotnet tool install --global x # install
98+
dotnet tool update -g x # update
99+
```
100+
101+
Although this is the last .NET runtime that the `x` tool will support as it's being phased out in favor of use-case specific `npx` scripts as it doesn't require a separate install or needs a .NET 10 SDK to be pre-installed.
102+
103+
The npx tools have the same behavior as the different x sub-features where you can just replace the command prefix with the npx script equivalent, e.g:
104+
105+
| x command | npx script | description |
106+
| ------------ | ----------------------- | ----------- |
107+
| `x new` | `npx create-net` | Create a new App from a .NET 10 project template |
108+
| `x mix` | `npx add-in` | Register and configure a Plugin with your App |
109+
| `x ts` | `npx get-dtos ts` | Regenerate latest TypeScript DTOs |
110+
| `x ts <url>` | `npx get-dtos ts <url>` | Generate DTOs for a remote ServiceStack API |

0 commit comments

Comments
 (0)