Endpoint Documentation
NSmithy can generate two complementary documentation UIs directly from your Smithy model and wire them up alongside your server with a single call each:
- Scalar — an interactive OpenAPI explorer at
/openapi, backed by aopenapi.jsongenerated from the model by smithy-openapi. Available for REST JSON services. - Sphinx HTML — auto-generated reference documentation at
/docs, produced by smithy-docgen and compiled to HTML automatically at build time. Available for all services.
Both are opt-in MSBuild properties and both copy their output into wwwroot/ so
ASP.NET Core’s built-in static file middleware serves them with zero extra config.
/openapi
/docsInstall the Package
Section titled “Install the Package”Add NSmithy.Server.AspNetCore.Docs to your server project:
<PackageReference Include="NSmithy.Server.AspNetCore.Docs" Version="0.1.0-preview.15" />This package provides the MapSmithyOpenApi() and MapSmithyDocs() extension
methods.
Enable the Generators
Section titled “Enable the Generators”Set the relevant MSBuild properties in your server .csproj:
<PropertyGroup> <!-- Generate Sphinx HTML documentation (all services) --> <SmithyGenerateDocs>true</SmithyGenerateDocs>
<!-- Generate openapi.json for REST JSON services (restJson1 only) --> <SmithyOpenApiProtocol>aws.protocols#restJson1</SmithyOpenApiProtocol></PropertyGroup>Both properties are false/empty by default.
Register the Endpoints
Section titled “Register the Endpoints”Call the extension methods in Program.cs:
using NSmithy.Server.AspNetCore.Docs;
var app = builder.Build();app.MapSmithyOpenApi(); // mounts Scalar at /openapi (requires SmithyOpenApiProtocol)app.MapSmithyDocs(); // serves Sphinx HTML at /docs (requires SmithyGenerateDocs)app.MapMyServiceHttp();app.Run();MapSmithyOpenApi() enables static file serving and mounts the Scalar UI at
/openapi, pointing it to /openapi.json which is generated from the model and
copied to wwwroot/openapi.json at build time.
MapSmithyDocs() enables static file serving and redirects /docs to
/docs/index.html. The Sphinx HTML is built automatically by smithy-docgen
during dotnet build and copied to wwwroot/docs/.
What Gets Generated
Section titled “What Gets Generated”On dotnet build, NSmithy:
- Runs
smithy buildwith thedocgenplugin (andopenapiplugin ifSmithyOpenApiProtocolis set). - smithy-docgen bootstraps a self-contained Python venv with Sphinx, builds the
HTML, and writes it to
obj/<config>/<tfm>/Smithy/source/docgen/build/html/. - MSBuild copies the HTML to
wwwroot/docs/and the OpenAPI spec towwwroot/openapi.json.
Python (3.11+) must be available on the host. A system Python installation is sufficient. If you use pixi or devenv, declare Python as a dependency there.
Add wwwroot/ to your .gitignore since the output is always regenerated at
build time:
wwwroot/Model Requirements for Docs Generation
Section titled “Model Requirements for Docs Generation”smithy-docgen validates that input and output structures follow the Smithy best
practices before generating documentation. Specifically, structures used as
operation inputs or outputs must carry the @input or @output trait, and the
same structure must not serve as both the input and output of an operation.
Use the inline input := / output := syntax (which applies these traits
automatically) or annotate named structures explicitly:
// ✅ inline syntax — @input and @output are applied automaticallyoperation Echo { input := { @required message: String } output := { @required message: String }}
// ✅ named structures with explicit traits@input structure EchoInput { @required message: String }@output structure EchoOutput { @required message: String }
// ❌ shared structure — smithy-docgen will refuse thisstructure EchoPayload { @required message: String }operation Echo { input: EchoPayload output: EchoPayload // same shape used for both roles}