Skip to content

Conversation

@simplicbe
Copy link
Member

@simplicbe simplicbe commented Nov 22, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Replaced Swagger API documentation with Scalar, featuring enhanced configuration options including contact information, licensing details, and terms of service metadata
    • Added configurable GraphQL integration support with auto-mapping capabilities
    • Introduced SignalR hubs configuration framework
  • Documentation

    • Added comprehensive migration guide for transitioning from Swagger to Scalar documentation

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 22, 2025

Walkthrough

Migration from Swagger to Scalar API documentation with addition of GraphQL extensibility hooks and SignalR hub configuration support in the Bootstrap class. Swagger extension removed and replaced with new Scalar extension module. GraphQL and documentation configuration now virtualized for extensibility.

Changes

Cohort / File(s) Summary
Documentation & Metadata
src/Simplic.OxS.Server/Attributes/HideInDocumentation.cs
Updated XML documentation comment to reference "API documentation" instead of "swagger documentation"
Bootstrap Configuration
src/Simplic.OxS.Server/Bootstrap.cs
Added new protected virtual members: GraphQLQueryType, HasSignalRHubs(), and ConfigureGraphQL() for extensibility. Replaced Swagger configuration with Scalar API documentation setup. Enhanced endpoint mapping to conditionally register GraphQL and hubs based on configuration flags. Authorization policy reformatted.
GraphQL Extension
src/Simplic.OxS.Server/Extensions/GraphQLExtension.cs
Made UseGraphQL<TQuery> builder parameter nullable. Added new AddGraphQLWithDocumentation() method accepting non-generic Type queryType for dynamic GraphQL server configuration with HttpRequestInterceptor, Authorization, MongoDB paging, projections, filtering, and sorting.
Scalar Documentation (New)
src/Simplic.OxS.Server/Extensions/ScalarExtension.cs
New file introducing Scalar API documentation module with three public data classes (ScalarOptions, ScalarContact, ScalarLicense) and internal extension methods for configuring Scalar services, registering documentation endpoints, and reflecting SignalR hubs and GraphQL queries into documentation metadata.
Swagger Removal
src/Simplic.OxS.Server/Extensions/SwaggerExtension.cs
Entire file removed, eliminating AddSwagger() method, HideInternalAPIFilter class, and GetKnownTypes() helper that previously configured Swagger/OpenAPI with Bearer/ApiKey schemes and polymorphism handling.
Migration Documentation
src/Simplic.OxS.Server/SCALAR_MIGRATION.md
New migration guide covering package changes, code adjustments, REST/GraphQL/SignalR implementation examples, and feature documentation.
Project Dependencies
src/Simplic.OxS.Server/Simplic.OxS.Server.csproj
Added Microsoft.AspNetCore.OpenApi package. Replaced Swashbuckle.AspNetCore with Scalar.AspNetCore. Removed SignalRSwaggerGen reference. Added Sample\ folder.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Bootstrap
    participant DI as Dependency Injection
    participant Scalar as Scalar Docs
    participant GraphQL
    participant SignalR
    
    rect rgba(100, 200, 150, 0.2)
    Note over Bootstrap,SignalR: Application Startup
    Bootstrap->>DI: HasSignalRHubs()?
    alt HasSignalRHubs = true
        Bootstrap->>DI: Register SignalR Hubs
    end
    
    Bootstrap->>DI: GraphQLQueryType?
    alt GraphQLQueryType != null
        Bootstrap->>GraphQL: AddGraphQLWithDocumentation()
        Bootstrap->>GraphQL: ConfigureGraphQL(builder)
    end
    
    Bootstrap->>DI: AddScalar + UseScalarDocumentation
    Bootstrap->>Scalar: Configure with hubs & GraphQL metadata
    end
    
    rect rgba(150, 150, 200, 0.2)
    Note over Client,Scalar: Runtime - API Documentation Access
    Client->>Scalar: GET /docs
    Scalar->>Scalar: BuildCustomDocumentationContent()
    alt IncludeSignalR
        Scalar->>SignalR: CreateWebSocketDocumentation()
    end
    alt IncludeGraphQL
        Scalar->>GraphQL: CreateGraphQLDocumentation()
    end
    Scalar-->>Client: Unified API Documentation
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Bootstrap.cs: High density of new extensibility patterns, authorization refactoring, endpoint mapping reorganization, and Scalar integration require careful verification of behavioral preservation and extension point design.
  • ScalarExtension.cs: Large new file with reflection-based introspection logic for SignalR hubs and GraphQL queries; complex metadata assembly and documentation generation warrants thorough testing.
  • Removal of SwaggerExtension.cs: Verify all Swagger functionality (security schemes, polymorphism, internal API filtering, SignalR integration) is correctly replicated or intentionally removed, and no dangling references exist.
  • GraphQLExtension.cs: New non-generic overload signature change and dynamic type handling differ from generic approach; confirm backward compatibility and proper registration flow.
  • Project file changes: Ensure Scalar.AspNetCore and Microsoft.AspNetCore.OpenApi versions are compatible and no transitive dependency conflicts arise.

Possibly related PRs

  • simplic/simplic-oxs-logistics-v2#33: GraphQL surface changes in Logistics project (removal of GraphQL types/repos) complement core server GraphQL extensibility hooks introduced in this PR.
  • simplic/simplic-oxs-profile#9: Package/dependency updates related to Swashbuckle removal and Scalar addition mirror the migration pattern from this PR.

Suggested reviewers

  • MaxPatyk

Poem

🐰 From Swagger's bulky arms, we hop away,
To Scalar's grace and GraphQL's sway,
With virtual hooks for extensibility,
And SignalR woven in, oh what agility!
Docs now unified, reflecting all the way,
A leaner server sees a brighter day. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Move from swagger to scalar' clearly and directly summarizes the primary change: replacing Swagger documentation with Scalar documentation throughout the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch f_move_to_scalar

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (5)
src/Simplic.OxS.Server/Simplic.OxS.Server.csproj (1)

20-30: Scalar/OpenAPI package references look consistent with the migration

Adding Microsoft.AspNetCore.OpenApi and Scalar.AspNetCore matches the move away from Swashbuckle and prepares for Scalar-based docs. Once the actual Scalar middleware/UI wiring is in place, these references should be exercised; if that work is postponed for a while, consider deferring Scalar.AspNetCore to avoid an unused dependency.

src/Simplic.OxS.Server/SCALAR_MIGRATION.md (1)

1-3: Clean up stray ?? markers in headings

Headings like “### ?? Package Changes”, “## ?? Documentation Features”, “## ?? Implementation Guide”, etc., contain literal ?? which look like lost emoji/placeholders. Recommend either removing them or replacing them with explicit icons/text so the markdown renders cleanly.

Also applies to: 37-38, 60-61, 151-152, 178-179, 186-187, 197-199, 203-205, 218-220

src/Simplic.OxS.Server/Extensions/GraphQLExtension.cs (1)

36-59: AddGraphQLWithDocumentation mirrors UseGraphQL; consider DRYing and clarifying “WithDocumentation”

The new AddGraphQLWithDocumentation correctly wires the same GraphQL server pipeline for a runtime Type and will work with Bootstrap.GraphQLQueryType. However:

  • Its body is almost identical to UseGraphQL<TQuery>; extracting a small private helper taking the query Type would avoid duplication.
  • Despite the name, this method currently doesn’t add anything documentation-specific; all documentation integration is deferred to Scalar-related helpers. Either renaming it or adding the documentation-specific bits later would make the intent clearer.
src/Simplic.OxS.Server/Extensions/ScalarExtension.cs (2)

59-100: Consolidate ScalarOptions configuration and remove unused parameters

AddScalar currently:

  • Ignores the env parameter.
  • Populates options from OpenApiInfo and forwards to AddScalarConfiguration.

AddScalarConfiguration then creates a fresh ScalarOptions instance, applies the configuration, calls AddEndpointsApiExplorer, and registers the options singleton—but the rest of the code (e.g., Bootstrap.Configure) then constructs another ScalarOptions instance manually and passes it to UseScalarDocumentation.

This means:

  • The DI-registered ScalarOptions is not used anywhere.
  • Options are effectively configured twice in two disconnected code paths.

Consider:

  • Dropping the unused env argument from AddScalar (or using it), and
  • Either reusing the DI-registered ScalarOptions in Configure/UseScalarDocumentation, or removing the DI registration until you actually consume it.

This will simplify the story around how Scalar is configured.


132-283: Helper documentation builders are currently unused and may drift from reality

BuildCustomDocumentationContent, CreateWebSocketDocumentation, and CreateGraphQLDocumentation construct rich documentation structures (Markdown content, SignalR hub metadata, GraphQL query metadata), but nothing in the current code calls them. As a result:

  • Any future consumer of these helpers will need to reconcile their assumptions (e.g., endpoints like /hubs/{hubName}, /graphql, /graphql/playground) with the actual mapped routes and UsePathBase behavior in Bootstrap.
  • Until they are wired into the Scalar UI, they add untested surface area.

Either hook these helpers into whatever Scalar-based UI you plan to use (so they actively drive documentation), or leave them out until that integration is ready to avoid stale or misleading documentation metadata.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d22cf18 and e048d6c.

📒 Files selected for processing (7)
  • src/Simplic.OxS.Server/Attributes/HideInDocumentation.cs (1 hunks)
  • src/Simplic.OxS.Server/Bootstrap.cs (6 hunks)
  • src/Simplic.OxS.Server/Extensions/GraphQLExtension.cs (2 hunks)
  • src/Simplic.OxS.Server/Extensions/ScalarExtension.cs (1 hunks)
  • src/Simplic.OxS.Server/Extensions/SwaggerExtension.cs (0 hunks)
  • src/Simplic.OxS.Server/SCALAR_MIGRATION.md (1 hunks)
  • src/Simplic.OxS.Server/Simplic.OxS.Server.csproj (3 hunks)
💤 Files with no reviewable changes (1)
  • src/Simplic.OxS.Server/Extensions/SwaggerExtension.cs
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: simplic/simplic-oxs-storage-management PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-26T05:52:00.195Z
Learning: Applies to {Program.cs,Startup.cs,**/Controllers/**/*.cs} : Implement API versioning and document with Swagger/OpenAPI (endpoints, parameters, responses, authentication)
📚 Learning: 2025-08-26T05:52:00.195Z
Learnt from: CR
Repo: simplic/simplic-oxs-storage-management PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-26T05:52:00.195Z
Learning: Applies to {Program.cs,Startup.cs,**/Controllers/**/*.cs} : Implement API versioning and document with Swagger/OpenAPI (endpoints, parameters, responses, authentication)

Applied to files:

  • src/Simplic.OxS.Server/Simplic.OxS.Server.csproj
  • src/Simplic.OxS.Server/Attributes/HideInDocumentation.cs
  • src/Simplic.OxS.Server/SCALAR_MIGRATION.md
  • src/Simplic.OxS.Server/Bootstrap.cs
  • src/Simplic.OxS.Server/Extensions/ScalarExtension.cs
📚 Learning: 2025-08-26T05:52:00.195Z
Learnt from: CR
Repo: simplic/simplic-oxs-storage-management PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-26T05:52:00.195Z
Learning: Applies to **/*.cs : Prefer built-in ASP.NET Core features over third-party dependencies; document external dependencies and their purpose in comments

Applied to files:

  • src/Simplic.OxS.Server/Simplic.OxS.Server.csproj
📚 Learning: 2025-08-26T05:52:00.195Z
Learnt from: CR
Repo: simplic/simplic-oxs-storage-management PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-26T05:52:00.195Z
Learning: Applies to {Program.cs,Startup.cs,**/Controllers/**/*.cs,**/Authorization/**/*.cs} : Use JWT Bearer authentication; support OAuth 2.0/OpenID Connect; role-based and policy-based authorization; integrate with Microsoft Entra ID; apply consistent security to controllers and minimal APIs

Applied to files:

  • src/Simplic.OxS.Server/Simplic.OxS.Server.csproj
  • src/Simplic.OxS.Server/Bootstrap.cs
📚 Learning: 2025-08-26T05:52:00.195Z
Learnt from: CR
Repo: simplic/simplic-oxs-storage-management PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-26T05:52:00.195Z
Learning: Applies to {Program.cs,**/Middleware/**/*.cs,**/Logging/**/*.cs,**/Telemetry/**/*.cs} : Use structured logging (e.g., Serilog), appropriate log levels, Application Insights integration, custom telemetry and correlation IDs; monitor performance, errors, usage

Applied to files:

  • src/Simplic.OxS.Server/Simplic.OxS.Server.csproj
  • src/Simplic.OxS.Server/Bootstrap.cs
📚 Learning: 2025-08-26T05:52:00.195Z
Learnt from: CR
Repo: simplic/simplic-oxs-storage-management PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-26T05:52:00.195Z
Learning: Applies to **/*.cs : Target ASP.NET Core (latest supported) for a web application

Applied to files:

  • src/Simplic.OxS.Server/Simplic.OxS.Server.csproj
📚 Learning: 2025-08-26T05:52:00.195Z
Learnt from: CR
Repo: simplic/simplic-oxs-storage-management PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-26T05:52:00.195Z
Learning: Applies to **/*.cs : Add XML documentation comments (///) for public classes, methods, and properties with <summary>, <param>, <returns> and use <example>/<code> when beneficial

Applied to files:

  • src/Simplic.OxS.Server/Attributes/HideInDocumentation.cs
📚 Learning: 2025-08-26T05:52:00.195Z
Learnt from: CR
Repo: simplic/simplic-oxs-storage-management PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-26T05:52:00.195Z
Learning: Applies to **/*.cs : Use dependency injection for all services

Applied to files:

  • src/Simplic.OxS.Server/Bootstrap.cs
🧬 Code graph analysis (3)
src/Simplic.OxS.Server/Extensions/GraphQLExtension.cs (1)
src/Simplic.OxS.Server/Middleware/HttpRequestInterceptor.cs (1)
  • HttpRequestInterceptor (13-81)
src/Simplic.OxS.Server/Bootstrap.cs (5)
src/Simplic.OxS.Server/Implementations/ServiceDefinitionService.cs (2)
  • ServiceDefinitionService (10-119)
  • Fill (17-79)
src/Simplic.OxS.Server/Filter/RequestContextActionFilter.cs (2)
  • RequestContextActionFilter (10-113)
  • RequestContextActionFilter (18-21)
src/Simplic.OxS.Server/Filter/ValidationActionFilter.cs (1)
  • ValidationActionFilter (10-23)
src/Simplic.OxS.Server/Filter/RequestContextHubFilter.cs (1)
  • RequestContextHubFilter (9-69)
src/Simplic.OxS.Server/Extensions/ScalarExtension.cs (4)
  • ScalarOptions (13-24)
  • ScalarContact (29-34)
  • ScalarLicense (39-43)
  • UseScalarDocumentation (108-125)
src/Simplic.OxS.Server/Extensions/ScalarExtension.cs (2)
src/Simplic.OxS.Server/Extensions/GraphQLExtension.cs (2)
  • IServiceCollection (16-34)
  • IServiceCollection (43-59)
src/Simplic.OxS.Server/Bootstrap.cs (2)
  • OpenApiInfo (256-276)
  • Action (307-307)
🔇 Additional comments (7)
src/Simplic.OxS.Server/Attributes/HideInDocumentation.cs (1)

3-5: Documentation update appropriately aligns with Swagger-to-Scalar migration.

The change from "swagger documentation" to "API documentation" is fitting for the migration and makes the documentation more implementation-agnostic. The summary clearly conveys the attribute's purpose.

src/Simplic.OxS.Server/Simplic.OxS.Server.csproj (1)

50-52: Sample folder inclusion is fine

Including a Sample\ folder in the project is a clear place for reference implementations of the new Scalar setup; no issues from a build/runtime perspective.

src/Simplic.OxS.Server/Extensions/GraphQLExtension.cs (1)

16-34: Generic GraphQL registration change is backward compatible

Making the builder parameter optional while keeping the same pipeline (interceptor, authorization, TimeSpan type, MongoDB providers) preserves existing behavior and adds flexibility for callers that don’t need extra configuration. No concerns here.

src/Simplic.OxS.Server/Bootstrap.cs (4)

71-82: Authorization defaults and new JwtOnly policy look sensible

Using JWT + ApiKey in the default policy and adding an explicit JwtOnly policy gives you flexibility to tighten auth on specific endpoints while preserving current behavior elsewhere. This aligns well with the existing RequestContext logic and doesn’t introduce obvious regressions.


108-148: Service definition, GraphQL, controllers, and SignalR wiring are coherent

  • Registering ServiceDefinitionService as a singleton and calling Fill() immediately ensures the service definition is built once and reused.
  • Conditional GraphQL registration via GraphQLQueryType + ConfigureGraphQL gives derived services a straightforward opt-in path.
  • Applying RequestContextActionFilter and ValidationActionFilter globally through MvcBuilder(services.AddControllers(...)) centralizes common concerns.
  • SignalR is always registered with RequestContextHubFilter, and redis backplane is added when a connection string is present.

Overall this block hangs together well and fits the existing abstractions.


206-219: Endpoint mapping with optional GraphQL is straightforward

Using UseEndpoints to map controllers, hubs (via MapHubs), additional endpoints (MapEndpoints), and conditionally MapGraphQL() based on GraphQLQueryType makes the graph of reachable endpoints explicit and extensible for derived services. No issues here.


246-252: GraphQL and SignalR extensibility hooks are well-designed

The new virtuals:

  • ConfigureGraphQL(IRequestExecutorBuilder builder) as a customization hook, and
  • GraphQLQueryType / HasSignalRHubs() as feature toggles

give derived bootstrap classes a clear, discoverable way to opt into GraphQL and to declare whether SignalR hubs exist for documentation purposes. Signatures and defaults are reasonable.

Also applies to: 309-323

Comment on lines +166 to 190
// Configure Scalar API documentation
var scalarOptions = new ScalarOptions
{
c.PreSerializeFilters.Add((swagger, httpReq) =>
ApiVersion = ApiVersion,
Title = GetApiInformation().Title,
Description = GetApiInformation().Description ?? "API Documentation",
Contact = new ScalarContact
{
if (env.IsDevelopment())
{
swagger.Servers = new List<OpenApiServer> { new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}{basePath}" } };
}
else
{
swagger.Servers = new List<OpenApiServer> { new OpenApiServer { Url = $"https://{httpReq.Host.Value}{basePath}" } };
}
});
});

app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint($"{basePath}/swagger/{ApiVersion}/swagger.json", $"Simplic.OxS.{ServiceName} {ApiVersion}");
c.SwaggerEndpoint($"{basePath}/swagger/{ApiVersion}-SignalR/swagger.json", $"Simplic.OxS.{ServiceName} {ApiVersion}-SignalR");
});
Name = GetApiInformation().Contact?.Name,
Email = GetApiInformation().Contact?.Email,
Url = GetApiInformation().Contact?.Url?.ToString()
},
License = new ScalarLicense
{
Name = GetApiInformation().License?.Name,
Url = GetApiInformation().License?.Url?.ToString()
},
TermsOfService = GetApiInformation().TermsOfService?.ToString(),
BasePath = basePath,
IncludeSignalR = HasSignalRHubs(),
IncludeGraphQL = GraphQLQueryType != null
};

app.UseScalarDocumentation(scalarOptions, env);

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Scalar options wiring is fine, but you’re still missing actual documentation endpoints

The ScalarOptions object is populated consistently (version, title, description, contact, license, base path, GraphQL/SignalR flags) and passed into UseScalarDocumentation. However, UseScalarDocumentation currently only writes to the console and does not expose a Scalar UI or OpenAPI endpoint; Swagger/SwaggerUI has been removed elsewhere.

Net effect from consumers’ point of view is that interactive API documentation endpoints disappear. Either wire the real documentation endpoints (e.g., via OpenAPI + Scalar UI) or clearly treat this as an intermediate step and keep Swagger until Scalar is fully hooked up.

🤖 Prompt for AI Agents
In src/Simplic.OxS.Server/Bootstrap.cs around lines 166-190, the ScalarOptions
are built and passed to UseScalarDocumentation but no actual documentation
endpoints or UI are registered; restore or wire up real docs so consumers still
get interactive docs. Either (A) re-enable the OpenAPI/Swagger middleware (e.g.,
app.UseSwagger(); app.UseSwaggerUI(...)) until Scalar’s UI/OpenAPI endpoints are
implemented, or (B) extend UseScalarDocumentation to register and map the actual
endpoints (OpenAPI JSON endpoint and a Scalar UI route) and ensure those routes
use the same ScalarOptions/BasePath; update Startup/Program pipeline to call
these middleware and serve static assets if needed so the interactive
documentation remains available.

Comment on lines +102 to +125
/// <summary>
/// Configure Scalar UI in the application pipeline
/// </summary>
/// <param name="app">Application builder</param>
/// <param name="options">Scalar configuration options</param>
/// <param name="env">Web host environment</param>
internal static void UseScalarDocumentation(this IApplicationBuilder app, ScalarOptions options, IWebHostEnvironment env)
{
// For now, provide a simple message that Scalar documentation is configured
// This can be enhanced when the proper Scalar setup is available
Console.WriteLine($"? Scalar API Documentation configured for {options.Title}");
Console.WriteLine($" - Version: {options.ApiVersion}");
Console.WriteLine($" - Base Path: {options.BasePath}");

if (options.IncludeGraphQL)
{
Console.WriteLine(" - GraphQL endpoint: /graphql");
}

if (options.IncludeSignalR)
{
Console.WriteLine(" - SignalR hubs: Configured");
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

UseScalarDocumentation only logs; no Scalar/OpenAPI endpoints are exposed

UseScalarDocumentation currently just writes a few informational lines to the console and does not:

  • Configure any Scalar UI middleware, or
  • Map any OpenAPI endpoints.

Given that Swagger/SwaggerUI has been removed, this means API documentation is no longer available over HTTP, which is a behavior regression relative to the previous setup and contradicts the migration doc that advertises new Scalar endpoints.

I’d strongly recommend wiring in the real documentation pipeline (OpenAPI + Scalar UI) before relying on this extension, or keeping Swagger in place until that wiring is implemented.

Please double‑check the intended Scalar/OpenAPI integration against the Scalar.AspNetCore and Microsoft.AspNetCore.OpenApi documentation to ensure the final design exposes the documented endpoints.


I'll verify the review comment by examining the codebase structure and configuration. Let me start by exploring the relevant files.


---

🏁 Script executed:

```shell
#!/bin/bash
# Examine the full ScalarExtension.cs file
cat src/Simplic.OxS.Server/Extensions/ScalarExtension.cs

Length of output: 8896


🏁 Script executed:

#!/bin/bash
# Search for Swagger or OpenAPI configuration elsewhere in the codebase
rg -n -i "swagger|openapi|scalar" --type=cs -C 3 | head -100

Length of output: 8138


🏁 Script executed:

#!/bin/bash
# Search for middleware configuration in Startup or Program files
fd -e cs | xargs grep -l "UseSwagger\|UseOpenApi\|UseScalar\|AddSwagger\|AddOpenApi" 2>/dev/null | head -20

Length of output: 88


🏁 Script executed:

#!/bin/bash
# Look for service registration patterns (AddScalar, AddOpenApi, AddSwagger)
rg -n "Add.*Swagger|Add.*OpenApi|Add.*Scalar" --type=cs -C 2

Length of output: 2681


Now let me verify the proper setup pattern for Scalar.AspNetCore and OpenAPI integration:





🌐 Web query:

Scalar.AspNetCore setup middleware configuration example

💡 Result:

Here are minimal Program.cs examples showing how to add Scalar.AspNetCore for the common OpenAPI generators.

  1. Microsoft.AspNetCore.OpenApi (recommended new minimal approach)
  • Install: dotnet add package Scalar.AspNetCore
  • Program.cs:
    using Scalar.AspNetCore;
    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddOpenApi();
    var app = builder.Build();
    if (app.Environment.IsDevelopment())
    {
    app.MapOpenApi(); // exposes /openapi/{documentName}.json
    app.MapScalarApiReference(); // maps the Scalar UI at /scalar
    }
    app.UseHttpsRedirection();
    app.MapControllers();
    app.Run();
  1. Swashbuckle (SwaggerGen)
    using Scalar.AspNetCore;
    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddEndpointsApiExplorer();
    builder.Services.AddSwaggerGen();
    var app = builder.Build();
    if (app.Environment.IsDevelopment())
    {
    app.UseSwagger(options => { options.RouteTemplate = "/openapi/{documentName}.json"; });
    app.MapScalarApiReference(); // map Scalar UI (default /scalar)
    }
    app.UseHttpsRedirection();
    app.MapControllers();
    app.Run();

Notes

  • Put Scalar mapping (MapScalarApiReference) behind an environment check (Development) for production safety.
  • You can pass options to MapScalarApiReference/MapScalarApiReference(...) to set Title, Theme, default client, etc.

Sources:

  • Scalar .NET integration docs (examples for Microsoft.OpenApi / Swashbuckle). [1]
  • AspNetCore.Scalar GitHub README (simple UseScalar / MapScalarApiReference example). [2]

References:
[1] https://guides.scalar.com/scalar/scalar-api-references/integrations/net-aspnet-core
[2] https://github.com/benirave/aspnetcore.scalar


🌐 Web query:

Microsoft.AspNetCore.OpenApi UseOpenApi middleware setup

💡 Result:

Short answer — use the Microsoft.AspNetCore.OpenApi package and call AddOpenApi() and MapOpenApi() (the package exposes an endpoint via MapOpenApi; there is no UseOpenApi middleware). Example:

  1. Install
    dotnet add package Microsoft.AspNetCore.OpenApi. [1]

  2. Program.cs
    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddOpenApi(); // register OpenAPI services. [2]

    var app = builder.Build();
    app.MapOpenApi(); // registers /openapi/{name}.json endpoint. [2][3]

    // optional: treat the OpenAPI route like any endpoint (cache, authorize, etc.)
    // e.g. app.MapOpenApi().RequireAuthorization(); [4]

    app.MapGet("/", () => "Hello");
    app.Run();

Notes:

  • The package generates the OpenAPI JSON document; it does not include a built‑in UI. Use Swashbuckle/Swagger UI or another UI if you need human-friendly docs. [2][3]
  • The WithOpenApi endpoint helper was used historically for per-endpoint operation metadata and is deprecated in newer runtimes (.NET 10+). Remove/migrate calls accordingly. [5]

Sources:
[1] NuGet: Microsoft.AspNetCore.OpenApi.
[2] .NET blog: OpenAPI document generation in .NET 9 (AddOpenApi / MapOpenApi).
[3] Community blog / migration posts about MapOpenApi registering /openapi/v1.json.
[4] Example showing endpoint metadata usage (MapOpenApi as endpoint).
[5] Microsoft compatibility note: WithOpenApi deprecation.


Wire in OpenAPI document generation and Scalar UI middleware endpoints

UseScalarDocumentation() currently only logs to the console. The following are missing:

  • AddOpenApi() service registration and MapOpenApi() endpoint mapping to expose the OpenAPI document
  • MapScalarApiReference() middleware call to expose the Scalar UI

Additionally, AddScalar() only registers AddEndpointsApiExplorer(), which is insufficient without the OpenAPI document generator itself. The helper methods (BuildCustomDocumentationContent, CreateWebSocketDocumentation, CreateGraphQLDocumentation) are defined but never invoked.

Required fixes:

  • In AddScalar() / AddScalarConfiguration(): Add services.AddOpenApi() (or services.AddSwaggerGen() if using Swashbuckle)
  • In UseScalarDocumentation(): Call app.MapOpenApi() and app.MapScalarApiReference() to expose the endpoints

This blocks API documentation availability over HTTP, which is a regression relative to the previous setup.

🤖 Prompt for AI Agents
src/Simplic.OxS.Server/Extensions/ScalarExtension.cs around lines 102-125:
UseScalarDocumentation currently only writes console messages and does not
expose OpenAPI/Scalar UI endpoints; update the startup wiring to call the
OpenAPI generator and map the endpoints — in the
AddScalar/AddScalarConfiguration registration add services.AddOpenApi() (or
services.AddSwaggerGen() if using Swashbuckle) in addition to
AddEndpointsApiExplorer(), and ensure the helper doc builders
(BuildCustomDocumentationContent, CreateWebSocketDocumentation,
CreateGraphQLDocumentation) are invoked when building the OpenAPI document; in
UseScalarDocumentation replace the console-only behavior by calling
app.MapOpenApi() and app.MapScalarApiReference() (and map GraphQL/SignalR doc
endpoints when IncludeGraphQL/IncludeSignalR are true) so the OpenAPI JSON and
Scalar UI are served over HTTP.

Comment on lines +11 to +21
### ?? Package Changes

**Removed:**
- `Swashbuckle.AspNetCore` - Replaced with modern alternatives
- `SignalRSwaggerGen` - Integrated into custom Scalar documentation

**Added:**
- `Scalar.AspNetCore` (v1.2.42) - Modern API documentation UI
- `Microsoft.AspNetCore.OpenApi` (v8.0.2) - .NET 8 native OpenAPI support

### ?? Code Changes
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Align “Package/Code Changes” section with the actual API surface

The doc mentions services.AddScalar() and app.UseScalar() replacements, but the code currently exposes AddScalar(...) and UseScalarDocumentation(...) (see Bootstrap and ScalarExtension). Also, the Scalar integration at this point is only configuring options/logging and does not yet wire a UI or OpenAPI endpoints. Please either (a) update the code to match the promised API and behavior, or (b) tone down this section to describe the current transitional state more accurately.

🤖 Prompt for AI Agents
In src/Simplic.OxS.Server/SCALAR_MIGRATION.md around lines 11 to 21, the docs
claim services.AddScalar() and app.UseScalar() and a UI/OpenAPI endpoint but the
code currently exposes AddScalar(...) and UseScalarDocumentation(...) and only
configures options/logging; either update the code to match the docs by
renaming/adding the public extension methods to AddScalar and UseScalar (or add
forwarding overloads that call existing AddScalar(...) and
UseScalarDocumentation(...)) and implement wiring for the UI/OpenAPI endpoints,
or change the markdown to accurately describe the transitional state by using
the real method names (AddScalar(...), UseScalarDocumentation(...)) and noting
that only options/logging are configured and no UI/OpenAPI endpoints are
registered yet.

Comment on lines +37 to +59
## ?? Documentation Features

### REST API Documentation
- **OpenAPI/Swagger compatible** - Maintains full compatibility with existing OpenAPI specifications
- **Interactive interface** - Modern, fast, and responsive documentation UI
- **Authentication support** - JWT Bearer and API Key authentication documented
- **Request/Response examples** - Comprehensive examples for all endpoints
- **Model schemas** - Detailed schema documentation for all data models

### GraphQL Documentation
- **Integrated GraphQL playground** - Access at `/graphql/ui` (development only)
- **Schema introspection** - Full GraphQL schema documentation
- **Query examples** - Sample queries and mutations
- **Type system documentation** - Complete type documentation
- **Real-time subscriptions** - WebSocket-based subscriptions support

### WebSocket Documentation (SignalR)
- **Hub documentation** - Automatic documentation of SignalR hubs
- **Method signatures** - Parameter and return type documentation
- **Connection examples** - JavaScript and .NET client examples
- **Authentication guidance** - JWT token integration examples
- **Group management** - Documentation for group-based messaging

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Documented documentation endpoints and features don’t yet exist in code

Sections “Documentation Features”, “Access Points”, and the SignalR/GraphQL docs claim:

  • automatic SignalR hub documentation,
  • a main Scalar UI at /{service-name}-api/{version}/scalar/v1,
  • an OpenAPI spec at /openapi/v1.json,
  • GraphQL playground at /graphql/ui (and later /graphql).

In the current implementation, UseScalarDocumentation only writes console messages and no HTTP endpoints are mapped, nor is Microsoft.AspNetCore.OpenApi or Scalar.AspNetCore wired to expose these URLs. This will mislead users following the guide. I’d suggest either implementing the described endpoints now or clearly marking them as planned/target behavior and documenting what is actually available today.

Also applies to: 178-185

🤖 Prompt for AI Agents
In src/Simplic.OxS.Server/SCALAR_MIGRATION.md around lines 37–59 (and also apply
to lines 178–185), the doc claims HTTP endpoints and UI (SignalR hub docs,
/{service-name}-api/{version}/scalar/v1, /openapi/v1.json, /graphql/ui) exist
but the code currently only writes console messages; either implement the
endpoints or mark them as planned — to implement: add and register
Microsoft.AspNetCore.OpenApi and Scalar.AspNetCore packages, wire up
OpenAPI/Swagger generation in Program.cs/Startup, map the OpenAPI JSON and
Swagger UI endpoints, enable and map the GraphQL playground endpoint and GraphQL
middleware, and ensure SignalR hub documentation middleware is registered and
hub routes are mapped; alternatively, update UseScalarDocumentation to return
actual endpoint URLs and change the markdown to clearly label these features as
"planned/not yet implemented" with instructions for where code will be added.

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.

2 participants