vld-aide
aide / schemars integration for the vld validation library.
Overview
Bridge between vld validation schemas and aide OpenAPI documentation generator.
Define your validation rules once in vld and get schemars::JsonSchema compatibility
for free — no need to duplicate with #[derive(JsonSchema)].
aide uses schemars for JSON Schema generation. This crate converts vld's JSON Schema
output to schemars::Schema, making your validated types usable with aide::axum::Json<T>,
aide::axum::Query<T>, and other aide extractors.
Installation
[]
= { = "0.1", = ["openapi"] }
= "0.1"
= { = "0.15", = ["axum"] }
Quick Start
impl_json_schema! macro
use *;
use impl_json_schema;
schema!
impl_json_schema!;
// Now `CreateUser` implements `schemars::JsonSchema`
// and works with aide for OpenAPI doc generation.
Custom schema name
impl_json_schema!;
With #[derive(Validate)]
use Validate;
use impl_json_schema;
impl_json_schema!;
// Schema properties will use camelCase: firstName, emailAddress, isActive
Usage with aide + axum
use ;
use Json;
use TransformOperation;
async
let app = new
.api_route;
Direct conversion
Convert any vld JSON schema value to schemars::Schema:
use vld_to_schemars;
let vld_schema = json!;
let schemars_schema = vld_to_schemars;
API Reference
| Item | Description |
|---|---|
impl_json_schema!(Type) |
Implement schemars::JsonSchema for a vld type |
impl_json_schema!(Type, "Name") |
Same, with custom schema name |
vld_to_schemars(&Value) |
Convert serde_json::Value to schemars::Schema |
Comparison with vld-utoipa
vld-utoipa |
vld-aide |
|
|---|---|---|
| Target library | utoipa | aide / schemars |
| Schema trait | utoipa::ToSchema |
schemars::JsonSchema |
| Macro | impl_to_schema! |
impl_json_schema! |
| OpenAPI version | 3.0 / 3.1 | 3.1 |
Running the example
License
MIT