Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/Uno.Templates/content/unoapp/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.1" />
<!--#endif-->
<!--#if (useServer)-->
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.8" />
<PackageVersion Include="Scalar.AspNetCore" Version="2.7.2" />
Comment on lines +26 to +27
Copy link
Copy Markdown
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" />

<!--#endif-->
<!--#if (useUITests)-->
<PackageVersion Include="Uno.UITest.Helpers" Version="$UnoUITestHelpersVersion$" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
<!--#if (useSerilog)-->
<PackageReference Include="Serilog.AspNetCore" />
<!--#endif-->
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Scalar.AspNetCore" />
Copy link
Copy Markdown
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>

<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<!--#if (useWasm)-->
<PackageReference Include="Uno.Wasm.Bootstrap.Server" />
<!--#endif -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,24 @@
builder.Services.Configure<RouteOptions>(options =>
options.LowercaseUrls = true);

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
// Include XML comments for all included assemblies
Directory.EnumerateFiles(AppContext.BaseDirectory, "*.xml")
.Where(x => x.Contains("MyExtensionsApp._1")
&& File.Exists(Path.Combine(
AppContext.BaseDirectory,
$"{Path.GetFileNameWithoutExtension(x)}.dll")))
.ToList()
.ForEach(path => c.IncludeXmlComments(path));
});
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();

Copy link
Copy Markdown
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;

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.MapOpenApi();
app.MapScalarApiReference(o =>
{
Copy link
Copy Markdown
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

o.EnabledClients = [
ScalarClient.HttpClient,
ScalarClient.Http11,
ScalarClient.JQuery,
ScalarClient.Xhr
];
});
}

app.UseHttpsRedirection();
Expand Down
Loading