Repository navigation
AspNetCore Expo OpenAPI
Expo's ASP.NET Core OpenAPI integration adds validation constraints to generated API documents. It describes the rules that API consumers need when constructing requests. Runtime validation still comes from [ExpoSystemBundle].
In the ASP.NET Core project, install the generator integration:
dotnet add package Brigade.Net.Partie.Extensions.Expo.Engines.AspNetCoreConfigure ASP.NET Core OpenAPI with the generated AddExpo helper:
builder.Services.AddOpenApi(options =>
{
options.AddExpo();
});
...
var app = builder.Build();
app.UsePartieRoutes();
app.MapOpenApi();The generated helper is in Microsoft.AspNetCore.OpenApi. Keep [Expo] on models whose rules should appear in schemas. The generator also discovers marked models in referenced assemblies.
| Expo rule | OpenAPI representation |
|---|---|
[IsRequired] |
Required property or request body |
| Inclusive constant comparisons | Minimum or maximum |
| Exclusive constant comparisons | Exclusive minimum or maximum |
| Equality to a constant | Constant constraint |
| Inequality to a constant | Negated constant constraint |
| String length rules | Minimum and maximum string length |
| Collection size rules | Minimum and maximum item count |
| Built-in formats | Format or regex pattern |
| Generated regex rules | Regex pattern |
Rules placed on collection items apply to the item schema. A minimum string length on List<string> constrains each string, while [ItemsHasMinimumLength] constrains the array length.
For path, query, and metadata binding, the integration adds rules to the matching parameter schema. JSON payload requiredness applies to the request body. Form payload rules apply to body properties, including required form fields.
Custom rules, comparisons between properties, whitespace checks, and defined-enum checks can require runtime logic that a schema constraint does not fully express. The integration adds a description naming the Expo rule for those cases.
A description does not make an API client enforce that rule. Keep runtime validation enabled, and provide clear messages for input that passes a client's schema checks but fails a model rule.
See Expo validation in ASP.NET Core for enforcement and Errors and metadata for the model's rule descriptions and field paths.
- Home
- Getting started
-
Package guides
- Partie
- Expo
-
Mise
- Database setup
- Table mappings
- Aliases
- Relationships
- Result rows
- SQL interpolation
- Queries
- Filtering
- Joins
- Aggregation
- Paging and ordering
- Subqueries
- Set operations
- Common table expressions
- Readers
- Streaming
- Writers
- Inserts
- Updates
- Deletes
- Returned rows
- Custom SQL and procedures
- Transactions
- Resource lifetimes
- Database dialects
- Diagnostics
- Integrations
- Recipes
- Reference
- Troubleshooting
- Development