Genocs.WebApi.OpenApi
Genocs.WebApi.OpenApi — Agent Reference Documentation
Consumer Mode for Agents
- Assume package is installed from NuGet.
- Do not rely on repository source code access.
- Prefer stable public APIs and extension methods documented here.
- If behavior is uncertain, fail safely and request package version and configuration details.
Purpose
Genocs.WebApi.OpenApi adds OpenAPI document generation and UI hosting (Swagger UI or ReDoc) for Genocs-based Web API services.
Quick Facts
| Key | Value |
|---|---|
| Package | Genocs.WebApi.OpenApi |
| Target frameworks | net10.0, net9.0, net8.0 |
| Primary role | OpenAPI/Swagger integration for Genocs hosts |
| Main APIs | AddOpenApiDocs overloads and UseOpenApiDocs |
Install
dotnet add package Genocs.WebApi.OpenApi
Minimal Integration Recipe (Program.cs)
using Genocs.Core.Builders;
using Genocs.WebApi.OpenApi;
var builder = WebApplication.CreateBuilder(args);
IGenocsBuilder gnxBuilder = builder
.AddGenocs()
.AddWebApi()
.AddOpenApiDocs();
gnxBuilder.Build();
var app = builder.Build();
app.UseOpenApiDocs();
app.Run();
Configuration
Use the openapi section.
{
"openapi": {
"enabled": true,
"reDocEnabled": false,
"name": "v1",
"title": "Orders API",
"version": "1.0.0",
"routePrefix": "docs"
}
}
| Setting | Type | Description |
|---|---|---|
enabled | bool | Enables OpenAPI service registration. |
reDocEnabled | bool | Switches UI rendering from Swagger UI to ReDoc. |
routePrefix | string | Base route for the JSON document and UI assets. |
Dependencies
Genocs.WebApiSwashbuckle.AspNetCore.*
Troubleshooting
- Swagger or ReDoc endpoints are missing.
Fix: Enable
openapi.enabledand ensureUseOpenApiDocs()is called in the app pipeline. - Security authorization controls do not appear in UI.
Fix: Set
openapi.includeSecuritytotrueand restart the service.