Skip to content

Updates Server for net9.0 OpenAPI support#1751

Open
dansiegel wants to merge 1 commit intounoplatform:mainfrom
dansiegel:dev/ds/server-net9
Open

Updates Server for net9.0 OpenAPI support#1751
dansiegel wants to merge 1 commit intounoplatform:mainfrom
dansiegel:dev/ds/server-net9

Conversation

@dansiegel
Copy link
Contributor

GitHub Issue (If applicable): closes #

PR Type

What kind of change does this PR introduce?

What is the current behavior?

What is the new behavior?

PR Checklist

Please check if your PR fulfills the following requirements:

  • Associated with an issue (GitHub or internal)

Other information

Internal Issue (If applicable):

@DevTKSS
Copy link
Contributor

DevTKSS commented Nov 28, 2025

@dansiegel would you consider adding this to the PR, to avoid the users of this would otherwhise get the same problem like I had?

Copy link
Contributor

@DevTKSS DevTKSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way the User can even use the Server Project with our Uno.Extensions.Http.Kiota Client just like the Uno Kiota Docs are telling about Swagger 👍
@jeromelaban what do you think of these additional suggested changes? 🚀

<PackageReference Include="Serilog.AspNetCore" />
<!--#endif-->
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Scalar.AspNetCore" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<PackageReference Include="Scalar.AspNetCore" />
<PackageReference Include="Scalar.AspNetCore" />
<PackageReference Include="Scalar.AspNetCore.Microsoft" />
<!-- Generate Open API Spec to use it e.g. with Uno.Extensions.Http.Kiota for your Uno App ! -->
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" />

And in the either way Uno Solution Items Provided Directory.Build.props its providing out of the box clean set up by adding the Assets just once there:

  <ItemGroup>
    <PackageReference Update="Microsoft.Extensions.ApiDescription.Server"
                      PrivateAssets="all"
                      IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
  </ItemGroup>

});
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
services.AddEndpointsApiExplorer();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
services.AddOpenApi(options =>
{
options.AddDocumentTransformer((OpenApiDocument document, OpenApiDocumentTransformerContext _, CancellationToken _) =>
{
document.Info = new Microsoft.OpenApi.OpenApiInfo
{
Title = "MyManufacturerERP API",
Version = "v1",
Description = "This is the API for $MyExtensionsApp$ , an ASP.NET Core Minimal APIs Powered by Uno Platform.",
Contact = new Microsoft.OpenApi.OpenApiContact
{
Name = "Your Name",
Email = "YourName@example.com",
Url = new Uri("https://www.example.com")
}
};
return Task.CompletedTask;
});
options.AddScalarTransformers();
});
return services;

app.UseSwaggerUI();
app.MapOpenApi();
app.MapScalarApiReference(o =>
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
{
// Use Fluent API to configure Scalar
// Learn more: https://guides.scalar.com/scalar/scalar-api-references/integrations/net-aspnet-core/integration
o.WithTheme(ScalarTheme.Saturn)
.WithClassicLayout()
.AddPreferredSecuritySchemes("Cookie")
.WithDocumentDownloadType(DocumentDownloadType.Json);
.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient)
// Or Add via direct Options Access

Comment on lines +26 to +27
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.8" />
<PackageVersion Include="Scalar.AspNetCore" Version="2.7.2" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.8" />
<PackageVersion Include="Scalar.AspNetCore" Version="2.7.2" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
<PackageVersion Include="Microsoft.Extensions.ApiDescription.Server" Version="10.0.0" />
<PackageVersion Include="Scalar.AspNetCore" Version="2.11.0" />
<PackageVersion Include="Scalar.AspNetCore.Microsoft" Version="2.10.3" />


<PropertyGroup>
<TargetFramework>$baseTargetFramework$</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<OpenApiGenerateDocumentsOptions>--file-name openapi</OpenApiGenerateDocumentsOptions>
<!-- Generate in project root directory instead of output directory -->
<OpenApiDocumentsDirectory>.</OpenApiDocumentsDirectory>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the Server project for net9.0+ [Bug] Server project doesn't build when targeting .NET 9

2 participants