Skip to main content

smithy

Attribute Macro smithy 

Source
#[smithy]
Expand description

Generate Smithy IDL schema from an impl block.

Smithy is AWS’s open-source interface definition language for defining APIs. The generated schema follows Smithy 2.0 specification.

§Example

use server_less::smithy;

struct UserService;

#[smithy(namespace = "com.example.users")]
impl UserService {
    /// Get user by ID
    fn get_user(&self, id: String) -> User { ... }

    /// Create a new user
    fn create_user(&self, name: String, email: String) -> User { ... }
}

// Get Smithy schema
let schema = UserService::smithy_schema();
// Write to file
UserService::write_smithy("service.smithy")?;

The generated schema can be used with the Smithy toolchain for code generation.