원클릭으로
scalar
Use when configuring Scalar API documentation UI for a .NET project.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when configuring Scalar API documentation UI for a .NET project.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when adding caching to .NET APIs or optimizing response times with distributed cache, output cache, or ETags.
Use when configuring API response formats, custom formatters, or Accept header handling.
Use when building controller-based REST APIs with action results, model binding, or MediatR integration.
Use when creating RESTful API controllers with MediatR dispatch and ProblemDetails error responses.
Use when designing gRPC services, proto files, or adding gRPC-Web or JSON transcoding.
Use when building minimal API endpoints with route groups, filters, or TypedResults.
| name | scalar |
| description | Use when configuring Scalar API documentation UI for a .NET project. |
| metadata | {"category":"api","agent":"api-designer","when-to-use":"When setting up Scalar API documentation with authentication and theming"} |
namespace {Company}.{Domain}.Api.Extensions;
public static class OpenApiExtensions
{
public static IServiceCollection AddOpenApiDocumentation(
this IServiceCollection services, IWebHostEnvironment environment)
{
services.AddOpenApi("v1", options =>
{
options.AddDocumentTransformer<BearerSecuritySchemeTransformer>();
});
return services;
}
public static IApplicationBuilder UseOpenApiDocumentation(
this IApplicationBuilder app, IWebHostEnvironment environment)
{
app.MapOpenApi();
app.MapScalarApiReference(options =>
{
options
.WithTitle("{Company} {Domain} API")
.WithTheme(ScalarTheme.BluePlanet)
.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient);
});
return app;
}
}
internal sealed class BearerSecuritySchemeTransformer(
IAuthenticationSchemeProvider provider)
: IOpenApiDocumentTransformer
{
public async Task TransformAsync(
OpenApiDocument document,
OpenApiDocumentTransformerContext context,
CancellationToken ct)
{
var schemes = await provider.GetAllSchemesAsync();
if (schemes.Any(s => s.Name == "Bearer"))
{
var requirements = new Dictionary<string, OpenApiSecurityScheme>
{
["Bearer"] = new()
{
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT"
}
};
document.Components ??= new();
document.Components.SecuritySchemes = requirements;
}
}
}
namespace {Company}.Gateways.Common.Scalar;
public sealed class ScalarBasicAuthMiddleware(
RequestDelegate next,
IOptions<ScalarAuthorizationOptions> options)
{
public async Task InvokeAsync(HttpContext context)
{
if (IsLocalRequest(context))
{
await next(context);
return;
}
var authHeader = context.Request.Headers.Authorization.ToString();
if (!ValidateBasicAuth(authHeader, options.Value))
{
context.Response.StatusCode = 401;
context.Response.Headers.WWWAuthenticate = "Basic realm=\"API Docs\"";
return;
}
await next(context);
}
private static bool IsLocalRequest(HttpContext context) =>
IPAddress.IsLoopback(context.Connection.RemoteIpAddress!);
}
builder.Services.AddOpenApiDocumentation(builder.Environment);
var app = builder.Build();
app.UseOpenApiDocumentation(app.Environment);
| Anti-Pattern | Correct Approach |
|---|---|
| Swagger UI for new projects | Use Scalar with MapScalarApiReference |
| Exposing docs without auth | Use ScalarBasicAuthMiddleware |
| Missing Bearer scheme | Add BearerSecuritySchemeTransformer |
grep -r "MapScalarApiReference\|AddOpenApi\|MapOpenApi" --include="*.cs"
grep -r "SwaggerUI\|UseSwagger" --include="*.cs" # Legacy check
AddOpenApi() in services and MapScalarApiReference() in pipelineBearerSecuritySchemeTransformer if JWT auth is used