Skip to content

feat(api): auto-generate HTTP handlers with OpenAPI documentation #75

@RAprogramm

Description

@RAprogramm

Summary

Implement automatic HTTP handler generation with full OpenAPI/Swagger documentation via utoipa integration.

Motivation

Currently users manually write HTTP handlers. With commands already generating business logic entry points, we can auto-generate the HTTP layer with professional API documentation.

Proposed Syntax

#[derive(Entity)]
#[entity(
    table = "users",
    commands,
    events,
    api(
        tag = "Users",
        tag_description = "User management API",
        path_prefix = "/api/v1",
        security = "bearer",
        public = [Register],
    )
)]
pub struct User {
    #[id]
    id: Uuid,
    
    /// User email address
    #[field(create, update, response)]
    #[validate(email, max_length = 255)]
    #[example = "user@example.com"]
    email: String,
    
    #[command(Register, summary = "Register new user")]
    #[command(Deactivate, summary = "Deactivate user")]
}

Generated Output

  • Axum handlers with #[utoipa::path] annotations
  • OpenAPI schemas for all DTOs with descriptions, constraints, examples
  • Router factory function
  • OpenApi struct for Swagger UI

Sub-tasks

Dependencies

  • utoipa
  • utoipa-axum

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI generation and documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions