Table of Contents

Class SwaggerConfigurationService

Namespace
arolariu.Backend.Core.Domain.General.Services.Swagger
Assembly
arolariu.Backend.Core.dll

Provides centralized configuration for Swagger/OpenAPI documentation generation and UI presentation. This service configures the API documentation system used by the arolariu.ro public API, including custom schemas, authentication requirements, and presentation options.

[ExcludeFromCodeCoverage]
internal static class SwaggerConfigurationService
Inheritance
SwaggerConfigurationService
Inherited Members

Remarks

This service is responsible for configuring three main aspects of Swagger integration: - Swagger generation options for OpenAPI specification creation - Swagger UI options for the interactive documentation interface - Swagger middleware options for serving the documentation

The generated documentation is available at the following endpoints: - Swagger UI: https://api.arolariu.ro/ (root path) - OpenAPI JSON: https://api.arolariu.ro/swagger/v1/swagger.json - Terms of Service: https://api.arolariu.ro/terms

The configuration includes: - JWT Bearer token authentication scheme - Custom type mappings for common response types - XML documentation comments integration - Enhanced UI features and customization

Methods

GetSwaggerGenOptions()

Configures comprehensive Swagger generation options for OpenAPI specification creation. This method defines the complete API documentation structure, including metadata, security schemes, custom type mappings, and XML documentation integration.

internal static Action<SwaggerGenOptions> GetSwaggerGenOptions()

Returns

Action<SwaggerGenOptions>

An Action<T> delegate that configures Swagger generation with custom schemas, authentication, and documentation settings.

Remarks

This method configures extensive Swagger generation options:

API Metadata: - Sets comprehensive API information including title, version, and detailed description - Includes contact information and terms of service URL - Provides licensing information under MIT License

Security Configuration: - Defines JWT Bearer token authentication scheme - Configures security requirements for protected endpoints - Includes detailed authentication instructions for API consumers

Custom Type Mappings: - Maps IResult to standardized response schema with success, message, and data properties - Maps ProblemDetails to RFC 7807 problem details schema - Maps IEnumerable<T> of key-value pairs to array schema for metadata responses

Documentation Enhancement: - Enables Swashbuckle annotations for enhanced API documentation - Uses inline definitions for enums to improve schema readability - Integrates XML documentation comments from compiled assembly - Applies custom document filters for additional processing

The generated OpenAPI specification follows OpenAPI 3.0 standards and includes comprehensive schema definitions for all API operations, enabling automatic client code generation and interactive testing.

GetSwaggerOptions()

Provides basic Swagger middleware configuration options. This method returns default options for the Swagger JSON endpoint serving.

internal static SwaggerOptions GetSwaggerOptions()

Returns

SwaggerOptions

A SwaggerOptions instance with default configuration for serving OpenAPI specifications.

Remarks

This method currently returns default options without customization. It serves as a placeholder for future middleware-specific configuration needs, such as custom serialization settings or route templates.

GetSwaggerUIOptions()

Configures the Swagger UI presentation options and behavior. This method customizes the interactive documentation interface for enhanced developer experience.

internal static SwaggerUIOptions GetSwaggerUIOptions()

Returns

SwaggerUIOptions

A configured SwaggerUIOptions instance with customized settings for the API documentation interface.

Remarks

The returned configuration includes the following customizations:

Navigation and Routing: - Sets the route prefix to empty string, making Swagger UI available at the root path - Configures the document title as "AROLARIU.RO Public API"

Authentication and Persistence: - Enables authorization persistence across browser sessions - Maintains user authentication state during documentation exploration

Display and Interaction Features: - Shows operation IDs for easier API reference - Displays request duration for performance monitoring - Enables syntax highlighting for better code readability - Configures model rendering to show examples by default - Sets appropriate expansion depth for nested models (2 levels) - Enables filtering capabilities for large API surfaces - Shows OpenAPI extensions and common extensions