openapi-and-scalar
Skill400 starsChanged 10 days agoMITView on GitHub
How this Minimal API builds its OpenAPI document and serves the Scalar API reference - AddOpenApi, the document and operation transformers, the bearer scheme when authentication is on, the Scalar options, and the tests that read the generated document. Use when changing the API description, tags, security scheme, Scalar settings, or when the API reference looks wrong.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- LeanMeanCleanApps/CleanWebApiedited, first seen Nov 15, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- LeanMeanCleanApps/CleanWebApi★ 476% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-a-use-caseSkill
- api-conventionsSkill
- branches-and-pull-requestsSkill
- cancellationSkill
- ci-for-your-solutionSkill
- ci-pipelineSkill
- clean-architecture-layersSkill
- configuration-and-environmentsSkill
- coverageSkill
- csharp-house-styleSkill
- data-access-ef-coreSkill
- database-migrationsSkill
- docker-and-composeSkill
- docs-and-voiceSkill
- errors-and-exceptionsSkill
- expose-a-use-caseSkill
- family-syncSkill
- health-checksSkill
- integration-testsSkill
- json-serializationSkill
- mapping-with-mapperlySkill
- mediatorSkill
- optional-token-authSkill
- packages-and-dependenciesSkill
- pagingSkill
- presentation-integration-testsSkill
- releasesSkill
- sample-dataSkill
- security-findingsSkill
- serilogSkill
- telemetrySkill
- template-authoringSkill
- test-designSkill
- time-providerSkill
- unit-testsSkill
- validationSkill
- writing-a-skillSkill
- xml-docs-and-openapiSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
When you add an endpoint, update the operation count in GetOpenApiDocument_ShouldDescribe_EveryOperation.
- Distinctive: line 29
Run the app and read the result at <http://localhost:7310/scalar>.
- Distinctive: line 62
Add Swashbuckle or NSwag. The built-in generator and Scalar replace them.
- Distinctive: line 65
Add the security scheme when authentication is off.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
OpenAPI and Scalar (Minimal API)
The rule
The OpenAPI document is generated at runtime by Microsoft.AspNetCore.OpenApi and served at /openapi/v1.json. Scalar (Scalar.AspNetCore) renders it at /scalar. Operation and schema text comes from XML comments (xml-docs-and-openapi); everything else is set by transformers in src/Presentation/OpenApi/.
| Transformer | Adds |
DocumentInfoTransformer | Title (with the environment name), description, contact, licence, external docs and the tag descriptions |
BearerSecurityTransformer | Only in a solution with authentication, and only when Authentication:Authority is set: the Bearer security scheme, a security requirement and a 401 response on every operation that needs a token |
Scalar is set up in WebApplicationExtensions.ConfigureApplication with the title, C# HttpClient as the default code sample, and its developer tools, agent, MCP and telemetry features turned off.
tests/Presentation.Tests.Integration/OpenApi/OpenApiDocumentTests.cs reads the generated document and fails if an operation has no summary, description, sample request or parameter descriptions, or a schema property has no description.
Steps
- A new tag needs a
CreateTag(...)line inDocumentInfoTransformerwith a one-sentence description, andWithTagson the endpoint group. - Something every operation needs goes in an operation transformer; something about the whole API goes in a document transformer. Register it in
AddOpenApiinWebApplicationBuilderExtensions. - Transformers are classes implementing
IOpenApiDocumentTransformerorIOpenApiOperationTransformer,sealed, with XML docs. Unit test them intests/Presentation.Tests.Unit/OpenApi/. - When you add an endpoint, update the operation count in
GetOpenApiDocument_ShouldDescribe_EveryOperation. - Run the app and read the result at http://localhost:7310/scalar.
Example
// src/Presentation/Extensions/WebApplicationBuilderExtensions.cs
_ = builder.Services.AddOpenApi(options =>
{
_ = options.AddDocumentTransformer<DocumentInfoTransformer>();
// Only with --include-auth.
if (authentication.Enabled)
{
_ = options.AddDocumentTransformer<BearerSecurityTransformer>();
_ = options.AddOperationTransformer<BearerSecurityTransformer>();
}
});// src/Presentation/Extensions/WebApplicationExtensions.cs
_ = app.MapOpenApi();
_ = app.MapScalarApiReference(options => options
.WithTitle("CleanMinimalApi API")
.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient)
.HideDeveloperTools()
.DisableAgent()
.DisableMcp()
.DisableTelemetry());Don't
- Add Swashbuckle or NSwag. The built-in generator and Scalar replace them.
- Describe operations with
WithSummaryorWithDescription. The XML comments are the one source. - Turn Scalar telemetry back on.
- Add the security scheme when authentication is off. The reference would ask for a token nobody needs.
Check
dotnet test --filter "FullyQualifiedName~OpenApi"
dotnet run --project ./src/Presentation # then open http://localhost:7310/scalarDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

