Valobtify.Swagger
is an extension for integrating Valobtify value objects with Swagger documentation in ASP.NET Core. It automates the process of mapping value objects to Swagger schemas, ensuring your API documentation is accurate and reflective of your domain model.
Install the Valobtify.Swagger
package via NuGet:
dotnet add package Valobtify.Swagger
Ensure your project uses Swashbuckle.AspNetCore for Swagger support.
-
Add Swagger to Your Project
First, configure Swagger in your ASP.NET Core project:builder.Services.AddSwaggerGen();
-
Add Valobtify Schema Filters
Use theAddValobtifySchemaFilters
extension method to enable value object schema support:builder.Services.AddSwaggerGen(options => { options.AddValobtifySchemaFilters(); });
-
Enable Middleware
Add Swagger middleware to your application pipeline:app.UseSwagger(); app.UseSwaggerUI();
The AddValobtifySchemaFilters
method ensures that all Valobtify value objects are correctly represented in your Swagger documentation. This means:
- Automatic schema generation: No manual configuration is needed.
- Consistent API documentation: Domain concepts using value objects are properly reflected.
- Valobtify: Core library for creating and using value objects in .NET.