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

KeyValue
PackageGenocs.WebApi.OpenApi
Target frameworksnet10.0, net9.0, net8.0
Primary roleOpenAPI/Swagger integration for Genocs hosts
Main APIsAddOpenApiDocs 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"
  }
}
SettingTypeDescription
enabledboolEnables OpenAPI service registration.
reDocEnabledboolSwitches UI rendering from Swagger UI to ReDoc.
routePrefixstringBase route for the JSON document and UI assets.

Dependencies

  • Genocs.WebApi
  • Swashbuckle.AspNetCore.*

Troubleshooting

  1. Swagger or ReDoc endpoints are missing. Fix: Enable openapi.enabled and ensure UseOpenApiDocs() is called in the app pipeline.
  2. Security authorization controls do not appear in UI. Fix: Set openapi.includeSecurity to true and restart the service.