Crate omni_schema_derive

Crate omni_schema_derive 

Source
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 type
  • rename - Custom name for the schema
  • rename_all - Rename all fields (camelCase, snake_case, PascalCase, etc.)
  • deprecated - Mark the type as deprecated
  • tag - Tag field name for internally tagged enums
  • content - Content field name for adjacently tagged enums
  • untagged - Use untagged enum representation

§Field-level attributes

  • description - Documentation for the field
  • rename - Custom name for the field
  • min_length / max_length - String length constraints
  • minimum / maximum - Numeric range constraints
  • pattern - Regex pattern for string validation
  • format - Format hint (email, uri, uuid, etc.)
  • default - Default value expression
  • deprecated - Mark the field as deprecated
  • skip - Skip this field in schema generation
  • flatten - Flatten nested struct fields
  • nullable - Mark field as nullable

Derive Macros§

Schema