Namespace Codebelt.Extensions.Swashbuckle.AspNetCore
When building RESTful APIs with ASP.NET Core, Swashbuckle.AspNetCore provides the Swagger and OpenAPI tooling. This namespace complements Swashbuckle.AspNetCore with pre-configured options, document and operation filters, and helper utilities to reduce boilerplate when documenting APIs that use standard security schemes and conventions.
Start here: Call AddRestfulSwagger on IServiceCollection to register both Swagger generator and UI options optimized for RESTful API patterns. This single call sets up user-agent headers, API key and bearer-token security schemes, and XML documentation inclusion with minimal configuration.
When to use: Choose this namespace when you are building an ASP.NET Core REST API and want to avoid repetitive Swagger configuration code. If you need granular control over individual Swagger filters or have non-standard security requirements, use Swashbuckle.AspNetCore directly and import only the extension methods you need from this namespace.
Usage: Configure both Swagger generation and UI in a single step with predefined filters for common security patterns, XPath document loading, and API versioning conventions.
Availability: .NET 10 and .NET 9
Complements: Swashbuckle.AspNetCore 🔗 Related: Codebelt.Extensions.Asp.Versioning 📘
Extension Members
| Type | Ext | Methods |
|---|---|---|
| IServiceCollection | ⬇️ | AddRestfulSwagger |
| SwaggerGenOptions | ⬇️ | AddUserAgent, AddXApiKeySecurity, AddJwtBearerSecurity, AddBasicAuthenticationSecurity |
| XPathDocument | ⬇️ | AddByType, AddByType<T>, AddByAssembly, AddByFilename, AddFromBaseDirectory, AddFromBaseDirectory<T>, AddFromReferencePacks, AddFromReferencePacks<T> |
Classes
- ConfigureSwaggerGenOptions
Represents something that configures the SwaggerGenOptions type. Note: These are run before all IPostConfigureOptions<TOptions>.
- ConfigureSwaggerUIOptions
Represents something that configures the SwaggerUIOptions type. Note: These are run before all IPostConfigureOptions<TOptions>.
- DocumentFilter
Represents the base class of an IDocumentFilter implementation.
- DocumentFilter<T>
Represents a configurable base class of an IDocumentFilter implementation.
- OpenApiInfoOptions
Represents a proxy for configuring an Open API Info Object that provides metadata about an Open API endpoint.
- OperationFilter
Represents the base class of an IOperationFilter implementation.
- OperationFilter<T>
Represents a configurable base class of an IOperationFilter implementation.
- RestfulSwaggerOptions
Provides programmatic configuration for the AddRestfulSwagger(IServiceCollection, Action<RestfulSwaggerOptions>) method.
- ServiceCollectionExtensions
Extension methods for the IServiceCollection interface.
- SwaggerGenOptionsExtensions
Extension methods for the SwaggerGenOptions class.
- UserAgentDocumentFilter
Provides a User-Agent field to the generated OpenApiDocument.
- UserAgentDocumentOptions
Provides programmatic configuration for the UserAgentDocumentFilter class.
- XPathDocumentExtensions
Extension methods for the XPathDocument class.