JAAvila.FluentOperations.OpenApi
1.5.0
dotnet add package JAAvila.FluentOperations.OpenApi --version 1.5.0
NuGet\Install-Package JAAvila.FluentOperations.OpenApi -Version 1.5.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JAAvila.FluentOperations.OpenApi" Version="1.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JAAvila.FluentOperations.OpenApi" Version="1.5.0" />
<PackageReference Include="JAAvila.FluentOperations.OpenApi" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JAAvila.FluentOperations.OpenApi --version 1.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JAAvila.FluentOperations.OpenApi, 1.5.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package JAAvila.FluentOperations.OpenApi@1.5.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JAAvila.FluentOperations.OpenApi&version=1.5.0
#tool nuget:?package=JAAvila.FluentOperations.OpenApi&version=1.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
JAAvila.FluentOperations.OpenApi
OpenAPI / Swagger schema filter integration for JAAvila.FluentOperations Quality Blueprints.
Automatically enriches Swashbuckle-generated OpenAPI schemas with validation constraints
that mirror the rules defined in your QualityBlueprint<T> classes — no duplication needed.
Supported mappings
| Blueprint operation | OpenAPI constraint |
|---|---|
NotBeNull |
property added to required |
NotBeEmpty |
minLength: 1 |
NotBeNullOrEmpty |
minLength: 1 + required |
HaveMinLength(n) |
minLength: n |
HaveMaxLength(n) |
maxLength: n |
HaveLengthBetween(a,b) |
minLength: a, maxLength: b |
Match(pattern) |
pattern: <regex> |
MatchRegex(regex) |
pattern: <regex> |
BeEmail |
format: email |
BeUrl |
format: uri |
BeGreaterThan(n) |
minimum: n, exclusiveMinimum: true |
BeLessThan(n) |
maximum: n, exclusiveMaximum: true |
BeGreaterThanOrEqualTo |
minimum: n |
BeLessThanOrEqualTo |
maximum: n |
BeOneOf([...]) |
enum: [...] |
| Other operations | x-validation-rules: [operationName] |
Usage
// 1. Register your blueprints with DI (using JAAvila.FluentOperations.DependencyInjection)
builder.Services.AddFluentOperations()
.AddBlueprint<UserBlueprint>();
// 2. Configure Swashbuckle to use the schema filter
builder.Services.AddSwaggerGen(options =>
{
// Resolve blueprints from DI and apply to swagger generation
var sp = builder.Services.BuildServiceProvider();
var blueprints = sp.GetRequiredService<IEnumerable<IBlueprintValidator>>();
options.AddFluentOperationsValidation(blueprints);
});
Blueprint example
public class UserBlueprint : QualityBlueprint<User>
{
public UserBlueprint()
{
using (Define())
{
For(x => x.Email).Test().NotBeNull().BeEmail();
For(x => x.Name).Test().NotBeNullOrEmpty().HaveMaxLength(100);
For(x => x.Age).Test().BeGreaterThanOrEqualTo(18).BeLessThan(150);
}
}
}
The generated OpenAPI schema for User will automatically include:
emailfield asrequired, withformat: emailnamefield asrequired, withmaxLength: 100agefield withminimum: 18,maximum: 150,exclusiveMaximum: true
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- JAAvila.FluentOperations (>= 1.5.0)
- Swashbuckle.AspNetCore (>= 6.5.0 && < 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.