Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 20, 2025

Migrates API documentation from Swagger UI to Scalar for improved performance and developer experience.

Changes

  • Package: Added Scalar.AspNetCore 2.11.8
  • Program.cs: Replaced UseSwaggerUI with MapScalarApiReference, configured dynamic API version discovery
  • ConfigureSwaggerOptions.cs: Updated terminology from "Swagger/OpenAPI" to "OpenAPI" for consistency
  • README.md: Added API Documentation section

Implementation

// Before
app.UseSwagger();
app.UseSwaggerUI(options => {
    options.RoutePrefix = string.Empty;
    foreach (var description in app.DescribeApiVersions()) {
        options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", 
                                description.GroupName.ToUpperInvariant());
    }
});

// After  
app.MapSwagger("/openapi/{documentName}.json");
app.MapScalarApiReference(options => {
    options.WithTitle("Best Weather Forecast API");
    var descriptions = app.DescribeApiVersions();
    foreach (var description in descriptions) {
        options.AddDocument(description.GroupName, $"/openapi/{description.GroupName}.json");
    }
});

SwaggerGen continues to generate OpenAPI documents; only the UI layer changed. All API endpoints, versioning, and existing tests remain unaffected. Scalar UI available at /scalar in development mode.

Original prompt

This section details on the original issue you should resolve

<issue_title>Replace Swagger UI with Scalar</issue_title>
<issue_description>Migrate the existing API documentation experience from Swagger UI to Scalar to improve performance, customization options, and long‑term maintainability. This update should preserve all current API functionality while providing a more modern, developer‑friendly interface.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 20, 2025 18:55
Co-authored-by: xavierjohn <1859710+xavierjohn@users.noreply.github.com>
Co-authored-by: xavierjohn <1859710+xavierjohn@users.noreply.github.com>
Co-authored-by: xavierjohn <1859710+xavierjohn@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace Swagger UI with Scalar for API documentation Replace Swagger UI with Scalar Dec 20, 2025
Copilot AI requested a review from xavierjohn December 20, 2025 19:01
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.

Replace Swagger UI with Scalar

2 participants