Expand description
§omni-schema-derive
Derive macros for the omni-schema library.
This crate provides the #[derive(Schema)] macro that generates schema
definitions from Rust structs and enums.
§Usage
ⓘ
use omni_schema::Schema;
#[derive(Schema)]
#[schema(description = "A user in the system")]
pub struct User {
#[schema(description = "Unique identifier")]
pub id: u64,
#[schema(min_length = 1, max_length = 100)]
pub name: String,
#[schema(format = "email")]
pub email: String,
}§Supported Attributes
§Type-level attributes
description- Documentation for the typerename- Custom name for the schemarename_all- Rename all fields (camelCase, snake_case, PascalCase, etc.)deprecated- Mark the type as deprecatedtag- Tag field name for internally tagged enumscontent- Content field name for adjacently tagged enumsuntagged- Use untagged enum representation
§Field-level attributes
description- Documentation for the fieldrename- Custom name for the fieldmin_length/max_length- String length constraintsminimum/maximum- Numeric range constraintspattern- Regex pattern for string validationformat- Format hint (email, uri, uuid, etc.)default- Default value expressiondeprecated- Mark the field as deprecatedskip- Skip this field in schema generationflatten- Flatten nested struct fieldsnullable- Mark field as nullable