Updates Server for net9.0 OpenAPI support#1751
Open
dansiegel wants to merge 1 commit intounoplatform:mainfrom
Open
Updates Server for net9.0 OpenAPI support#1751dansiegel wants to merge 1 commit intounoplatform:mainfrom
dansiegel wants to merge 1 commit intounoplatform:mainfrom
Conversation
26b9fb5 to
5a35595
Compare
Contributor
|
@dansiegel would you consider adding this to the PR, to avoid the users of this would otherwhise get the same problem like I had? |
DevTKSS
suggested changes
Nov 28, 2025
Contributor
DevTKSS
left a comment
There was a problem hiding this comment.
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" /> |
Contributor
There was a problem hiding this comment.
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(); | ||
|
|
Contributor
There was a problem hiding this comment.
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 => | ||
| { |
Contributor
There was a problem hiding this comment.
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" /> |
Contributor
There was a problem hiding this comment.
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> |
Contributor
There was a problem hiding this comment.
Suggested change
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | |
| <OpenApiGenerateDocumentsOptions>--file-name openapi</OpenApiGenerateDocumentsOptions> | |
| <!-- Generate in project root directory instead of output directory --> | |
| <OpenApiDocumentsDirectory>.</OpenApiDocumentsDirectory> |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Other information
Internal Issue (If applicable):